setup({timeout: 180000});
var t = async_test(document.title, {timeout: 180000}), adapter, powerOnSuccess, onBondingSuccess, onBondingError,
- gotDeviceInfo, gotDeviceError, onSocketConnect, onSocketError, flag = false;
+ gotDeviceInfo, gotDeviceError, onSocketConnect, onSocketError, flag = false, found = false;
t.step(function () {
if (BT_SUPPORT) { // network.bluetooth support
assert_unreached("onBondingError exception:" + e.message);
});
- powerOnSuccess = t.step_func(function () {
- adapter.createBonding(REMOTE_DEVICE_ADDRESS, onBondingSuccess, onBondingError);
+ stopDiscoverySuccess1 = t.step_func(function () {
+ console.log("stopDiscoverySuccess1");
+ });
+
+ discoverDevicesSuccessCallback = {
+ onstarted: t.step_func(function () {
+ }),
+ ondevicefound: t.step_func(function (device) {
+ if (device.address === REMOTE_DEVICE_ADDRESS) {
+ stopDiscovery(t, adapter, stopDiscoverySuccess1);
+ adapter.createBonding(REMOTE_DEVICE_ADDRESS, onBondingSuccess, onBondingError)
+ }
+ }),
+ ondevicedisappeared: t.step_func(function (address) {
+ }),
+ onfinished: t.step_func(function (devices) {
+ if (devices.length > 0) {
+ found = false;
+ for (var i = 0; i < devices.length; i++) {
+ if (devices[i].address === REMOTE_DEVICE_ADDRESS) {
+ found = true;
+ break;
+ }
+ }
+ if (found === false) {
+ assert_unreached("Device not found:" + REMOTE_DEVICE_ADDRESS);
+ }
+ } else {
+ setTimeout(stopDiscoverySuccess, 1000);
+ }
+ })
+ };
+
+ discoverDevicesError = t.step_func(function (e) {
+ assert_unreached("discoverDevicesError exception:" + e.message);
+ });
+
+ stopDiscoverySuccess = t.step_func(function () {
+ adapter.discoverDevices(discoverDevicesSuccessCallback, discoverDevicesError);
});
adapter = tizen.bluetooth.getDefaultAdapter();
- setPowered(t, adapter, powerOnSuccess);
+ stopDiscovery(t, adapter, stopDiscoverySuccess);
} else {
t.done();