3 Copyright (c) 2015 Samsung Electronics Co., Ltd.
5 Licensed under the Apache License, Version 2.0 (the License);
6 you may not use this file except in compliance with the License.
7 You may obtain a copy of the License at
9 http://www.apache.org/licenses/LICENSE-2.0
11 Unless required by applicable law or agreed to in writing, software
12 distributed under the License is distributed on an "AS IS" BASIS,
13 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 See the License for the specific language governing permissions and
15 limitations under the License.
18 Qunfang Lin <qunfang.lin@samsung.com>
24 <title>BluetoothGATTCharacteristic_readValue_with_errorCallback</title>
25 <meta charset="utf-8"/>
26 <script src="support/unitcommon.js"></script>
27 <script src="support/bluetooth_common.js"></script>
32 //==== TEST: BluetoothGATTCharacteristic_readValue_with_errorCallback
33 //==== LABEL Check if BluetoothGATTCharacteristic::readValue method works properly with optional argument
35 //==== SPEC Tizen Web API:Communication:Bluetooth:BluetoothGATTCharacteristic:readValue M
37 //==== EXECUTION_TYPE manual
38 //==== PRE The bluetooth of the remote/test device MUST support BLE and be turned on and discoverable from other devices.
39 //==== TEST_CRITERIA MOA MR
41 setup({timeout: 60000});
43 var t = async_test(document.title, {timeout: 60000}), adapter, bleScanSuccessCallback, bleScanRrrorCallback, flag = false,
44 onconnected, onerror, service, characteristic, device = null, ReadValueSuccessCallback, errorCallback, retVal, i, charFlag = false;
47 errorCallback = t.step_func(function (error) {
48 assert_unreached("readValue() error callback was invoked: " + error.name + " msg: " + error.message);
51 ReadValueSuccessCallback = t.step_func(function (value) {
52 assert_equals(retVal, undefined, "readValue should return undefined");
57 onconnected = t.step_func(function () {
58 service = device.getService(device.uuids[0]);
59 if (service.characteristics.length > 0) {
60 for(i = 0; i < service.characteristics.length; i++) {
61 if(service.characteristics[i].isReadable == true && charFlag == false) {
63 characteristic = service.characteristics[i];
64 retVal = characteristic.readValue(ReadValueSuccessCallback, errorCallback);
70 onerror = t.step_func(function (error) {
71 assert_unreached("connect() error callback was invoked: " + error.name + " msg: " + error.message);
74 bleScanSuccessCallback = t.step_func(function (bledevice) {
75 if (bledevice.address == REMOTE_BLE_DEVICE_ADDRESS && device == null) {
79 device.connect(onconnected, onerror);
85 bleScanRrrorCallback = t.step_func(function (error) {
86 assert_unreached("startScan() error callback was invoked: " + error.name + " msg: " + error.message);
89 adapter = tizen.bluetooth.getLEAdapter();
91 adapter.startScan(bleScanSuccessCallback, bleScanRrrorCallback);