From 02d06d76f3044a95e2fea6ce7bf9ed900bc1715e Mon Sep 17 00:00:00 2001 From: Lukasz Bardeli Date: Thu, 25 May 2017 06:54:59 +0200 Subject: [PATCH] [Bluetooth] Adjust html to new standards Change-Id: Ica86e81596a45cc3bda6f6644bf5acb86a4341da Signed-off-by: Lukasz Bardeli --- .../html/device_api/mobile/tizen/bluetooth.html | 1770 +++++++++++--------- .../html/device_api/wearable/tizen/bluetooth.html | 1499 ++++++++--------- 2 files changed, 1720 insertions(+), 1549 deletions(-) diff --git a/org.tizen.web.apireference/html/device_api/mobile/tizen/bluetooth.html b/org.tizen.web.apireference/html/device_api/mobile/tizen/bluetooth.html index 28ecb3f..3c38e59 100644 --- a/org.tizen.web.apireference/html/device_api/mobile/tizen/bluetooth.html +++ b/org.tizen.web.apireference/html/device_api/mobile/tizen/bluetooth.html @@ -47,23 +47,32 @@ For more information on the Bluetooth features, see
  • 1. Type Definitions
  • @@ -178,30 +187,37 @@ For more information on the Bluetooth features, see BluetoothManager -BluetoothAdapter getDefaultAdapter ()
    - BluetoothLEAdapter getLEAdapter () +
    +BluetoothAdapter getDefaultAdapter ()
    +
    +BluetoothLEAdapter getLEAdapter ()
    + BluetoothAdapter -void setName (DOMString name, optional SuccessCallback? successCallback, optional ErrorCallback? errorCallback)
    - void setPowered (boolean state, optional SuccessCallback? successCallback, optional ErrorCallback? errorCallback)
    - void setChangeListener (BluetoothAdapterChangeCallback listener)
    - void unsetChangeListener ()
    - void discoverDevices (BluetoothDiscoverDevicesSuccessCallback successCallback, optional ErrorCallback? errorCallback)
    - void stopDiscovery (optional SuccessCallback? successCallback, optional ErrorCallback? errorCallback)
    - void getKnownDevices (BluetoothDeviceArraySuccessCallback successCallback, optional ErrorCallback? errorCallback)
    - void getDevice (BluetoothAddress address, BluetoothDeviceSuccessCallback successCallback, optional ErrorCallback? errorCallback)
    - void createBonding (BluetoothAddress address, BluetoothDeviceSuccessCallback successCallback, optional ErrorCallback? errorCallback)
    - void destroyBonding (BluetoothAddress address, optional SuccessCallback? successCallback, optional ErrorCallback? errorCallback)
    - void registerRFCOMMServiceByUUID (BluetoothUUID uuid, DOMString name, BluetoothServiceSuccessCallback successCallback, optional ErrorCallback? errorCallback)
    - BluetoothProfileHandler getBluetoothProfileHandler (BluetoothProfileType profileType) + +
    void setName (DOMString name, optional SuccessCallback? successCallback, optional ErrorCallback? errorCallback)
    +
    void setChangeListener (BluetoothAdapterChangeCallback listener)
    +
    void unsetChangeListener ()
    +
    void discoverDevices (BluetoothDiscoverDevicesSuccessCallback successCallback, optional ErrorCallback? errorCallback)
    +
    void stopDiscovery (optional SuccessCallback? successCallback, optional ErrorCallback? errorCallback)
    +
    void getKnownDevices (BluetoothDeviceArraySuccessCallback successCallback, optional ErrorCallback? errorCallback)
    +
    void getDevice (BluetoothAddress address, BluetoothDeviceSuccessCallback successCallback, optional ErrorCallback? errorCallback)
    +
    void createBonding (BluetoothAddress address, BluetoothDeviceSuccessCallback successCallback, optional ErrorCallback? errorCallback)
    +
    void destroyBonding (BluetoothAddress address, optional SuccessCallback? successCallback, optional ErrorCallback? errorCallback)
    +
    void registerRFCOMMServiceByUUID (BluetoothUUID uuid, DOMString name, BluetoothServiceSuccessCallback successCallback, optional ErrorCallback? errorCallback)
    +
    +BluetoothProfileHandler getBluetoothProfileHandler (BluetoothProfileType profileType)
    + BluetoothLEAdapter -void startScan (BluetoothLEScanCallback successCallback, optional ErrorCallback? errorCallback)
    - void stopScan ()
    - void startAdvertise (BluetoothLEAdvertiseData advertiseData, BluetoothAdvertisePacketType packetType, BluetoothLEAdvertiseCallback successCallback, optional ErrorCallback? errorCallback, optional BluetoothAdvertisingMode? mode, optional boolean? connectable)
    - void stopAdvertise () + +
    void startScan (BluetoothLEScanCallback successCallback, optional ErrorCallback? errorCallback)
    +
    void stopScan ()
    +
    void startAdvertise (BluetoothLEAdvertiseData advertiseData, BluetoothAdvertisePacketType packetType, BluetoothLEAdvertiseCallback successCallback, optional ErrorCallback? errorCallback, optional BluetoothAdvertisingMode? mode, optional boolean? connectable)
    +
    void stopAdvertise ()
    + BluetoothGATTService @@ -209,55 +225,67 @@ For more information on the Bluetooth features, see BluetoothGATTCharacteristic -void readValue (ReadValueSuccessCallback successCallback, optional ErrorCallback? errorCallback)
    - void writeValue (byte[] value, optional SuccessCallback? successCallback, optional ErrorCallback? errorCallback)
    - long addValueChangeListener (ReadValueSuccessCallback callback)
    - void removeValueChangeListener (long watchID) + +
    void readValue (ReadValueSuccessCallback successCallback, optional ErrorCallback? errorCallback)
    +
    void writeValue (byte[] value, optional SuccessCallback? successCallback, optional ErrorCallback? errorCallback)
    +
    long addValueChangeListener (ReadValueSuccessCallback callback)
    +
    void removeValueChangeListener (long watchID)
    + BluetoothGATTDescriptor -void readValue (ReadValueSuccessCallback successCallback, optional ErrorCallback? errorCallback)
    - void writeValue (byte[] value, optional SuccessCallback? successCallback, optional ErrorCallback? errorCallback) + +
    void readValue (ReadValueSuccessCallback successCallback, optional ErrorCallback? errorCallback)
    +
    void writeValue (byte[] value, optional SuccessCallback? successCallback, optional ErrorCallback? errorCallback)
    + BluetoothLEScanCallback -void onsuccess (BluetoothLEDevice device) +
    void onsuccess (BluetoothLEDevice device)
    BluetoothLEAdvertiseCallback -void onstate (BluetoothAdvertisingState state) +
    void onstate (BluetoothAdvertisingState state)
    BluetoothLEConnectChangeCallback -void onconnected (BluetoothLEDevice device)
    - void ondisconnected (BluetoothLEDevice device) + +
    void onconnected (BluetoothLEDevice device)
    +
    void ondisconnected (BluetoothLEDevice device)
    + ReadValueSuccessCallback -void onread (byte[] value) +
    void onread (byte[] value)
    BluetoothDevice -void connectToServiceByUUID (BluetoothUUID uuid, BluetoothSocketSuccessCallback successCallback, optional ErrorCallback? errorCallback) +
    void connectToServiceByUUID (BluetoothUUID uuid, BluetoothSocketSuccessCallback successCallback, optional ErrorCallback? errorCallback)
    BluetoothLEDevice -void connect (optional SuccessCallback? successCallback, optional ErrorCallback? errorCallback)
    - void disconnect (optional SuccessCallback? successCallback, optional ErrorCallback? errorCallback)
    - BluetoothGATTService getService (BluetoothUUID uuid)
    - BluetoothUUID[] getServiceAllUuids ()
    - long addConnectStateChangeListener (BluetoothLEConnectChangeCallback listener)
    - void removeConnectStateChangeListener (long watchID) + +
    void connect (optional SuccessCallback? successCallback, optional ErrorCallback? errorCallback)
    +
    void disconnect (optional SuccessCallback? successCallback, optional ErrorCallback? errorCallback)
    +
    +BluetoothGATTService getService (BluetoothUUID uuid)
    +
    +BluetoothUUID[] getServiceAllUuids ()
    +
    long addConnectStateChangeListener (BluetoothLEConnectChangeCallback listener)
    +
    void removeConnectStateChangeListener (long watchID)
    + BluetoothSocket -unsigned long writeData (byte[] data)
    - byte[] readData ()
    - void close () + +
    unsigned long writeData (byte[] data)
    +
    byte[] readData ()
    +
    void close ()
    + BluetoothClass -boolean hasService (unsigned short service) +
    boolean hasService (unsigned short service)
    BluetoothClassDeviceMajor @@ -273,7 +301,7 @@ For more information on the Bluetooth features, see BluetoothServiceHandler -void unregister (optional SuccessCallback? successCallback, optional ErrorCallback? errorCallback) +
    void unregister (optional SuccessCallback? successCallback, optional ErrorCallback? errorCallback)
    BluetoothProfileHandler @@ -281,61 +309,71 @@ For more information on the Bluetooth features, see BluetoothHealthProfileHandler -void registerSinkApplication (unsigned short dataType, DOMString name, BluetoothHealthApplicationSuccessCallback successCallback, optional ErrorCallback? errorCallback)
    - void connectToSource (BluetoothDevice peer, BluetoothHealthApplication application, BluetoothHealthChannelSuccessCallback successCallback, optional ErrorCallback? errorCallback) + +
    void registerSinkApplication (unsigned short dataType, DOMString name, BluetoothHealthApplicationSuccessCallback successCallback, optional ErrorCallback? errorCallback)
    +
    void connectToSource (BluetoothDevice peer, BluetoothHealthApplication application, BluetoothHealthChannelSuccessCallback successCallback, optional ErrorCallback? errorCallback)
    + BluetoothHealthApplication -void unregister (optional SuccessCallback? successCallback, optional ErrorCallback? errorCallback) +
    void unregister (optional SuccessCallback? successCallback, optional ErrorCallback? errorCallback)
    BluetoothHealthChannel -void close ()
    - unsigned long sendData (byte[] data)
    - void setListener (BluetoothHealthChannelChangeCallback listener)
    - void unsetListener () + +
    void close ()
    +
    unsigned long sendData (byte[] data)
    +
    void setListener (BluetoothHealthChannelChangeCallback listener)
    +
    void unsetListener ()
    + BluetoothAdapterChangeCallback -void onstatechanged (boolean powered)
    - void onnamechanged (DOMString name)
    - void onvisibilitychanged (boolean visible) + +
    void onstatechanged (boolean powered)
    +
    void onnamechanged (DOMString name)
    +
    void onvisibilitychanged (boolean visible)
    + BluetoothDeviceSuccessCallback -void onsuccess (BluetoothDevice device) +
    void onsuccess (BluetoothDevice device)
    BluetoothDeviceArraySuccessCallback -void onsuccess (BluetoothDevice[] devices) +
    void onsuccess (BluetoothDevice[] devices)
    BluetoothDiscoverDevicesSuccessCallback -void onstarted ()
    - void ondevicefound (BluetoothDevice device)
    - void ondevicedisappeared (BluetoothAddress address)
    - void onfinished (BluetoothDevice[] foundDevices) + +
    void onstarted ()
    +
    void ondevicefound (BluetoothDevice device)
    +
    void ondevicedisappeared (BluetoothAddress address)
    +
    void onfinished (BluetoothDevice[] foundDevices)
    + BluetoothSocketSuccessCallback -void onsuccess (BluetoothSocket socket) +
    void onsuccess (BluetoothSocket socket)
    BluetoothServiceSuccessCallback -void onsuccess (BluetoothServiceHandler handler) +
    void onsuccess (BluetoothServiceHandler handler)
    BluetoothHealthApplicationSuccessCallback -void onsuccess (BluetoothHealthApplication application) +
    void onsuccess (BluetoothHealthApplication application)
    BluetoothHealthChannelSuccessCallback -void onsuccess (BluetoothHealthChannel channel) +
    void onsuccess (BluetoothHealthChannel channel)
    BluetoothHealthChannelChangeCallback -void onmessage (byte[] data)
    - void onclose () + +
    void onmessage (byte[] data)
    +
    void onclose ()
    + @@ -643,8 +681,8 @@ This dictionary is used as an input parameter of the BluetoothLEAdvertiseData co

    Code example:

     var advertData =
     {
    -   includeName: false, uuids: ["f236-41a4"], solicitationuuids: ["5857-4d3f"],
    -   appearance: 192, includeTxPowerLevel: false
    +  includeName: false, uuids: ["f236-41a4"], solicitationuuids: ["5857-4d3f"],
    +  appearance: 192, includeTxPowerLevel: false
     }
     
    @@ -678,8 +716,8 @@ This represents the data to be advertised as well as the scan response data for

    Code example:

     var advertData =
     {
    -   includeName: false, uuids: ["f236-41a4"], solicitationuuids: ["5857-4d3f"],
    -   appearance: 192, includeTxPowerLevel: false
    +  includeName: false, uuids: ["f236-41a4"], solicitationuuids: ["5857-4d3f"],
    +  appearance: 192, includeTxPowerLevel: false
     }
     var advertise = new tizen.BluetoothLEAdvertiseData(advertData);
     
    @@ -925,11 +963,11 @@ Instead, use http://tizen.org/privilege/bluetooth.

    Code example:

     try
     {
    -   var adapter = tizen.bluetooth.getDefaultAdapter();
    +  var adapter = tizen.bluetooth.getDefaultAdapter();
     }
     catch (err)
     {
    -   console.log(err.name + ": " + err.message);
    +  console.log(err.name + ": " + err.message);
     }
     
    @@ -985,11 +1023,11 @@ Instead, use http://tizen.org/privilege/bluetooth.

    Code example:

     try
     {
    -   var adapter = tizen.bluetooth.getLEAdapter();
    +  var adapter = tizen.bluetooth.getLEAdapter();
     }
     catch (err)
     {
    -   console.log(err.name + ": " + err.message);
    +  console.log(err.name + ": " + err.message);
     }
     
    @@ -1012,10 +1050,6 @@ catch (err) optional SuccessCallback? successCallback, optional ErrorCallback? errorCallback) raises(WebAPIException); - void setPowered(boolean state, - optional SuccessCallback? successCallback, - optional ErrorCallback? errorCallback) raises(WebAPIException); - void setChangeListener(BluetoothAdapterChangeCallback listener) raises(WebAPIException); void unsetChangeListener() raises(WebAPIException); @@ -1236,35 +1270,36 @@ var bt_always_on = tizen.systeminfo.getCapability("http://tizen.org/capability/n function changeName(newName) { - if (adapter.name != newName) - { - /* Initiate change name */ - adapter.setName(newName, function() - { - console.log("Adapter name changed to " + adapter.name); - }, function(e) - { - console.log("Failed to change name: " + e.message); - }); - } + if (adapter.name != newName) + { + /* Initiate change name */ + adapter.setName(newName, function() + { + console.log("Adapter name changed to " + adapter.name); + }, function(e) + { + console.log("Failed to change name: " + e.message); + }); + } } if (bt_always_on === false) { - changeName("myDevice"); + changeName("myDevice"); } -
    +
    setPowered
    -
    +
    Sets the state of a Bluetooth adapter to on or off by sending a request to Bluetooth hardware to change the power state. For most Bluetooth actions, the Bluetooth adapter must be powered on.
    -

    Deprecated. - Deprecated since 2.3. Instead, let the user turn on/off Bluetooth through the Settings application. see the Bluetooth Tutorial.

    +

    Deprecated. + Deprecated since 2.3. Instead, let the user turn on/off Bluetooth through the Settings application. See Managing Bluetooth Tutorial. +

    void setPowered(boolean state, optional SuccessCallback? successCallback, optional ErrorCallback? errorCallback);
                  

    @@ -1336,44 +1371,44 @@ var adapter = tizen.bluetooth.getDefaultAdapter(); function powerOn() { - /* If adapter is not powered on */ - if (!adapter.powered) - { - /* Initiates power on */ - adapter.setPowered(true, function() - { - console.log("Bluetooth powered on success."); - }, function(e) - { - console.log("Failed to power on Bluetooth: " + e.message); - }); - } + /* If adapter is not powered on */ + if (!adapter.powered) + { + /* Initiates power on */ + adapter.setPowered(true, function() + { + console.log("Bluetooth powered on success."); + }, function(e) + { + console.log("Failed to power on Bluetooth: " + e.message); + }); + } } function powerOff() { - /* If powered on */ - if (adapter.powered) - { - /* Initiates power off */ - adapter.setPowered(false, function() - { - console.log("Bluetooth powered off successfully."); - }, function(e) - { - console.log("Failed to power off Bluetooth: " + e.message); - }); - } + /* If powered on */ + if (adapter.powered) + { + /* Initiates power off */ + adapter.setPowered(false, function() + { + console.log("Bluetooth powered off successfully."); + }, function(e) + { + console.log("Failed to power off Bluetooth: " + e.message); + }); + } } var bt_always_on = tizen.systeminfo.getCapability("http://tizen.org/capability/network.bluetooth.always_on"); if (bt_always_on === true) { - console.log("Bluetooth cannot be turn off or on because this device must be always enabled."); + console.log("Bluetooth cannot be turn off or on because this device must be always enabled."); } else { - powerOn(); + powerOn(); } @@ -1419,18 +1454,18 @@ else

    Code example:

     var changeListener =
     {
    -   onstatechanged: function(powered)
    -   {
    -      console.log("Power state is changed into: " + powered);
    -   },
    -   onnamechanged: function(name)
    -   {
    -      console.log("Name is changed to: " + name);
    -   },
    -   onvisibilitychanged: function(visible)
    -   {
    -      console.log("Visibility is changed into: " + visible);
    -   }
    +  onstatechanged: function(powered)
    +  {
    +    console.log("Power state is changed into: " + powered);
    +  },
    +  onnamechanged: function(name)
    +  {
    +    console.log("Name is changed to: " + name);
    +  },
    +  onvisibilitychanged: function(visible)
    +  {
    +    console.log("Visibility is changed into: " + visible);
    +  }
     };
     
     var adapter = tizen.bluetooth.getDefaultAdapter();
    @@ -1469,20 +1504,20 @@ var adapter = tizen.bluetooth.getDefaultAdapter();
     
     var changeListener =
     {
    -   onstatechanged: function(powered)
    -   {
    -      console.log("Power state is changed into: " + powered);
    -      if (!powered)
    -         adapter.unsetChangeListener();
    -   },
    -   onnamechanged: function(name)
    -   {
    -      console.log("Name is changed to: " + name);
    -   },
    -   onvisibilitychanged: function(visible)
    -   {
    -      console.log("Visibility is changed into: " + visible);
    -   }
    +  onstatechanged: function(powered)
    +  {
    +    console.log("Power state is changed into: " + powered);
    +    if (!powered)
    +      adapter.unsetChangeListener();
    +  },
    +  onnamechanged: function(name)
    +  {
    +    console.log("Name is changed to: " + name);
    +  },
    +  onvisibilitychanged: function(visible)
    +  {
    +    console.log("Visibility is changed into: " + visible);
    +  }
     };
     
     adapter.setChangeListener(changeListener);
    @@ -1572,41 +1607,41 @@ var adapter = tizen.bluetooth.getDefaultAdapter();
     
     function startDiscovery()
     {
    -   var discoverDevicesSuccessCallback =
    -   {
    -      onstarted: function()
    -      {
    -         console.log("Device discovery started...");
    -      },
    -      ondevicefound: function(device)
    -      {
    -         console.log("Found device - name: " + device.name + ", Address: " + device.address);
    -      },
    -      ondevicedisappeared: function(address)
    -      {
    -         console.log("Device disappeared: " + address);
    -      },
    -      onfinished: function(devices)
    +  var discoverDevicesSuccessCallback =
    +  {
    +    onstarted: function()
    +    {
    +      console.log("Device discovery started...");
    +    },
    +    ondevicefound: function(device)
    +    {
    +      console.log("Found device - name: " + device.name + ", Address: "+ device.address);
    +    },
    +    ondevicedisappeared: function(address)
    +    {
    +      console.log("Device disappeared: " + address);
    +    },
    +    onfinished: function(devices)
    +    {
    +      console.log("Found Devices");
    +      for (var i = 0; i < devices.length; i++)
           {
    -         console.log("Found Devices");
    -         for (var i = 0; i < devices.length; i++)
    -         {
    -            console.log("Name: " + devices[i].name + ", Address: " + devices[i].address);
    -         }
    -         console.log("Total: " + devices.length);
    +        console.log("Name: " + devices[i].name + ", Address: " + devices[i].address);
           }
    -   };
    -
    -   /* Starts searching for nearby devices, for about 12 sec */
    -   adapter.discoverDevices(discoverDevicesSuccessCallback, function(e)
    -   {
    -      console.log("Failed to search devices: " + e.message + "(" + e.name + ")");
    -   });
    +      console.log("Total: " + devices.length);
    +    }
    +  };
    +
    +  /* Starts searching for nearby devices, for about 12 sec */
    +  adapter.discoverDevices(discoverDevicesSuccessCallback, function(e)
    +  {
    +    console.log("Failed to search devices: " + e.message + "(" + e.name + ")");
    +  });
     }
     
     function onSetPoweredError(e)
     {
    -   console.log("Could not turn on device, reason: " + e.message + "(" + e.name + ")");
    +  console.log("Could not turn on device, reason: " + e.message + "(" + e.name + ")");
     }
     
     adapter.setPowered(true, startDiscovery, onSetPoweredError);
    @@ -1684,57 +1719,57 @@ var adapter = tizen.bluetooth.getDefaultAdapter();
     /* Calls this method whenever user finds one of the device */
     function cancelDiscovery()
     {
    -   adapter.stopDiscovery(function()
    -   {
    -      console.log("Stop discovery success.");
    -   }, function(e)
    -   {
    -      console.log("Error while stopDiscovery:" + e.message);
    -   });
    +  adapter.stopDiscovery(function()
    +  {
    +    console.log("Stop discovery success.");
    +  }, function(e)
    +  {
    +    console.log("Error while stopDiscovery:" + e.message);
    +  });
     }
     
     function startDiscovery()
     {
    -   var discoverDevicesSuccessCallback =
    -   {
    -      onstarted: function()
    -      {
    -         console.log("Device discovery started...");
    -      },
    -      ondevicefound: function(device)
    -      {
    -         console.log("Found device - name: " + device.name + ", Address: " + device.address);
    -         /* Shows the device to user to check if this is the device user is looking for */
    -         /* For example, add this to list view */
    -
    -         cancelDiscovery();
    -      },
    -      ondevicedisappeared: function(address)
    +  var discoverDevicesSuccessCallback =
    +  {
    +    onstarted: function()
    +    {
    +      console.log("Device discovery started...");
    +    },
    +    ondevicefound: function(device)
    +    {
    +      console.log("Found device - name: " + device.name + ", Address: "+ device.address);
    +      /* Shows the device to user to check if this is the device user is looking for */
    +      /* For example, add this to list view */
    +
    +      cancelDiscovery();
    +    },
    +    ondevicedisappeared: function(address)
    +    {
    +      console.log("Device disappeared: " + address);
    +      /* Removes from list, as it is no longer valid */
    +    },
    +    onfinished: function(devices)
    +    {
    +      console.log("Found Devices");
    +      for (var i = 0; i < devices.length; i++)
           {
    -         console.log("Device disappeared: " + address);
    -         /* Removes from list, as it is no longer valid */
    -      },
    -      onfinished: function(devices)
    -      {
    -         console.log("Found Devices");
    -         for (var i = 0; i < devices.length; i++)
    -         {
    -            console.log("Name: " + devices[i].name + ", Address: " + devices[i].address);
    -         }
    -         console.log("Total: " + devices.length);
    +        console.log("Name: " + devices[i].name + ", Address: " + devices[i].address);
           }
    -   };
    -
    -   /* Starts searching for nearby devices, for about 12 sec */
    -   adapter.discoverDevices(discoverDevicesSuccessCallback, function(e)
    -   {
    -      console.log("Failed to search devices: " + e.message + "(" + e.name + ")");
    -   });
    +      console.log("Total: " + devices.length);
    +    }
    +  };
    +
    +  /* Starts searching for nearby devices, for about 12 sec */
    +  adapter.discoverDevices(discoverDevicesSuccessCallback, function(e)
    +  {
    +    console.log("Failed to search devices: " + e.message + "(" + e.name + ")");
    +  });
     }
     
     function onSetPoweredError(e)
     {
    -   console.log("Could not turn on device, reason: " + e.message + "(" + e.name + ")");
    +  console.log("Could not turn on device, reason: " + e.message + "(" + e.name + ")");
     }
     
     adapter.setPowered(true, startDiscovery, onSetPoweredError);
    @@ -1820,22 +1855,22 @@ var adapter = tizen.bluetooth.getDefaultAdapter();
     
     function onGotDevices(devices)
     {
    -   console.log("Devices");
    -   for (var i = 0; i < devices.length; i++)
    -   {
    -      console.log(" Name: " + devices[i].name + ", Address: " + devices[i].address);
    -   }
    -   console.log("Total: " + devices.length);
    +  console.log("Devices");
    +  for (var i = 0; i < devices.length; i++)
    +  {
    +    console.log(" Name: " + devices[i].name + ", Address: " + devices[i].address);
    +  }
    +  console.log("Total: " + devices.length);
     }
     
     function onError(e)
     {
    -   console.log("Error: " + e.message);
    +  console.log("Error: " + e.message);
     }
     
     function onBluetoothsetPowered()
     {
    -   adapter.getKnownDevices(onGotDevices, onError);
    +  adapter.getKnownDevices(onGotDevices, onError);
     }
     
     /* Turns on Bluetooth */
    @@ -1919,15 +1954,15 @@ Instead, use http://tizen.org/privilege/bluetooth.
     

    Code example:

     function gotDeviceInfo(device)
     {
    -   console.log("Device Name: " + device.name);
    -   console.log("Device Address: " + device.address);
    -   console.log("Device Class: " + device.deviceClass.major);
    -   console.log("Is Bonded: " + (device.isBonded ? "Yes" : "No"));
    +  console.log("Device Name: " + device.name);
    +  console.log("Device Address: " + device.address);
    +  console.log("Device Class: " + device.deviceClass.major);
    +  console.log("Is Bonded: " + (device.isBonded ? "Yes" : "No"));
     }
     
     function onError(e)
     {
    -   console.log("Could not get device info:" + e.message);
    +  console.log("Could not get device info:" + e.message);
     }
     
     var adapter = tizen.bluetooth.getDefaultAdapter();
    @@ -2009,14 +2044,14 @@ Instead, use http://tizen.org/privilege/bluetooth.
     

    Code example:

     function onBondingSuccess(device)
     {
    -   console.log("Device Name:" + device.name);
    -   console.log("Device Address:" + device.address);
    -   console.log("Device Service UUIDs:" + device.uuids.join("\n"));
    +  console.log("Device Name:" + device.name);
    +  console.log("Device Address:" + device.address);
    +  console.log("Device Service UUIDs:" + device.uuids.join("\n"));
     }
     
     function onError(e)
     {
    -   console.log("Could not create bonding, reason:" + e.message);
    +  console.log("Could not create bonding, reason:" + e.message);
     }
     
     var adapter = tizen.bluetooth.getDefaultAdapter();
    @@ -2100,23 +2135,23 @@ var adapter = tizen.bluetooth.getDefaultAdapter();
     
     function gotDevice(device)
     {
    -   if (device.isBonded)
    -   {
    -      /* Initiates destroying bonding */
    -      adapter.destroyBonding(device.address, function()
    -      {
    -         console.log("Succeeded to destroy the bond success with:" + device.address);
    -      }, function(e)
    -      {
    -         console.log("Failed to destroy the bond with " + device.address + ", reason: " + e.message);
    -      });
    -   }
    +  if (device.isBonded)
    +  {
    +    /* Initiates destroying bonding */
    +    adapter.destroyBonding(device.address, function()
    +    {
    +      console.log("Succeeded to destroy the bond success with:" + device.address);
    +    }, function(e)
    +    {
    +      console.log("Failed to destroy the bond with " + device.address + ", reason: " + e.message);
    +    });
    +  }
     }
     
     var deviceAddress = "35:F4:59:D1:7A:03";
     adapter.getDevice(deviceAddress, gotDevice, function(e)
     {
    -   console.log("Failed to get device info for " + deviceAddress + ", reason: " + e.message);
    +  console.log("Failed to get device info for " + deviceAddress + ", reason: " + e.message);
     });
     
    @@ -2213,47 +2248,51 @@ var serviceSocket = null; function chatServiceSuccessCb(recordHandler) { - console.log("Chat service registration succeeds!"); - chatServiceHandler = recordHandler; - recordHandler.onconnect = function(socket) - { - console.log("Client connected: " + socket.peer.name + "," + socket.peer.address); - serviceSocket = socket; - /* Messages received from remote device */ - socket.onmessage = function() - { - var data = socket.readData(); - /* Handles message code goes here */ - }; + console.log("Chat service registration succeeds!"); + chatServiceHandler = recordHandler; + recordHandler.onconnect = function(socket) + { + console.log("Client connected: " + socket.peer.name + "," + socket.peer.address); + serviceSocket = socket; + /* Messages received from remote device */ + socket.onmessage = function() + { + var data = socket.readData(); + /* Handles message code goes here */ + }; - socket.onclose = function() - { - console.log('The socket is closed.'); - serviceSocket = null; - }; - }; + socket.onclose = function() + { + console.log("The socket is closed."); + serviceSocket = null; + }; + }; }; function publishChatService() { - var CHAT_SERVICE_UUID = "5BCE9431-6C75-32AB-AFE0-2EC108A30860"; - adapter.registerRFCOMMServiceByUUID(CHAT_SERVICE_UUID, "Chat service", chatServiceSuccessCb, - /* Error handler: function(e) {console.log("Could not register service record, Error: " + e.message);} */); + var CHAT_SERVICE_UUID = "5BCE9431-6C75-32AB-AFE0-2EC108A30860"; + adapter.registerRFCOMMServiceByUUID(CHAT_SERVICE_UUID, "Chat service", chatServiceSuccessCb, + /* Error handler */ + function(e) + { + console.log( "Could not register service record, Error: " + e.message); + }); } function unregisterChatService() { - if (chatServiceHandler != null) - { - chatServiceHandler.unregister(function() - { - console.log("Chat service is unregistered"); - chatServiceHandler = null; - }, function(e) - { - console.log("Failed to unregister service: " + e.message); - }); - } + if (chatServiceHandler != null) + { + chatServiceHandler.unregister(function() + { + console.log("Chat service is unregistered"); + chatServiceHandler = null; + }, function(e) + { + console.log("Failed to unregister service: " + e.message); + }); + } }
    @@ -2282,6 +2321,10 @@ function unregisterChatService() +
    +

    Return value:

    + BluetoothProfileHandler Represents the Bluetooth profile handle. +

    Exceptions:

    • WebAPIException
        @@ -2305,11 +2348,11 @@ var healthCapability = tizen.systeminfo.getCapability("http://tizen.org/feature/ if (healthCapability) { - healthProfileHandler = adapter.getBluetoothProfileHandler("HEALTH"); + healthProfileHandler = adapter.getBluetoothProfileHandler("HEALTH"); } else { - console.log("Bluetooth Health Profile is not supported on this device."); + console.log("Bluetooth Health Profile is not supported on this device."); }
    @@ -2419,7 +2462,7 @@ Instead, use http://tizen.org/privilege/bluetooth. var adapter = tizen.bluetooth.getLEAdapter(); adapter.startScan(function onsuccess(device) { - console.log("[Found device] address: " + device.address); + console.log("[Found device] address: " + device.address); }); @@ -2466,11 +2509,11 @@ Instead, use http://tizen.org/privilege/bluetooth. var adapter = tizen.bluetooth.getLEAdapter(); adapter.startScan(function onsuccess(device) { - if (device.address == "11:22:33:44:55:66") - { - console.log("Found device: " + device.name); - adapter.stopScan(); - } + if (device.address == "11:22:33:44:55:66") + { + console.log("Found device: " + device.name); + adapter.stopScan(); + } }); @@ -2568,11 +2611,11 @@ var battery_svc_uuid_16 = "180f"; /* Service UUID, 16-bit UUID is supported (e.g var heart_rate_svc_uuid_16 = "180d"; /* Service solicitation UUID, 16-bit UUID is supported (e.g. 180d) */ var advertiseOptions = { - includeName: true, /* Whether the device name should be included */ - includeTxPowerLevel: true, /* Whether the transmission power level should be included */ - appearance: 192, /* External appearance of device, 192 - Generic Watch */ - uuids: [battery_svc_uuid_16], - solicitationuuids: [heart_rate_svc_uuid_16] + includeName: true, /* Whether the device name should be included */ + includeTxPowerLevel: true, /* Whether the transmission power level should be included */ + appearance: 192, /* External appearance of device, 192 - Generic Watch */ + uuids: [battery_svc_uuid_16], + solicitationuuids: [heart_rate_svc_uuid_16] }; var advertiseData = new tizen.BluetoothLEAdvertiseData(advertiseOptions); @@ -2580,10 +2623,10 @@ var connectable = true; adapter.startAdvertise(advertiseData, "ADVERTISE", function onstate(state) { - console.log("Advertiser state: " + state); + console.log("Advertiser state: " + state); }, function(e) { - console.log("Failed to startAdvertise: " + e.message); + console.log("Failed to startAdvertise: " + e.message); }, "LOW_LATENCY", connectable); @@ -2632,18 +2675,18 @@ var battery_svc_uuid_16 = "180f"; /* Service UUID, 16-bit UUID is supported (e.g var heart_rate_svc_uuid_16 = "180d"; /* Service solicitation UUID, 16-bit UUID is supported (e.g. 180d) */ var advertiseOptions = { - includeName: true, /* Whether the device name should be included */ - includeTxPowerLevel: true, /* Whether the transmission power level should be included */ - appearance: 192, /* External appearance of device, 192 - Generic Watch */ - uuids: [battery_svc_uuid_16], - solicitationuuids: [heart_rate_svc_uuid_16] + includeName: true, /* Whether the device name should be included */ + includeTxPowerLevel: true, /* Whether the transmission power level should be included */ + appearance: 192, /* External appearance of device, 192 - Generic Watch */ + uuids: [battery_svc_uuid_16], + solicitationuuids: [heart_rate_svc_uuid_16] }; var advertiseData = new tizen.BluetoothLEAdvertiseData(advertiseOptions); adapter.startAdvertise(advertiseData, "ADVERTISE", function onstate(state) { - console.log("Advertiser state: " + state); + console.log("Advertiser state: " + state); }); adapter.stopAdvertise(); @@ -2670,16 +2713,16 @@ adapter.stopAdvertise();

    Code example:

     function onconnected(device)
     {
    -   console.log("Connected to device");
    -   var service = device.getService(device.uuids[0]);
    -   console.log("Service got");
    +  console.log("Connected to device");
    +  var service = device.getService(device.uuids[0]);
    +  console.log("Service got");
     }
     
     var adapter = tizen.bluetooth.getLEAdapter();
     adapter.startScan(function onsuccess(device)
     {
    -   console.log("[Found device] address: " + device.address);
    -   device.connect(onconnected.bind(null, device), onerror);
    +  console.log("[Found device] address: " + device.address);
    +  device.connect(onconnected.bind(null, device), onerror);
     });
     
    @@ -2717,7 +2760,7 @@ console.log("Service UUID " + service.uuid); var service = device.getService(device.uuids[0]); for (var i = 0; i service.services.length; ++i) { - console.log("Subservices UUID " + service.services[i].uuid); + console.log("Subservices UUID " + service.services[i].uuid); } @@ -2737,7 +2780,7 @@ for (var i = 0; i service.services.length; ++i) var service = device.getService(device.uuids[0]); for (var i = 0; i service.characteristics.length; ++i) { - console.log("Subservices UUID " + service.characteristics[i].isWritable); + console.log("Subservices UUID " + service.characteristics[i].isWritable); } @@ -2938,35 +2981,35 @@ Instead, use http://tizen.org/privilege/bluetooth.

    Code example:

     function onerror(e)
     {
    -   console.log("Failed to connect to device: " + e.message);
    +  console.log("Failed to connect to device: " + e.message);
     }
     
     function proccessDevice(device)
     {
    -   device.connect(onConnected, onerror);
    -   function onConnected()
    -   {
    -      var service = device.getService(device.uuids[0]);
    -      if (service.characteristics.length > 0)
    +  device.connect(onConnected, onerror);
    +  function onConnected()
    +  {
    +    var service = device.getService(device.uuids[0]);
    +    if (service.characteristics.length > 0)
    +    {
    +      var characteristic = service.characteristics[0];
    +      characteristic.readValue(function(val)
           {
    -         var characteristic = service.characteristics[0];
    -         characteristic.readValue(function(val)
    -         {
    -            console.log("Value read: " + val);
    -            device.disconnect();
    -         });
    -      }
    -   }
    +        console.log("Value read: " + val);
    +        device.disconnect();
    +      });
    +    }
    +  }
     }
     
     var adapter = tizen.bluetooth.getLEAdapter();
     adapter.startScan(function onsuccess(device)
     {
    -   if (device.address == "11:22:33:44:55:66")
    -   {
    -      console.log("Found device: " + device.name);
    -      proccessDevice(device);
    -   }
    +  if (device.address == "11:22:33:44:55:66")
    +  {
    +    console.log("Found device: " + device.name);
    +    proccessDevice(device);
    +  }
     });
     
    @@ -3041,39 +3084,39 @@ Instead, use http://tizen.org/privilege/bluetooth.

    Code example:

     function onerror(e)
     {
    -   console.log("Failed to connect to device: " + e.message);
    +  console.log("Failed to connect to device: " + e.message);
     }
     
     function proccessDevice(device)
     {
    -   device.connect(onConnected, onerror);
    -   function onConnected()
    -   {
    -      var service = device.getService(device.uuids[0]);
    -      if (service.characteristics.length > 0)
    +  device.connect(onConnected, onerror);
    +  function onConnected()
    +  {
    +    var service = device.getService(device.uuids[0]);
    +    if (service.characteristics.length > 0)
    +    {
    +      var characteristic = service.characteristics[0];
    +      var data = new Array(1, 2, 3, 4, 5, 6);
    +      characteristic.writeValue(data, function()
           {
    -         var characteristic = service.characteristics[0];
    -         var data = new Array(1, 2, 3, 4, 5, 6);
    -         characteristic.writeValue(data, function()
    -         {
    -            console.log("Value written");
    -            device.disconnect();
    -         }, function(e)
    -         {
    -            console.log("Failed to write: " + e.message);
    -         });
    -      }
    -   }
    +        console.log("Value written");
    +        device.disconnect();
    +      }, function(e)
    +      {
    +        console.log("Failed to write: " + e.message);
    +      });
    +    }
    +  }
     }
     
     var adapter = tizen.bluetooth.getLEAdapter();
     adapter.startScan(function onsuccess(device)
     {
    -   if (device.address == "11:22:33:44:55:66")
    -   {
    -      console.log("Found device: " + device.name);
    -      proccessDevice(device);
    -   }
    +  if (device.address == "11:22:33:44:55:66")
    +  {
    +    console.log("Found device: " + device.name);
    +     proccessDevice(device);
    +  }
     });
     
    @@ -3127,35 +3170,34 @@ Instead, use http://tizen.org/privilege/bluetooth.

    Code example:

     function proccessDevice(device)
     {
    -   function onConnected()
    -   {
    -      var service = device.getService("5BCE9431-6C75-32AB-AFE0-2EC108A30860");
    -      if (service.characteristics.length > 0)
    -      {
    -         var characteristic = service.characteristics[0];
    -         var watchID;
    -
    -         watchID = characteristic.addValueChangeListener(function(value)
    -         {
    -            console.log("Characteristic value changed: " + value);
    -            characteristic.removeValueChangeListener(watchID);
    -            device.disconnect();
    -         });
    -      }
    -   }
    +  function onConnected()
    +  {
    +    var service = device.getService("5BCE9431-6C75-32AB-AFE0-2EC108A30860");
    +    if (service.characteristics.length > 0)
    +    {
    +      var characteristic = service.characteristics[0];
    +      var watchID;
     
    -   device.connect(onConnected);
    +      watchID = characteristic.addValueChangeListener(function(value)
    +      {
    +        console.log("Characteristic value changed: " + value);
    +        characteristic.removeValueChangeListener(watchID);
    +        device.disconnect();
    +      });
    +    }
    +  }
    +    device.connect(onConnected);
     }
     
     var adapter = tizen.bluetooth.getLEAdapter();
     adapter.startScan(function onsuccess(device)
     {
    -   if (device.address == "11:22:33:44:55:66")
    -   {
    -      console.log("Found device: " + device.name);
    -      adapter.stopScan();
    -      proccessDevice(device);
    -   }
    +  if (device.address == "11:22:33:44:55:66")
    +  {
    +    console.log("Found device: " + device.name);
    +    adapter.stopScan();
    +     proccessDevice(device);
    +  }
     });
     
    @@ -3273,36 +3315,36 @@ Instead, use http://tizen.org/privilege/bluetooth.

    Code example:

     function onerror(e)
     {
    -   console.log("Failed to connect to device: " + e.message);
    +  console.log("Failed to connect to device: " + e.message);
     }
     
     function proccessDevice(device)
     {
    -   device.connect(onConnected, onerror);
    -   function onConnected()
    -   {
    -      var service = device.getService(device.uuids[0]);
    -      if (service.characteristics.length > 0)
    +  device.connect(onConnected, onerror);
    +  function onConnected()
    +  {
    +    var service = device.getService(device.uuids[0]);
    +    if (service.characteristics.length > 0)
    +    {
    +      var characteristic = service.characteristics[0];
    +      var descriptor = characteristic.descriptors[0];
    +      descriptor.readValue(function(val)
           {
    -         var characteristic = service.characteristics[0];
    -         var descriptor = characteristic.descriptors[0];
    -         descriptor.readValue(function(val)
    -         {
    -            console.log("Value read: " + val);
    -            device.disconnect();
    -         });
    -      }
    -   }
    +        console.log("Value read: " + val);
    +        device.disconnect();
    +      });
    +    }
    +  }
     }
     
     var adapter = tizen.bluetooth.getLEAdapter();
     adapter.startScan(function onsuccess(device)
     {
    -   if (device.address == "11:22:33:44:55:66")
    -   {
    -      console.log("Found device: " + device.name);
    -      proccessDevice(device);
    -   }
    +  if (device.address == "11:22:33:44:55:66")
    +  {
    +    console.log("Found device: " + device.name);
    +    proccessDevice(device);
    +  }
     });
     
    @@ -3377,40 +3419,40 @@ Instead, use http://tizen.org/privilege/bluetooth.

    Code example:

     function onerror(e)
     {
    -   console.log("Failed to connect to device: " + e.message);
    +  console.log("Failed to connect to device: " + e.message);
     }
     
     function proccessDevice(device)
     {
    -   device.connect(onConnected, onerror);
    -   function onConnected()
    -   {
    -      var service = device.getService(device.uuids[0]);
    -      if (service.characteristics.length > 0)
    +  device.connect(onConnected, onerror);
    +  function onConnected()
    +  {
    +    var service = device.getService(device.uuids[0]);
    +    if (service.characteristics.length > 0)
    +    {
    +      var characteristic = service.characteristics[0];
    +      var data = new Array(1, 2, 3, 4, 5, 6);
    +      var descriptor = characteristic.descriptors[0];
    +      descriptor.writeValue(data, function()
           {
    -         var characteristic = service.characteristics[0];
    -         var data = new Array(1, 2, 3, 4, 5, 6);
    -         var descriptor = characteristic.descriptors[0];
    -         descriptor.writeValue(data, function()
    -         {
    -            console.log("Value written");
    -            device.disconnect();
    -         }, function(e)
    -         {
    -            console.log("Failed to write: " + e.message);
    -         });
    -      }
    -   }
    +        console.log("Value written");
    +        device.disconnect();
    +      }, function(e)
    +      {
    +        console.log("Failed to write: " + e.message);
    +      });
    +    }
    +  }
     }
     
     var adapter = tizen.bluetooth.getLEAdapter();
     adapter.startScan(function onsuccess(device)
     {
    -   if (device.address == "11:22:33:44:55:66")
    -   {
    -      console.log("Found device: " + device.name);
    -      proccessDevice(device);
    -   }
    +  if (device.address == "11:22:33:44:55:66")
    +  {
    +    console.log("Found device: " + device.name);
    +    proccessDevice(device);
    +  }
     });
     
    @@ -3666,7 +3708,7 @@ A BluetoothDevice object can be retrieved using one of the following AP var adapter = tizen.bluetooth.getDefaultAdapter(); adapter.getDevice("11:22:33:44:55:66", function(device) { - console.log("Device Name: " + device.name); + console.log("Device Name: " + device.name); }); @@ -3685,7 +3727,7 @@ adapter.getDevice("11:22:33:44:55:66", function(device) var adapter = tizen.bluetooth.getDefaultAdapter(); adapter.getDevice("11:22:33:44:55:66", function(device) { - console.log("Device Address: " + device.address); + console.log("Device Address: " + device.address); }); @@ -3704,7 +3746,7 @@ adapter.getDevice("11:22:33:44:55:66", function(device) var adapter = tizen.bluetooth.getDefaultAdapter(); adapter.getDevice("11:22:33:44:55:66", function(device) { - console.log("Device Major Class: " + device.deviceClass.major); + console.log("Device Major Class: " + device.deviceClass.major); }); @@ -3723,7 +3765,7 @@ adapter.getDevice("11:22:33:44:55:66", function(device) var adapter = tizen.bluetooth.getDefaultAdapter(); adapter.getDevice("11:22:33:44:55:66", function(device) { - console.log("Is bonded: " + (device.isBonded ? "Yes" : "No")); + console.log("Is bonded: " + (device.isBonded ? "Yes" : "No")); }); @@ -3742,7 +3784,7 @@ adapter.getDevice("11:22:33:44:55:66", function(device) var adapter = tizen.bluetooth.getDefaultAdapter(); adapter.getDevice("11:22:33:44:55:66", function(device) { - console.log("Is trusted: " + (device.isTrusted ? "Yes" : "No")); + console.log("Is trusted: " + (device.isTrusted ? "Yes" : "No")); }); @@ -3761,7 +3803,7 @@ adapter.getDevice("11:22:33:44:55:66", function(device) var adapter = tizen.bluetooth.getDefaultAdapter(); adapter.getDevice("11:22:33:44:55:66", function(device) { - console.log("Is connected: " + (device.isConnected ? "Yes" : "No")); + console.log("Is connected: " + (device.isConnected ? "Yes" : "No")); }); @@ -3782,24 +3824,24 @@ var adapter = tizen.bluetooth.getDefaultAdapter(); var CHAT_SERVICE_UUID = "5BCE9431-6C75-32AB-AFE0-2EC108A30860"; adapter.getDevice("11:22:33:44:55:66", function(device) { - var uuids = device.uuids; - var services = ""; - for (var i = 0; i < uuids.length; i++) - { - services += uuids[i] + "\n"; - } - console.log("Services found: " + services); - if (uuids.indexOf(CHAT_SERVICE_UUID) != -1) - { - /* Connects to service */ - device.connectToServiceByUUID(CHAT_SERVICE_UUID, function(socket) - { - /* Connected to service, handle socket */ - }, function(e) - { - console.log("Could not connect to chat service !!!. Error: " + e.message); - }); - } + var uuids = device.uuids; + var services = ""; + for (var i = 0; i < uuids.length; i++) + { + services += uuids[i] + "\n"; + } + console.log("Services found: " + services); + if (uuids.indexOf(CHAT_SERVICE_UUID) != -1) + { + /* Connects to service */ + device.connectToServiceByUUID(CHAT_SERVICE_UUID, function(socket) + { + /* Connected to service, handle socket */ + }, function(e) + { + console.log("Could not connect to chat service !!!. Error: " + e.message); + }); + } }); @@ -3887,57 +3929,57 @@ var clientSocket = null; /* Calls a method that is invoked when user wants to send a message to a remote device */ function sendMessage(msg) { - /* Validates socket state, if everything is ok */ - if (clientSocket != null && clientSocket.state == "OPEN") - { - /* Sends the message */ - clientSocket.writeData(msg); - } + /* Validates socket state, if everything is ok */ + if (clientSocket != null && clientSocket.state == "OPEN") + { + /* Sends the message */ + clientSocket.writeData(msg); + } } /* Calls a method that is invoked when a socket is open */ function onSocketConnected(socket) { - clientSocket = socket; - console.log("Opening a socket successfully!!!"); - socket.onmessage = function() - { - var data = socket.readData(); - var recvmsg = ""; - for (var i = 0; i < data.length; i++) - { - recvmsg += String.fromCharCode(data[i]); - } - console.log("server msg >> " + recvmsg); - }; - - socket.onclose = function() - { - console.log("socket disconnected."); - }; + clientSocket = socket; + console.log("Opening a socket successfully!!!"); + socket.onmessage = function() + { + var data = socket.readData(); + var recvmsg = ""; + for (var i = 0; i < data.length; i++) + { + recvmsg += String.fromCharCode(data[i]); + } + console.log("server msg >> " + recvmsg); + }; + + socket.onclose = function() + { + console.log("socket disconnected."); + }; } function onDeviceReady(device) { - /* Validates device and service uuid */ - if (device.uuids.indexOf("5BCE9431-6C75-32AB-AFE0-2EC108A30860") != -1) - { - /* Opens socket */ - device.connectToServiceByUUID("5BCE9431-6C75-32AB-AFE0-2EC108A30860", onSocketConnected, function(e) - { - console.log("Error connecting to service. Reason: " + e.message); - }); - } - else - { - console.log("Chat service is not supported by this device"); - } + /* Validates device and service uuid */ + if (device.uuids.indexOf("5BCE9431-6C75-32AB-AFE0-2EC108A30860") != -1) + { + /* Opens socket */ + device.connectToServiceByUUID("5BCE9431-6C75-32AB-AFE0-2EC108A30860", onSocketConnected, function(e) + { + console.log("Error connecting to service. Reason: " + e.message); + }); + } + else + { + console.log("Chat service is not supported by this device"); + } } function onSetPowered() { - /* Gets the BluetoothDevice object */ - adapter.getDevice("35:F4:59:D1:7A:03", onDeviceReady, function(e) {console.log("Error: " + e.message);}); + /* Gets the BluetoothDevice object */ + adapter.getDevice("35:F4:59:D1:7A:03", onDeviceReady, function(e) {console.log("Error: " + e.message); }); } adapter.setPowered(true, onSetPowered, function(e) {console.log("Could not turn on Bluetooth adapter. reason: " + e.message); }); @@ -4006,7 +4048,7 @@ A BluetoothLEDevice object can be retrieved by using one of the followi var adapter = tizen.bluetooth.getLEAdapter(); adapter.startScan(function onsuccess(device) { - console.log("Found device: " + device.address); + console.log("Found device: " + device.address); }); @@ -4025,14 +4067,14 @@ adapter.startScan(function onsuccess(device) var adapter = tizen.bluetooth.getLEAdapter(); adapter.startScan(function onsuccess(device) { - console.log("Found device: " + device.name); + console.log("Found device: " + device.name); });
  • readonly -unsigned long txpowerlevel [nullable]
    +long txpowerlevel [nullable]
    The transmission power level of the Bluetooth LE device from the scan result information.

    @@ -4044,7 +4086,7 @@ adapter.startScan(function onsuccess(device) var adapter = tizen.bluetooth.getLEAdapter(); adapter.startScan(function onsuccess(device) { - console.log("Found device: " + device.txpowerlevel); + console.log("Found device: " + device.txpowerlevel); });

    @@ -4063,7 +4105,7 @@ adapter.startScan(function onsuccess(device) var adapter = tizen.bluetooth.getLEAdapter(); adapter.startScan(function onsuccess(device) { - console.log("Found device: " + device.appearance); + console.log("Found device: " + device.appearance); }); @@ -4083,13 +4125,13 @@ adapter.startScan(function onsuccess(device) var adapter = tizen.bluetooth.getLEAdapter(); adapter.startScan(function onsuccess(device) { - var uuids = device.uuids; - var services = ""; - for (var i = 0; i < uuids.length; i++) - { - services += uuids[i] + "\n"; - } - console.log("Service found: " + services); + var uuids = device.uuids; + var services = ""; + for (var i = 0; i < uuids.length; i++) + { + services += uuids[i] + "\n"; + } + console.log("Service found: " + services); }); @@ -4109,13 +4151,13 @@ adapter.startScan(function onsuccess(device) var adapter = tizen.bluetooth.getLEAdapter(); adapter.startScan(function onsuccess(device) { - var uuids = device.solicitationuuids; - var services = ""; - for (var i = 0; i < uuids.length; i++) - { - services += uuids[i] + "\n"; - } - console.log("Service solicitations found: " + services); + var uuids = device.solicitationuuids; + var services = ""; + for (var i = 0; i < uuids.length; i++) + { + services += uuids[i] + "\n"; + } + console.log("Service solicitations found: " + services); }); @@ -4135,13 +4177,13 @@ adapter.startScan(function onsuccess(device) var adapter = tizen.bluetooth.getLEAdapter(); adapter.startScan(function onsuccess(device) { - var serviceData = device.serviceData; - var data = ""; - for (var i = 0; i < serviceData.length; i++) - { - data += serviceData[i].id + serviceData[i].data + "\n"; - } - console.log("Service data found: " + data); + var serviceData = device.serviceData; + var data = ""; + for (var i = 0; i < serviceData.length; i++) + { + data += serviceData[i].id + serviceData[i].data + "\n"; + } + console.log("Service data found: " + data); }); @@ -4160,9 +4202,9 @@ adapter.startScan(function onsuccess(device) var adapter = tizen.bluetooth.getLEAdapter(); adapter.startScan(function onsuccess(device) { - var manufacturerData = device.manufacturerData; - console.log("Manufacture id: " + manufacturerData.id); - console.log("Manufacture data: " + manufacturerData.data); + var manufacturerData = device.manufacturerData; + console.log("Manufacture id: " + manufacturerData.id); + console.log("Manufacture data: " + manufacturerData.data); }); @@ -4186,8 +4228,8 @@ The signal strength depends on distance (between the device and the beacon) and var adapter = tizen.bluetooth.getLEAdapter(); adapter.startScan(function onsuccess(device) { - console.log("Found device: " + device.name); - console.log("RSSI: " + device.rssi); + console.log("Found device: " + device.name); + console.log("RSSI: " + device.rssi); }); @@ -4268,21 +4310,21 @@ Instead, use http://tizen.org/privilege/bluetooth.

    Code example:

     function onerror(e)
     {
    -   console.log("Failed to connect to device: " + e.message);
    +  console.log("Failed to connect to device: " + e.message);
     }
     
     function onconnected()
     {
    -   console.log("Connected to device");
    +  console.log("Connected to device");
     }
     
     var adapter = tizen.bluetooth.getLEAdapter();
     adapter.startScan(function onsuccess(device)
     {
    -   if (device.address == "11:22:33:44:55:66")
    -   {
    -      console.log("Found device: " + device.name);
    -      device.connect(onconnected, onerror);
    +  if (device.address == "11:22:33:44:55:66")
    +  {
    +    console.log("Found device: " + device.name);
    +    device.connect(onconnected, onerror);
        }
     });
     
    @@ -4354,27 +4396,27 @@ Instead, use http://tizen.org/privilege/bluetooth.

    Code example:

     function onerror(e)
     {
    -   console.log("Error occurred: " + e.message);
    +  console.log("Error occurred: " + e.message);
     }
     
     function onDeviceFound(device)
     {
    -   function ondisconnect()
    -   {
    -      console.log("Disconnected");
    -   }
    -
    -   function onconnected()
    -   {
    -      console.log("Connected to device");
    -      device.disconnect(ondisconnect, onerror);
    -   }
    -
    -   if (device.address == "11:22:33:44:55:66")
    -   {
    -      console.log("Found device: " + device.name);
    -      device.connect(onconnected, onerror);
    -   }
    +  function ondisconnect()
    +  {
    +    console.log("Disconnected");
    +  }
    +
    +  function onconnected()
    +  {
    +    console.log("Connected to device");
    +    device.disconnect(ondisconnect, onerror);
    +  }
    +
    +  if (device.address == "11:22:33:44:55:66")
    +  {
    +    console.log("Found device: " + device.name);
    +    device.connect(onconnected, onerror);
    +  }
     }
     
     var adapter = tizen.bluetooth.getLEAdapter();
    @@ -4438,23 +4480,23 @@ Instead, use http://tizen.org/privilege/bluetooth.
     

    Code example:

     function onconnected(device)
     {
    -   console.log("Connected to device");
    -   var service = device.getService(device.uuids[0]);
    -   console.log("Service got");
    +  console.log("Connected to device");
    +  var service = device.getService(device.uuids[0]);
    +  console.log("Service got");
     }
     
     function onerror(e)
     {
    -   console.log("Error occurred: " + e.message);
    +  console.log("Error occurred: " + e.message);
     }
     
     function onDeviceFound(device)
     {
    -   if (device.address == "11:22:33:44:55:66")
    -   {
    -      console.log("Found device: " + device.name);
    -      device.connect(onconnected.bind(null, device), onerror);
    -   }
    +  if (device.address == "11:22:33:44:55:66")
    +  {
    +    console.log("Found device: " + device.name);
    +    device.connect(onconnected.bind(null, device), onerror);
    +  }
     }
     
     var adapter = tizen.bluetooth.getLEAdapter();
    @@ -4483,41 +4525,56 @@ adapter.startScan(onDeviceFound, onerror);
                 Privilege: 
      http://tizen.org/privilege/bluetooth
                 

    +
    +

    Return value:

    + BluetoothUUID[] The array of all service UUIDs that belong to the connected GATT server. +

    Exceptions:

    • WebAPIException
        -
      • with error type InvalidValuesError, If GATT server is not available.

      • -
      • with error type NotSupportedError, If the feature is not supported.

      • -
      +
    • + with error type InvalidValuesError: If GATT server is not available. +

    • +
    • + with error type NotSupportedError: If the feature is not supported. +

    • +
  • Code example:

    +/*Below variable should represent valid address of discoverable bluetooth low energy device */
    +var remoteAddress = "11:22:33:44:55:66";
    +
     function onconnected(device)
     {
    -   console.log("Connected to device");
    -   var services = device.getServiceAllUuids();
    -   console.log("Services length " + services.length);
    +  console.log("Connected to device");
    +  var services = device.getServiceAllUuids();
    +  console.log("Services length " + services.length);
     }
     
     function onerror(e)
     {
    -   console.log("Error occurred: " + e.message);
    +  console.log("Error occurred: " + e.message);
     }
     
     function onDeviceFound(device)
     {
    -   if (device.address == "11:22:33:44:55:66")
    -   {
    -      console.log("Found device: " + device.name);
    -      device.connect(onconnected.bind(null, device), onerror);
    -   }
    +  if (device.address == remoteAddress)
    +  {
    +    device.connect(onconnected.bind(null, device), onerror);
    +  }
     }
     
     var adapter = tizen.bluetooth.getLEAdapter();
     adapter.startScan(onDeviceFound, onerror);
     
    +
    +

    Output example:

     Connected to device
    + Services length 2
    + 
    +
    addConnectStateChangeListener @@ -4556,29 +4613,29 @@ adapter.startScan(onDeviceFound, onerror);

    Code example:

     function onerror(e)
     {
    -   console.log("Error occurred: " + e.message);
    +  console.log("Error occurred: " + e.message);
     }
     
     function onDeviceFound(device)
     {
    -   var onConnectionStateChange =
    -   {
    -      onconnected: function(device)
    -      {
    -         console.log("Device " + device.name + " connected");
    -      },
    -      ondisconnected: function(device)
    -      {
    -         console.log("Device " + device.name + " disconnected");
    -      }
    -   }
    -
    -   if (device.address === "11:22:33:44:55:66")
    -   {
    -      console.log("Found device: " + device.name);
    -      device.addConnectStateChangeListener(onConnectionStateChange);
    -      device.connect();
    -   }
    +  var onConnectionStateChange =
    +  {
    +    onconnected: function(device)
    +    {
    +      console.log("Device " + device.name + " connected");
    +    },
    +    ondisconnected: function(device)
    +    {
    +      console.log("Device " + device.name + " disconnected");
    +    }
    +  }
    +
    +  if (device.address === "11:22:33:44:55:66")
    +  {
    +    console.log("Found device: " + device.name);
    +    device.addConnectStateChangeListener(onConnectionStateChange);
    +    device.connect();
    +  }
     }
     
     var adapter = tizen.bluetooth.getLEAdapter();
    @@ -4612,30 +4669,30 @@ adapter.startScan(onDeviceFound, onerror);
     

    Code example:

     function onerror(e)
     {
    -   console.log("Error occurred: " + e.message);
    +  console.log("Error occurred: " + e.message);
     }
     
     function onDeviceFound(device)
     {
    -   var onConnectionStateChange =
    -   {
    -      onconnected: function(device)
    -      {
    -         console.log("Device " + device.name + " connected");
    -      },
    -      ondisconnected: function(device)
    -      {
    -         console.log("Device " + device.name + " disconnected");
    -         device.removeConnectStateChangeListener(listenerID);
    -      }
    -   }
    -
    -   if (device.address === "11:22:33:44:55:66")
    -   {
    -      console.log("Found device: " + device.name);
    -      listenerID = device.addConnectStateChangeListener(onConnectionStateChange);
    -      device.connect();
    -   }
    +  var onConnectionStateChange =
    +  {
    +    onconnected: function(device)
    +    {
    +      console.log("Device " + device.name + " connected");
    +    },
    +    ondisconnected: function(device)
    +    {
    +      console.log("Device " + device.name + " disconnected");
    +      device.removeConnectStateChangeListener(listenerID);
    +    }
    +  }
    +
    +  if (device.address === "11:22:33:44:55:66")
    +  {
    +    console.log("Found device: " + device.name);
    +    listenerID = device.addConnectStateChangeListener(onConnectionStateChange);
    +    device.connect();
    +  }
     }
     
     var adapter = tizen.bluetooth.getLEAdapter();
    @@ -4806,46 +4863,46 @@ var adapter = tizen.bluetooth.getDefaultAdapter();
     
     function onSocketConnected(socket)
     {
    -   console.log("Opened connection to remote device");
    -   socket.onmessage = function()
    -   {
    -      console.log("Message received: " + socket.readData());
    -   };
    -
    -   socket.onclose = function()
    -   {
    -      console.log("Socket closed with " + socket.peer.name);
    -   };
    -
    -   /* Sends data to peer */
    -   var textmsg = "Test";
    -   var sendtextmsg = new Array();
    -   for (var i = 0; i < textmsg.length; i++)
    -   {
    -      sendtextmsg[i] = textmsg.charCodeAt(i);
    -   }
    -   socket.writeData(sendtextmsg);
    +  console.log("Opened connection to remote device");
    +  socket.onmessage = function()
    +  {
    +    console.log("Message received: " + socket.readData());
    +  };
    +
    +  socket.onclose = function()
    +  {
    +    console.log("Socket closed with " + socket.peer.name);
    +  };
    +
    +  /* Sends data to peer */
    +  var textmsg = "Test";
    +  var sendtextmsg = new Array();
    +  for (var i = 0; i < textmsg.length; i++)
    +  {
    +    sendtextmsg[i] = textmsg.charCodeAt(i);
    +  }
    +  socket.writeData(sendtextmsg);
     }
     
     function onSocketError(e)
     {
    -   console.log("Error connecting to service. Reason: " + e.message);
    +  console.log("Error connecting to service. Reason: " + e.message);
     }
     
     function onDeviceReady(device)
     {
    -   /* Validates device and service uuid */
    -   if (device.uuids.indexOf("5BCE9431-6C75-32AB-AFE0-2EC108A30860") != -1)
    -   {
    -      /* Opens socket */
    -      device.connectToServiceByUUID("5BCE9431-6C75-32AB-AFE0-2EC108A30860", onSocketConnected, onSocketError);
    -   }
    +  /* Validates device and service uuid */
    +  if (device.uuids.indexOf("5BCE9431-6C75-32AB-AFE0-2EC108A30860") != -1)
    +  {
    +    /* Opens socket */
    +    device.connectToServiceByUUID("5BCE9431-6C75-32AB-AFE0-2EC108A30860", onSocketConnected, onSocketError);
    +  }
     }
     
     function onSetPowered()
     {
    -   /* Gets the BluetoothDevice object */
    -   adapter.getDevice("35:F4:59:D1:7A:03", onDeviceReady, function(e) {console.log("Error: " + e.message);});
    +  /* Gets the BluetoothDevice object */
    +  adapter.getDevice("35:F4:59:D1:7A:03", onDeviceReady, function(e) {console.log("Error: " + e.message);});
     }
     
     adapter.setPowered(true, onSetPowered, function(e) {console.log("Could not turn on Bluetooth adapter. reason: " + e.message);});
    @@ -4904,41 +4961,41 @@ var adapter = tizen.bluetooth.getDefaultAdapter();
     
     function onError(e)
     {
    -   console.log("Error connecting to service. Reason: " + e.message);
    +  console.log("Error connecting to service. Reason: " + e.message);
     }
     
     function onSocketConnected(socket)
     {
    -   console.log("Opening socket success!!!");
    +  console.log("Opening socket success!!!");
     
    -   socket.onmessage = function()
    -   {
    -      /* Gets a message from peer, reads it */
    -      var data = socket.readData();
    +  socket.onmessage = function()
    +  {
    +    /* Gets a message from peer, reads it */
    +    var data = socket.readData();
     
    -      /* Code to evaluate message goes here */
    -   };
    +    /* Code to evaluate message goes here */
    +  };
     
    -   socket.onclose = function()
    -   {
    -      console.log("Socket closed with " + socket.peer.name);
    -   };
    +  socket.onclose = function()
    +  {
    +    console.log("Socket closed with " + socket.peer.name);
    +  };
     }
     
     function onDeviceReady(device)
     {
    -   /* Validates device and service uuid */
    -   if (device.uuids.indexOf("5BCE9431-6C75-32AB-AFE0-2EC108A30860") != -1)
    -   {
    -      /* Opens socket */
    -      device.connectToServiceByUUID("5BCE9431-6C75-32AB-AFE0-2EC108A30860", onSocketConnected, onError);
    -   }
    +  /* Validates device and service uuid */
    +  if (device.uuids.indexOf("5BCE9431-6C75-32AB-AFE0-2EC108A30860") != -1)
    +  {
    +    /* Opens socket */
    +    device.connectToServiceByUUID("5BCE9431-6C75-32AB-AFE0-2EC108A30860", onSocketConnected, onError);
    +  }
     }
     
     function onSetPowered()
     {
    -   /* Gets the BluetoothDevice object */
    -   adapter.getDevice("35:F4:59:D1:7A:03", onDeviceReady, function(e) {console.log("Error: " + e.message);});
    +  /* Gets the BluetoothDevice object */
    +  adapter.getDevice("35:F4:59:D1:7A:03", onDeviceReady, function(e) {console.log("Error: " + e.message);});
     }
     
     adapter.setPowered(true, onSetPowered, function(e) {console.log("Could not turn on Bluetooth adapter. reason: " + e.message);});
    @@ -5001,7 +5058,7 @@ Instead, use http://tizen.org/privilege/bluetooth.
     
             readonly attribute octet minor;
     
    -        readonly attribute unsigned short [] services ;
    +        readonly attribute unsigned short [] services;
     
             boolean hasService(unsigned short service) raises(WebAPIException);
         };
    @@ -5052,22 +5109,22 @@ var adapter = tizen.bluetooth.getDefaultAdapter(); function evaluateDevice(address) { - adapter.getDevice(address, function(device) - { - if (device.deviceClass.major == tizen.bluetooth.deviceMajor.COMPUTER) - { - /* Shows computer icon for this device */ - console.log("Device is computer"); - } - else if (device.deviceClass.major == tizen.bluetooth.deviceMajor.PHONE) - { - /* Shows phone icon */ - console.log("Device is a Phone"); - } - }, function(e) - { - console.log("Couldn't get any device with the given address: " + e.message); - }); + adapter.getDevice(address, function(device) + { + if (device.deviceClass.major == tizen.bluetooth.deviceMajor.COMPUTER) + { + /* Shows computer icon for this device */ + console.log("Device is computer"); + } + else if (device.deviceClass.major == tizen.bluetooth.deviceMajor.PHONE) + { + /* Shows phone icon */ + console.log("Device is a Phone"); + } + }, function(e) + { + console.log("Couldn't get any device with the given address: " + e.message); + }); } evaluateDevice("11:22:33:44:55:66"); @@ -5140,6 +5197,10 @@ Instead, use http://tizen.org/privilege/bluetooth. +
    +

    Return value:

    + boolean true, if given service exists in the services. +

    Exceptions:

    • WebAPIException
        @@ -5160,13 +5221,13 @@ Instead, use http://tizen.org/privilege/bluetooth. var adapter = tizen.bluetooth.getDefaultAdapter(); adapter.getDevice("12:34:56:78:9A:BC", function(device) { - if (device.deviceClass.hasService(tizen.bluetooth.deviceService.POSITIONING)) - { - console.log("Device supports Positioning service"); - } + if (device.deviceClass.hasService(tizen.bluetooth.deviceService.POSITIONING)) + { + console.log("Device supports Positioning service"); + } }, function(e) { - console.log("Couldn't get device for given address: " + e.message); + console.log("Couldn't get device for given address: " + e.message); });
    @@ -5333,7 +5394,8 @@ adapter.getDevice("12:34:56:78:9A:BC", function(device)
  • readonly BluetoothUUID uuid
    - The UUID of the service. + The UUID of the service. See example +.

    Since: @@ -5343,7 +5405,8 @@ adapter.getDevice("12:34:56:78:9A:BC", function(device)

  • readonly DOMString name
    - The name of the service. + The name of the service. See example +.

    Since: @@ -5353,7 +5416,7 @@ adapter.getDevice("12:34:56:78:9A:BC", function(device)

  • readonly boolean isConnected
    - The flag indicating whether any remote devices is using this service. + The flag indicating whether any remote devices is using this service. See example.

    Since: @@ -5376,6 +5439,42 @@ By default, this attribute is set to null.

  • +
    +

    Code example:

    +var adapter = tizen.bluetooth.getDefaultAdapter();
    +
    +function chatServiceSuccessCb(handler)
    +{
    +  console.log("Chat service " + handler.name + " with UUID " + handler.uuid + " is successfully registered!");
    +  console.log("There is " + (handler.isConnected ? "a" : "no") + " device using this service");
    +
    +  handler.onconnect = function(socket)
    +  {
    +    console.log("Client is connected: " + socket.peer.name + "," + socket.peer.address);
    +    socket.onmessage = function()
    +    {
    +      var data = socket.readData();
    +      /* Handle message code goes here */
    +    };
    +
    +    /* Expected close */
    +    socket.onclose = function()
    +    {
    +      console.log("The socket is closed.");
    +    };
    +  };
    +}
    +
    +function errorCb(e)
    +{
    +  console.log("Could not register service record, Error: " + e.message);
    +}
    +
    +var CHAT_SERVICE_UUID = "5BCE9431-6C75-32AB-AFE0-2EC108A30860";
    +adapter.registerRFCOMMServiceByUUID(CHAT_SERVICE_UUID, "Chat service", chatServiceSuccessCb, errorCb);
    +
    +
    +
    @@ -5448,46 +5547,50 @@ var chatServiceHandler = null; function chatServiceSuccessCb(handler) { - console.log("Chat service registration was successful!"); + console.log("Chat service registration was successful!"); - chatServiceHandler = handler; - handler.onconnect = function(socket) - { - console.log("Client is connected: " + socket.peer.name + "," + socket.peer.address); - socket.onmessage = function() - { - var data = socket.readData(); - /* Handle message code here */ - }; + chatServiceHandler = handler; + handler.onconnect = function(socket) + { + console.log("Client is connected: " + socket.peer.name + "," + socket.peer.address); + socket.onmessage = function() + { + var data = socket.readData(); + /* Handle message code goes here */ + }; - /* Expected close */ - socket.onclose = function() - { - console.log('The socket is closed.'); - }; - }; + /* Expected close */ + socket.onclose = function() + { + console.log("The socket is closed."); + }; + }; } function publishChatService() { - var CHAT_SERVICE_UUID = "5BCE9431-6C75-32AB-AFE0-2EC108A30860"; - adapter.registerRFCOMMServiceByUUID(CHAT_SERVICE_UUID, "Chat service", chatServiceSuccessCb, - /* Error handler: function(e) {console.log("Could not register service record, Error: " + e.message);} */); + var CHAT_SERVICE_UUID = "5BCE9431-6C75-32AB-AFE0-2EC108A30860"; + adapter.registerRFCOMMServiceByUUID(CHAT_SERVICE_UUID, "Chat service", chatServiceSuccessCb, + /* Error handler */ + function(e) + { + console.log("Could not register service record, Error: " + e.message); + }); } function unRegisterChatService() { - if (chatServiceHandler != null) - { - chatServiceHandler.unregister(function() - { - chatServiceHandler = null; - console.log("Chat service is unregistered."); + if (chatServiceHandler != null) + { + chatServiceHandler.unregister(function() + { + chatServiceHandler = null; + console.log("Chat service is unregistered."); }, function(e) - { - console.log("Error: " + e.message); - }); - } + { + console.log("Error: " + e.message); + }); + } } @@ -5519,6 +5622,22 @@ function unRegisterChatService() Since: 2.2

    +
    +

    Code example:

    +var adapter = tizen.bluetooth.getDefaultAdapter();
    +var healthCapability = tizen.systeminfo.getCapability("http://tizen.org/feature/network.bluetooth.health");
    +
    +if (healthCapability)
    +{
    +  var healthProfileHandler = adapter.getBluetoothProfileHandler("HEALTH");
    +  console.log("Bluetooth profile type is " + healthProfileHandler.profileType);
    +}
    +else
    +{
    +  console.log("Bluetooth Health Profile is not supported on this device.");
    +}
    +
    +
    @@ -5620,12 +5739,12 @@ var healthProfileHandler = adapter.getBluetoothProfileHandler("HEALTH"); function healthRegisterSuccess(app) { - console.log("Registered application: " + app.name); + console.log("Registered application: " + app.name); } function healthRegisterError(e) { - console.log("Failed to register application: " + e.message); + console.log("Failed to register application: " + e.message); }; healthProfileHandler.registerSinkApplication(4100, "testSinkApp", healthRegisterSuccess, healthRegisterError); @@ -5711,33 +5830,33 @@ var registerHealthApp = null; function healthConnectSuccess(channel) { - console.log("Health device is connected"); - var status = "Name of remote device: " + channel.peer.name + - "channel type of device profile: " + channel.channelType + - "health application name: " + channel.appication.name; - console.log(status); + console.log("Health device is connected"); + var status = "Name of remote device: " + channel.peer.name + + "channel type of device profile: " + channel.channelType + + "health application name: " + channel.appication.name; + console.log(status); } function healthConnectError(e) { - console.log("Failed to connect to source: " + e.message); + console.log("Failed to connect to source: " + e.message); }; function gotDeviceInfo(device) { - healthProfileHandler.connectToSource(device, registerHealthApp, healthConnectSuccess, healthConnectError); + healthProfileHandler.connectToSource(device, registerHealthApp, healthConnectSuccess, healthConnectError); } function healthRegisterSuccess(app) { - console.log("Registered application: " + app.name); - registerHealthApp = app; - adapter.getDevice("35:F4:59:D1:7A:03", gotDeviceInfo); + console.log("Registered application: " + app.name); + registerHealthApp = app; + adapter.getDevice("35:F4:59:D1:7A:03", gotDeviceInfo); } function healthRegisterError(e) { - console.log("Failed to register application: " + e.message); + console.log("Failed to register application: " + e.message); }; healthProfileHandler.registerSinkApplication(4100, "testSinkApp", healthRegisterSuccess, healthRegisterError); @@ -5777,7 +5896,7 @@ healthProfileHandler.registerSinkApplication(4100, "testSinkApp", healthRegister

    -For example, pulse oximeter is 4100 and blood pressure monitor is 4103. +For example, pulse oximeter is 4100 and blood pressure monitor is 4103. See example.

    @@ -5788,7 +5907,7 @@ For example, pulse oximeter is 4100 and blood pressure monitor is 4103.

  • readonly DOMString name
    - The friendly name associated with sink application. + The friendly name associated with sink application. See example.

    Since: @@ -5815,6 +5934,30 @@ By default, this attribute is set to null.

  • +
    +

    Code example:

    +var adapter = tizen.bluetooth.getDefaultAdapter();
    +var healthProfileHandler = adapter.getBluetoothProfileHandler("HEALTH");
    +
    +function healthRegisterSuccess(app)
    +{
    +  console.log("Registered application: " + app.name);
    +  console.log("Data type used for communication is " + app.dataType);
    +
    +  app.onconnect = function(channel)
    +  {
    +    console.log("Health device is connected");
    +  }
    +}
    +
    +function healthRegisterError(e)
    +{
    +  console.log("Failed to register application: " + e.message);
    +};
    +
    +healthProfileHandler.registerSinkApplication(4100, "testSinkApp", healthRegisterSuccess, healthRegisterError);
    +
    +
    @@ -5890,51 +6033,51 @@ var healthApp = null; function healthRegisterSuccess(app) { - console.log("Registered application: " + app.name); - healthApp = app; - healthApp.onconnect = function(channel) - { - console.log("Connected!!"); - }; + console.log("Registered application: " + app.name); + healthApp = app; + healthApp.onconnect = function(channel) + { + console.log("Connected!!"); + }; } function healthRegisterError(e) { - console.log("Failed to register application: " + e.message); + console.log("Failed to register application: " + e.message); }; function startSink() { - try - { - healthProfileHandler.registerSinkApplication(4100, "testSinkApp", healthRegisterSuccess, healthRegisterError); - } - catch (e) - { - console.log("Error: " + e.message); - } + try + { + healthProfileHandler.registerSinkApplication(4100, "testSinkApp", healthRegisterSuccess, healthRegisterError); + } + catch (e) + { + console.log("Error: " + e.message); + } } function stopSink() { - try - { - if (healthApp != null) + try + { + if (healthApp != null) + { + healthApp.unregister(function() { - healthApp.unregister(function() - { - healthApp = null; - console.log("Health application is unregistered."); - }, function(e) - { - console.log("Error: " + e.message); - }); - } - } - catch (err) - { - console.log("Error: " + err.message); - } + healthApp = null; + console.log("Health application is unregistered."); + }, function(e) + { + console.log("Error: " + e.message); + }); + } + } + catch (err) + { + console.log("Error: " + err.message); + } } @@ -5976,7 +6119,7 @@ function stopSink()
  • readonly BluetoothDevice peer
    - The remote device to which this channel is connected. + The remote device to which this channel is connected. See example.

    Since: @@ -5986,7 +6129,7 @@ function stopSink()

  • readonly BluetoothHealthChannelType channelType
    - The type of this channel. + The type of this channel. See example.

    Since: @@ -5996,7 +6139,7 @@ function stopSink()

  • readonly BluetoothHealthApplication application
    - The health application which is used to communicate with the remote device. + The health application which is used to communicate with the remote device. See example.

    Since: @@ -6012,6 +6155,28 @@ function stopSink() Since: 2.2

    +
    +

    Code example:

    +var adapter = tizen.bluetooth.getDefaultAdapter();
    +var healthProfileHandler = adapter.getBluetoothProfileHandler("HEALTH");
    +
    +function healthRegisterSuccess(app)
    +{
    +  app.onconnect = function(channel)
    +  {
    +    console.log("Health device " + (channel.isConnected ? "is" : "is not") + " connected to " + channel.peer.name + " remote device");
    +    console.log("Channel type is " + channel.channelType + " and health application name used for communication is " + channel.application.name);
    +  }
    +}
    +
    +function healthRegisterError(e)
    +{
    +  console.log("Failed to register application: " + e.message);
    +};
    +
    +healthProfileHandler.registerSinkApplication(4100, "testSinkApp", healthRegisterSuccess, healthRegisterError);
    +
    +
  • @@ -6066,17 +6231,17 @@ var healthProfileHandler = adapter.getBluetoothProfileHandler("HEALTH"); function healthRegisterSuccess(app) { - console.log("Registered application: " + app.name); - app.onconnect = function(channel) - { - console.log("Health device is connected"); - channel.close(); - } + console.log("Registered application: " + app.name); + app.onconnect = function(channel) + { + console.log("Health device is connected"); + channel.close(); + } } function healthRegisterError(e) { - console.log("Failed to register application: " + e.message); + console.log("Failed to register application: " + e.message); }; healthProfileHandler.registerSinkApplication(4100, "testSinkApp", healthRegisterSuccess, healthRegisterError); @@ -6144,19 +6309,27 @@ Instead, use http://tizen.org/privilege/bluetooth. var adapter = tizen.bluetooth.getDefaultAdapter(); var healthProfileHandler = adapter.getBluetoothProfileHandler("HEALTH"); +/* Data to send */ +var textmsg = "Test"; +var dataToSend = new Array(); +for (var i = 0; i < textmsg.length; i++) +{ + dataToSend[i] = textmsg.charCodeAt(i); +} + function healthRegisterSuccess(app) { - console.log("Registered application: " + app.name); - app.onconnect = function(channel) - { - console.log("Health device is connected"); - channel.sendData(dataToSend); - } + console.log("Registered application: " + app.name); + app.onconnect = function(channel) + { + console.log("Health device is connected"); + channel.sendData(dataToSend); + } } function healthRegisterError(e) { - console.log("Failed to register application: " + e.message); + console.log("Failed to register application: " + e.message); }; healthProfileHandler.registerSinkApplication(4100, "testSinkApp", healthRegisterSuccess, healthRegisterError); @@ -6219,29 +6392,29 @@ var healthProfileHandler = adapter.getBluetoothProfileHandler("HEALTH"); var channelCallback = { - onmessage: function(data) - { - console.log("data is received") - }, - onclose: function() - { - console.log("channel is closed"); - } + onmessage: function(data) + { + console.log("data is received") + }, + onclose: function() + { + console.log("channel is closed"); + } }; function healthRegisterSuccess(app) { - console.log("Registered application: " + app.name); - app.onconnect = function(channel) - { - console.log("Health device is connected"); - channel.setListener(channelCallback); - } + console.log("Registered application: " + app.name); + app.onconnect = function(channel) + { + console.log("Health device is connected"); + channel.setListener(channelCallback); + } } function healthRegisterError(e) { - console.log("Failed to register application: " + e.message); + console.log("Failed to register application: " + e.message); }; healthProfileHandler.registerSinkApplication(4100, "testSinkApp", healthRegisterSuccess, healthRegisterError); @@ -6294,31 +6467,31 @@ var connectedChannel = null; var channelCallback = { - onmessage: function(data) - { - console.log("data is received") - }, - onclose: function() - { - console.log("channel is closed"); - connectedChannel.unsetListener(); - } + onmessage: function(data) + { + console.log("data is received") + }, + onclose: function() + { + console.log("channel is closed"); + connectedChannel.unsetListener(); + } }; function healthRegisterSuccess(app) { - console.log("Registered application: " + app.name); - app.onconnect = function(channel) - { - console.log("Health device is connected"); - connectedChannel = channel; - connectedChannel.setListener(channelCallback); - } + console.log("Registered application: " + app.name); + app.onconnect = function(channel) + { + console.log("Health device is connected"); + connectedChannel = channel; + connectedChannel.setListener(channelCallback); + } } function healthRegisterError(e) { - console.log("Failed to register application: " + e.message); + console.log("Failed to register application: " + e.message); }; healthProfileHandler.registerSinkApplication(4100, "testSinkApp", healthRegisterSuccess, healthRegisterError); @@ -6961,10 +7134,6 @@ To guarantee that the Bluetooth Low Energy application runs on a device with Blu optional SuccessCallback? successCallback, optional ErrorCallback? errorCallback) raises(WebAPIException); - void setPowered(boolean state, - optional SuccessCallback? successCallback, - optional ErrorCallback? errorCallback) raises(WebAPIException); - void setChangeListener(BluetoothAdapterChangeCallback listener) raises(WebAPIException); void unsetChangeListener() raises(WebAPIException); @@ -7075,12 +7244,13 @@ To guarantee that the Bluetooth Low Energy application runs on a device with Blu [NoInterfaceObject] interface BluetoothLEDevice { readonly attribute BluetoothAddress address; readonly attribute DOMString? name; - readonly attribute unsigned long? txpowerlevel; + readonly attribute long? txpowerlevel; readonly attribute unsigned long? appearance; readonly attribute BluetoothUUID[]? uuids; readonly attribute BluetoothLESolicitationUUID[]? solicitationuuids; readonly attribute BluetoothLEServiceData[]? serviceData; readonly attribute BluetoothLEManufacturerData? manufacturerData; + readonly attribute long rssi; void connect(optional SuccessCallback? successCallback, optional ErrorCallback? errorCallback) raises(WebAPIException); @@ -7116,7 +7286,7 @@ To guarantee that the Bluetooth Low Energy application runs on a device with Blu readonly attribute octet minor; - readonly attribute unsigned short [] services ; + readonly attribute unsigned short [] services; boolean hasService(unsigned short service) raises(WebAPIException); }; diff --git a/org.tizen.web.apireference/html/device_api/wearable/tizen/bluetooth.html b/org.tizen.web.apireference/html/device_api/wearable/tizen/bluetooth.html index ceaa7a5..fce43c6 100644 --- a/org.tizen.web.apireference/html/device_api/wearable/tizen/bluetooth.html +++ b/org.tizen.web.apireference/html/device_api/wearable/tizen/bluetooth.html @@ -197,7 +197,6 @@ For more information on the Bluetooth features, see BluetoothAdapter
    void setName (DOMString name, optional SuccessCallback? successCallback, optional ErrorCallback? errorCallback)
    -
    void setPowered (boolean state, optional SuccessCallback? successCallback, optional ErrorCallback? errorCallback)
    void setChangeListener (BluetoothAdapterChangeCallback listener)
    void unsetChangeListener ()
    void discoverDevices (BluetoothDiscoverDevicesSuccessCallback successCallback, optional ErrorCallback? errorCallback)
    @@ -682,8 +681,8 @@ This dictionary is used as an input parameter of the BluetoothLEAdvertiseData co

    Code example:

     var advertData =
     {
    -   includeName: false, uuids: ["f236-41a4"], solicitationuuids: ["5857-4d3f"],
    -   appearance: 192, includeTxPowerLevel: false
    +  includeName: false, uuids: ["f236-41a4"], solicitationuuids: ["5857-4d3f"],
    +  appearance: 192, includeTxPowerLevel: false
     }
     
    @@ -717,8 +716,8 @@ This represents the data to be advertised as well as the scan response data for

    Code example:

     var advertData =
     {
    -   includeName: false, uuids: ["f236-41a4"], solicitationuuids: ["5857-4d3f"],
    -   appearance: 192, includeTxPowerLevel: false
    +  includeName: false, uuids: ["f236-41a4"], solicitationuuids: ["5857-4d3f"],
    +  appearance: 192, includeTxPowerLevel: false
     }
     var advertise = new tizen.BluetoothLEAdvertiseData(advertData);
     
    @@ -964,11 +963,11 @@ Instead, use http://tizen.org/privilege/bluetooth.

    Code example:

     try
     {
    -   var adapter = tizen.bluetooth.getDefaultAdapter();
    +  var adapter = tizen.bluetooth.getDefaultAdapter();
     }
     catch (err)
     {
    -   console.log(err.name + ": " + err.message);
    +  console.log(err.name + ": " + err.message);
     }
     
    @@ -1024,11 +1023,11 @@ Instead, use http://tizen.org/privilege/bluetooth.

    Code example:

     try
     {
    -   var adapter = tizen.bluetooth.getLEAdapter();
    +  var adapter = tizen.bluetooth.getLEAdapter();
     }
     catch (err)
     {
    -   console.log(err.name + ": " + err.message);
    +  console.log(err.name + ": " + err.message);
     }
     
    @@ -1051,10 +1050,6 @@ catch (err) optional SuccessCallback? successCallback, optional ErrorCallback? errorCallback) raises(WebAPIException); - void setPowered(boolean state, - optional SuccessCallback? successCallback, - optional ErrorCallback? errorCallback) raises(WebAPIException); - void setChangeListener(BluetoothAdapterChangeCallback listener) raises(WebAPIException); void unsetChangeListener() raises(WebAPIException); @@ -1275,21 +1270,21 @@ var bt_always_on = tizen.systeminfo.getCapability("http://tizen.org/capability/n function changeName(newName) { - if (adapter.name != newName) - { - /* Initiate change name */ - adapter.setName(newName, function() - { - console.log("Adapter name changed to " + adapter.name); - }, function(e) - { - console.log("Failed to change name: " + e.message); - }); - } + if (adapter.name != newName) + { + /* Initiate change name */ + adapter.setName(newName, function() + { + console.log("Adapter name changed to " + adapter.name); + }, function(e) + { + console.log("Failed to change name: " + e.message); + }); + } } if (bt_always_on === false) { - changeName("myDevice"); + changeName("myDevice"); } @@ -1303,7 +1298,7 @@ if (bt_always_on === false) For most Bluetooth actions, the Bluetooth adapter must be powered on.

    Deprecated. - Deprecated since 2.3. Instead, let the user turn on/off Bluetooth through the Settings application. See Managing Bluetooth Tutorial. + Deprecated since 2.3. Instead, let the user turn on/off Bluetooth through the Settings application. See Managing Bluetooth Tutorial.

    void setPowered(boolean state, optional SuccessCallback? successCallback, optional ErrorCallback? errorCallback);
                  
    @@ -1376,44 +1371,44 @@ var adapter = tizen.bluetooth.getDefaultAdapter(); function powerOn() { - /* If adapter is not powered on */ - if (!adapter.powered) - { - /* Initiates power on */ - adapter.setPowered(true, function() - { - console.log("Bluetooth powered on success."); - }, function(e) - { - console.log("Failed to power on Bluetooth: " + e.message); - }); - } + /* If adapter is not powered on */ + if (!adapter.powered) + { + /* Initiates power on */ + adapter.setPowered(true, function() + { + console.log("Bluetooth powered on success."); + }, function(e) + { + console.log("Failed to power on Bluetooth: " + e.message); + }); + } } function powerOff() { - /* If powered on */ - if (adapter.powered) - { - /* Initiates power off */ - adapter.setPowered(false, function() - { - console.log("Bluetooth powered off successfully."); - }, function(e) - { - console.log("Failed to power off Bluetooth: " + e.message); - }); - } + /* If powered on */ + if (adapter.powered) + { + /* Initiates power off */ + adapter.setPowered(false, function() + { + console.log("Bluetooth powered off successfully."); + }, function(e) + { + console.log("Failed to power off Bluetooth: " + e.message); + }); + } } var bt_always_on = tizen.systeminfo.getCapability("http://tizen.org/capability/network.bluetooth.always_on"); if (bt_always_on === true) { - console.log("Bluetooth cannot be turn off or on because this device must be always enabled."); + console.log("Bluetooth cannot be turn off or on because this device must be always enabled."); } else { - powerOn(); + powerOn(); } @@ -1459,18 +1454,18 @@ else

    Code example:

     var changeListener =
     {
    -   onstatechanged: function(powered)
    -   {
    -      console.log("Power state is changed into: " + powered);
    -   },
    -   onnamechanged: function(name)
    -   {
    -      console.log("Name is changed to: " + name);
    -   },
    -   onvisibilitychanged: function(visible)
    -   {
    -      console.log("Visibility is changed into: " + visible);
    -   }
    +  onstatechanged: function(powered)
    +  {
    +    console.log("Power state is changed into: " + powered);
    +  },
    +  onnamechanged: function(name)
    +  {
    +    console.log("Name is changed to: " + name);
    +  },
    +  onvisibilitychanged: function(visible)
    +  {
    +    console.log("Visibility is changed into: " + visible);
    +  }
     };
     
     var adapter = tizen.bluetooth.getDefaultAdapter();
    @@ -1509,20 +1504,20 @@ var adapter = tizen.bluetooth.getDefaultAdapter();
     
     var changeListener =
     {
    -   onstatechanged: function(powered)
    -   {
    -      console.log("Power state is changed into: " + powered);
    -      if (!powered)
    -         adapter.unsetChangeListener();
    -   },
    -   onnamechanged: function(name)
    -   {
    -      console.log("Name is changed to: " + name);
    -   },
    -   onvisibilitychanged: function(visible)
    -   {
    -      console.log("Visibility is changed into: " + visible);
    -   }
    +  onstatechanged: function(powered)
    +  {
    +    console.log("Power state is changed into: " + powered);
    +    if (!powered)
    +      adapter.unsetChangeListener();
    +  },
    +  onnamechanged: function(name)
    +  {
    +    console.log("Name is changed to: " + name);
    +  },
    +  onvisibilitychanged: function(visible)
    +  {
    +    console.log("Visibility is changed into: " + visible);
    +  }
     };
     
     adapter.setChangeListener(changeListener);
    @@ -1612,41 +1607,41 @@ var adapter = tizen.bluetooth.getDefaultAdapter();
     
     function startDiscovery()
     {
    -   var discoverDevicesSuccessCallback =
    -   {
    -      onstarted: function()
    -      {
    -         console.log("Device discovery started...");
    -      },
    -      ondevicefound: function(device)
    +  var discoverDevicesSuccessCallback =
    +  {
    +    onstarted: function()
    +    {
    +      console.log("Device discovery started...");
    +    },
    +    ondevicefound: function(device)
    +    {
    +      console.log("Found device - name: " + device.name + ", Address: "+ device.address);
    +    },
    +    ondevicedisappeared: function(address)
    +    {
    +      console.log("Device disappeared: " + address);
    +    },
    +    onfinished: function(devices)
    +    {
    +      console.log("Found Devices");
    +      for (var i = 0; i < devices.length; i++)
           {
    -         console.log("Found device - name: " + device.name + ", Address: " + device.address);
    -      },
    -      ondevicedisappeared: function(address)
    -      {
    -         console.log("Device disappeared: " + address);
    -      },
    -      onfinished: function(devices)
    -      {
    -         console.log("Found Devices");
    -         for (var i = 0; i < devices.length; i++)
    -         {
    -            console.log("Name: " + devices[i].name + ", Address: " + devices[i].address);
    -         }
    -         console.log("Total: " + devices.length);
    +        console.log("Name: " + devices[i].name + ", Address: " + devices[i].address);
           }
    -   };
    -
    -   /* Starts searching for nearby devices, for about 12 sec */
    -   adapter.discoverDevices(discoverDevicesSuccessCallback, function(e)
    -   {
    -      console.log("Failed to search devices: " + e.message + "(" + e.name + ")");
    -   });
    +      console.log("Total: " + devices.length);
    +    }
    +  };
    +
    +  /* Starts searching for nearby devices, for about 12 sec */
    +  adapter.discoverDevices(discoverDevicesSuccessCallback, function(e)
    +  {
    +    console.log("Failed to search devices: " + e.message + "(" + e.name + ")");
    +  });
     }
     
     function onSetPoweredError(e)
     {
    -   console.log("Could not turn on device, reason: " + e.message + "(" + e.name + ")");
    +  console.log("Could not turn on device, reason: " + e.message + "(" + e.name + ")");
     }
     
     adapter.setPowered(true, startDiscovery, onSetPoweredError);
    @@ -1724,57 +1719,57 @@ var adapter = tizen.bluetooth.getDefaultAdapter();
     /* Calls this method whenever user finds one of the device */
     function cancelDiscovery()
     {
    -   adapter.stopDiscovery(function()
    -   {
    -      console.log("Stop discovery success.");
    -   }, function(e)
    -   {
    -      console.log("Error while stopDiscovery:" + e.message);
    -   });
    +  adapter.stopDiscovery(function()
    +  {
    +    console.log("Stop discovery success.");
    +  }, function(e)
    +  {
    +    console.log("Error while stopDiscovery:" + e.message);
    +  });
     }
     
     function startDiscovery()
     {
    -   var discoverDevicesSuccessCallback =
    -   {
    -      onstarted: function()
    -      {
    -         console.log("Device discovery started...");
    -      },
    -      ondevicefound: function(device)
    -      {
    -         console.log("Found device - name: " + device.name + ", Address: " + device.address);
    -         /* Shows the device to user to check if this is the device user is looking for */
    -         /* For example, add this to list view */
    -
    -         cancelDiscovery();
    -      },
    -      ondevicedisappeared: function(address)
    -      {
    -         console.log("Device disappeared: " + address);
    -         /* Removes from list, as it is no longer valid */
    -      },
    -      onfinished: function(devices)
    +  var discoverDevicesSuccessCallback =
    +  {
    +    onstarted: function()
    +    {
    +      console.log("Device discovery started...");
    +    },
    +    ondevicefound: function(device)
    +    {
    +      console.log("Found device - name: " + device.name + ", Address: "+ device.address);
    +      /* Shows the device to user to check if this is the device user is looking for */
    +      /* For example, add this to list view */
    +
    +      cancelDiscovery();
    +    },
    +    ondevicedisappeared: function(address)
    +    {
    +      console.log("Device disappeared: " + address);
    +      /* Removes from list, as it is no longer valid */
    +    },
    +    onfinished: function(devices)
    +    {
    +      console.log("Found Devices");
    +      for (var i = 0; i < devices.length; i++)
           {
    -         console.log("Found Devices");
    -         for (var i = 0; i < devices.length; i++)
    -         {
    -            console.log("Name: " + devices[i].name + ", Address: " + devices[i].address);
    -         }
    -         console.log("Total: " + devices.length);
    +        console.log("Name: " + devices[i].name + ", Address: " + devices[i].address);
           }
    -   };
    -
    -   /* Starts searching for nearby devices, for about 12 sec */
    -   adapter.discoverDevices(discoverDevicesSuccessCallback, function(e)
    -   {
    -      console.log("Failed to search devices: " + e.message + "(" + e.name + ")");
    -   });
    +      console.log("Total: " + devices.length);
    +    }
    +  };
    +
    +  /* Starts searching for nearby devices, for about 12 sec */
    +  adapter.discoverDevices(discoverDevicesSuccessCallback, function(e)
    +  {
    +    console.log("Failed to search devices: " + e.message + "(" + e.name + ")");
    +  });
     }
     
     function onSetPoweredError(e)
     {
    -   console.log("Could not turn on device, reason: " + e.message + "(" + e.name + ")");
    +  console.log("Could not turn on device, reason: " + e.message + "(" + e.name + ")");
     }
     
     adapter.setPowered(true, startDiscovery, onSetPoweredError);
    @@ -1860,22 +1855,22 @@ var adapter = tizen.bluetooth.getDefaultAdapter();
     
     function onGotDevices(devices)
     {
    -   console.log("Devices");
    -   for (var i = 0; i < devices.length; i++)
    -   {
    -      console.log(" Name: " + devices[i].name + ", Address: " + devices[i].address);
    -   }
    -   console.log("Total: " + devices.length);
    +  console.log("Devices");
    +  for (var i = 0; i < devices.length; i++)
    +  {
    +    console.log(" Name: " + devices[i].name + ", Address: " + devices[i].address);
    +  }
    +  console.log("Total: " + devices.length);
     }
     
     function onError(e)
     {
    -   console.log("Error: " + e.message);
    +  console.log("Error: " + e.message);
     }
     
     function onBluetoothsetPowered()
     {
    -   adapter.getKnownDevices(onGotDevices, onError);
    +  adapter.getKnownDevices(onGotDevices, onError);
     }
     
     /* Turns on Bluetooth */
    @@ -1959,15 +1954,15 @@ Instead, use http://tizen.org/privilege/bluetooth.
     

    Code example:

     function gotDeviceInfo(device)
     {
    -   console.log("Device Name: " + device.name);
    -   console.log("Device Address: " + device.address);
    -   console.log("Device Class: " + device.deviceClass.major);
    -   console.log("Is Bonded: " + (device.isBonded ? "Yes" : "No"));
    +  console.log("Device Name: " + device.name);
    +  console.log("Device Address: " + device.address);
    +  console.log("Device Class: " + device.deviceClass.major);
    +  console.log("Is Bonded: " + (device.isBonded ? "Yes" : "No"));
     }
     
     function onError(e)
     {
    -   console.log("Could not get device info:" + e.message);
    +  console.log("Could not get device info:" + e.message);
     }
     
     var adapter = tizen.bluetooth.getDefaultAdapter();
    @@ -2049,14 +2044,14 @@ Instead, use http://tizen.org/privilege/bluetooth.
     

    Code example:

     function onBondingSuccess(device)
     {
    -   console.log("Device Name:" + device.name);
    -   console.log("Device Address:" + device.address);
    -   console.log("Device Service UUIDs:" + device.uuids.join("\n"));
    +  console.log("Device Name:" + device.name);
    +  console.log("Device Address:" + device.address);
    +  console.log("Device Service UUIDs:" + device.uuids.join("\n"));
     }
     
     function onError(e)
     {
    -   console.log("Could not create bonding, reason:" + e.message);
    +  console.log("Could not create bonding, reason:" + e.message);
     }
     
     var adapter = tizen.bluetooth.getDefaultAdapter();
    @@ -2140,23 +2135,23 @@ var adapter = tizen.bluetooth.getDefaultAdapter();
     
     function gotDevice(device)
     {
    -   if (device.isBonded)
    -   {
    -      /* Initiates destroying bonding */
    -      adapter.destroyBonding(device.address, function()
    -      {
    -         console.log("Succeeded to destroy the bond success with:" + device.address);
    -      }, function(e)
    -      {
    -         console.log("Failed to destroy the bond with " + device.address + ", reason: " + e.message);
    -      });
    -   }
    +  if (device.isBonded)
    +  {
    +    /* Initiates destroying bonding */
    +    adapter.destroyBonding(device.address, function()
    +    {
    +      console.log("Succeeded to destroy the bond success with:" + device.address);
    +    }, function(e)
    +    {
    +      console.log("Failed to destroy the bond with " + device.address + ", reason: " + e.message);
    +    });
    +  }
     }
     
     var deviceAddress = "35:F4:59:D1:7A:03";
     adapter.getDevice(deviceAddress, gotDevice, function(e)
     {
    -   console.log("Failed to get device info for " + deviceAddress + ", reason: " + e.message);
    +  console.log("Failed to get device info for " + deviceAddress + ", reason: " + e.message);
     });
     
    @@ -2253,47 +2248,51 @@ var serviceSocket = null; function chatServiceSuccessCb(recordHandler) { - console.log("Chat service registration succeeds!"); - chatServiceHandler = recordHandler; - recordHandler.onconnect = function(socket) - { - console.log("Client connected: " + socket.peer.name + "," + socket.peer.address); - serviceSocket = socket; - /* Messages received from remote device */ - socket.onmessage = function() - { - var data = socket.readData(); - /* Handles message code goes here */ - }; + console.log("Chat service registration succeeds!"); + chatServiceHandler = recordHandler; + recordHandler.onconnect = function(socket) + { + console.log("Client connected: " + socket.peer.name + "," + socket.peer.address); + serviceSocket = socket; + /* Messages received from remote device */ + socket.onmessage = function() + { + var data = socket.readData(); + /* Handles message code goes here */ + }; - socket.onclose = function() - { - console.log('The socket is closed.'); - serviceSocket = null; - }; - }; + socket.onclose = function() + { + console.log("The socket is closed."); + serviceSocket = null; + }; + }; }; function publishChatService() { - var CHAT_SERVICE_UUID = "5BCE9431-6C75-32AB-AFE0-2EC108A30860"; - adapter.registerRFCOMMServiceByUUID(CHAT_SERVICE_UUID, "Chat service", chatServiceSuccessCb, - /* Error handler: function(e) {console.log("Could not register service record, Error: " + e.message);} */); + var CHAT_SERVICE_UUID = "5BCE9431-6C75-32AB-AFE0-2EC108A30860"; + adapter.registerRFCOMMServiceByUUID(CHAT_SERVICE_UUID, "Chat service", chatServiceSuccessCb, + /* Error handler */ + function(e) + { + console.log( "Could not register service record, Error: " + e.message); + }); } function unregisterChatService() { - if (chatServiceHandler != null) - { - chatServiceHandler.unregister(function() - { - console.log("Chat service is unregistered"); - chatServiceHandler = null; - }, function(e) - { - console.log("Failed to unregister service: " + e.message); - }); - } + if (chatServiceHandler != null) + { + chatServiceHandler.unregister(function() + { + console.log("Chat service is unregistered"); + chatServiceHandler = null; + }, function(e) + { + console.log("Failed to unregister service: " + e.message); + }); + } }
    @@ -2349,11 +2348,11 @@ var healthCapability = tizen.systeminfo.getCapability("http://tizen.org/feature/ if (healthCapability) { - healthProfileHandler = adapter.getBluetoothProfileHandler("HEALTH"); + healthProfileHandler = adapter.getBluetoothProfileHandler("HEALTH"); } else { - console.log("Bluetooth Health Profile is not supported on this device."); + console.log("Bluetooth Health Profile is not supported on this device."); }
    @@ -2463,7 +2462,7 @@ Instead, use http://tizen.org/privilege/bluetooth. var adapter = tizen.bluetooth.getLEAdapter(); adapter.startScan(function onsuccess(device) { - console.log("[Found device] address: " + device.address); + console.log("[Found device] address: " + device.address); }); @@ -2510,11 +2509,11 @@ Instead, use http://tizen.org/privilege/bluetooth. var adapter = tizen.bluetooth.getLEAdapter(); adapter.startScan(function onsuccess(device) { - if (device.address == "11:22:33:44:55:66") - { - console.log("Found device: " + device.name); - adapter.stopScan(); - } + if (device.address == "11:22:33:44:55:66") + { + console.log("Found device: " + device.name); + adapter.stopScan(); + } }); @@ -2612,11 +2611,11 @@ var battery_svc_uuid_16 = "180f"; /* Service UUID, 16-bit UUID is supported (e.g var heart_rate_svc_uuid_16 = "180d"; /* Service solicitation UUID, 16-bit UUID is supported (e.g. 180d) */ var advertiseOptions = { - includeName: true, /* Whether the device name should be included */ - includeTxPowerLevel: true, /* Whether the transmission power level should be included */ - appearance: 192, /* External appearance of device, 192 - Generic Watch */ - uuids: [battery_svc_uuid_16], - solicitationuuids: [heart_rate_svc_uuid_16] + includeName: true, /* Whether the device name should be included */ + includeTxPowerLevel: true, /* Whether the transmission power level should be included */ + appearance: 192, /* External appearance of device, 192 - Generic Watch */ + uuids: [battery_svc_uuid_16], + solicitationuuids: [heart_rate_svc_uuid_16] }; var advertiseData = new tizen.BluetoothLEAdvertiseData(advertiseOptions); @@ -2624,10 +2623,10 @@ var connectable = true; adapter.startAdvertise(advertiseData, "ADVERTISE", function onstate(state) { - console.log("Advertiser state: " + state); + console.log("Advertiser state: " + state); }, function(e) { - console.log("Failed to startAdvertise: " + e.message); + console.log("Failed to startAdvertise: " + e.message); }, "LOW_LATENCY", connectable); @@ -2676,18 +2675,18 @@ var battery_svc_uuid_16 = "180f"; /* Service UUID, 16-bit UUID is supported (e.g var heart_rate_svc_uuid_16 = "180d"; /* Service solicitation UUID, 16-bit UUID is supported (e.g. 180d) */ var advertiseOptions = { - includeName: true, /* Whether the device name should be included */ - includeTxPowerLevel: true, /* Whether the transmission power level should be included */ - appearance: 192, /* External appearance of device, 192 - Generic Watch */ - uuids: [battery_svc_uuid_16], - solicitationuuids: [heart_rate_svc_uuid_16] + includeName: true, /* Whether the device name should be included */ + includeTxPowerLevel: true, /* Whether the transmission power level should be included */ + appearance: 192, /* External appearance of device, 192 - Generic Watch */ + uuids: [battery_svc_uuid_16], + solicitationuuids: [heart_rate_svc_uuid_16] }; var advertiseData = new tizen.BluetoothLEAdvertiseData(advertiseOptions); adapter.startAdvertise(advertiseData, "ADVERTISE", function onstate(state) { - console.log("Advertiser state: " + state); + console.log("Advertiser state: " + state); }); adapter.stopAdvertise(); @@ -2714,16 +2713,16 @@ adapter.stopAdvertise();

    Code example:

     function onconnected(device)
     {
    -   console.log("Connected to device");
    -   var service = device.getService(device.uuids[0]);
    -   console.log("Service got");
    +  console.log("Connected to device");
    +  var service = device.getService(device.uuids[0]);
    +  console.log("Service got");
     }
     
     var adapter = tizen.bluetooth.getLEAdapter();
     adapter.startScan(function onsuccess(device)
     {
    -   console.log("[Found device] address: " + device.address);
    -   device.connect(onconnected.bind(null, device), onerror);
    +  console.log("[Found device] address: " + device.address);
    +  device.connect(onconnected.bind(null, device), onerror);
     });
     
    @@ -2761,7 +2760,7 @@ console.log("Service UUID " + service.uuid); var service = device.getService(device.uuids[0]); for (var i = 0; i service.services.length; ++i) { - console.log("Subservices UUID " + service.services[i].uuid); + console.log("Subservices UUID " + service.services[i].uuid); } @@ -2781,7 +2780,7 @@ for (var i = 0; i service.services.length; ++i) var service = device.getService(device.uuids[0]); for (var i = 0; i service.characteristics.length; ++i) { - console.log("Subservices UUID " + service.characteristics[i].isWritable); + console.log("Subservices UUID " + service.characteristics[i].isWritable); } @@ -2982,35 +2981,35 @@ Instead, use http://tizen.org/privilege/bluetooth.

    Code example:

     function onerror(e)
     {
    -   console.log("Failed to connect to device: " + e.message);
    +  console.log("Failed to connect to device: " + e.message);
     }
     
     function proccessDevice(device)
     {
    -   device.connect(onConnected, onerror);
    -   function onConnected()
    -   {
    -      var service = device.getService(device.uuids[0]);
    -      if (service.characteristics.length > 0)
    +  device.connect(onConnected, onerror);
    +  function onConnected()
    +  {
    +    var service = device.getService(device.uuids[0]);
    +    if (service.characteristics.length > 0)
    +    {
    +      var characteristic = service.characteristics[0];
    +      characteristic.readValue(function(val)
           {
    -         var characteristic = service.characteristics[0];
    -         characteristic.readValue(function(val)
    -         {
    -            console.log("Value read: " + val);
    -            device.disconnect();
    -         });
    -      }
    -   }
    +        console.log("Value read: " + val);
    +        device.disconnect();
    +      });
    +    }
    +  }
     }
     
     var adapter = tizen.bluetooth.getLEAdapter();
     adapter.startScan(function onsuccess(device)
     {
    -   if (device.address == "11:22:33:44:55:66")
    -   {
    -      console.log("Found device: " + device.name);
    -      proccessDevice(device);
    -   }
    +  if (device.address == "11:22:33:44:55:66")
    +  {
    +    console.log("Found device: " + device.name);
    +    proccessDevice(device);
    +  }
     });
     
    @@ -3085,39 +3084,39 @@ Instead, use http://tizen.org/privilege/bluetooth.

    Code example:

     function onerror(e)
     {
    -   console.log("Failed to connect to device: " + e.message);
    +  console.log("Failed to connect to device: " + e.message);
     }
     
     function proccessDevice(device)
     {
    -   device.connect(onConnected, onerror);
    -   function onConnected()
    -   {
    -      var service = device.getService(device.uuids[0]);
    -      if (service.characteristics.length > 0)
    +  device.connect(onConnected, onerror);
    +  function onConnected()
    +  {
    +    var service = device.getService(device.uuids[0]);
    +    if (service.characteristics.length > 0)
    +    {
    +      var characteristic = service.characteristics[0];
    +      var data = new Array(1, 2, 3, 4, 5, 6);
    +      characteristic.writeValue(data, function()
           {
    -         var characteristic = service.characteristics[0];
    -         var data = new Array(1, 2, 3, 4, 5, 6);
    -         characteristic.writeValue(data, function()
    -         {
    -            console.log("Value written");
    -            device.disconnect();
    -         }, function(e)
    -         {
    -            console.log("Failed to write: " + e.message);
    -         });
    -      }
    -   }
    +        console.log("Value written");
    +        device.disconnect();
    +      }, function(e)
    +      {
    +        console.log("Failed to write: " + e.message);
    +      });
    +    }
    +  }
     }
     
     var adapter = tizen.bluetooth.getLEAdapter();
     adapter.startScan(function onsuccess(device)
     {
    -   if (device.address == "11:22:33:44:55:66")
    -   {
    -      console.log("Found device: " + device.name);
    -      proccessDevice(device);
    -   }
    +  if (device.address == "11:22:33:44:55:66")
    +  {
    +    console.log("Found device: " + device.name);
    +     proccessDevice(device);
    +  }
     });
     
    @@ -3171,35 +3170,34 @@ Instead, use http://tizen.org/privilege/bluetooth.

    Code example:

     function proccessDevice(device)
     {
    -   function onConnected()
    -   {
    -      var service = device.getService("5BCE9431-6C75-32AB-AFE0-2EC108A30860");
    -      if (service.characteristics.length > 0)
    -      {
    -         var characteristic = service.characteristics[0];
    -         var watchID;
    -
    -         watchID = characteristic.addValueChangeListener(function(value)
    -         {
    -            console.log("Characteristic value changed: " + value);
    -            characteristic.removeValueChangeListener(watchID);
    -            device.disconnect();
    -         });
    -      }
    -   }
    +  function onConnected()
    +  {
    +    var service = device.getService("5BCE9431-6C75-32AB-AFE0-2EC108A30860");
    +    if (service.characteristics.length > 0)
    +    {
    +      var characteristic = service.characteristics[0];
    +      var watchID;
     
    -   device.connect(onConnected);
    +      watchID = characteristic.addValueChangeListener(function(value)
    +      {
    +        console.log("Characteristic value changed: " + value);
    +        characteristic.removeValueChangeListener(watchID);
    +        device.disconnect();
    +      });
    +    }
    +  }
    +    device.connect(onConnected);
     }
     
     var adapter = tizen.bluetooth.getLEAdapter();
     adapter.startScan(function onsuccess(device)
     {
    -   if (device.address == "11:22:33:44:55:66")
    -   {
    -      console.log("Found device: " + device.name);
    -      adapter.stopScan();
    -      proccessDevice(device);
    -   }
    +  if (device.address == "11:22:33:44:55:66")
    +  {
    +    console.log("Found device: " + device.name);
    +    adapter.stopScan();
    +     proccessDevice(device);
    +  }
     });
     
    @@ -3317,36 +3315,36 @@ Instead, use http://tizen.org/privilege/bluetooth.

    Code example:

     function onerror(e)
     {
    -   console.log("Failed to connect to device: " + e.message);
    +  console.log("Failed to connect to device: " + e.message);
     }
     
     function proccessDevice(device)
     {
    -   device.connect(onConnected, onerror);
    -   function onConnected()
    -   {
    -      var service = device.getService(device.uuids[0]);
    -      if (service.characteristics.length > 0)
    +  device.connect(onConnected, onerror);
    +  function onConnected()
    +  {
    +    var service = device.getService(device.uuids[0]);
    +    if (service.characteristics.length > 0)
    +    {
    +      var characteristic = service.characteristics[0];
    +      var descriptor = characteristic.descriptors[0];
    +      descriptor.readValue(function(val)
           {
    -         var characteristic = service.characteristics[0];
    -         var descriptor = characteristic.descriptors[0];
    -         descriptor.readValue(function(val)
    -         {
    -            console.log("Value read: " + val);
    -            device.disconnect();
    -         });
    -      }
    -   }
    +        console.log("Value read: " + val);
    +        device.disconnect();
    +      });
    +    }
    +  }
     }
     
     var adapter = tizen.bluetooth.getLEAdapter();
     adapter.startScan(function onsuccess(device)
     {
    -   if (device.address == "11:22:33:44:55:66")
    -   {
    -      console.log("Found device: " + device.name);
    -      proccessDevice(device);
    -   }
    +  if (device.address == "11:22:33:44:55:66")
    +  {
    +    console.log("Found device: " + device.name);
    +    proccessDevice(device);
    +  }
     });
     
    @@ -3421,40 +3419,40 @@ Instead, use http://tizen.org/privilege/bluetooth.

    Code example:

     function onerror(e)
     {
    -   console.log("Failed to connect to device: " + e.message);
    +  console.log("Failed to connect to device: " + e.message);
     }
     
     function proccessDevice(device)
     {
    -   device.connect(onConnected, onerror);
    -   function onConnected()
    -   {
    -      var service = device.getService(device.uuids[0]);
    -      if (service.characteristics.length > 0)
    +  device.connect(onConnected, onerror);
    +  function onConnected()
    +  {
    +    var service = device.getService(device.uuids[0]);
    +    if (service.characteristics.length > 0)
    +    {
    +      var characteristic = service.characteristics[0];
    +      var data = new Array(1, 2, 3, 4, 5, 6);
    +      var descriptor = characteristic.descriptors[0];
    +      descriptor.writeValue(data, function()
           {
    -         var characteristic = service.characteristics[0];
    -         var data = new Array(1, 2, 3, 4, 5, 6);
    -         var descriptor = characteristic.descriptors[0];
    -         descriptor.writeValue(data, function()
    -         {
    -            console.log("Value written");
    -            device.disconnect();
    -         }, function(e)
    -         {
    -            console.log("Failed to write: " + e.message);
    -         });
    -      }
    -   }
    +        console.log("Value written");
    +        device.disconnect();
    +      }, function(e)
    +      {
    +        console.log("Failed to write: " + e.message);
    +      });
    +    }
    +  }
     }
     
     var adapter = tizen.bluetooth.getLEAdapter();
     adapter.startScan(function onsuccess(device)
     {
    -   if (device.address == "11:22:33:44:55:66")
    -   {
    -      console.log("Found device: " + device.name);
    -      proccessDevice(device);
    -   }
    +  if (device.address == "11:22:33:44:55:66")
    +  {
    +    console.log("Found device: " + device.name);
    +    proccessDevice(device);
    +  }
     });
     
    @@ -3710,7 +3708,7 @@ A BluetoothDevice object can be retrieved using one of the following AP var adapter = tizen.bluetooth.getDefaultAdapter(); adapter.getDevice("11:22:33:44:55:66", function(device) { - console.log("Device Name: " + device.name); + console.log("Device Name: " + device.name); }); @@ -3729,7 +3727,7 @@ adapter.getDevice("11:22:33:44:55:66", function(device) var adapter = tizen.bluetooth.getDefaultAdapter(); adapter.getDevice("11:22:33:44:55:66", function(device) { - console.log("Device Address: " + device.address); + console.log("Device Address: " + device.address); }); @@ -3748,7 +3746,7 @@ adapter.getDevice("11:22:33:44:55:66", function(device) var adapter = tizen.bluetooth.getDefaultAdapter(); adapter.getDevice("11:22:33:44:55:66", function(device) { - console.log("Device Major Class: " + device.deviceClass.major); + console.log("Device Major Class: " + device.deviceClass.major); }); @@ -3767,7 +3765,7 @@ adapter.getDevice("11:22:33:44:55:66", function(device) var adapter = tizen.bluetooth.getDefaultAdapter(); adapter.getDevice("11:22:33:44:55:66", function(device) { - console.log("Is bonded: " + (device.isBonded ? "Yes" : "No")); + console.log("Is bonded: " + (device.isBonded ? "Yes" : "No")); }); @@ -3786,7 +3784,7 @@ adapter.getDevice("11:22:33:44:55:66", function(device) var adapter = tizen.bluetooth.getDefaultAdapter(); adapter.getDevice("11:22:33:44:55:66", function(device) { - console.log("Is trusted: " + (device.isTrusted ? "Yes" : "No")); + console.log("Is trusted: " + (device.isTrusted ? "Yes" : "No")); }); @@ -3805,7 +3803,7 @@ adapter.getDevice("11:22:33:44:55:66", function(device) var adapter = tizen.bluetooth.getDefaultAdapter(); adapter.getDevice("11:22:33:44:55:66", function(device) { - console.log("Is connected: " + (device.isConnected ? "Yes" : "No")); + console.log("Is connected: " + (device.isConnected ? "Yes" : "No")); }); @@ -3826,24 +3824,24 @@ var adapter = tizen.bluetooth.getDefaultAdapter(); var CHAT_SERVICE_UUID = "5BCE9431-6C75-32AB-AFE0-2EC108A30860"; adapter.getDevice("11:22:33:44:55:66", function(device) { - var uuids = device.uuids; - var services = ""; - for (var i = 0; i < uuids.length; i++) - { - services += uuids[i] + "\n"; - } - console.log("Services found: " + services); - if (uuids.indexOf(CHAT_SERVICE_UUID) != -1) - { - /* Connects to service */ - device.connectToServiceByUUID(CHAT_SERVICE_UUID, function(socket) - { - /* Connected to service, handle socket */ - }, function(e) - { - console.log("Could not connect to chat service !!!. Error: " + e.message); - }); - } + var uuids = device.uuids; + var services = ""; + for (var i = 0; i < uuids.length; i++) + { + services += uuids[i] + "\n"; + } + console.log("Services found: " + services); + if (uuids.indexOf(CHAT_SERVICE_UUID) != -1) + { + /* Connects to service */ + device.connectToServiceByUUID(CHAT_SERVICE_UUID, function(socket) + { + /* Connected to service, handle socket */ + }, function(e) + { + console.log("Could not connect to chat service !!!. Error: " + e.message); + }); + } }); @@ -3931,57 +3929,57 @@ var clientSocket = null; /* Calls a method that is invoked when user wants to send a message to a remote device */ function sendMessage(msg) { - /* Validates socket state, if everything is ok */ - if (clientSocket != null && clientSocket.state == "OPEN") - { - /* Sends the message */ - clientSocket.writeData(msg); - } + /* Validates socket state, if everything is ok */ + if (clientSocket != null && clientSocket.state == "OPEN") + { + /* Sends the message */ + clientSocket.writeData(msg); + } } /* Calls a method that is invoked when a socket is open */ function onSocketConnected(socket) { - clientSocket = socket; - console.log("Opening a socket successfully!!!"); - socket.onmessage = function() - { - var data = socket.readData(); - var recvmsg = ""; - for (var i = 0; i < data.length; i++) - { - recvmsg += String.fromCharCode(data[i]); - } - console.log("server msg >> " + recvmsg); - }; - - socket.onclose = function() - { - console.log("socket disconnected."); - }; + clientSocket = socket; + console.log("Opening a socket successfully!!!"); + socket.onmessage = function() + { + var data = socket.readData(); + var recvmsg = ""; + for (var i = 0; i < data.length; i++) + { + recvmsg += String.fromCharCode(data[i]); + } + console.log("server msg >> " + recvmsg); + }; + + socket.onclose = function() + { + console.log("socket disconnected."); + }; } function onDeviceReady(device) { - /* Validates device and service uuid */ - if (device.uuids.indexOf("5BCE9431-6C75-32AB-AFE0-2EC108A30860") != -1) - { - /* Opens socket */ - device.connectToServiceByUUID("5BCE9431-6C75-32AB-AFE0-2EC108A30860", onSocketConnected, function(e) - { - console.log("Error connecting to service. Reason: " + e.message); - }); - } - else - { - console.log("Chat service is not supported by this device"); - } + /* Validates device and service uuid */ + if (device.uuids.indexOf("5BCE9431-6C75-32AB-AFE0-2EC108A30860") != -1) + { + /* Opens socket */ + device.connectToServiceByUUID("5BCE9431-6C75-32AB-AFE0-2EC108A30860", onSocketConnected, function(e) + { + console.log("Error connecting to service. Reason: " + e.message); + }); + } + else + { + console.log("Chat service is not supported by this device"); + } } function onSetPowered() { - /* Gets the BluetoothDevice object */ - adapter.getDevice("35:F4:59:D1:7A:03", onDeviceReady, function(e) {console.log("Error: " + e.message);}); + /* Gets the BluetoothDevice object */ + adapter.getDevice("35:F4:59:D1:7A:03", onDeviceReady, function(e) {console.log("Error: " + e.message); }); } adapter.setPowered(true, onSetPowered, function(e) {console.log("Could not turn on Bluetooth adapter. reason: " + e.message); }); @@ -4050,7 +4048,7 @@ A BluetoothLEDevice object can be retrieved by using one of the followi var adapter = tizen.bluetooth.getLEAdapter(); adapter.startScan(function onsuccess(device) { - console.log("Found device: " + device.address); + console.log("Found device: " + device.address); }); @@ -4069,7 +4067,7 @@ adapter.startScan(function onsuccess(device) var adapter = tizen.bluetooth.getLEAdapter(); adapter.startScan(function onsuccess(device) { - console.log("Found device: " + device.name); + console.log("Found device: " + device.name); }); @@ -4088,7 +4086,7 @@ adapter.startScan(function onsuccess(device) var adapter = tizen.bluetooth.getLEAdapter(); adapter.startScan(function onsuccess(device) { - console.log("Found device: " + device.txpowerlevel); + console.log("Found device: " + device.txpowerlevel); }); @@ -4107,7 +4105,7 @@ adapter.startScan(function onsuccess(device) var adapter = tizen.bluetooth.getLEAdapter(); adapter.startScan(function onsuccess(device) { - console.log("Found device: " + device.appearance); + console.log("Found device: " + device.appearance); }); @@ -4127,13 +4125,13 @@ adapter.startScan(function onsuccess(device) var adapter = tizen.bluetooth.getLEAdapter(); adapter.startScan(function onsuccess(device) { - var uuids = device.uuids; - var services = ""; - for (var i = 0; i < uuids.length; i++) - { - services += uuids[i] + "\n"; - } - console.log("Service found: " + services); + var uuids = device.uuids; + var services = ""; + for (var i = 0; i < uuids.length; i++) + { + services += uuids[i] + "\n"; + } + console.log("Service found: " + services); }); @@ -4153,13 +4151,13 @@ adapter.startScan(function onsuccess(device) var adapter = tizen.bluetooth.getLEAdapter(); adapter.startScan(function onsuccess(device) { - var uuids = device.solicitationuuids; - var services = ""; - for (var i = 0; i < uuids.length; i++) - { - services += uuids[i] + "\n"; - } - console.log("Service solicitations found: " + services); + var uuids = device.solicitationuuids; + var services = ""; + for (var i = 0; i < uuids.length; i++) + { + services += uuids[i] + "\n"; + } + console.log("Service solicitations found: " + services); }); @@ -4179,13 +4177,13 @@ adapter.startScan(function onsuccess(device) var adapter = tizen.bluetooth.getLEAdapter(); adapter.startScan(function onsuccess(device) { - var serviceData = device.serviceData; - var data = ""; - for (var i = 0; i < serviceData.length; i++) - { - data += serviceData[i].id + serviceData[i].data + "\n"; - } - console.log("Service data found: " + data); + var serviceData = device.serviceData; + var data = ""; + for (var i = 0; i < serviceData.length; i++) + { + data += serviceData[i].id + serviceData[i].data + "\n"; + } + console.log("Service data found: " + data); }); @@ -4204,9 +4202,9 @@ adapter.startScan(function onsuccess(device) var adapter = tizen.bluetooth.getLEAdapter(); adapter.startScan(function onsuccess(device) { - var manufacturerData = device.manufacturerData; - console.log("Manufacture id: " + manufacturerData.id); - console.log("Manufacture data: " + manufacturerData.data); + var manufacturerData = device.manufacturerData; + console.log("Manufacture id: " + manufacturerData.id); + console.log("Manufacture data: " + manufacturerData.data); }); @@ -4230,8 +4228,8 @@ The signal strength depends on distance (between the device and the beacon) and var adapter = tizen.bluetooth.getLEAdapter(); adapter.startScan(function onsuccess(device) { - console.log("Found device: " + device.name); - console.log("RSSI: " + device.rssi); + console.log("Found device: " + device.name); + console.log("RSSI: " + device.rssi); }); @@ -4312,21 +4310,21 @@ Instead, use http://tizen.org/privilege/bluetooth.

    Code example:

     function onerror(e)
     {
    -   console.log("Failed to connect to device: " + e.message);
    +  console.log("Failed to connect to device: " + e.message);
     }
     
     function onconnected()
     {
    -   console.log("Connected to device");
    +  console.log("Connected to device");
     }
     
     var adapter = tizen.bluetooth.getLEAdapter();
     adapter.startScan(function onsuccess(device)
     {
    -   if (device.address == "11:22:33:44:55:66")
    -   {
    -      console.log("Found device: " + device.name);
    -      device.connect(onconnected, onerror);
    +  if (device.address == "11:22:33:44:55:66")
    +  {
    +    console.log("Found device: " + device.name);
    +    device.connect(onconnected, onerror);
        }
     });
     
    @@ -4398,27 +4396,27 @@ Instead, use http://tizen.org/privilege/bluetooth.

    Code example:

     function onerror(e)
     {
    -   console.log("Error occurred: " + e.message);
    +  console.log("Error occurred: " + e.message);
     }
     
     function onDeviceFound(device)
     {
    -   function ondisconnect()
    -   {
    -      console.log("Disconnected");
    -   }
    -
    -   function onconnected()
    -   {
    -      console.log("Connected to device");
    -      device.disconnect(ondisconnect, onerror);
    -   }
    -
    -   if (device.address == "11:22:33:44:55:66")
    -   {
    -      console.log("Found device: " + device.name);
    -      device.connect(onconnected, onerror);
    -   }
    +  function ondisconnect()
    +  {
    +    console.log("Disconnected");
    +  }
    +
    +  function onconnected()
    +  {
    +    console.log("Connected to device");
    +    device.disconnect(ondisconnect, onerror);
    +  }
    +
    +  if (device.address == "11:22:33:44:55:66")
    +  {
    +    console.log("Found device: " + device.name);
    +    device.connect(onconnected, onerror);
    +  }
     }
     
     var adapter = tizen.bluetooth.getLEAdapter();
    @@ -4482,23 +4480,23 @@ Instead, use http://tizen.org/privilege/bluetooth.
     

    Code example:

     function onconnected(device)
     {
    -   console.log("Connected to device");
    -   var service = device.getService(device.uuids[0]);
    -   console.log("Service got");
    +  console.log("Connected to device");
    +  var service = device.getService(device.uuids[0]);
    +  console.log("Service got");
     }
     
     function onerror(e)
     {
    -   console.log("Error occurred: " + e.message);
    +  console.log("Error occurred: " + e.message);
     }
     
     function onDeviceFound(device)
     {
    -   if (device.address == "11:22:33:44:55:66")
    -   {
    -      console.log("Found device: " + device.name);
    -      device.connect(onconnected.bind(null, device), onerror);
    -   }
    +  if (device.address == "11:22:33:44:55:66")
    +  {
    +    console.log("Found device: " + device.name);
    +    device.connect(onconnected.bind(null, device), onerror);
    +  }
     }
     
     var adapter = tizen.bluetooth.getLEAdapter();
    @@ -4545,27 +4543,27 @@ adapter.startScan(onDeviceFound, onerror);
             
     

    Code example:

    -/* Below variable should represent valid address of discoverable bluetooth low energy device */
    +/*Below variable should represent valid address of discoverable bluetooth low energy device */
     var remoteAddress = "11:22:33:44:55:66";
     
     function onconnected(device)
     {
    -   console.log("Connected to device");
    -   var services = device.getServiceAllUuids();
    -   console.log("Services length " + services.length);
    +  console.log("Connected to device");
    +  var services = device.getServiceAllUuids();
    +  console.log("Services length " + services.length);
     }
     
     function onerror(e)
     {
    -   console.log("Error occurred: " + e.message);
    +  console.log("Error occurred: " + e.message);
     }
     
     function onDeviceFound(device)
     {
    -   if (device.address == remoteAddress)
    -   {
    -      device.connect(onconnected.bind(null, device), onerror);
    -   }
    +  if (device.address == remoteAddress)
    +  {
    +    device.connect(onconnected.bind(null, device), onerror);
    +  }
     }
     
     var adapter = tizen.bluetooth.getLEAdapter();
    @@ -4615,29 +4613,29 @@ adapter.startScan(onDeviceFound, onerror);
     

    Code example:

     function onerror(e)
     {
    -   console.log("Error occurred: " + e.message);
    +  console.log("Error occurred: " + e.message);
     }
     
     function onDeviceFound(device)
     {
    -   var onConnectionStateChange =
    -   {
    -      onconnected: function(device)
    -      {
    -         console.log("Device " + device.name + " connected");
    -      },
    -      ondisconnected: function(device)
    -      {
    -         console.log("Device " + device.name + " disconnected");
    -      }
    -   }
    -
    -   if (device.address === "11:22:33:44:55:66")
    -   {
    -      console.log("Found device: " + device.name);
    -      device.addConnectStateChangeListener(onConnectionStateChange);
    -      device.connect();
    -   }
    +  var onConnectionStateChange =
    +  {
    +    onconnected: function(device)
    +    {
    +      console.log("Device " + device.name + " connected");
    +    },
    +    ondisconnected: function(device)
    +    {
    +      console.log("Device " + device.name + " disconnected");
    +    }
    +  }
    +
    +  if (device.address === "11:22:33:44:55:66")
    +  {
    +    console.log("Found device: " + device.name);
    +    device.addConnectStateChangeListener(onConnectionStateChange);
    +    device.connect();
    +  }
     }
     
     var adapter = tizen.bluetooth.getLEAdapter();
    @@ -4671,30 +4669,30 @@ adapter.startScan(onDeviceFound, onerror);
     

    Code example:

     function onerror(e)
     {
    -   console.log("Error occurred: " + e.message);
    +  console.log("Error occurred: " + e.message);
     }
     
     function onDeviceFound(device)
     {
    -   var onConnectionStateChange =
    -   {
    -      onconnected: function(device)
    -      {
    -         console.log("Device " + device.name + " connected");
    -      },
    -      ondisconnected: function(device)
    -      {
    -         console.log("Device " + device.name + " disconnected");
    -         device.removeConnectStateChangeListener(listenerID);
    -      }
    -   }
    -
    -   if (device.address === "11:22:33:44:55:66")
    -   {
    -      console.log("Found device: " + device.name);
    -      listenerID = device.addConnectStateChangeListener(onConnectionStateChange);
    -      device.connect();
    -   }
    +  var onConnectionStateChange =
    +  {
    +    onconnected: function(device)
    +    {
    +      console.log("Device " + device.name + " connected");
    +    },
    +    ondisconnected: function(device)
    +    {
    +      console.log("Device " + device.name + " disconnected");
    +      device.removeConnectStateChangeListener(listenerID);
    +    }
    +  }
    +
    +  if (device.address === "11:22:33:44:55:66")
    +  {
    +    console.log("Found device: " + device.name);
    +    listenerID = device.addConnectStateChangeListener(onConnectionStateChange);
    +    device.connect();
    +  }
     }
     
     var adapter = tizen.bluetooth.getLEAdapter();
    @@ -4865,46 +4863,46 @@ var adapter = tizen.bluetooth.getDefaultAdapter();
     
     function onSocketConnected(socket)
     {
    -   console.log("Opened connection to remote device");
    -   socket.onmessage = function()
    -   {
    -      console.log("Message received: " + socket.readData());
    -   };
    -
    -   socket.onclose = function()
    -   {
    -      console.log("Socket closed with " + socket.peer.name);
    -   };
    -
    -   /* Sends data to peer */
    -   var textmsg = "Test";
    -   var sendtextmsg = new Array();
    -   for (var i = 0; i < textmsg.length; i++)
    -   {
    -      sendtextmsg[i] = textmsg.charCodeAt(i);
    -   }
    -   socket.writeData(sendtextmsg);
    +  console.log("Opened connection to remote device");
    +  socket.onmessage = function()
    +  {
    +    console.log("Message received: " + socket.readData());
    +  };
    +
    +  socket.onclose = function()
    +  {
    +    console.log("Socket closed with " + socket.peer.name);
    +  };
    +
    +  /* Sends data to peer */
    +  var textmsg = "Test";
    +  var sendtextmsg = new Array();
    +  for (var i = 0; i < textmsg.length; i++)
    +  {
    +    sendtextmsg[i] = textmsg.charCodeAt(i);
    +  }
    +  socket.writeData(sendtextmsg);
     }
     
     function onSocketError(e)
     {
    -   console.log("Error connecting to service. Reason: " + e.message);
    +  console.log("Error connecting to service. Reason: " + e.message);
     }
     
     function onDeviceReady(device)
     {
    -   /* Validates device and service uuid */
    -   if (device.uuids.indexOf("5BCE9431-6C75-32AB-AFE0-2EC108A30860") != -1)
    -   {
    -      /* Opens socket */
    -      device.connectToServiceByUUID("5BCE9431-6C75-32AB-AFE0-2EC108A30860", onSocketConnected, onSocketError);
    -   }
    +  /* Validates device and service uuid */
    +  if (device.uuids.indexOf("5BCE9431-6C75-32AB-AFE0-2EC108A30860") != -1)
    +  {
    +    /* Opens socket */
    +    device.connectToServiceByUUID("5BCE9431-6C75-32AB-AFE0-2EC108A30860", onSocketConnected, onSocketError);
    +  }
     }
     
     function onSetPowered()
     {
    -   /* Gets the BluetoothDevice object */
    -   adapter.getDevice("35:F4:59:D1:7A:03", onDeviceReady, function(e) {console.log("Error: " + e.message);});
    +  /* Gets the BluetoothDevice object */
    +  adapter.getDevice("35:F4:59:D1:7A:03", onDeviceReady, function(e) {console.log("Error: " + e.message);});
     }
     
     adapter.setPowered(true, onSetPowered, function(e) {console.log("Could not turn on Bluetooth adapter. reason: " + e.message);});
    @@ -4963,41 +4961,41 @@ var adapter = tizen.bluetooth.getDefaultAdapter();
     
     function onError(e)
     {
    -   console.log("Error connecting to service. Reason: " + e.message);
    +  console.log("Error connecting to service. Reason: " + e.message);
     }
     
     function onSocketConnected(socket)
     {
    -   console.log("Opening socket success!!!");
    +  console.log("Opening socket success!!!");
     
    -   socket.onmessage = function()
    -   {
    -      /* Gets a message from peer, reads it */
    -      var data = socket.readData();
    +  socket.onmessage = function()
    +  {
    +    /* Gets a message from peer, reads it */
    +    var data = socket.readData();
     
    -      /* Code to evaluate message goes here */
    -   };
    +    /* Code to evaluate message goes here */
    +  };
     
    -   socket.onclose = function()
    -   {
    -      console.log("Socket closed with " + socket.peer.name);
    -   };
    +  socket.onclose = function()
    +  {
    +    console.log("Socket closed with " + socket.peer.name);
    +  };
     }
     
     function onDeviceReady(device)
     {
    -   /* Validates device and service uuid */
    -   if (device.uuids.indexOf("5BCE9431-6C75-32AB-AFE0-2EC108A30860") != -1)
    -   {
    -      /* Opens socket */
    -      device.connectToServiceByUUID("5BCE9431-6C75-32AB-AFE0-2EC108A30860", onSocketConnected, onError);
    -   }
    +  /* Validates device and service uuid */
    +  if (device.uuids.indexOf("5BCE9431-6C75-32AB-AFE0-2EC108A30860") != -1)
    +  {
    +    /* Opens socket */
    +    device.connectToServiceByUUID("5BCE9431-6C75-32AB-AFE0-2EC108A30860", onSocketConnected, onError);
    +  }
     }
     
     function onSetPowered()
     {
    -   /* Gets the BluetoothDevice object */
    -   adapter.getDevice("35:F4:59:D1:7A:03", onDeviceReady, function(e) {console.log("Error: " + e.message);});
    +  /* Gets the BluetoothDevice object */
    +  adapter.getDevice("35:F4:59:D1:7A:03", onDeviceReady, function(e) {console.log("Error: " + e.message);});
     }
     
     adapter.setPowered(true, onSetPowered, function(e) {console.log("Could not turn on Bluetooth adapter. reason: " + e.message);});
    @@ -5060,7 +5058,7 @@ Instead, use http://tizen.org/privilege/bluetooth.
     
             readonly attribute octet minor;
     
    -        readonly attribute unsigned short [] services ;
    +        readonly attribute unsigned short [] services;
     
             boolean hasService(unsigned short service) raises(WebAPIException);
         };
    @@ -5111,22 +5109,22 @@ var adapter = tizen.bluetooth.getDefaultAdapter(); function evaluateDevice(address) { - adapter.getDevice(address, function(device) - { - if (device.deviceClass.major == tizen.bluetooth.deviceMajor.COMPUTER) - { - /* Shows computer icon for this device */ - console.log("Device is computer"); - } - else if (device.deviceClass.major == tizen.bluetooth.deviceMajor.PHONE) - { - /* Shows phone icon */ - console.log("Device is a Phone"); - } - }, function(e) - { - console.log("Couldn't get any device with the given address: " + e.message); - }); + adapter.getDevice(address, function(device) + { + if (device.deviceClass.major == tizen.bluetooth.deviceMajor.COMPUTER) + { + /* Shows computer icon for this device */ + console.log("Device is computer"); + } + else if (device.deviceClass.major == tizen.bluetooth.deviceMajor.PHONE) + { + /* Shows phone icon */ + console.log("Device is a Phone"); + } + }, function(e) + { + console.log("Couldn't get any device with the given address: " + e.message); + }); } evaluateDevice("11:22:33:44:55:66"); @@ -5223,13 +5221,13 @@ Instead, use http://tizen.org/privilege/bluetooth. var adapter = tizen.bluetooth.getDefaultAdapter(); adapter.getDevice("12:34:56:78:9A:BC", function(device) { - if (device.deviceClass.hasService(tizen.bluetooth.deviceService.POSITIONING)) - { - console.log("Device supports Positioning service"); - } + if (device.deviceClass.hasService(tizen.bluetooth.deviceService.POSITIONING)) + { + console.log("Device supports Positioning service"); + } }, function(e) { - console.log("Couldn't get device for given address: " + e.message); + console.log("Couldn't get device for given address: " + e.message); });
    @@ -5396,7 +5394,8 @@ adapter.getDevice("12:34:56:78:9A:BC", function(device)
  • readonly BluetoothUUID uuid
    - The UUID of the service. See example. + The UUID of the service. See example +.

    Since: @@ -5406,7 +5405,8 @@ adapter.getDevice("12:34:56:78:9A:BC", function(device)

  • readonly DOMString name
    - The name of the service. See example. + The name of the service. See example +.

    Since: @@ -5445,29 +5445,29 @@ var adapter = tizen.bluetooth.getDefaultAdapter(); function chatServiceSuccessCb(handler) { - console.log("Chat service " + handler.name + " with UUID " + handler.uuid + " is successfully registered!"); - console.log("There is " + (handler.isConnected ? "a" : "no") + " device using this service"); + console.log("Chat service " + handler.name + " with UUID " + handler.uuid + " is successfully registered!"); + console.log("There is " + (handler.isConnected ? "a" : "no") + " device using this service"); - handler.onconnect = function(socket) - { - console.log("Client is connected: " + socket.peer.name + "," + socket.peer.address); - socket.onmessage = function() - { - var data = socket.readData(); - /* Handle message code here */ - }; + handler.onconnect = function(socket) + { + console.log("Client is connected: " + socket.peer.name + "," + socket.peer.address); + socket.onmessage = function() + { + var data = socket.readData(); + /* Handle message code goes here */ + }; - /* Expected close */ - socket.onclose = function() - { - console.log('The socket is closed.'); - }; - }; + /* Expected close */ + socket.onclose = function() + { + console.log("The socket is closed."); + }; + }; } function errorCb(e) { - console.log("Could not register service record, Error: " + e.message); + console.log("Could not register service record, Error: " + e.message); } var CHAT_SERVICE_UUID = "5BCE9431-6C75-32AB-AFE0-2EC108A30860"; @@ -5546,46 +5546,50 @@ var chatServiceHandler = null; function chatServiceSuccessCb(handler) { - console.log("Chat service registration was successful!"); + console.log("Chat service registration was successful!"); - chatServiceHandler = handler; - handler.onconnect = function(socket) - { - console.log("Client is connected: " + socket.peer.name + "," + socket.peer.address); - socket.onmessage = function() - { - var data = socket.readData(); - /* Handle message code here */ - }; + chatServiceHandler = handler; + handler.onconnect = function(socket) + { + console.log("Client is connected: " + socket.peer.name + "," + socket.peer.address); + socket.onmessage = function() + { + var data = socket.readData(); + /* Handle message code goes here */ + }; - /* Expected close */ - socket.onclose = function() - { - console.log('The socket is closed.'); - }; - }; + /* Expected close */ + socket.onclose = function() + { + console.log("The socket is closed."); + }; + }; } function publishChatService() { - var CHAT_SERVICE_UUID = "5BCE9431-6C75-32AB-AFE0-2EC108A30860"; - adapter.registerRFCOMMServiceByUUID(CHAT_SERVICE_UUID, "Chat service", chatServiceSuccessCb, - /* Error handler: function(e) {console.log("Could not register service record, Error: " + e.message);} */); + var CHAT_SERVICE_UUID = "5BCE9431-6C75-32AB-AFE0-2EC108A30860"; + adapter.registerRFCOMMServiceByUUID(CHAT_SERVICE_UUID, "Chat service", chatServiceSuccessCb, + /* Error handler */ + function(e) + { + console.log("Could not register service record, Error: " + e.message); + }); } function unRegisterChatService() { - if (chatServiceHandler != null) - { - chatServiceHandler.unregister(function() - { - chatServiceHandler = null; - console.log("Chat service is unregistered."); + if (chatServiceHandler != null) + { + chatServiceHandler.unregister(function() + { + chatServiceHandler = null; + console.log("Chat service is unregistered."); }, function(e) - { - console.log("Error: " + e.message); - }); - } + { + console.log("Error: " + e.message); + }); + } }

  • @@ -5624,12 +5628,12 @@ var healthCapability = tizen.systeminfo.getCapability("http://tizen.org/feature/ if (healthCapability) { - var healthProfileHandler = adapter.getBluetoothProfileHandler("HEALTH"); - console.log("Bluetooth profile type is " + healthProfileHandler.profileType); + var healthProfileHandler = adapter.getBluetoothProfileHandler("HEALTH"); + console.log("Bluetooth profile type is " + healthProfileHandler.profileType); } else { - console.log("Bluetooth Health Profile is not supported on this device."); + console.log("Bluetooth Health Profile is not supported on this device."); }
    @@ -5734,12 +5738,12 @@ var healthProfileHandler = adapter.getBluetoothProfileHandler("HEALTH"); function healthRegisterSuccess(app) { - console.log("Registered application: " + app.name); + console.log("Registered application: " + app.name); } function healthRegisterError(e) { - console.log("Failed to register application: " + e.message); + console.log("Failed to register application: " + e.message); }; healthProfileHandler.registerSinkApplication(4100, "testSinkApp", healthRegisterSuccess, healthRegisterError); @@ -5825,33 +5829,33 @@ var registerHealthApp = null; function healthConnectSuccess(channel) { - console.log("Health device is connected"); - var status = "Name of remote device: " + channel.peer.name + - "channel type of device profile: " + channel.channelType + - "health application name: " + channel.appication.name; - console.log(status); + console.log("Health device is connected"); + var status = "Name of remote device: " + channel.peer.name + + "channel type of device profile: " + channel.channelType + + "health application name: " + channel.appication.name; + console.log(status); } function healthConnectError(e) { - console.log("Failed to connect to source: " + e.message); + console.log("Failed to connect to source: " + e.message); }; function gotDeviceInfo(device) { - healthProfileHandler.connectToSource(device, registerHealthApp, healthConnectSuccess, healthConnectError); + healthProfileHandler.connectToSource(device, registerHealthApp, healthConnectSuccess, healthConnectError); } function healthRegisterSuccess(app) { - console.log("Registered application: " + app.name); - registerHealthApp = app; - adapter.getDevice("35:F4:59:D1:7A:03", gotDeviceInfo); + console.log("Registered application: " + app.name); + registerHealthApp = app; + adapter.getDevice("35:F4:59:D1:7A:03", gotDeviceInfo); } function healthRegisterError(e) { - console.log("Failed to register application: " + e.message); + console.log("Failed to register application: " + e.message); }; healthProfileHandler.registerSinkApplication(4100, "testSinkApp", healthRegisterSuccess, healthRegisterError); @@ -5936,18 +5940,18 @@ var healthProfileHandler = adapter.getBluetoothProfileHandler("HEALTH"); function healthRegisterSuccess(app) { - console.log("Registered application: " + app.name); - console.log("Data type used for communication is " + app.dataType); + console.log("Registered application: " + app.name); + console.log("Data type used for communication is " + app.dataType); - app.onconnect = function(channel) - { - console.log("Health device is connected"); - } + app.onconnect = function(channel) + { + console.log("Health device is connected"); + } } function healthRegisterError(e) { - console.log("Failed to register application: " + e.message); + console.log("Failed to register application: " + e.message); }; healthProfileHandler.registerSinkApplication(4100, "testSinkApp", healthRegisterSuccess, healthRegisterError); @@ -6028,51 +6032,51 @@ var healthApp = null; function healthRegisterSuccess(app) { - console.log("Registered application: " + app.name); - healthApp = app; - healthApp.onconnect = function(channel) - { - console.log("Connected!!"); - }; + console.log("Registered application: " + app.name); + healthApp = app; + healthApp.onconnect = function(channel) + { + console.log("Connected!!"); + }; } function healthRegisterError(e) { - console.log("Failed to register application: " + e.message); + console.log("Failed to register application: " + e.message); }; function startSink() { - try - { - healthProfileHandler.registerSinkApplication(4100, "testSinkApp", healthRegisterSuccess, healthRegisterError); - } - catch (e) - { - console.log("Error: " + e.message); - } + try + { + healthProfileHandler.registerSinkApplication(4100, "testSinkApp", healthRegisterSuccess, healthRegisterError); + } + catch (e) + { + console.log("Error: " + e.message); + } } function stopSink() { - try - { - if (healthApp != null) + try + { + if (healthApp != null) + { + healthApp.unregister(function() { - healthApp.unregister(function() - { - healthApp = null; - console.log("Health application is unregistered."); - }, function(e) - { - console.log("Error: " + e.message); - }); - } - } - catch (err) - { - console.log("Error: " + err.message); - } + healthApp = null; + console.log("Health application is unregistered."); + }, function(e) + { + console.log("Error: " + e.message); + }); + } + } + catch (err) + { + console.log("Error: " + err.message); + } } @@ -6157,16 +6161,16 @@ var healthProfileHandler = adapter.getBluetoothProfileHandler("HEALTH"); function healthRegisterSuccess(app) { - app.onconnect = function(channel) - { - console.log("Health device " + (channel.isConnected ? "is" : "is not") + " connected to " + channel.peer.name + " remote device"); - console.log("Channel type is " + channel.channelType + " and health application name used for communication is " + channel.application.name); - } + app.onconnect = function(channel) + { + console.log("Health device " + (channel.isConnected ? "is" : "is not") + " connected to " + channel.peer.name + " remote device"); + console.log("Channel type is " + channel.channelType + " and health application name used for communication is " + channel.application.name); + } } function healthRegisterError(e) { - console.log("Failed to register application: " + e.message); + console.log("Failed to register application: " + e.message); }; healthProfileHandler.registerSinkApplication(4100, "testSinkApp", healthRegisterSuccess, healthRegisterError); @@ -6226,17 +6230,17 @@ var healthProfileHandler = adapter.getBluetoothProfileHandler("HEALTH"); function healthRegisterSuccess(app) { - console.log("Registered application: " + app.name); - app.onconnect = function(channel) - { - console.log("Health device is connected"); - channel.close(); - } + console.log("Registered application: " + app.name); + app.onconnect = function(channel) + { + console.log("Health device is connected"); + channel.close(); + } } function healthRegisterError(e) { - console.log("Failed to register application: " + e.message); + console.log("Failed to register application: " + e.message); }; healthProfileHandler.registerSinkApplication(4100, "testSinkApp", healthRegisterSuccess, healthRegisterError); @@ -6309,22 +6313,22 @@ var textmsg = "Test"; var dataToSend = new Array(); for (var i = 0; i < textmsg.length; i++) { - dataToSend[i] = textmsg.charCodeAt(i); + dataToSend[i] = textmsg.charCodeAt(i); } function healthRegisterSuccess(app) { - console.log("Registered application: " + app.name); - app.onconnect = function(channel) - { - console.log("Health device is connected"); - channel.sendData(dataToSend); - } + console.log("Registered application: " + app.name); + app.onconnect = function(channel) + { + console.log("Health device is connected"); + channel.sendData(dataToSend); + } } function healthRegisterError(e) { - console.log("Failed to register application: " + e.message); + console.log("Failed to register application: " + e.message); }; healthProfileHandler.registerSinkApplication(4100, "testSinkApp", healthRegisterSuccess, healthRegisterError); @@ -6387,29 +6391,29 @@ var healthProfileHandler = adapter.getBluetoothProfileHandler("HEALTH"); var channelCallback = { - onmessage: function(data) - { - console.log("data is received") - }, - onclose: function() - { - console.log("channel is closed"); - } + onmessage: function(data) + { + console.log("data is received") + }, + onclose: function() + { + console.log("channel is closed"); + } }; function healthRegisterSuccess(app) { - console.log("Registered application: " + app.name); - app.onconnect = function(channel) - { - console.log("Health device is connected"); - channel.setListener(channelCallback); - } + console.log("Registered application: " + app.name); + app.onconnect = function(channel) + { + console.log("Health device is connected"); + channel.setListener(channelCallback); + } } function healthRegisterError(e) { - console.log("Failed to register application: " + e.message); + console.log("Failed to register application: " + e.message); }; healthProfileHandler.registerSinkApplication(4100, "testSinkApp", healthRegisterSuccess, healthRegisterError); @@ -6462,31 +6466,31 @@ var connectedChannel = null; var channelCallback = { - onmessage: function(data) - { - console.log("data is received") - }, - onclose: function() - { - console.log("channel is closed"); - connectedChannel.unsetListener(); - } + onmessage: function(data) + { + console.log("data is received") + }, + onclose: function() + { + console.log("channel is closed"); + connectedChannel.unsetListener(); + } }; function healthRegisterSuccess(app) { - console.log("Registered application: " + app.name); - app.onconnect = function(channel) - { - console.log("Health device is connected"); - connectedChannel = channel; - connectedChannel.setListener(channelCallback); - } + console.log("Registered application: " + app.name); + app.onconnect = function(channel) + { + console.log("Health device is connected"); + connectedChannel = channel; + connectedChannel.setListener(channelCallback); + } } function healthRegisterError(e) { - console.log("Failed to register application: " + e.message); + console.log("Failed to register application: " + e.message); }; healthProfileHandler.registerSinkApplication(4100, "testSinkApp", healthRegisterSuccess, healthRegisterError); @@ -7129,10 +7133,6 @@ To guarantee that the Bluetooth Low Energy application runs on a device with Blu optional SuccessCallback? successCallback, optional ErrorCallback? errorCallback) raises(WebAPIException); - void setPowered(boolean state, - optional SuccessCallback? successCallback, - optional ErrorCallback? errorCallback) raises(WebAPIException); - void setChangeListener(BluetoothAdapterChangeCallback listener) raises(WebAPIException); void unsetChangeListener() raises(WebAPIException); @@ -7249,6 +7249,7 @@ To guarantee that the Bluetooth Low Energy application runs on a device with Blu readonly attribute BluetoothLESolicitationUUID[]? solicitationuuids; readonly attribute BluetoothLEServiceData[]? serviceData; readonly attribute BluetoothLEManufacturerData? manufacturerData; + readonly attribute long rssi; void connect(optional SuccessCallback? successCallback, optional ErrorCallback? errorCallback) raises(WebAPIException); @@ -7284,7 +7285,7 @@ To guarantee that the Bluetooth Low Energy application runs on a device with Blu readonly attribute octet minor; - readonly attribute unsigned short [] services ; + readonly attribute unsigned short [] services; boolean hasService(unsigned short service) raises(WebAPIException); }; -- 2.7.4