The following Bluetooth functionalities are provided:
For more information on the Bluetooth features, see Bluetooth Guide.
Since: 1.0
typedef DOMString BluetoothAddress;
Since: 1.0
enum BluetoothSocketState { "CLOSED", "OPEN" };
Since: 1.0
enum BluetoothProfileType { "HEALTH" };
Since: 2.2
enum BluetoothHealthChannelType { "RELIABLE", "STREAMING" };
Since: 2.2
typedef DOMString BluetoothLESolicitationUUID;
Since: 2.3.1
enum BluetoothAdvertisePacketType { "ADVERTISE", "SCAN_RESPONSE" };
Since: 2.3.1
[NoInterfaceObject] interface BluetoothManagerObject { readonly attribute BluetoothManager bluetooth; };
Tizen implements BluetoothManagerObject;
Since: 1.0
The tizen.bluetooth object allows access to the Bluetooth API.
[Constructor(DOMString uuid, DOMString data)] interface BluetoothLEServiceData { attribute BluetoothUUID uuid; attribute DOMString data; };
Since: 2.3.1
BluetoothLEServiceData(DOMString uuid, DOMString data);
Since: 2.3.1
Since: 2.3.1
[Constructor(DOMString id, DOMString data)] interface BluetoothLEManufacturerData { attribute DOMString id; attribute DOMString data; };
Since: 2.3.1
BluetoothLEManufacturerData(DOMString id, DOMString data);
Code example:
// Creates a manufacturerData. var manufacture = new tizen.BluetoothLEManufacturerData("127", "0x0057");
Since: 2.3.1
The string should consist of hexadecimal characters only (A-F, a-f, 0-9). If the string's length is odd, the last character will be omitted. The string may start without or with one of below prefixes:
See also, usage of BluetoothLEManufacturerData.
Since: 2.3.1
dictionary BluetoothLEAdvertiseDataInit { boolean? includeName; BluetoothUUID[]? uuids; BluetoothLESolicitationUUID[]? solicitationuuids; unsigned long? appearance; boolean? includeTxPowerLevel; BluetoothLEServiceData? serviceData; BluetoothLEManufacturerData? manufacturerData; };
Since: 2.3.1
This dictionary is used as an input parameter of the BluetoothLEAdvertiseData constructor.
[Constructor(optional BluetoothLEAdvertiseDataInit? init)] interface BluetoothLEAdvertiseData { attribute boolean? includeName; attribute BluetoothUUID[]? uuids; attribute BluetoothLESolicitationUUID[]? solicitationuuids; attribute unsigned long? appearance; attribute boolean? includeTxPowerLevel; attribute BluetoothLEServiceData? serviceData; attribute BluetoothLEManufacturerData? manufacturerData; };
Since: 2.3.1
The BluetoothLEAdvertiseData container for Bluetooth LE advertising. This represents the data to be advertised as well as the scan response data for active scans.
BluetoothLEAdvertiseData(optional BluetoothLEAdvertiseDataInit? init);
Since: 2.3.1
Since: 2.3.1
Since: 2.3.1
See the list of appearance codes for sample values.
Since: 2.3.1
Since: 2.3.1
Since: 2.3.1
Since: 2.3.1
[NoInterfaceObject] interface BluetoothManager { readonly attribute BluetoothClassDeviceMajor deviceMajor; readonly attribute BluetoothClassDeviceMinor deviceMinor; readonly attribute BluetoothClassDeviceService deviceService; BluetoothAdapter getDefaultAdapter() raises(WebAPIException); BluetoothLEAdapter getLEAdapter() raises(WebAPIException); };
Since: 1.0
Since: 1.0
Since: 1.0
Since: 1.0
getDefaultAdapter
BluetoothAdapter getDefaultAdapter();
Since: 1.0
Privilege level: public
Privilege: http://tizen.org/privilege/bluetooth.gap
Return value:
BluetoothAdapter The local BluetoothAdapter object.Exceptions:
with error type SecurityError, if the application does not have the privilege to call this method.
with error type UnknownError, if any other error occurs.
Code example:
try { var adapter = tizen.bluetooth.getDefaultAdapter() ; } catch (err) { console.log (err.name +": " + err.message); }
getLEAdapter
BluetoothLEAdapter getLEAdapter();
Since: 2.3.1
Privilege level: public
Privilege: http://tizen.org/privilege/bluetooth.admin
Remark : To check if this method is supported or not, use tizen.systeminfo.getCapability("http://tizen.org/feature/network.bluetooth.le").
Return value:
BluetoothLEAdapter The local BluetoothLEAdapter object.Exceptions:
with error type SecurityError, if the application does not have the privilege to call this method.
with error type NotSupportedError, if the feature is not supported.
with error type UnknownError, if any other error occurs.
Code example:
try { var adapter = tizen.bluetooth.getLEAdapter(); } catch (err) { console.log(err.name +": " + err.message); }
[NoInterfaceObject] interface BluetoothAdapter { readonly attribute DOMString name; readonly attribute BluetoothAddress address; readonly attribute boolean powered; readonly attribute boolean visible; void setName(DOMString name, optional SuccessCallback? successCallback, optional ErrorCallback? errorCallback) raises(WebAPIException); void setPowered(boolean state, optional SuccessCallback? successCallback, optional ErrorCallback? errorCallback) raises(WebAPIException); void setVisible(boolean mode, optional SuccessCallback? successCallback, optional ErrorCallback? errorCallback, optional unsigned short? timeout) raises(WebAPIException); void setChangeListener(BluetoothAdapterChangeCallback listener) raises(WebAPIException); void unsetChangeListener() raises(WebAPIException); void discoverDevices(BluetoothDiscoverDevicesSuccessCallback successCallback, optional ErrorCallback? errorCallback) raises(WebAPIException); void stopDiscovery(optional SuccessCallback? successCallback, optional ErrorCallback? errorCallback) raises(WebAPIException); void getKnownDevices(BluetoothDeviceArraySuccessCallback successCallback, optional ErrorCallback? errorCallback) raises(WebAPIException); void getDevice(BluetoothAddress address, BluetoothDeviceSuccessCallback successCallback, optional ErrorCallback? errorCallback) raises(WebAPIException); void createBonding(BluetoothAddress address, BluetoothDeviceSuccessCallback successCallback, optional ErrorCallback? errorCallback) raises(WebAPIException); void destroyBonding(BluetoothAddress address, optional SuccessCallback? successCallback, optional ErrorCallback? errorCallback) raises(WebAPIException); void registerRFCOMMServiceByUUID(BluetoothUUID uuid, DOMString name, BluetoothServiceSuccessCallback successCallback, optional ErrorCallback? errorCallback) raises(WebAPIException); BluetoothProfileHandler getBluetoothProfileHandler(BluetoothProfileType profileType) raises(WebAPIException); };
Since: 1.0
This interface offers methods to control local Bluetooth behavior, such as:
Since: 1.0
Code example:
// Access adapter name var adapter = tizen.bluetooth.getDefaultAdapter(); console.log ("Bluetooth adapter name: " + adapter.name);
Since: 1.0
Code example:
var adapter = tizen.bluetooth.getDefaultAdapter(); console.log("Bluetooth device address: " + adapter.address);
This attribute holds one of the following 2 values:
Since: 1.0
Code example:
var adapter = tizen.bluetooth.getDefaultAdapter(); console.log("Bluetooth state: " + (adapter.powered ? "On" : "Off"));
Since: 1.0
Code example:
// Queries the current visible state var adapter = tizen.bluetooth.getDefaultAdapter(); console.log ("Bluetooth Visibility: " + (adapter.visible ? "On" : "Off"));
setName
void setName(DOMString name, optional SuccessCallback? successCallback, optional ErrorCallback? errorCallback);
Since: 1.0
Sends a request to Bluetooth hardware to change the name of the local Bluetooth adapter to name.
The ErrorCallback is launched with these error types:
Privilege level: public
Privilege: http://tizen.org/privilege/bluetooth.admin
Remark : To check if this method is supported or not, use tizen.systeminfo.getCapability("http://tizen.org/capability/network.bluetooth.always_on")
Parameters:
Exceptions:
with error type TypeMismatchError, if any of the input parameter is not compatible with the expected type for that parameter.
with error type SecurityError, if the application does not have the privilege to call this method.
Code example:
var adapter = tizen.bluetooth.getDefaultAdapter(); var bt_always_on = tizen.systeminfo.getCapability("http://tizen.org/capability/network.bluetooth.always_on"); 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 (bt_always_on === false) { changeName("myDevice"); }
setPowered
Deprecated. It is deprecated since Tizen 2.3 and will be removed in Tizen 3.0. Instead, let the user turn on/off Bluetooth through the Settings application. For more information, see the Bluetooth Tutorial.
void setPowered(boolean state, optional SuccessCallback? successCallback, optional ErrorCallback? errorCallback);
Since: 1.0
The ErrorCallback is launched with these error names:
Privilege level: public
Privilege: http://tizen.org/privilege/bluetooth.admin
Remark : To check if this method is supported or not, use this.systeminfo.getCapability( "http://tizen.org/capability/network.bluetooth.always_on").
Parameters:
Exceptions:
with error type TypeMismatchError, if any of the input parameter is not compatible with the expected type for that parameter.
with error type SecurityError, if the application does not have the privilege to call this method.
Code example:
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); }); } } 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); }); } } 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."); } else { powerOn(); }
setVisible
Deprecated. It is deprecated since Tizen 2.3 and will be removed in Tizen 3.0. Instead, let the user change theBluetooth visibility through the Settings application. See the Bluetooth Tutorial.
void setVisible(boolean mode, optional SuccessCallback? successCallback, optional ErrorCallback? errorCallback, optional unsigned short? timeout);
Since: 1.0
If mode is true, then the device is visible to other devices, that is, it responds to inquiry calls from remote devices for time period defined (in seconds) by timeout. After the timeout, the device will become invisible.
If timeout is not passed or an invalid parameter is passed, the timeout defaults to 180 seconds (3 minutes). A timeout of 0 is considered unlimited.
The ErrorCallback is launched with these error types:
Privilege level: platform
Privilege: http://tizen.org/privilege/bluetoothmanager
Remark : To check if this method is supported or not, use tizen.systeminfo.getCapability("http://tizen.org/capability/network.bluetooth.always_on")
Parameters:
Exceptions:
with error type TypeMismatchError, if any of the input parameter is not compatible with the expected type for that parameter.
with error type SecurityError, if the application does not have the privilege to call this method.
Code example:
var adapter = tizen.bluetooth.getDefaultAdapter(); function showMe() { if (adapter.visible == false) { //Shows device adapter.setVisible(true, function() { console.log ('Device is visible to other devices for 3 minutes.'); }, function(e) { console.log ('Error: ' + e.message + '(' + e.name + ')'); }); } else { console.log("Device is already in discoverable mode."); } } function hideMe() { if (adapter.visible) { // Hides device adapter.setVisible(false, function() { console.log('Device is in-visible now.'); }, function(e) { console.log ('Error: ' + e.message + '(' + e.name + ')'); }); } else { console.log("Device is already in invisible mode."); } } var bt_always_on = tizen.systeminfo.getCapability("http://tizen.org/capability/network.bluetooth.always_on"); if (bt_always_on === true) { console.log("Because Bluetooth must be always discoverable from the remote Bluetooth devices, this method does not work. NotSupportedError would be returned through ErrorCallback."); } else { powerOn(); }
setChangeListener
void setChangeListener(BluetoothAdapterChangeCallback listener);
Since: 2.2
Parameters:
Exceptions:
with error type TypeMismatchError, if the input parameter is not compatible with the expected type.
with error type SecurityError, if this functionality is not allowed.
with error type UnknownError, if any other error occurs.
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); } }; var adapter = tizen.bluetooth.getDefaultAdapter(); adapter.setChangeListener(changeListener);
unsetChangeListener
void unsetChangeListener();
Since: 2.2
Exceptions:
with error type SecurityError, if this functionality is not allowed.
with error type UnknownError, if any other error occurs.
Code example:
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); } }; adapter.setChangeListener(changeListener);
discoverDevices
void discoverDevices(BluetoothDiscoverDevicesSuccessCallback successCallback, optional ErrorCallback? errorCallback);
Since: 1.0
This method initiates the device discovery process. Depending on the progress of this process the following methods are invoked:
A discovery process can be canceled anytime, by calling stopDiscovery() on the BluetoothAdapter.
The ErrorCallback is launched with these error types:
Privilege level: public
Privilege: http://tizen.org/privilege/bluetooth.gap
Parameters:
Exceptions:
with error type TypeMismatchError, if any of the input parameter is not compatible with the expected type for that parameter.
with error type SecurityError, if the application does not have the privilege to call this method.
Code example:
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) { 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); } }; // 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 + ")"); } adapter.setPowered(true, startDiscovery, onSetPoweredError);
stopDiscovery
void stopDiscovery(optional SuccessCallback? successCallback, optional ErrorCallback? errorCallback);
Since: 1.0
Device discovery is a heavyweight procedure, hence we recommend stopping discovery as soon as the required device is found. This method cancels an active discovery session.
The ErrorCallback is launched with these error types:
Privilege level: public
Privilege: http://tizen.org/privilege/bluetooth.gap
Parameters:
Exceptions:
with error type TypeMismatchError, if any of the input parameter is not compatible with the expected type for that parameter.
with error type SecurityError, if the application does not have the privilege to call this method.
Code example:
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); }); } 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) { 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); } }; // 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 + ")"); } adapter.setPowered(true, startDiscovery, onSetPoweredError);
getKnownDevices
void getKnownDevices(BluetoothDeviceArraySuccessCallback successCallback, optional ErrorCallback? errorCallback);
Since: 1.0
A known device is one of the following:
On success, it returns the list of currently known devices through BluetoothDeviceArraySuccessCallback.
The ErrorCallback is launched with these error types:
Privilege level: public
Privilege: http://tizen.org/privilege/bluetooth.gap
Parameters:
Exceptions:
with error type TypeMismatchError, if the input parameter is not compatible with the expected type for that parameter
with error type SecurityError, if the application does not have the privilege to call this method.
Code example:
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); } function onError(e) { console.log ("Error: " + e.message); } function onBluetoothsetPowered() { adapter.getKnownDevices(onGotDevices, onError); } // Turns on Bluetooth adapter.setPowered(true, onBluetoothsetPowered);
getDevice
void getDevice(BluetoothAddress address, BluetoothDeviceSuccessCallback successCallback, optional ErrorCallback? errorCallback);
Since: 1.0
This method returns device information stored in the local Bluetooth adapter for the specified device address through BluetoothDeviceSuccessCallback. A valid hardware address must be passed, such as "35:F4:59:D1:7A:03".
The ErrorCallback is launched with these error types:
Privilege level: public
Privilege: http://tizen.org/privilege/bluetooth.gap
Parameters:
Exceptions:
with error type TypeMismatchError, if the input parameter is not compatible with the expected type for that parameter
with error type SecurityError, if the application does not have the privilege to call this method.
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")); } function onError(e) { console.log ("Could not get device info:" + e.message); } var adapter = tizen.bluetooth.getDefaultAdapter(); adapter.getDevice("35:F4:59:D1:7A:03", gotDeviceInfo, onError);
createBonding
void createBonding(BluetoothAddress address, BluetoothDeviceSuccessCallback successCallback, optional ErrorCallback? errorCallback);
Since: 1.0
If the bonding process is successful, the device information is sent in successCallback.
The ErrorCallback is launched with these error types:
Privilege level: public
Privilege: http://tizen.org/privilege/bluetooth.gap
Parameters:
Exceptions:
with error type TypeMismatchError, if the input parameter is not compatible with the expected type for that parameter.
with error type SecurityError, if the application does not have the privilege to call this method.
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")); } function onError(e) { console.log ("Could not create bonding, reason:" + e.message); } var adapter = tizen.bluetooth.getDefaultAdapter(); adapter.createBonding("35:F4:59:D1:7A:03", onBondingSuccess, onError);
destroyBonding
void destroyBonding(BluetoothAddress address, optional SuccessCallback? successCallback, optional ErrorCallback? errorCallback);
Since: 1.0
This method initiates the process of removing the specified address from the list of bonded devices.
The ErrorCallback is launched with these error types:
Privilege level: public
Privilege: http://tizen.org/privilege/bluetooth.gap
Parameters:
Exceptions:
with error type TypeMismatchError, if the input parameter is not compatible with the expected type for that parameter
with error type SecurityError, if the application does not have the privilege to call this method.
Code example:
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); }); } } 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); });
registerRFCOMMServiceByUUID
void registerRFCOMMServiceByUUID(BluetoothUUID uuid, DOMString name, BluetoothServiceSuccessCallback successCallback, optional ErrorCallback? errorCallback);
Since: 1.0
On success of the service registration, it returns a BluetoothServiceHandler object as the first parameter of successCallback, and listens for client connections. The service handler can be used to be notified on client connections or to unregister the service. User interaction is mandatory to connect to a registered service.
If any client(remote device) connects to this service, then BluetoothServiceHandler.onconnect() is invoked with BluetoothSocket object.
BluetoothServiceHandler.unregister() can be used to unregister the service record from the device service database and stop listening for client connections.
The ErrorCallback is launched with these error types:
Privilege level: public
Privilege: http://tizen.org/privilege/bluetooth.spp
Parameters:
Exceptions:
with error type TypeMismatchError, if the input parameter is not compatible with the expected type for that parameter.
with error type SecurityError, if the application does not have the privilege to call this method.
Code example:
var adapter = tizen.bluetooth.getDefaultAdapter(); // Holds currently registered service record var chatServiceHandler = null; // Holds currently open socket 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 }; 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); }); } 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); }); } }
getBluetoothProfileHandler
BluetoothProfileHandler getBluetoothProfileHandler(BluetoothProfileType profileType);
Since: 2.2
Remark : To check if HEALTH type is supported or not, use tizen.systeminfo.getCapability("http://tizen.org/feature/network.bluetooth.health")
Parameters:
Exceptions:
with error type TypeMismatchError, if the input parameter is not compatible with the expected type for that parameter.
with error type NotSupportedError, if the given profileType is not supported on a device.
with error type UnknownError, if any other error occurs.
Code example:
var adapter = tizen.bluetooth.getDefaultAdapter(); var healthProfileHandler; var healthCapability = tizen.systeminfo.getCapability("http://tizen.org/feature/network.bluetooth.health"); if (healthCapability) { healthProfileHandler = adapter.getBluetoothProfileHandler("HEALTH"); } else { console.log("Bluetooth Health Profile is not supported on this device."); }
[NoInterfaceObject] interface BluetoothLEAdapter { void startScan(BluetoothLEScanCallback successCallback, optional ErrorCallback? errorCallback) raises(WebAPIException); void stopScan() raises(WebAPIException); void startAdvertise(BluetoothLEAdvertiseData advertiseData, BluetoothAdvertisePacketType packetType, BluetoothLEAdvertiseCallback successCallback, optional ErrorCallback? errorCallback, optional BluetoothAdvertisingMode? mode, optional boolean? connectable) raises(WebAPIException); void stopAdvertise() raises(WebAPIException); };
Since: 2.3.1
This interface offers methods to control local Bluetooth Low Energy behavior, such as:
startScan
void startScan(BluetoothLEScanCallback successCallback, optional ErrorCallback? errorCallback);
Since: 2.3.1
The scanning process can be canceled anytime, by calling the stopScan() method in the BluetoothLEAdapter interface.
The ErrorCallback will be launched in the following situations:
Privilege level: public
Privilege: http://tizen.org/privilege/bluetooth.admin
Parameters:
Exceptions:
with error type TypeMismatchError, if any input attribute is not compatible with the expected type for this attribute.
with error type InvalidStateError, if device is currently in progress of scanning, if the local Bluetooth le adapter is currently not enabled.
with error type SecurityError, if the application does not have the privilege to call this method.
Code example:
var adapter = tizen.bluetooth.getLEAdapter(); adapter.startScan( function onsuccess(device) { console.log("[Found device] address: " + device.address); } );
stopScan
void stopScan();
Since: 2.3.1
Privilege level: public
Privilege: http://tizen.org/privilege/bluetooth.admin
Exceptions:
with error type SecurityError, if the application does not have the privilege to call this method.
with error type UnknownError, if any other error occurs
Code example:
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(); } } );
startAdvertise
void startAdvertise(BluetoothLEAdvertiseData advertiseData, BluetoothAdvertisePacketType packetType, BluetoothLEAdvertiseCallback successCallback, optional ErrorCallback? errorCallback, optional BluetoothAdvertisingMode? mode, optional boolean? connectable);
Since: 2.3.1
A advertising process can be canceled anytime, by calling stopAdvertise() on the BluetoothLEAdapter.
The ErrorCallback will be launched in the following situations:
Privilege level: public
Privilege: http://tizen.org/privilege/bluetooth.admin
Parameters:
Exceptions:
with error type TypeMismatchError, if any input attribute is not compatible with the expected type for this attribute.
with error type QuotaExceededError, if any input attribute is not compatible with the maximum data size for this attribute.
with error type InvalidStateError, if device is currently in progress of advertising, if the local Bluetooth le adapter is currently not enabled.
with error type SecurityError, if the application does not have the privilege to call this method.
Code example:
var adapter = tizen.bluetooth.getLEAdapter(); var battery_svc_uuid_16 = "180f"; // the service UUID, 16-bit UUID is supported. (e.g. 180f) var heart_rate_svc_uuid_16 = "180d"; // the 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, // The external appearance of device, 192 - Generic Watch uuids: [battery_svc_uuid_16], solicitationuuids: [heart_rate_svc_uuid_16] }; var advertiseData = new tizen.BluetoothLEAdvertiseData(advertiseOptions); var connectable = true; adapter.startAdvertise( advertiseData, "ADVERTISE", function onstate(state) { console.log("Advertiser state: " + state); }, function(e) { console.log("Failed to startAdvertise : " + e.message); }, "LOW_LATENCY", connectable);
stopAdvertise
void stopAdvertise();
Since: 2.3.1
Privilege level: public
Privilege: http://tizen.org/privilege/bluetooth.admin
Exceptions:
with error type SecurityError, if the application does not have the privilege to call this method.
with error type UnknownError, if any other error occurs
Code example:
var adapter = tizen.bluetooth.getLEAdapter(); var battery_svc_uuid_16 = "180f"; // the service UUID, 16-bit UUID is supported. (e.g. 180f) var heart_rate_svc_uuid_16 = "180d"; // the 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, // The 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); }); adapter.stopAdvertise();
[NoInterfaceObject] interface BluetoothGATTService { readonly attribute BluetoothUUID uuid; readonly attribute BluetoothGATTService[] services; readonly attribute BluetoothGATTCharacteristic[] characteristics; };
Since: 2.3.1
Since: 2.3.1
Since: 2.3.1
Since: 2.3.1
[NoInterfaceObject] interface BluetoothGATTCharacteristic { readonly attribute BluetoothGATTDescriptor[] descriptors; readonly attribute boolean isBroadcast; readonly attribute boolean hasExtendedProperties; readonly attribute boolean isNotify; readonly attribute boolean isIndication; readonly attribute boolean isReadable; readonly attribute boolean isSignedWrite; readonly attribute boolean isWritable; readonly attribute boolean isWriteNoResponse; void readValue(ReadValueSuccessCallback successCallback, optional ErrorCallback? errorCallback) raises(WebAPIException); void writeValue(byte[] value, optional SuccessCallback? successCallback, optional ErrorCallback? errorCallback) raises(WebAPIException); long addValueChangeListener(ReadValueSuccessCallback callback) raises(WebAPIException); void removeValueChangeListener(long watchID); };
Since: 2.3.1
Since: 2.3.1
Since: 2.3.1
Since: 2.3.1
Since: 2.3.1
Since: 2.3.1
Since: 2.3.1
Since: 2.3.1
Since: 2.3.1
Since: 2.3.1
readValue
void readValue(ReadValueSuccessCallback successCallback, optional ErrorCallback? errorCallback);
Since: 2.3.1
The ErrorCallback is launched with these error types:
Privilege level: public
Privilege: http://tizen.org/privilege/bluetooth.admin
Parameters:
Exceptions:
with error type TypeMismatchError, if the input parameter is not compatible with the expected type for that parameter.
with error type InvalidStateError, if the local Bluetooth le adapter is currently not enabled.
with error type SecurityError, if the application does not have the privilege to call this method.
Code example:
function onerror(e) { 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) { var characteristic = service.characteristics[0]; characteristic.readValue(function(val) { 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); } } );
writeValue
void writeValue(byte[] value, optional SuccessCallback? successCallback, optional ErrorCallback? errorCallback);
Since: 2.3.1
The ErrorCallback is launched with these error types:
Privilege level: public
Privilege: http://tizen.org/privilege/bluetooth.admin
Parameters:
Exceptions:
with error type TypeMismatchError, if the input parameter is not compatible with the expected type for that parameter.
with error type InvalidStateError, if the local Bluetooth le adapter is currently not enabled.
with error type SecurityError, if the application does not have the privilege to call this method.
Code example:
function onerror(e) { 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) { 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); }); } } } 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); } } );
addValueChangeListener
long addValueChangeListener(ReadValueSuccessCallback callback);
Since: 2.3.1
Privilege level: public
Privilege: http://tizen.org/privilege/bluetooth.admin
Parameters:
Return value:
long The watchID to be used to unregister the listenerExceptions:
with error type SecurityError, if the application does not have the privilege to call this method.
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(); }); } } 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); } } );
removeValueChangeListener
void removeValueChangeListener(long watchID);
Since: 2.3.1
Parameters:
[NoInterfaceObject] interface BluetoothGATTDescriptor { void readValue(ReadValueSuccessCallback successCallback, optional ErrorCallback? errorCallback) raises(WebAPIException); void writeValue(byte[] value, optional SuccessCallback? successCallback, optional ErrorCallback? errorCallback) raises(WebAPIException); };
Since: 2.3.1
readValue
void readValue(ReadValueSuccessCallback successCallback, optional ErrorCallback? errorCallback);
Since: 2.3.1
The ErrorCallback is launched with these error types:
Privilege level: public
Privilege: http://tizen.org/privilege/bluetooth.admin
Parameters:
Exceptions:
with error type TypeMismatchError, if the input parameter is not compatible with the expected type for that parameter.
with error type InvalidStateError, if the local Bluetooth le adapter is currently not enabled.
with error type SecurityError, if the application does not have the privilege to call this method.
Code example:
function onerror(e) { 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) { var characteristic = service.characteristics[0]; var descriptor = characteristic.descriptors[0]; descriptor.readValue(function(val) { 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); } } );
writeValue
void writeValue(byte[] value, optional SuccessCallback? successCallback, optional ErrorCallback? errorCallback);
Since: 2.3.1
The ErrorCallback is launched with these error types:
Privilege level: public
Privilege: http://tizen.org/privilege/bluetooth.admin
Parameters:
Exceptions:
with error type TypeMismatchError, if the input parameter is not compatible with the expected type for that parameter.
with error type InvalidStateError, if the local Bluetooth le adapter is currently not enabled.
with error type SecurityError, if the application does not have the privilege to call this method.
Code example:
function onerror(e) { 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) { 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); }); } } } 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); } } );
[Callback=FunctionOnly, NoInterfaceObject] interface BluetoothLEScanCallback { void onsuccess(BluetoothLEDevice device); };
Since: 2.3.1
onsuccess
void onsuccess(BluetoothLEDevice device);
Since: 2.3.1
Parameters:
[Callback=FunctionOnly, NoInterfaceObject] interface BluetoothLEAdvertiseCallback { void onstate(BluetoothAdvertisingState state); };
Since: 2.3.1
onstate
void onstate(BluetoothAdvertisingState state);
Since: 2.3.1
Parameters:
[Callback, NoInterfaceObject] interface BluetoothLEConnectChangeCallback { void onconnected(BluetoothLEDevice device); void ondisconnected(BluetoothLEDevice device); };
Since: 2.3.1
onconnected
void onconnected(BluetoothLEDevice device);
Since: 2.3.1
Parameters:
ondisconnected
void ondisconnected(BluetoothLEDevice device);
Since: 2.3.1
Parameters:
[Callback=FunctionOnly, NoInterfaceObject] interface ReadValueSuccessCallback { void onread(byte[] value); };
Since: 2.3.1
[NoInterfaceObject] interface BluetoothDevice { readonly attribute DOMString name; readonly attribute BluetoothAddress address; readonly attribute BluetoothClass deviceClass; readonly attribute boolean isBonded; readonly attribute boolean isTrusted; readonly attribute boolean isConnected; readonly attribute BluetoothUUID[] uuids; void connectToServiceByUUID(BluetoothUUID uuid, BluetoothSocketSuccessCallback successCallback, optional ErrorCallback? errorCallback) raises(WebAPIException); };
Since: 1.0
A BluetoothDevice object can be retrieved using one of the following APIs:
Since: 1.0
Code example:
var adapter = tizen.bluetooth.getDefaultAdapter(); adapter.getDevice("11:22:33:44:55:66", function(device) { console.log("Device Name: " + device.name); });
Since: 1.0
Code example:
var adapter = tizen.bluetooth.getDefaultAdapter(); adapter.getDevice("11:22:33:44:55:66", function(device) { console.log("Device Address: " + device.address); });
Since: 1.0
Code example:
var adapter = tizen.bluetooth.getDefaultAdapter(); adapter.getDevice("11:22:33:44:55:66", function(device) { console.log("Device Major Class: " + device.deviceClass.major); });
Since: 1.0
Code example:
var adapter = tizen.bluetooth.getDefaultAdapter(); adapter.getDevice("11:22:33:44:55:66", function(device) { console.log("Is bonded: " + (device.isBonded ? "Yes" : "No")); });
Since: 1.0
Code example:
var adapter = tizen.bluetooth.getDefaultAdapter(); adapter.getDevice("11:22:33:44:55:66", function(device) { console.log("Is trusted: " + (device.isTrusted ? "Yes" : "No")); });
Since: 1.0
Code example:
var adapter = tizen.bluetooth.getDefaultAdapter(); adapter.getDevice("11:22:33:44:55:66", function(device) { console.log("Is connected: " + (device.isConnected ? "Yes" : "No")); });
Since: 1.0
Code example:
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); }); } });
connectToServiceByUUID
void connectToServiceByUUID(BluetoothUUID uuid, BluetoothSocketSuccessCallback successCallback, optional ErrorCallback? errorCallback);
Since: 1.0
If opening a connection is successful, then a BluetoothSocket object with open state is sent using successCallback, through which data can be exchanged by both devices.
The ErrorCallback is launched with these error types:
Privilege level: public
Privilege: http://tizen.org/privilege/bluetooth.spp
Parameters:
Exceptions:
with error type TypeMismatchError, if the input parameter is not compatible with the expected type for that parameter
with error type SecurityError, if the application does not have the privilege to call this method.
Code example:
var adapter = tizen.bluetooth.getDefaultAdapter(); 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); } } // 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."); }; } 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"); } } function onSetPowered() { // 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); });
[NoInterfaceObject] interface BluetoothLEDevice { readonly attribute BluetoothAddress address; readonly attribute DOMString? name; readonly attribute unsigned long? txpowerlevel; readonly attribute unsigned long? appearance; readonly attribute BluetoothUUID[]? uuids; readonly attribute BluetoothLESolicitationUUID[]? solicitationuuids; readonly attribute BluetoothLEServiceData[]? serviceData; readonly attribute BluetoothLEManufacturerData? manufacturerData; void connect(optional SuccessCallback? successCallback, optional ErrorCallback? errorCallback) raises(WebAPIException); void disconnect(optional SuccessCallback? successCallback, optional ErrorCallback? errorCallback) raises(WebAPIException); BluetoothGATTService getService(BluetoothUUID uuid) raises(WebAPIException); long addConnectStateChangeListener(BluetoothLEConnectChangeCallback listener) raises(WebAPIException); void removeConnectStateChangeListener(long watchID); };
Since: 2.3.1
A BluetoothLEDevice object can be retrieved by using one of the following APIs:
Since: 2.3.1
Code example:
var adapter = tizen.bluetooth.getLEAdapter(); adapter.startScan( function onsuccess(device) { console.log("Found device: " + device.address); } );
Since: 2.3.1
Code example:
var adapter = tizen.bluetooth.getLEAdapter(); adapter.startScan( function onsuccess(device) { console.log("Found device: " + device.name); } );
Since: 2.3.1
Code example:
var adapter = tizen.bluetooth.getLEAdapter(); adapter.startScan( function onsuccess(device) { console.log("Found device: " + device.txpowerlevel); } );
Since: 2.3.1
Code example:
var adapter = tizen.bluetooth.getLEAdapter(); adapter.startScan( function onsuccess(device) { console.log("Found device: " + device.appearance); } );
Since: 2.3.1
Code example:
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); } );
Since: 2.3.1
Code example:
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); } );
Since: 2.3.1
Code example:
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); } );
Since: 2.3.1
Code example:
var adapter = tizen.bluetooth.getLEAdapter(); // On an advertising device: var advertiseOptions = { manufacturerData: new tizen.BluetoothLEManufacturerData("127", "0xDeadc0dE") }; var advertiseData = new tizen.BluetoothLEAdvertiseData(advertiseOptions); adapter.startAdvertise(advertiseData, "ADVERTISE", function onstate(state) { console.log("Advertiser state: " + state); }, function(e) { console.log("Failed to startAdvertise : " + e.message); }, "LOW_LATENCY"); // On scanning device: adapter.startScan( function onsuccess(device) { var manufacturerData = device.manufacturerData; console.log("Found device, manufacturerData: " + JSON.stringify(device.manufacturerData)); } );
Output example:
Advertiser state: STARTED Found device, manufacturerData: {"id":"127","data":"DEADC0DE"}
connect
void connect(optional SuccessCallback? successCallback, optional ErrorCallback? errorCallback);
Since: 2.3.1
Connection is required to readValue() and writeValue() from the remote device.
The ErrorCallback is launched with these error types:
Privilege level: public
Privilege: http://tizen.org/privilege/bluetooth.admin
Parameters:
Exceptions:
with error type TypeMismatchError, if the input parameter is not compatible with the expected type for that parameter.
with error type SecurityError, if the application does not have the privilege to call this method.
Code example:
function onerror(e) { console.log("Failed to connect to device: " + e.message); } function onconnected() { 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); } } );
disconnect
void disconnect(optional SuccessCallback? successCallback, optional ErrorCallback? errorCallback);
Since: 2.3.1
The ErrorCallback is launched with these error types:
Privilege level: public
Privilege: http://tizen.org/privilege/bluetooth.admin
Parameters:
Exceptions:
with error type TypeMismatchError, if the input parameter is not compatible with the expected type for that parameter.
with error type InvalidStateError, if device is currently not connected
with error type SecurityError, if the application does not have the privilege to call this method.
Code example:
function onerror(e) { console.log("Error occured: " + 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); } } var adapter = tizen.bluetooth.getLEAdapter(); adapter.startScan(onDeviceFound, onerror);
getService
BluetoothGATTService getService(BluetoothUUID uuid);
Since: 2.3.1
Privilege level: public
Privilege: http://tizen.org/privilege/bluetooth.admin
Parameters:
Exceptions:
with error type NotFoundError, if there is no service with the given UUID.
with error type SecurityError, if the application does not have the privilege to call this method.
with error type InvalidStateError, if the GATT service is not available.
with error type UnknownError, if any other error occurs.
Code example:
function onconnected(device) { console.log("Connected to device"); var service = device.getService(device.uuids[0]); console.log("Service got"); } function onerror(e) { console.log("Error occured: " + 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); } } var adapter = tizen.bluetooth.getLEAdapter(); adapter.startScan(onDeviceFound, onerror);
addConnectStateChangeListener
long addConnectStateChangeListener(BluetoothLEConnectChangeCallback listener);
Since: 2.3.1
Parameters:
Return value:
long The watchID to be used to unregister the listenerExceptions:
with error type UnknownError, if any other error occurs.
Code example:
function onerror(e) { console.log("Error occured: " + 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 adapter = tizen.bluetooth.getLEAdapter(); adapter.startScan(onDeviceFound, onerror);
removeConnectStateChangeListener
void removeConnectStateChangeListener(long watchID);
Since: 2.3.1
Parameters:
Code example:
function onerror(e) { console.log("Error occured: " + 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 adapter = tizen.bluetooth.getLEAdapter(); var listenerID = null; adapter.startScan(onDeviceFound, onerror);
[NoInterfaceObject] interface BluetoothSocket { readonly attribute BluetoothUUID uuid; readonly attribute BluetoothSocketState state; readonly attribute BluetoothDevice peer; [TreatNonCallableAsNull] attribute SuccessCallback? onmessage raises(WebAPIException); [TreatNonCallableAsNull] attribute SuccessCallback? onclose raises(WebAPIException); unsigned long writeData(byte[] data) raises(WebAPIException); byte[] readData() raises(WebAPIException); void close() raises(WebAPIException); };
Since: 1.0
The socket object is created by BluetoothDevice.connectToServiceByUUID() or BluetoothAdapter.registerRFCOMMServiceByUUID().
Since: 1.0
Since: 1.0
Since: 1.0
Since: 1.0
Exceptions:
with error type TypeMismatchError, if any input attribute is not compatible with the expected type for this attribute.
Since: 1.0
Exceptions:
with error type TypeMismatchError, if any input attribute is not compatible with the expected type for this attribute.
writeData
unsigned long writeData(byte[] data);
Since: 1.0
Privilege level: public
Privilege: http://tizen.org/privilege/bluetooth.spp
Parameters:
Return value:
unsigned long The number of bytes actually sentExceptions:
with error type TypeMismatchError, if any input parameters in not compatible with the expected type for that parameter.
with error type SecurityError, if the application does not have the privilege to call this method.
with error type UnknownError, if any other error occurs.
Code example:
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); } function onSocketError(e) { 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 ); } } function onSetPowered() { // 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); });
readData
byte[] readData();
Since: 1.0
This method should be called only in the BluetoothSocket.onmessage handler, that is, when data is ready on the socket.
Privilege level: public
Privilege: http://tizen.org/privilege/bluetooth.spp
Return value:
byte[] The sequence of bytes successfully readExceptions:
with error type SecurityError, if the application does not have the privilege to call this method.
with error type UnknownError, if any other error occurs.
Code example:
var adapter = tizen.bluetooth.getDefaultAdapter(); function onError(e) { console.log ("Error connecting to service. Reason: " + e.message); } function onSocketConnected(socket) { console.log ("Opening socket success!!!"); socket.onmessage = function() { // Gets a message from peer, reads it var data = socket.readData(); // // Code to evaluate message goes here // }; 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); } } function onSetPowered() { // 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); });
close
void close();
Since: 1.0
BluetoothSocket.state changes to CLOSED, and BluetoothSocket.onclose() is invoked on success.
Privilege level: public
Privilege: http://tizen.org/privilege/bluetooth.spp
Exceptions:
with error type SecurityError, if the application does not have the privilege to call this method.
with error type UnknownError, if any other error occurs.
[NoInterfaceObject] interface BluetoothClass { readonly attribute octet major; readonly attribute octet minor; readonly attribute unsigned short [] services ; boolean hasService(unsigned short service) raises(WebAPIException); };
Since: 1.0
Bluetooth device class describes the characteristics and capabilities of a device.
Bluetooth CoD is a 24 bit integer created by the union of three components:
The Major and Minor classes are intended to define a general family of devices with which any particular implementation wishes to be associated. No assumptions should be made about specific functionality or characteristics of any application, based solely on the assignment of a Major or minor device class.
The BluetoothClassDeviceMajor interface contains the list of known values.
Since: 1.0
Code example:
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); }); } evaluateDevice("11:22:33:44:55:66");
The BluetoothClassDeviceMinor interface contains the list of known values.
Since: 1.0
Since: 1.0
hasService
boolean hasService(unsigned short service);
Since: 1.0
Privilege level: public
Privilege: http://tizen.org/privilege/bluetooth.gap
Parameters:
Exceptions:
with error type InvalidValuesError, if any of the input parameters contain an invalid value.
with error type SecurityError, if the application does not have the privilege to call this method.
with error type UnknownError, if any other error occurs.
Code example:
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"); } }, function(e) { console.log("Couldn't get device for given address: " + e.message); });
[NoInterfaceObject] interface BluetoothClassDeviceMajor { const octet MISC = 0x00; const octet COMPUTER = 0x01; const octet PHONE = 0x02; const octet NETWORK = 0x03; const octet AUDIO_VIDEO = 0x04; const octet PERIPHERAL = 0x05; const octet IMAGING = 0x06; const octet WEARABLE = 0x07; const octet TOY = 0x08; const octet HEALTH = 0x09; const octet UNCATEGORIZED = 0x1F; };
Since: 1.0
[NoInterfaceObject] interface BluetoothClassDeviceMinor { const octet COMPUTER_UNCATEGORIZED = 0x00; const octet COMPUTER_DESKTOP = 0x01; const octet COMPUTER_SERVER = 0x02; const octet COMPUTER_LAPTOP = 0x03; const octet COMPUTER_HANDHELD_PC_OR_PDA = 0x04; const octet COMPUTER_PALM_PC_OR_PDA = 0x05; const octet COMPUTER_WEARABLE = 0x06; const octet PHONE_UNCATEGORIZED = 0x00; const octet PHONE_CELLULAR = 0x01; const octet PHONE_CORDLESS = 0x02; const octet PHONE_SMARTPHONE = 0x03; const octet PHONE_MODEM_OR_GATEWAY = 0x04; const octet PHONE_ISDN = 0x05; const octet AV_UNRECOGNIZED = 0x00; const octet AV_WEARABLE_HEADSET = 0x01; const octet AV_HANDSFREE = 0x02; const octet AV_MICROPHONE = 0x04; const octet AV_LOUDSPEAKER = 0x05; const octet AV_HEADPHONES = 0x06; const octet AV_PORTABLE_AUDIO = 0x07; const octet AV_CAR_AUDIO = 0x08; const octet AV_SETTOP_BOX = 0x09; const octet AV_HIFI = 0x0a; const octet AV_VCR = 0x0b; const octet AV_VIDEO_CAMERA = 0x0c; const octet AV_CAMCORDER = 0x0d; const octet AV_MONITOR = 0x0e; const octet AV_DISPLAY_AND_LOUDSPEAKER = 0x0f; const octet AV_VIDEO_CONFERENCING = 0x10; const octet AV_GAMING_TOY = 0x12; const octet PERIPHERAL_UNCATEGORIZED = 0; const octet PERIPHERAL_KEYBOARD = 0x10; const octet PERIPHERAL_POINTING_DEVICE = 0x20; const octet PERIPHERAL_KEYBOARD_AND_POINTING_DEVICE = 0x30; const octet PERIPHERAL_JOYSTICK = 0x01; const octet PERIPHERAL_GAMEPAD = 0x02; const octet PERIPHERAL_REMOTE_CONTROL = 0x03; const octet PERIPHERAL_SENSING_DEVICE = 0x04; const octet PERIPHERAL_DEGITIZER_TABLET = 0x05; const octet PERIPHERAL_CARD_READER = 0x06; const octet PERIPHERAL_DIGITAL_PEN = 0x07; const octet PERIPHERAL_HANDHELD_SCANNER = 0x08; const octet PERIPHERAL_HANDHELD_INPUT_DEVICE = 0x09; const octet IMAGING_UNCATEGORIZED = 0x00; const octet IMAGING_DISPLAY = 0x04; const octet IMAGING_CAMERA = 0x08; const octet IMAGING_SCANNER = 0x10; const octet IMAGING_PRINTER = 0x20; const octet WEARABLE_WRITST_WATCH = 0x01; const octet WEARABLE_PAGER = 0x02; const octet WEARABLE_JACKET = 0x03; const octet WEARABLE_HELMET = 0x04; const octet WEARABLE_GLASSES = 0x05; const octet TOY_ROBOT = 0x01; const octet TOY_VEHICLE = 0x02; const octet TOY_DOLL = 0x03; const octet TOY_CONTROLLER = 0x04; const octet TOY_GAME = 0x05; const octet HEALTH_UNDEFINED = 0x00; const octet HEALTH_BLOOD_PRESSURE_MONITOR = 0x01; const octet HEALTH_THERMOMETER = 0x02; const octet HEALTH_WEIGHING_SCALE = 0x03; const octet HEALTH_GLUCOSE_METER = 0x04; const octet HEALTH_PULSE_OXIMETER = 0x05; const octet HEALTH_PULSE_RATE_MONITOR = 0x06; const octet HEALTH_DATA_DISPLAY = 0x07; const octet HEALTH_STEP_COUNTER = 0x08; const octet HEALTH_BODY_COMPOSITION_ANALYZER = 0x09; const octet HEALTH_PEAK_FLOW_MONITOR = 0x0a; const octet HEALTH_MEDICATION_MONITOR = 0x0b; const octet HEALTH_KNEE_PROSTHESIS = 0x0c; const octet HEALTH_ANKLE_PROSTHESIS = 0x0d; };
Since: 1.0
[NoInterfaceObject] interface BluetoothClassDeviceService { const unsigned short LIMITED_DISCOVERABILITY = 0x0001; const unsigned short POSITIONING = 0x0008; const unsigned short NETWORKING = 0x0010; const unsigned short RENDERING = 0x0020; const unsigned short CAPTURING = 0x0040; const unsigned short OBJECT_TRANSFER = 0x0080; const unsigned short AUDIO = 0x0100; const unsigned short TELEPHONY = 0x0200; const unsigned short INFORMATION = 0x0400; };
Since: 1.0
[NoInterfaceObject] interface BluetoothServiceHandler { readonly attribute BluetoothUUID uuid; readonly attribute DOMString name; readonly attribute boolean isConnected; [TreatNonCallableAsNull] attribute BluetoothSocketSuccessCallback? onconnect raises(WebAPIException); void unregister(optional SuccessCallback? successCallback, optional ErrorCallback? errorCallback) raises(WebAPIException); };
Since: 1.0
Since: 1.0
Since: 1.0
Since: 1.0
Since: 1.0
Exceptions:
with error type TypeMismatchError, if any input attribute is not compatible with the expected type for this attribute.
unregister
void unregister(optional SuccessCallback? successCallback, optional ErrorCallback? errorCallback);
Since: 1.0
The ErrorCallback is launched with these error types:
Privilege level: public
Privilege: http://tizen.org/privilege/bluetooth.spp
Parameters:
Exceptions:
with error type TypeMismatchError, if the input parameter is not compatible with the expected type for that parameter.
with error type SecurityError, if the application does not have the privilege to call this method.
Code example:
var adapter = tizen.bluetooth.getDefaultAdapter(); var chatServiceHandler = null; function chatServiceSuccessCb(handler) { 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 goes here //.... }; // 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); }); } function unRegisterChatService() { if (chatServiceHandler != null) { chatServiceHandler.unregister(function() { chatServiceHandler = null; console.log("Chat service is unregistered."); }, function(e) { console.log ("Error: " + e.message); }); } }
[NoInterfaceObject] interface BluetoothProfileHandler { readonly attribute BluetoothProfileType profileType; };
Since: 2.2
Since: 2.2
[NoInterfaceObject] interface BluetoothHealthProfileHandler : BluetoothProfileHandler { void registerSinkApplication(unsigned short dataType, DOMString name, BluetoothHealthApplicationSuccessCallback successCallback, optional ErrorCallback? errorCallback) raises(WebAPIException); void connectToSource(BluetoothDevice peer, BluetoothHealthApplication application, BluetoothHealthChannelSuccessCallback successCallback, optional ErrorCallback? errorCallback) raises(WebAPIException); };
Since: 2.2
registerSinkApplication
void registerSinkApplication(unsigned short dataType, DOMString name, BluetoothHealthApplicationSuccessCallback successCallback, optional ErrorCallback? errorCallback);
Since: 2.2
The ErrorCallback is launched with these error types:
Privilege level: public
Privilege: http://tizen.org/privilege/bluetooth.health
Parameters:
Exceptions:
with error type SecurityError, if the application does not have the privilege to call this method.
with error type TypeMismatchError, if any of the input parameter is not compatible with the expected type for that parameter.
Code example:
var adapter = tizen.bluetooth.getDefaultAdapter(); var healthProfileHandler = adapter.getBluetoothProfileHandler("HEALTH"); function healthRegisterSuccess(app) { console.log("Registered application: " + app.name); } function healthRegisterError(e) { console.log("Failed to register application: " + e.message); }; healthProfileHandler.registerSinkApplication(4100, "testSinkApp", healthRegisterSuccess, healthRegisterError);
connectToSource
void connectToSource(BluetoothDevice peer, BluetoothHealthApplication application, BluetoothHealthChannelSuccessCallback successCallback, optional ErrorCallback? errorCallback);
Since: 2.2
The ErrorCallback is launched with these error types:
Privilege level: public
Privilege: http://tizen.org/privilege/bluetooth.health
Parameters:
Exceptions:
with error type SecurityError, if the application does not have the privilege to call this method.
with error type TypeMismatchError, if any of the input parameter is not compatible with the expected type for that parameter.
Code example:
var adapter = tizen.bluetooth.getDefaultAdapter(); var healthProfileHandler = adapter.getBluetoothProfileHandler("HEALTH"); var registerHealthApp = null; function healthConnectSuccess(channel) { console.log("Health device is connected"); } function healthConnectError(e) { console.log("Failed to connect to source: " + e.message); }; function gotDeviceInfo(device) { 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); } function healthRegisterError(e) { console.log("Failed to register application: " + e.message); }; healthProfileHandler.registerSinkApplication(4100, "testSinkApp", healthRegisterSuccess, healthRegisterError);
[NoInterfaceObject] interface BluetoothHealthApplication { readonly attribute unsigned short dataType; readonly attribute DOMString name; [TreatNonCallableAsNull] attribute BluetoothHealthChannelSuccessCallback? onconnect raises(WebAPIException); void unregister(optional SuccessCallback? successCallback, optional ErrorCallback? errorCallback) raises(WebAPIException); };
Since: 2.2
For example, pulse oximeter is 4100 and blood pressure monitor is 4103.
Since: 2.2
Since: 2.2
By default, this attribute is set to null.
Since: 2.2
Exceptions:
with error type TypeMismatchError, if an input attribute is not compatible with the expected type for this attribute.
unregister
void unregister(optional SuccessCallback? successCallback, optional ErrorCallback? errorCallback);
Since: 2.2
The ErrorCallback is launched with these error types:
Privilege level: public
Privilege: http://tizen.org/privilege/bluetooth.health
Parameters:
Exceptions:
with error type SecurityError, if the application does not have the privilege to call this method.
with error type TypeMismatchError, if any of the input parameter is not compatible with the expected type for that parameter.
Code example:
var adapter = tizen.bluetooth.getDefaultAdapter(); var healthProfileHandler = adapter.getBluetoothProfileHandler("HEALTH"); var healthApp = null; function healthRegisterSuccess(app) { 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); }; function startSink() { try { healthProfileHandler.registerSinkApplication(4100, "testSinkApp", healthRegisterSuccess, healthRegisterError); } catch(e) { console.log("Error: " + e.message); } } function stopSink() { try { if (healthApp != null) { 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); } }
[NoInterfaceObject] interface BluetoothHealthChannel { readonly attribute BluetoothDevice peer; readonly attribute BluetoothHealthChannelType channelType; readonly attribute BluetoothHealthApplication application; readonly attribute boolean isConnected; void close() raises(WebAPIException); unsigned long sendData(byte[] data) raises(WebAPIException); void setListener(BluetoothHealthChannelChangeCallback listener) raises(WebAPIException); void unsetListener() raises(WebAPIException); };
Since: 2.2
Since: 2.2
Since: 2.2
Since: 2.2
Since: 2.2
close
void close();
Since: 2.2
Privilege level: public
Privilege: http://tizen.org/privilege/bluetooth.health
Exceptions:
with error type SecurityError, if the application does not have the privilege to call this method.
with error type ServiceNotAvailableError, if a Bluetooth device is turned off.
with error type UnknownError, if any other error occurs.
Code example:
var adapter = tizen.bluetooth.getDefaultAdapter(); 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(); } } function healthRegisterError(e) { console.log("Failed to register application: " + e.message); }; healthProfileHandler.registerSinkApplication(4100, "testSinkApp", healthRegisterSuccess, healthRegisterError);
sendData
unsigned long sendData(byte[] data);
Since: 2.2
Privilege level: public
Privilege: http://tizen.org/privilege/bluetooth.health
Parameters:
Return value:
unsigned long Number of bytes actually sentExceptions:
with error type SecurityError, if the application does not have the privilege to call this method.
with error type ServiceNotAvailableError, if a Bluetooth device is turned off.
with error type TypeMismatchError, if any of the input parameter is not compatible with the expected type for that parameter.
with error type UnknownError, if any other error occurs.
Code example:
var adapter = tizen.bluetooth.getDefaultAdapter(); 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.sendData(dataToSend); } } function healthRegisterError(e) { console.log("Failed to register application: " + e.message); }; healthProfileHandler.registerSinkApplication(4100, "testSinkApp", healthRegisterSuccess, healthRegisterError);
setListener
void setListener(BluetoothHealthChannelChangeCallback listener);
Since: 2.2
Privilege level: public
Privilege: http://tizen.org/privilege/bluetooth.health
Parameters:
Exceptions:
with error type TypeMismatchError, if the input parameter is not compatible with the expected type.
with error type SecurityError, if the application does not have the privilege to call this method.
with error type UnknownError, if any other error occurs.
Code example:
var adapter = tizen.bluetooth.getDefaultAdapter(); var healthProfileHandler = adapter.getBluetoothProfileHandler("HEALTH"); var channelCallback = { 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); } } function healthRegisterError(e) { console.log("Failed to register application: " + e.message); }; healthProfileHandler.registerSinkApplication(4100, "testSinkApp", healthRegisterSuccess, healthRegisterError);
unsetListener
void unsetListener();
Since: 2.2
Privilege level: public
Privilege: http://tizen.org/privilege/bluetooth.health
Exceptions:
with error type SecurityError, if the application does not have the privilege to call this method.
with error type UnknownError, if any other error occurs.
Code example:
var adapter = tizen.bluetooth.getDefaultAdapter(); var healthProfileHandler = adapter.getBluetoothProfileHandler("HEALTH"); var connectedChannel = null; var channelCallback = { 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); } } function healthRegisterError(e) { console.log("Failed to register application: " + e.message); }; healthProfileHandler.registerSinkApplication(4100, "testSinkApp", healthRegisterSuccess, healthRegisterError);
[Callback, NoInterfaceObject] interface BluetoothAdapterChangeCallback { void onstatechanged(boolean powered); void onnamechanged(DOMString name); void onvisibilitychanged(boolean visible); };
Since: 2.2
onstatechanged
void onstatechanged(boolean powered);
Since: 2.2
Parameters:
onnamechanged
void onnamechanged(DOMString name);
Since: 2.2
Parameters:
onvisibilitychanged
void onvisibilitychanged(boolean visible);
Since: 2.2
Parameters:
[Callback=FunctionOnly, NoInterfaceObject] interface BluetoothDeviceSuccessCallback { void onsuccess(BluetoothDevice device); };
Since: 1.0
onsuccess
void onsuccess(BluetoothDevice device);
Since: 1.0
Parameters:
[Callback=FunctionOnly, NoInterfaceObject] interface BluetoothDeviceArraySuccessCallback { void onsuccess(BluetoothDevice[] devices); };
Since: 1.0
onsuccess
void onsuccess(BluetoothDevice[] devices);
Since: 1.0
Parameters:
[Callback, NoInterfaceObject] interface BluetoothDiscoverDevicesSuccessCallback { void onstarted(); void ondevicefound(BluetoothDevice device); void ondevicedisappeared(BluetoothAddress address); void onfinished(BluetoothDevice[] foundDevices); };
Since: 1.0
onstarted
void onstarted();
Since: 1.0
ondevicefound
void ondevicefound(BluetoothDevice device);
Since: 1.0
Parameters:
ondevicedisappeared
void ondevicedisappeared(BluetoothAddress address);
Since: 1.0
Parameters:
onfinished
void onfinished(BluetoothDevice[] foundDevices);
Since: 1.0
Parameters:
[Callback=FunctionOnly, NoInterfaceObject] interface BluetoothSocketSuccessCallback { void onsuccess(BluetoothSocket socket); };
Since: 1.0
onsuccess
void onsuccess(BluetoothSocket socket);
Since: 1.0
Parameters:
[Callback=FunctionOnly, NoInterfaceObject] interface BluetoothServiceSuccessCallback { void onsuccess(BluetoothServiceHandler handler); };
Since: 1.0
onsuccess
void onsuccess(BluetoothServiceHandler handler);
Since: 1.0
Parameters:
[Callback=FunctionOnly, NoInterfaceObject] interface BluetoothHealthApplicationSuccessCallback { void onsuccess(BluetoothHealthApplication application); };
Since: 2.2
onsuccess
void onsuccess(BluetoothHealthApplication application);
Since: 2.2
Parameters:
[Callback=FunctionOnly, NoInterfaceObject] interface BluetoothHealthChannelSuccessCallback { void onsuccess(BluetoothHealthChannel channel); };
Since: 2.2
onsuccess
void onsuccess(BluetoothHealthChannel channel);
Since: 2.2
Parameters:
[Callback, NoInterfaceObject] interface BluetoothHealthChannelChangeCallback { void onmessage(byte[] data); void onclose(); };
Since: 2.2
To guarantee that the Bluetooth application runs on a device with Bluetooth feature, declare the following feature requirements in the config file:
To guarantee that the Bluetooth healthcare application runs on a device with Bluetooth health profile feature, declare the following feature requirements in the config file:
To guarantee that the Bluetooth Low Energy application runs on a device with Bluetooth Low Energy feature, declare the following feature requirements in the config file:
module Bluetooth { typedef DOMString BluetoothAddress; typedef DOMString BluetoothUUID; enum BluetoothSocketState { "CLOSED", "OPEN" }; enum BluetoothProfileType { "HEALTH" }; enum BluetoothHealthChannelType { "RELIABLE", "STREAMING" }; typedef DOMString BluetoothLESolicitationUUID; enum BluetoothAdvertisePacketType { "ADVERTISE", "SCAN_RESPONSE" }; enum BluetoothAdvertisingState { "STARTED", "STOPPED" }; enum BluetoothAdvertisingMode { "BALANCED", "LOW_LATENCY", "LOW_ENERGY" }; [NoInterfaceObject] interface BluetoothManagerObject { readonly attribute BluetoothManager bluetooth; }; Tizen implements BluetoothManagerObject; [Constructor(DOMString uuid, DOMString data)] interface BluetoothLEServiceData { attribute BluetoothUUID uuid; attribute DOMString data; }; [Constructor(DOMString id, DOMString data)] interface BluetoothLEManufacturerData { attribute DOMString id; attribute DOMString data; }; dictionary BluetoothLEAdvertiseDataInit { boolean? includeName; BluetoothUUID[]? uuids; BluetoothLESolicitationUUID[]? solicitationuuids; unsigned long? appearance; boolean? includeTxPowerLevel; BluetoothLEServiceData? serviceData; BluetoothLEManufacturerData? manufacturerData; }; [Constructor(optional BluetoothLEAdvertiseDataInit? init)] interface BluetoothLEAdvertiseData { attribute boolean? includeName; attribute BluetoothUUID[]? uuids; attribute BluetoothLESolicitationUUID[]? solicitationuuids; attribute unsigned long? appearance; attribute boolean? includeTxPowerLevel; attribute BluetoothLEServiceData? serviceData; attribute BluetoothLEManufacturerData? manufacturerData; }; [NoInterfaceObject] interface BluetoothManager { readonly attribute BluetoothClassDeviceMajor deviceMajor; readonly attribute BluetoothClassDeviceMinor deviceMinor; readonly attribute BluetoothClassDeviceService deviceService; BluetoothAdapter getDefaultAdapter() raises(WebAPIException); BluetoothLEAdapter getLEAdapter() raises(WebAPIException); }; [NoInterfaceObject] interface BluetoothAdapter { readonly attribute DOMString name; readonly attribute BluetoothAddress address; readonly attribute boolean powered; readonly attribute boolean visible; void setName(DOMString name, optional SuccessCallback? successCallback, optional ErrorCallback? errorCallback) raises(WebAPIException); void setPowered(boolean state, optional SuccessCallback? successCallback, optional ErrorCallback? errorCallback) raises(WebAPIException); void setVisible(boolean mode, optional SuccessCallback? successCallback, optional ErrorCallback? errorCallback, optional unsigned short? timeout) raises(WebAPIException); void setChangeListener(BluetoothAdapterChangeCallback listener) raises(WebAPIException); void unsetChangeListener() raises(WebAPIException); void discoverDevices(BluetoothDiscoverDevicesSuccessCallback successCallback, optional ErrorCallback? errorCallback) raises(WebAPIException); void stopDiscovery(optional SuccessCallback? successCallback, optional ErrorCallback? errorCallback) raises(WebAPIException); void getKnownDevices(BluetoothDeviceArraySuccessCallback successCallback, optional ErrorCallback? errorCallback) raises(WebAPIException); void getDevice(BluetoothAddress address, BluetoothDeviceSuccessCallback successCallback, optional ErrorCallback? errorCallback) raises(WebAPIException); void createBonding(BluetoothAddress address, BluetoothDeviceSuccessCallback successCallback, optional ErrorCallback? errorCallback) raises(WebAPIException); void destroyBonding(BluetoothAddress address, optional SuccessCallback? successCallback, optional ErrorCallback? errorCallback) raises(WebAPIException); void registerRFCOMMServiceByUUID(BluetoothUUID uuid, DOMString name, BluetoothServiceSuccessCallback successCallback, optional ErrorCallback? errorCallback) raises(WebAPIException); BluetoothProfileHandler getBluetoothProfileHandler(BluetoothProfileType profileType) raises(WebAPIException); }; [NoInterfaceObject] interface BluetoothLEAdapter { void startScan(BluetoothLEScanCallback successCallback, optional ErrorCallback? errorCallback) raises(WebAPIException); void stopScan() raises(WebAPIException); void startAdvertise(BluetoothLEAdvertiseData advertiseData, BluetoothAdvertisePacketType packetType, BluetoothLEAdvertiseCallback successCallback, optional ErrorCallback? errorCallback, optional BluetoothAdvertisingMode? mode, optional boolean? connectable) raises(WebAPIException); void stopAdvertise() raises(WebAPIException); }; [NoInterfaceObject] interface BluetoothGATTService { readonly attribute BluetoothUUID uuid; readonly attribute BluetoothGATTService[] services; readonly attribute BluetoothGATTCharacteristic[] characteristics; }; [NoInterfaceObject] interface BluetoothGATTCharacteristic { readonly attribute BluetoothGATTDescriptor[] descriptors; readonly attribute boolean isBroadcast; readonly attribute boolean hasExtendedProperties; readonly attribute boolean isNotify; readonly attribute boolean isIndication; readonly attribute boolean isReadable; readonly attribute boolean isSignedWrite; readonly attribute boolean isWritable; readonly attribute boolean isWriteNoResponse; void readValue(ReadValueSuccessCallback successCallback, optional ErrorCallback? errorCallback) raises(WebAPIException); void writeValue(byte[] value, optional SuccessCallback? successCallback, optional ErrorCallback? errorCallback) raises(WebAPIException); long addValueChangeListener(ReadValueSuccessCallback callback) raises(WebAPIException); void removeValueChangeListener(long watchID); }; [NoInterfaceObject] interface BluetoothGATTDescriptor { void readValue(ReadValueSuccessCallback successCallback, optional ErrorCallback? errorCallback) raises(WebAPIException); void writeValue(byte[] value, optional SuccessCallback? successCallback, optional ErrorCallback? errorCallback) raises(WebAPIException); }; [Callback=FunctionOnly, NoInterfaceObject] interface BluetoothLEScanCallback { void onsuccess(BluetoothLEDevice device); }; [Callback=FunctionOnly, NoInterfaceObject] interface BluetoothLEAdvertiseCallback { void onstate(BluetoothAdvertisingState state); }; [Callback, NoInterfaceObject] interface BluetoothLEConnectChangeCallback { void onconnected(BluetoothLEDevice device); void ondisconnected(BluetoothLEDevice device); }; [Callback=FunctionOnly, NoInterfaceObject] interface ReadValueSuccessCallback { void onread(byte[] value); }; [NoInterfaceObject] interface BluetoothDevice { readonly attribute DOMString name; readonly attribute BluetoothAddress address; readonly attribute BluetoothClass deviceClass; readonly attribute boolean isBonded; readonly attribute boolean isTrusted; readonly attribute boolean isConnected; readonly attribute BluetoothUUID[] uuids; void connectToServiceByUUID(BluetoothUUID uuid, BluetoothSocketSuccessCallback successCallback, optional ErrorCallback? errorCallback) raises(WebAPIException); }; [NoInterfaceObject] interface BluetoothLEDevice { readonly attribute BluetoothAddress address; readonly attribute DOMString? name; readonly attribute unsigned long? txpowerlevel; readonly attribute unsigned long? appearance; readonly attribute BluetoothUUID[]? uuids; readonly attribute BluetoothLESolicitationUUID[]? solicitationuuids; readonly attribute BluetoothLEServiceData[]? serviceData; readonly attribute BluetoothLEManufacturerData? manufacturerData; void connect(optional SuccessCallback? successCallback, optional ErrorCallback? errorCallback) raises(WebAPIException); void disconnect(optional SuccessCallback? successCallback, optional ErrorCallback? errorCallback) raises(WebAPIException); BluetoothGATTService getService(BluetoothUUID uuid) raises(WebAPIException); long addConnectStateChangeListener(BluetoothLEConnectChangeCallback listener) raises(WebAPIException); void removeConnectStateChangeListener(long watchID); }; [NoInterfaceObject] interface BluetoothSocket { readonly attribute BluetoothUUID uuid; readonly attribute BluetoothSocketState state; readonly attribute BluetoothDevice peer; [TreatNonCallableAsNull] attribute SuccessCallback? onmessage raises(WebAPIException); [TreatNonCallableAsNull] attribute SuccessCallback? onclose raises(WebAPIException); unsigned long writeData(byte[] data) raises(WebAPIException); byte[] readData() raises(WebAPIException); void close() raises(WebAPIException); }; [NoInterfaceObject] interface BluetoothClass { readonly attribute octet major; readonly attribute octet minor; readonly attribute unsigned short [] services ; boolean hasService(unsigned short service) raises(WebAPIException); }; [NoInterfaceObject] interface BluetoothClassDeviceMajor { const octet MISC = 0x00; const octet COMPUTER = 0x01; const octet PHONE = 0x02; const octet NETWORK = 0x03; const octet AUDIO_VIDEO = 0x04; const octet PERIPHERAL = 0x05; const octet IMAGING = 0x06; const octet WEARABLE = 0x07; const octet TOY = 0x08; const octet HEALTH = 0x09; const octet UNCATEGORIZED = 0x1F; }; [NoInterfaceObject] interface BluetoothClassDeviceMinor { const octet COMPUTER_UNCATEGORIZED = 0x00; const octet COMPUTER_DESKTOP = 0x01; const octet COMPUTER_SERVER = 0x02; const octet COMPUTER_LAPTOP = 0x03; const octet COMPUTER_HANDHELD_PC_OR_PDA = 0x04; const octet COMPUTER_PALM_PC_OR_PDA = 0x05; const octet COMPUTER_WEARABLE = 0x06; const octet PHONE_UNCATEGORIZED = 0x00; const octet PHONE_CELLULAR = 0x01; const octet PHONE_CORDLESS = 0x02; const octet PHONE_SMARTPHONE = 0x03; const octet PHONE_MODEM_OR_GATEWAY = 0x04; const octet PHONE_ISDN = 0x05; const octet AV_UNRECOGNIZED = 0x00; const octet AV_WEARABLE_HEADSET = 0x01; const octet AV_HANDSFREE = 0x02; const octet AV_MICROPHONE = 0x04; const octet AV_LOUDSPEAKER = 0x05; const octet AV_HEADPHONES = 0x06; const octet AV_PORTABLE_AUDIO = 0x07; const octet AV_CAR_AUDIO = 0x08; const octet AV_SETTOP_BOX = 0x09; const octet AV_HIFI = 0x0a; const octet AV_VCR = 0x0b; const octet AV_VIDEO_CAMERA = 0x0c; const octet AV_CAMCORDER = 0x0d; const octet AV_MONITOR = 0x0e; const octet AV_DISPLAY_AND_LOUDSPEAKER = 0x0f; const octet AV_VIDEO_CONFERENCING = 0x10; const octet AV_GAMING_TOY = 0x12; const octet PERIPHERAL_UNCATEGORIZED = 0; const octet PERIPHERAL_KEYBOARD = 0x10; const octet PERIPHERAL_POINTING_DEVICE = 0x20; const octet PERIPHERAL_KEYBOARD_AND_POINTING_DEVICE = 0x30; const octet PERIPHERAL_JOYSTICK = 0x01; const octet PERIPHERAL_GAMEPAD = 0x02; const octet PERIPHERAL_REMOTE_CONTROL = 0x03; const octet PERIPHERAL_SENSING_DEVICE = 0x04; const octet PERIPHERAL_DEGITIZER_TABLET = 0x05; const octet PERIPHERAL_CARD_READER = 0x06; const octet PERIPHERAL_DIGITAL_PEN = 0x07; const octet PERIPHERAL_HANDHELD_SCANNER = 0x08; const octet PERIPHERAL_HANDHELD_INPUT_DEVICE = 0x09; const octet IMAGING_UNCATEGORIZED = 0x00; const octet IMAGING_DISPLAY = 0x04; const octet IMAGING_CAMERA = 0x08; const octet IMAGING_SCANNER = 0x10; const octet IMAGING_PRINTER = 0x20; const octet WEARABLE_WRITST_WATCH = 0x01; const octet WEARABLE_PAGER = 0x02; const octet WEARABLE_JACKET = 0x03; const octet WEARABLE_HELMET = 0x04; const octet WEARABLE_GLASSES = 0x05; const octet TOY_ROBOT = 0x01; const octet TOY_VEHICLE = 0x02; const octet TOY_DOLL = 0x03; const octet TOY_CONTROLLER = 0x04; const octet TOY_GAME = 0x05; const octet HEALTH_UNDEFINED = 0x00; const octet HEALTH_BLOOD_PRESSURE_MONITOR = 0x01; const octet HEALTH_THERMOMETER = 0x02; const octet HEALTH_WEIGHING_SCALE = 0x03; const octet HEALTH_GLUCOSE_METER = 0x04; const octet HEALTH_PULSE_OXIMETER = 0x05; const octet HEALTH_PULSE_RATE_MONITOR = 0x06; const octet HEALTH_DATA_DISPLAY = 0x07; const octet HEALTH_STEP_COUNTER = 0x08; const octet HEALTH_BODY_COMPOSITION_ANALYZER = 0x09; const octet HEALTH_PEAK_FLOW_MONITOR = 0x0a; const octet HEALTH_MEDICATION_MONITOR = 0x0b; const octet HEALTH_KNEE_PROSTHESIS = 0x0c; const octet HEALTH_ANKLE_PROSTHESIS = 0x0d; }; [NoInterfaceObject] interface BluetoothClassDeviceService { const unsigned short LIMITED_DISCOVERABILITY = 0x0001; const unsigned short POSITIONING = 0x0008; const unsigned short NETWORKING = 0x0010; const unsigned short RENDERING = 0x0020; const unsigned short CAPTURING = 0x0040; const unsigned short OBJECT_TRANSFER = 0x0080; const unsigned short AUDIO = 0x0100; const unsigned short TELEPHONY = 0x0200; const unsigned short INFORMATION = 0x0400; }; [NoInterfaceObject] interface BluetoothServiceHandler { readonly attribute BluetoothUUID uuid; readonly attribute DOMString name; readonly attribute boolean isConnected; [TreatNonCallableAsNull] attribute BluetoothSocketSuccessCallback? onconnect raises(WebAPIException); void unregister(optional SuccessCallback? successCallback, optional ErrorCallback? errorCallback) raises(WebAPIException); }; [NoInterfaceObject] interface BluetoothProfileHandler { readonly attribute BluetoothProfileType profileType; }; [NoInterfaceObject] interface BluetoothHealthProfileHandler : BluetoothProfileHandler { void registerSinkApplication(unsigned short dataType, DOMString name, BluetoothHealthApplicationSuccessCallback successCallback, optional ErrorCallback? errorCallback) raises(WebAPIException); void connectToSource(BluetoothDevice peer, BluetoothHealthApplication application, BluetoothHealthChannelSuccessCallback successCallback, optional ErrorCallback? errorCallback) raises(WebAPIException); }; [NoInterfaceObject] interface BluetoothHealthApplication { readonly attribute unsigned short dataType; readonly attribute DOMString name; [TreatNonCallableAsNull] attribute BluetoothHealthChannelSuccessCallback? onconnect raises(WebAPIException); void unregister(optional SuccessCallback? successCallback, optional ErrorCallback? errorCallback) raises(WebAPIException); }; [NoInterfaceObject] interface BluetoothHealthChannel { readonly attribute BluetoothDevice peer; readonly attribute BluetoothHealthChannelType channelType; readonly attribute BluetoothHealthApplication application; readonly attribute boolean isConnected; void close() raises(WebAPIException); unsigned long sendData(byte[] data) raises(WebAPIException); void setListener(BluetoothHealthChannelChangeCallback listener) raises(WebAPIException); void unsetListener() raises(WebAPIException); }; [Callback, NoInterfaceObject] interface BluetoothAdapterChangeCallback { void onstatechanged(boolean powered); void onnamechanged(DOMString name); void onvisibilitychanged(boolean visible); }; [Callback=FunctionOnly, NoInterfaceObject] interface BluetoothDeviceSuccessCallback { void onsuccess(BluetoothDevice device); }; [Callback=FunctionOnly, NoInterfaceObject] interface BluetoothDeviceArraySuccessCallback { void onsuccess(BluetoothDevice[] devices); }; [Callback, NoInterfaceObject] interface BluetoothDiscoverDevicesSuccessCallback { void onstarted(); void ondevicefound(BluetoothDevice device); void ondevicedisappeared(BluetoothAddress address); void onfinished(BluetoothDevice[] foundDevices); }; [Callback=FunctionOnly, NoInterfaceObject] interface BluetoothSocketSuccessCallback { void onsuccess(BluetoothSocket socket); }; [Callback=FunctionOnly, NoInterfaceObject] interface BluetoothServiceSuccessCallback { void onsuccess(BluetoothServiceHandler handler); }; [Callback=FunctionOnly, NoInterfaceObject] interface BluetoothHealthApplicationSuccessCallback { void onsuccess(BluetoothHealthApplication application); }; [Callback=FunctionOnly, NoInterfaceObject] interface BluetoothHealthChannelSuccessCallback { void onsuccess(BluetoothHealthChannel channel); }; [Callback, NoInterfaceObject] interface BluetoothHealthChannelChangeCallback { void onmessage(byte[] data); void onclose(); }; };