diff --git a/docs/application/web/api/6.0/device_api/mobile/tizen/bluetooth.html b/docs/application/web/api/6.0/device_api/mobile/tizen/bluetooth.html index bdb05ddf4f..5daa2005d1 100644 --- a/docs/application/web/api/6.0/device_api/mobile/tizen/bluetooth.html +++ b/docs/application/web/api/6.0/device_api/mobile/tizen/bluetooth.html @@ -32,6 +32,8 @@ Advertise for remote devices (including Bluetooth LE devices)
For more information on the Bluetooth features, see Bluetooth Guide. @@ -73,6 +75,15 @@
typedef (BluetoothGATTService or BluetoothGATTServerService) BluetoothGATTServiceVariant;+
Since: + 6.0 +
+typedef (BluetoothGATTCharacteristic or BluetoothGATTServerCharacteristic) BluetoothGATTCharacteristicVariant;+
Since: + 6.0 +
+typedef (BluetoothGATTDescriptor or BluetoothGATTServerDescriptor) BluetoothGATTDescriptorVariant;+
Since: + 6.0 +
+Since: @@ -740,8 +882,9 @@
Since: 2.3.1 @@ -876,16 +1019,39 @@
Since: + 6.0 +
+Remark: + Only 16-bit BluetoothLEServiceData::uuid values can be advertised. Duplicated uuid values in servicesData are not allowed for advertising. +
+Remark: + If this attribute is in neither null nor undefined, the value of deprecated BluetoothLEAdvertiseData::serviceData attribute is ignored. +
+Code example:
var advertise = new tizen.BluetoothLEAdvertiseData();
+
+var firstService = new tizen.BluetoothLEServiceData("11e5", "0x1811");
+var secondService = new tizen.BluetoothLEServiceData("a5e8", "0x1815");
+advertise.servicesData = [firstService, secondService];
+
+Deprecated. + Deprecated since 6.0. Instead, use BluetoothLEAdvertiseData::servicesData. +
Since: 2.3.1
-Remark: - Only 16-bit BluetoothLEServiceData::uuid values can be advertised. -
Code example:
var advertise = new tizen.BluetoothLEAdvertiseData();
var service = new tizen.BluetoothLEServiceData("11e5", "0x1811");
@@ -922,6 +1088,7 @@ Attributes
readonly attribute BluetoothClassDeviceService deviceService;
BluetoothAdapter getDefaultAdapter() raises(WebAPIException);
BluetoothLEAdapter getLEAdapter() raises(WebAPIException);
+ BluetoothGATTServer getGATTServer() raises(WebAPIException);
byte[] toByteArray(Bytes data) raises(WebAPIException);
DOMString toDOMString(Bytes data) raises(WebAPIException);
Uint8Array toUint8Array(Bytes data) raises(WebAPIException);
@@ -1093,6 +1260,50 @@ Methods
getGATTServer
+BluetoothGATTServer getGATTServer();
Since: + 6.0 +
+Privilege level: + public +
+Privilege: + http://tizen.org/privilege/bluetooth +
+Return value:
+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 AbortError, if any other error occurs. +
Code example:
var server = tizen.bluetooth.getGATTServer(); ++
toByteArray
Code example:
var dataInt8Array = new Int8Array([-21, 31]);
var dataUint8Array = new Uint8Array([240, 129]);
var dataString = "0x18b1";
-console.log("converted from Int8Array: " + tizen.bluetooth.toByteArray(dataInt8Array));
-console.log("converted from Uint8Array: " + tizen.bluetooth.toByteArray(dataUint8Array));
-console.log("converted from DOMString: " + tizen.bluetooth.toByteArray(dataString));
+
+var fromInt8Array = tizen.bluetooth.toByteArray(dataInt8Array);
+var fromUint8Array = tizen.bluetooth.toByteArray(dataUint8Array);
+var fromString = tizen.bluetooth.toByteArray(dataString);
+
+console.log("converted from Int8Array: " + JSON.stringify(fromInt8Array));
+console.log("converted from Uint8Array: " + JSON.stringify(fromUint8Array));
+console.log("converted from DOMString: " + JSON.stringify(fromString));
Output example:
converted from Int8Array: Int8Array(2) [-21, 31] -converted from Uint8Array: Int8Array(2) [-16, -127] -converted from DOMString: Int8Array(2) [24, -79] +Output example:
converted from Int8Array: [235, 31] +converted from Uint8Array: [240, 129] +converted from DOMString: [244, 177]
Code example:
var dataInt8Array = new Int8Array([-21, 31]);
var dataUint8Array = new Uint8Array([240, 129]);
var dataString = "0x18b1";
-console.log("converted from Int8Array: " + tizen.bluetooth.toUint8Array(dataInt8Array));
-console.log("converted from Uint8Array: " + tizen.bluetooth.toUint8Array(dataUint8Array));
-console.log("converted from DOMString: " + tizen.bluetooth.toUint8Array(dataString));
+
+var fromInt8Array = tizen.bluetooth.toUint8Array(dataInt8Array);
+var fromUint8Array = tizen.bluetooth.toUint8Array(dataUint8Array);
+var fromString = tizen.bluetooth.toUint8Array(dataString);
+
+console.log("converted from Int8Array: " + JSON.stringify(fromInt8Array));
+console.log("converted from Uint8Array: " + JSON.stringify(fromUint8Array));
+console.log("converted from DOMString: " + JSON.stringify(fromString));
Output example:
converted from Int8Array: Uint8Array(2) [235, 31] -converted from Uint8Array: Uint8Array(2) [240, 129] -converted from DOMString: Uint8Array(2) [24, 177] +Output example:
converted from Int8Array: {"0":235, "1":31} +converted from Uint8Array: {"0":240, "1":129} +converted from DOMString: {"0":24, "1":177}
Code example:
tizen.bluetooth.uuidTo128bit("1234");
-tizen.bluetooth.uuidTo128bit("ab5690ef");
-tizen.bluetooth.uuidTo128bit("abcdef01-2345-6789-abcd-ef0123456789");
+Code example:
var uuidFrom16bits = tizen.bluetooth.uuidTo128bit("1234");
+var uuidFrom32bits = tizen.bluetooth.uuidTo128bit("ab5690ef");
+var uuidFrom128bits = tizen.bluetooth.uuidTo128bit("abcdef01-2345-6789-abcd-ef0123456789");
+
+console.log(uuidFrom16bits);
+console.log(uuidFrom32bits);
+console.log(uuidFrom128bits);
[NoInterfaceObject] interface BluetoothLEAdapter {
void startScan(BluetoothLEScanCallback successCallback, optional ErrorCallback? errorCallback) raises(WebAPIException);
void stopScan() raises(WebAPIException);
+ boolean isScanning() 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);
+ long addConnectStateChangeListener(BluetoothLEConnectChangeCallback listener) raises(WebAPIException);
+ void removeConnectStateChangeListener(long watchID);
};
Since: 2.3.1 @@ -2802,6 +3030,56 @@
isScanning
+boolean isScanning();
Since: + 6.0 +
+Return value:
+Exceptions:
++ with error type NotSupportedError, if the device does not support this functionality. +
+ with error type UnknownError, if any other error occurs. +
Code example:
var adapter = tizen.bluetooth.getLEAdapter();
+var scanningStarted = adapter.isScanning();
+console.log("Scanning status: " + scanningStarted);
+if (!scanningStarted)
+{
+ adapter.startScan(function onsuccess(device)
+ {
+ console.log("Scanning status: " + adapter.isScanning());
+ adapter.stopScan();
+ });
+}
+
+Output example:
Scanning status: false +Scanning status: true ++
startAdvertise
with error type QuotaExceededError, if any input attribute is not compatible with the maximum data size for this attribute.
+ with error type InvalidValuesError, if advertising services data contains duplicated UUIDs. +
with error type InvalidStateError, if device is currently in progress of advertising, if the local Bluetooth le adapter is currently not enabled.
addConnectStateChangeListener
+ [NoInterfaceObject] interface BluetoothGATTService {
- readonly attribute BluetoothUUID uuid;
- readonly attribute BluetoothUUID? serviceUuid;
- readonly attribute BluetoothGATTService[] services;
- readonly attribute BluetoothGATTCharacteristic[] characteristics;
- };
+ Registers a listener that is called whenever a GATT connection with another device is established or terminated.
+ long addConnectStateChangeListener(BluetoothLEConnectChangeCallback listener);
Since: - 2.3.1 -
+ 6.0 + ++The BluetoothLEConnectChangeCallback, registered with this function, is called in the following cases: +
+Parameters:
+Return value:
+Exceptions:
++ with error type TypeMismatchError, if the input parameter is not compatible with the expected type for that parameter. +
Code example:
function onconnected(device) +Code example:
/* This application is running the local GATT Server and does not connect to remote GATT servers. */ +/* To be able to notify connected clients about characteristic values' changes, it saves their data. */ +var connectedClients = []; + +function onConnected(device) { - console.log("Connected to device"); - var service = device.getService(device.uuids[0]); - console.log("Service got"); + console.log("A client connected: " + device.address); + connectedClients.push(device); } -var adapter = tizen.bluetooth.getLEAdapter(); -adapter.startScan(function onsuccess(device) +function onDisconnected(device) { - console.log("[Found device] address: " + device.address); - device.connect(onconnected.bind(null, device), onerror); -}); + console.log("A client disconnected: " + device.address); + connectedClients = connectedClients.filter(function(connectedClient) + { + return connectedClient.address !== device.address; + }); +} + +tizen.bluetooth.getLEAdapter().addConnectStateChangeListener( + {onconnected: onConnected, ondisconnected: onDisconnected});
Output example:
A client connected: 6A:33:B1:17:D4:81 +A client connected: 4B:1F:DD:35:41:19 +A client connected: CC:D4:11:E5:72:4B +A client disconnected: 6A:33:B1:17:D4:81 ++
removeConnectStateChangeListener
+Deprecated. - Deprecated since 6.0. Instead, use BluetoothGATTService::serviceUuid. -
+void removeConnectStateChangeListener(long watchID);
Since: - 2.3.1 + 6.0 +
++This function unregisters a BluetoothLEConnectChangeCallback registered with BluetoothLEAdapter.addConnectStateChangeListener() method. +
+Parameters:
+Code example:
/* This application is running the local GATT Server and does not connect to remote GATT servers. */
+function onConnected(device)
+{
+ console.log("A client connected: " + device.address);
+}
+
+function onDisconnected(device)
+{
+ console.log("A client disconnected: " + device.address);
+}
+
+/* Save watchId to be able to remove the listener later */
+var watchId = tizen.bluetooth.getLEAdapter().addConnectStateChangeListener(
+ {onconnected: onConnected, ondisconnected: onDisconnected});
+
+/* A little later, the listener is no longer needed, and can be removed with */
+/* removeConnectStateChangeListener(watchId) method */
+
+Output example:
A client connected: 6A:33:B1:17:D4:81 +A client connected: 4B:1F:DD:35:41:19 +A client connected: CC:D4:11:E5:72:4B +A client disconnected: 6A:33:B1:17:D4:81 ++
[NoInterfaceObject] interface BluetoothGATTService {
+ readonly attribute BluetoothUUID uuid;
+ readonly attribute BluetoothUUID? serviceUuid;
+ readonly attribute BluetoothGATTServiceVariant[] services;
+ readonly attribute BluetoothGATTCharacteristicVariant[] characteristics;
+ };
+Since: + 2.3.1 +
+Code example:
function onconnected(device)
+{
+ console.log("Connected to device");
+ var service = device.getService(device.uuids[0]);
+ console.log("Service got");
+}
+
+var adapter = tizen.bluetooth.getLEAdapter();
+adapter.startScan(function onsuccess(device)
+{
+ console.log("[Found device] address: " + device.address);
+ device.connect(onconnected.bind(null, device), onerror);
+});
+
+Deprecated. + Deprecated since 6.0. Instead, use BluetoothGATTService::serviceUuid. +
+Since: + 2.3.1
Remark: uuid is set to "0xFFFF", if the value cannot be retrieved. @@ -3063,13 +3474,16 @@
Since: 2.3.1
+Remark: + It can be either type BluetoothGATTService for services retrieved from remote GATT servers or type BluetoothGATTServerService for services retrieved from the local GATT server. +
Code example:
var service = device.getService(device.uuids[0]); for (var i = 0; i < service.services.length; ++i) @@ -3081,13 +3495,16 @@Attributes
Since: 2.3.1
+Remark: + It can be either type BluetoothGATTCha racteristic for characteristics retrieved from services of remote GATT servers or type BluetoothGATTServerCharacteristic for characteristics retrieved from services of local GATT server. +
Code example:
var service = device.getService(device.uuids[0]); for (var i = 0; i < service.characteristics.length; ++i) @@ -3100,13 +3517,154 @@Attributes
dictionary BluetoothGATTServerServiceInit {
+ BluetoothUUID serviceUuid;
+ boolean isPrimary = true;
+ BluetoothGATTServerServiceInit[]? includedServices = null;
+ BluetoothGATTServerCharacteristicInit[]? characteristics = null;
+ };
+Since: + 6.0 +
++This dictionary defines the GATT services to be registered to the local GATT server. +
+Code example:
/* serviceA and serviceB are objects of type BluetoothGATTServerServiceInit. */
+/* hrmCharacteristic is a BluetoothGATTServerCharacteristicInit object. */
+var serviceParameters =
+{
+ serviceUuid: "4b102e75",
+ isPrimary: true,
+ includedServices: [serviceA, serviceB],
+ characteristics: [hrmCharacteristic]
+};
+
+[NoInterfaceObject] interface BluetoothGATTServerService : BluetoothGATTService { + readonly attribute boolean isPrimary; + void unregister(optional SuccessCallback? successCallback, optional ErrorCallback? errorCallback) raises(WebAPIException); + };+
Since: + 6.0 +
+ +Since: + 6.0 +
+unregister
+void unregister(optional SuccessCallback? successCallback, optional ErrorCallback? errorCallback);
Since: + 6.0 +
++The ErrorCallback is launched with these error types: +
+Privilege level: + public +
+Privilege: + http://tizen.org/privilege/bluetooth +
+Remark: + GATT services included in other GATT services cannot be unregistered. +
+Remark: + If this method is called for the only GATT service, currently registered in the local running GATT server, the server stops running. +
+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. +
+ with error type AbortError, if any other error occurs. +
Code example:
/* The service has been registered in the GATT server for a while. Now it is no longer needed. */
+function onsuccess()
+{
+ console.log("Service unregistered");
+}
+
+function onerror(error)
+{
+ console.log("Failed to unregister service: " + error.message);
+}
+
+tizen.bluetooth.getGATTServer().services[0].unregister(onsuccess, onerror);
+
+ [NoInterfaceObject] interface BluetoothGATTCharacteristic {
- readonly attribute BluetoothGATTDescriptor[] descriptors;
+ readonly attribute BluetoothGATTDescriptorVariant[] descriptors;
readonly attribute boolean isBroadcast;
readonly attribute boolean hasExtendedProperties;
readonly attribute boolean isNotify;
@@ -3130,13 +3688,16 @@ Attributes
Since: 2.3.1
+Remark: + The type of this field is BluetoothGATTDescriptor for descriptors of characteristics retrieved from services of remote GATT servers and BluetoothGATTServerDescriptor for descriptors of characteristics retrieved from the services of local GATT server. +
Privilege: http://tizen.org/privilege/bluetooth
+Remark: + BluetothGATTServerCharacteristic objects do not support this function. An attempt to call it for such an object will result in an exception. +
Parameters:
with error type SecurityError, if the application does not have the privilege to call this method.
+ with error type NotSupportedError, if the method is called for BluetoothGATTServerCharacteristic. +
Privilege: http://tizen.org/privilege/bluetooth
+Remark: + BluetothGATTServerCharacteristic objects do not support this function. An attempt to call it for such an object will result in an exception. +
Parameters:
with error type SecurityError, if the application does not have the privilege to call this method.
+ with error type NotSupportedError, if the method is called for BluetoothGATTServerCharacteristic. +
Privilege: http://tizen.org/privilege/bluetooth
+Remark: + BluetothGATTServerCharacteristic objects do not support this function. An attempt to call it for such an object will result in an exception. +
Parameters:
Exceptions:
-+
with error type SecurityError, if the application does not have the privilege to call this method. -
+ with error type NotSupportedError, if the method is called for BluetoothGATTServerCharacteristic. +
Remark: Example of using can be find at addValueChangeListener code example.
+Remark: + Value change listeners cannot be registered and thus unregistered for BluetothGATTServerCharacteristic objects. An attempt to remove value change listener for such an object will result in no operation. +
Parameters:
[NoInterfaceObject] interface BluetoothGATTDescriptor {
- readonly attribute BluetoothUUID? uuid;
- void readValue(ReadValueSuccessCallback successCallback, optional ErrorCallback? errorCallback) raises(WebAPIException);
- void writeValue(Bytes value, optional SuccessCallback? successCallback, optional ErrorCallback? errorCallback)
- raises(WebAPIException);
+ dictionary BluetoothGATTServerCharacteristicInit {
+ BluetoothUUID uuid;
+ BluetoothGATTServerDescriptorInit[]? descriptors = null;
+ boolean isBroadcast = false;
+ boolean hasExtendedProperties = false;
+ boolean isNotify = false;
+ boolean isIndication = false;
+ boolean isReadable = false;
+ boolean isSignedWrite = false;
+ boolean isWritable = false;
+ boolean isWriteNoResponse = false;
+ boolean readPermission = false;
+ boolean writePermission = false;
+ boolean encryptedReadPermission = false;
+ boolean encryptedWritePermission = false;
+ boolean encryptedSignedReadPermission = false;
+ boolean encryptedSignedWritePermission = false;
+ ReadValueRequestCallback? readValueRequestCallback = null;
+ SuccessCallback? readValueSendResponseSuccessCallback = null;
+ ErrorCallback? readValueSendResponseErrorCallback = null;
+ WriteValueRequestCallback? writeValueRequestCallback = null;
+ SuccessCallback? writeValueSendResponseSuccessCallback = null;
+ ErrorCallback? writeValueSendResponseErrorCallback = null;
};
Since:
- 2.3.1
+ 6.0
-
+
+
+This dictionary is used as a definition of a characteristic to be registered in a service of the local GATT server.
readValueRequestCallback and writeValueRequestCallback are callbacks called when a client reads or writes the value of the characteristic respectively. They can be set or replaced with another functions, after registering the service containing the characteristic, with BluetoothGATTServerCharacteristic.setReadValueRequestCallback() and BluetoothGATTServerCharacteristic.setWriteValueRequestCallback().
readValueSendResponseSuccessCallback and writeValueSendResponseSuccessCallback are success callbacks called when a response sent from readValueRequestCallback or writeValueRequestCallback reaches client. They can be set or replaced with another functions, after registering the service containing the characteristic, with BluetoothGATTServerCharacteristic.setReadValueRequestCallback() and BluetoothGATTServerCharacteristic.setWriteValueRequestCallback().
readValueSendResponseErrorCallback and writeValueSendResponseErrorCallback are error callbacks called when an attempt to send a response to a client from readValueRequestCallback or writeValueRequestCallback fails. They can be set or replaced with another functions, after registering the service containing the characteristic, with BluetoothGATTServerCharacteristic.setReadValueRequestCallback() and BluetoothGATTServerCharacteristic.setWriteValueRequestCallback().
+
+
+
+Code example:
/* nameDescriptor, placeDescriptor are BluetoothGATTServerDescriptorInit objects */
+/* readValueCallback, writeValueCallback are read/write request callbacks */
+/* readValueSendResponseSuccessCallback and writeValueSendResponseSuccessCallback */
+/* are success callbacks */
+/* and writeValueSendResponseErrorCallback and readValueSendResponseErrorCallback */
+/* are error callbacks */
+var characteristicParameters =
+{
+ uuid: "0180",
+ descriptors: [nameDescriptor, placeDescriptor],
+ /* Characteristic's properties */
+ isBroadcast: false,
+ hasExtendedProperties: false,
+ isNotify: false,
+ isIndication: false,
+ isReadable: true,
+ isSignedWrite: false,
+ isWritable: true,
+ isWriteNoResponse: false,
+ /* Characteristic's permissions */
+ readPermission: true,
+ writePermission: true,
+ encryptedReadPermission: false,
+ encryptedWritePermission: false,
+ encryptedSignedReadPermission: false,
+ encryptedSignedWritePermission: false,
+ readValueRequestCallback: readValueCallback,
+ readValueSendResponseSuccessCallback: readValueSendResponseSuccessCallback,
+ readValueSendResponseErrorCallback: readValueSendResponseErrorCallback,
+ writeValueRequestCallback: writeValueCallback,
+ writeValueSendResponseSuccessCallback: writeValueSendResponseSuccessCallback,
+ writeValueSendResponseErrorCallback: writeValueSendResponseErrorCallback
+};
+
+
+
+
+2.14. BluetoothGATTServerCharacteristic
+
+ A subclass representing GATT characteristic used to construct a service of the local Bluetooth GATT server.
+It extends BluetoothGATTCharacteristic with permissions and methods implementing interactions of the characteristic with remote clients.
+
+ [NoInterfaceObject] interface BluetoothGATTServerCharacteristic : BluetoothGATTCharacteristic {
+ readonly attribute boolean readPermission;
+ readonly attribute boolean writePermission;
+ readonly attribute boolean encryptedReadPermission;
+ readonly attribute boolean encryptedWritePermission;
+ readonly attribute boolean encryptedSignedReadPermission;
+ readonly attribute boolean encryptedSignedWritePermission;
+ void notifyAboutValueChange(Bytes value, BluetoothAddress? clientAddress, optional NotificationCallback? notificationCallback,
+ optional ErrorCallback? errorCallback) raises(WebAPIException);
+ void setReadValueRequestCallback(ReadValueRequestCallback readValueRequestCallback, optional SuccessCallback? successCallback,
+ optional ErrorCallback? errorCallback, optional SuccessCallback? sendResponseSuccessCallback,
+ optional ErrorCallback? sendResponseErrorCallback) raises(WebAPIException);
+ void setWriteValueRequestCallback(WriteValueRequestCallback writeValueRequestCallback, optional SuccessCallback? successCallback,
+ optional ErrorCallback? errorCallback, optional SuccessCallback? sendResponseSuccessCallback,
+ optional ErrorCallback? sendResponseErrorCallback) raises(WebAPIException);
+ };
+Since:
+ 6.0
+
+
+
Attributes
--
+
+-
readonly
-BluetoothUUID uuid [nullable]
- UUID of the descriptor.
+boolean readPermission
+ Indicates if clients have the permission to read the value of the characteristic.
Since:
6.0
-Remark:
- uuid is set to null, if the value cannot be retrieved.
-
-
-
-
-Methods
-
--
-
readValue
-
--
-
- Reads descriptor value from remote device. Updates descriptor value attribute.
+
+
-
+ readonly
+boolean writePermission
+ Indicates if clients have the permission to write the value of the characteristic.
-
void readValue(ReadValueSuccessCallback successCallback, optional ErrorCallback? errorCallback);
Since:
- 2.3.1
+ 6.0
-
-
-The ErrorCallback is launched with these error types:
+
+
-
+ readonly
+boolean encryptedReadPermission
+ Indicates if clients have the permission to read the value of the characteristic through encrypted connections.
+
+
Since:
+ 6.0
-
- -
+
+-
+ readonly
+boolean encryptedWritePermission
+ Indicates if clients have the permission to write the value of the characteristic through encrypted connections.
+
+
Since:
+ 6.0
+
+
+-
+ readonly
+boolean encryptedSignedReadPermission
+ Indicates if clients have the permission to perform signed reads of the characteristic's value.
+
+
Since:
+ 6.0
+
+
+-
+ readonly
+boolean encryptedSignedWritePermission
+ Indicates if clients have the permission to perform signed writes of the characteristic's value.
+
+
Since:
+ 6.0
+
+
+
+
+
+Methods
+
+-
+
notifyAboutValueChange
+
+-
+
+ Notifies the clients of the local GATT server of the changes in the characteristic.
+
+
void notifyAboutValueChange(Bytes value, BluetoothAddress? clientAddress, optional NotificationCallback? notificationCallback,
+ optional ErrorCallback? errorCallback);
+Since:
+ 6.0
+
+
+
+This function sends a BLE notification or indication about a change of characteristic's value to clients that registered for it. If a particular client is specified, only he gets the update.
+Otherwise it is sent to all clients connected to the local GATT server, who registered for the updates.
+
+Clients can only register for characteristic's notifications or indications, if the characteristic defines a Client Characteristic Configuration Descriptor (CCCD), as described in the Bluetooth standard.
+CCCD has to be defined as any other descriptor, using BluetoothGATTServerDescriptorInit.
+
+
+
+
+The ErrorCallback is launched with these error types:
+
+
+ -
+ InvalidValuesError - If any of the parameters is invalid.
+ -
+ NotSupportedError - If the feature is not supported.
+ -
+ AbortError - If any other error occurs.
+
+
+Privilege level:
+ public
+
+Privilege:
+ http://tizen.org/privilege/bluetooth
+
+Remark:
+ To notify the clients the service with current characteristic must be registered (see BluetoothGATTServer::registerService()) and available for clients (see BluetoothGATTServer::start()).
+
+
+Parameters:
+
+ -
+value:
+ The new value of the characteristic.
+
+ -
+clientAddress [nullable]:
+ The address of the client to be notified about the value change. If a null is passed, all clients will be notified.
+
+ -
+notificationCallback [optional] [nullable]:
+ The callback called for each attempt of a client notification.
+
+ -
+errorCallback [optional] [nullable]:
+ Callback function that is called in case of failure of sending notification.
+
+
+
+
+Exceptions:
+ - WebAPIException
+
+ 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:
/* this example assumes that the local gatt server with at least one service which has at least one */
+/* characteristic already exists */
+var callback =
+{
+ onnotificationsuccess: function(clientAddress)
+ {
+ console.log(clientAddress + " notified about change.");
+ },
+ onnotificationfail: function(clientAddress, error)
+ {
+ console.error("Couldn't notify " + clientAddress + " about change:" + error.name);
+ },
+ onnotificationfinish: function(clientAddress)
+ {
+ console.log("Finished notifying about change.");
+ }
+};
+
+function errorCallback(error)
+{
+ console.error("Failed to notify about value change: " + error.name + ": " + error.message);
+}
+
+server.services[0].characteristics[0].notifyAboutValueChange("1234", null, callback, errorCallback);
+
+
+
+-
+
setReadValueRequestCallback
+
+-
+
+ Registers the callback called when a client reads the value of the characteristic from the local GATT server.
+
+
void setReadValueRequestCallback(ReadValueRequestCallback readValueRequestCallback, optional SuccessCallback? successCallback,
+ optional ErrorCallback? errorCallback, optional SuccessCallback? sendResponseSuccessCallback,
+ optional ErrorCallback? sendResponseErrorCallback);
+Since:
+ 6.0
+
+
+
+The callback, registered with this function, is called when a remote client requests to read the value of the characteristic.
+The server can respond to such requests by returning a GATTRequestReply object from the callback.
+If ReadValueRequestCallback for the characteristic is not registered, or it does not return a GATTRequestReply, clients will not be able to get the value of this characteristic.
+
+A callback set with this function overwrites any previously set ReadValueRequestCallback.
+
+
+The errorCallback will be launched in the following situations:
+
+
+ -
+ NotSupportedError - If the feature is not supported.
+ -
+ AbortError - If any other error occurs.
+
+
+The sendResponseErrorCallback will be launched in the following situations:
+
+
+ -
+ NotSupportedError - If the feature is not supported.
+ -
+ InvalidValuesError - If GATTRequestReply::statusCode or GATTRequestReply::data is invalid.
+ -
+ AbortError - If any other error occurs.
+
+
+Privilege level:
+ public
+
+Privilege:
+ http://tizen.org/privilege/bluetooth
+
+
+Parameters:
+
+ -
+readValueRequestCallback:
+ The callback called when a client reads the value of the characteristic.
+
+ -
+successCallback [optional] [nullable]:
+ Callback function that is called when the readValueRequestCallback is registered successfully.
+
+ -
+errorCallback [optional] [nullable]:
+ Callback function that is called in case of failure of readValueRequestCallback registration.
+
+ -
+sendResponseSuccessCallback [optional] [nullable]:
+ Callback function that is called when responses returned from readValueRequestCallbacks are sent successfully.
+
+ -
+sendResponseErrorCallback [optional] [nullable]:
+ Callback function that is called when responses returned from readValueRequestCallbacks are not sent due to an error.
+
+
+
+
+Exceptions:
+ - WebAPIException
+
+ 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:
/* this example assumes that the local gatt server with at least one service which has at least one */
+/* characteristic already exists */
+var callback = function(clientAddress, offset)
+{
+ console.log(clientAddress + " requested to read characteristic's value with offset: " + offset);
+ return new tizen.GATTRequestReply(0, "0x1234");
+};
+
+server.services[0].characteristics[0].setReadValueRequestCallback(callback);
+
+
+
+-
+
setWriteValueRequestCallback
+
+-
+
+ Registers the callback called when a client writes the value of the characteristic of the local GATT server.
+
+
void setWriteValueRequestCallback(WriteValueRequestCallback writeValueRequestCallback, optional SuccessCallback? successCallback,
+ optional ErrorCallback? errorCallback, optional SuccessCallback? sendResponseSuccessCallback,
+ optional ErrorCallback? sendResponseErrorCallback);
+Since:
+ 6.0
+
+
+
+The callback, registered with this function, is called when a remote client requests to write the value of the characteristic.
+The server can respond to such requests by returning a GATTRequestReply object from the callback.
+If WriteValueRequestCallback for the characteristic is not registered, or it does not return a GATTRequestReply, clients will not be able to get the value of this characteristic.
+
+A callback set with this function overwrites any previously set WriteValueRequestCallback.
+
+
+The errorCallback will be launched in the following situations:
+
+
+ -
+ NotSupportedError - If the feature is not supported.
+ -
+ AbortError - If any other error occurs.
+
+
+The sendResponseErrorCallback will be launched in the following situations:
+
+
+ -
+ NotSupportedError - If the feature is not supported.
+ -
+ InvalidValuesError - If GATTRequestReply::statusCode or GATTRequestReply::data is invalid.
+ -
+ AbortError - If any other error occurs.
+
+
+Privilege level:
+ public
+
+Privilege:
+ http://tizen.org/privilege/bluetooth
+
+
+Parameters:
+
+ -
+writeValueRequestCallback:
+ The callback called when a client writes the value of the characteristic.
+
+ -
+successCallback [optional] [nullable]:
+ Callback function that is called when the writeValueRequestCallback is registered successfully.
+
+ -
+errorCallback [optional] [nullable]:
+ Callback function that is called in case of failure of writeValueRequestCallback registration.
+
+ -
+sendResponseSuccessCallback [optional] [nullable]:
+ Callback function that is called when responses returned from writeValueRequestCallbacks are sent successfully.
+
+ -
+sendResponseErrorCallback [optional] [nullable]:
+ Callback function that is called when responses returned from writeValueRequestCallbacks are not sent due to an error.
+
+
+
+
+Exceptions:
+ - WebAPIException
+
+ 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:
/* this example assumes that the local gatt server with at least one service which has at least one */
+/* characteristic already exists */
+var callback = function(clientAddress, value, offset, replyRequired)
+{
+ console.log(clientAddress + " requested to write characteristic's value: " + value +
+ " with offset: " + offset);
+ return replyRequired ? new tizen.GATTRequestReply(0, "0x1234") : null;
+};
+
+server.services[0].characteristics[0].setWriteValueRequestCallback(callback);
+
+
+
+
+
+
+
+2.15. BluetoothGATTDescriptor
+
+ Bluetooth Low Energy descriptor.
+
+ [NoInterfaceObject] interface BluetoothGATTDescriptor {
+ readonly attribute BluetoothUUID? uuid;
+ void readValue(ReadValueSuccessCallback successCallback, optional ErrorCallback? errorCallback) raises(WebAPIException);
+ void writeValue(Bytes value, optional SuccessCallback? successCallback, optional ErrorCallback? errorCallback)
+ raises(WebAPIException);
+ };
+Since:
+ 2.3.1
+
+
+Attributes
+-
+ readonly
+BluetoothUUID uuid [nullable]
+ UUID of the descriptor.
+
+
Since:
+ 6.0
+
+Remark:
+ uuid is set to null, if the value cannot be retrieved.
+
+
+
+
+Methods
+
+-
+
readValue
+
+-
+
+ Reads descriptor value from remote device. Updates descriptor value attribute.
+
+
void readValue(ReadValueSuccessCallback successCallback, optional ErrorCallback? errorCallback);
+Since:
+ 2.3.1
+
+
+
+The ErrorCallback is launched with these error types:
+
+
+ -
+ UnknownError - If any other error occurs
+
+
+Privilege level:
+ public
+
+Privilege:
+ http://tizen.org/privilege/bluetooth
+
+Remark:
+ BluetothGATTServerDescriptor objects do not support this function. An attempt to call it for such an object will result in an exception.
+
+
+Parameters:
+
+ -
+successCallback:
+ Callback function that is called when the descriptor value is read successfully.
+
+ -
+errorCallback [optional] [nullable]:
+ Callback function that is called in case of failure.
+
+
+
+
+Exceptions:
+ - WebAPIException
+
+ 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.
+
+
+ with error type NotSupportedError, if the method is called for BluetoothGATTServerDescriptor.
+
+
+
+
+
+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
+
+-
+
+ Writes the descriptor value to the remote device.
+
+
void writeValue(Bytes value, optional SuccessCallback? successCallback, optional ErrorCallback? errorCallback);
+Since:
+ 2.3.1
+
+
+
+The ErrorCallback is launched with these error types:
+
+
+ -
UnknownError - If any other error occurs
@@ -3582,16 +4729,601 @@ Methods
Privilege:
http://tizen.org/privilege/bluetooth
+Remark:
+ BluetothGATTServerDescriptor objects do not support this function. An attempt to call it for such an object will result in an exception.
+
+
+Parameters:
+
+ -
+value:
+ The descriptor value to write.
+
+ -
+successCallback [optional] [nullable]:
+ Callback function that is called when the descriptor value is written successfully.
+
+ -
+errorCallback [optional] [nullable]:
+ Callback function that is called in case of failure.
+
+
+
+
+Exceptions:
+ - WebAPIException
+
+ 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.
+
+
+ with error type NotSupportedError, if the method is called for BluetoothGATTServerDescriptor.
+
+
+
+
+
+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);
+ }
+});
+
+
+
+
+
+
+
+2.16. BluetoothGATTServerDescriptorInit
+
+ A dictionary for specifying GATT descriptor parameters.
+
+ dictionary BluetoothGATTServerDescriptorInit {
+ BluetoothUUID uuid;
+ boolean readPermission = false;
+ boolean writePermission = false;
+ boolean encryptedReadPermission = false;
+ boolean encryptedWritePermission = false;
+ boolean encryptedSignedReadPermission = false;
+ boolean encryptedSignedWritePermission = false;
+ ReadValueRequestCallback? readValueRequestCallback = null;
+ SuccessCallback? readValueSendResponseSuccessCallback = null;
+ ErrorCallback? readValueSendResponseErrorCallback = null;
+ WriteValueRequestCallback? writeValueRequestCallback = null;
+ SuccessCallback? writeValueSendResponseSuccessCallback = null;
+ ErrorCallback? writeValueSendResponseErrorCallback = null;
+ };
+Since:
+ 6.0
+
+
+
+This dictionary is used as a definition of a descriptor to be registered in a characteristic of the local GATT server.
readValueRequestCallback and writeValueRequestCallback are callbacks called when a client reads or writes the value of the descriptor respectively. They can be set or replaced with another functions after registering the service containing the descriptor with BluetoothGATTServerDescriptor.setReadValueRequestCallback() and BluetoothGATTServerDescriptor.setWriteValueRequestCallback().
readValueSendResponseSuccessCallback and writeValueSendResponseSuccessCallback are success callbacks called when a response sent from readValueRequestCallback or writeValueRequestCallback reaches client. They can be set or replaced with another functions, after registering the service containing the characteristic, with BluetoothGATTServerDescriptor.setReadValueRequestCallback() and BluetoothGATTServerDescriptor.setWriteValueRequestCallback().
readValueSendResponseErrorCallback and writeValueSendResponseErrorCallback are error callbacks called when an attempt to send a response to a client from readValueRequestCallback or writeValueRequestCallback fails. They can be set or replaced with another functions, after registering the service containing the characteristic, with BluetoothGATTServerDescriptor.setReadValueRequestCallback() and BluetoothGATTServerDescriptor.setWriteValueRequestCallback().
+
+
+
+Code example:
/* readValueCallback, writeValueCallback are read/write request callbacks */
+/* readValueSendResponseSuccessCallback and writeValueSendResponseSuccessCallback are success */
+/* callbacks */
+/* and writeValueSendResponseErrorCallback and readValueSendResponseErrorCallback are error */
+/* callbacks */
+var descriptorProperties =
+{
+ uuid: "0180",
+ /* Descriptor's permissions */
+ readPermission: true,
+ writePermission: true,
+ encryptedReadPermission: false,
+ encryptedWritePermission: false,
+ encryptedSignedReadPermission: false,
+ encryptedSignedWritePermission: false,
+ /* Read/write value callbacks */
+ readValueRequestCallback: readValueCallback,
+ readValueSendResponseSuccessCallback: readValueSendResponseSuccessCallback,
+ readValueSendResponseErrorCallback: readValueSendResponseErrorCallback,
+ writeValueRequestCallback: writeValueCallback,
+ writeValueSendResponseSuccessCallback: writeValueSendResponseSuccessCallback,
+ writeValueSendResponseErrorCallback: writeValueSendResponseErrorCallback
+};
+
+
+
+
+2.17. BluetoothGATTServerDescriptor
+
+ A subclass representing GATT descriptors of characteristics registered in services of the local server.
+It extends BluetoothGATTDescriptor with permissions and methods implementing interactions of the descriptor with remote clients.
+
+ [NoInterfaceObject] interface BluetoothGATTServerDescriptor : BluetoothGATTDescriptor {
+ readonly attribute boolean readPermission;
+ readonly attribute boolean writePermission;
+ readonly attribute boolean encryptedReadPermission;
+ readonly attribute boolean encryptedWritePermission;
+ readonly attribute boolean encryptedSignedReadPermission;
+ readonly attribute boolean encryptedSignedWritePermission;
+ void setReadValueRequestCallback(ReadValueRequestCallback readValueRequestCallback, optional SuccessCallback? successCallback,
+ optional ErrorCallback? errorCallback, optional SuccessCallback? sendResponseSuccessCallback,
+ optional ErrorCallback? sendResponseErrorCallback) raises(WebAPIException);
+ void setWriteValueRequestCallback(WriteValueRequestCallback writeValueRequestCallback, optional SuccessCallback? successCallback,
+ optional ErrorCallback? errorCallback, optional SuccessCallback? sendResponseSuccessCallback,
+ optional ErrorCallback? sendResponseErrorCallback) raises(WebAPIException);
+ };
+Since:
+ 6.0
+
+
+
+Attributes
+
+-
+ readonly
+boolean readPermission
+ Indicates if clients have the permission to read the value of the descriptor.
+
+
Since:
+ 6.0
+
+
+-
+ readonly
+boolean writePermission
+ Indicates if clients have the permission to write the value of the descriptor.
+
+
Since:
+ 6.0
+
+
+-
+ readonly
+boolean encryptedReadPermission
+ Indicates if clients have the permission to read the value of the descriptor through encrypted connections.
+
+
Since:
+ 6.0
+
+
+-
+ readonly
+boolean encryptedWritePermission
+ Indicates if clients have the permission to write the value of the descriptor through encrypted connections.
+
+
Since:
+ 6.0
+
+
+-
+ readonly
+boolean encryptedSignedReadPermission
+ Indicates if clients have the permission to perform signed reads of the charactersitic's value.
+
+
Since:
+ 6.0
+
+
+-
+ readonly
+boolean encryptedSignedWritePermission
+ Indicates if clients have the permission to perform signed writes of the charactersitic's value.
+
+
Since:
+ 6.0
+
+
+
+
+
+Methods
+
+-
+
setReadValueRequestCallback
+
+-
+
+ Registers the callback called when a client reads the value of the descriptor from the local GATT server.
+
+
void setReadValueRequestCallback(ReadValueRequestCallback readValueRequestCallback, optional SuccessCallback? successCallback,
+ optional ErrorCallback? errorCallback, optional SuccessCallback? sendResponseSuccessCallback,
+ optional ErrorCallback? sendResponseErrorCallback);
+Since:
+ 6.0
+
+
+
+The callback, registered with this function, is called when a remote client requests to read the value of the descriptor.
+The server can respond to such requests by returning a GATTRequestReply object from the callback.
+If ReadValueRequestCallback for the descriptor is not registered, or it does not return a GATTRequestReply, clients will not be able to get the value of this descriptor.
+
+A callback set with this function overwrites any previously set ReadValueRequestCallback.
+
+
+The errorCallback will be launched in the following situations:
+
+
+ -
+ NotSupportedError - If the feature is not supported.
+ -
+ AbortError - If any other error occurs.
+
+
+The sendResponseErrorCallback will be launched in the following situations:
+
+
+ -
+ NotSupportedError - If the feature is not supported.
+ -
+ InvalidValuesError - If GATTRequestReply::statusCode or GATTRequestReply::data is invalid.
+ -
+ AbortError - If any other error occurs.
+
+
+Privilege level:
+ public
+
+Privilege:
+ http://tizen.org/privilege/bluetooth
+
+
+Parameters:
+
+ -
+readValueRequestCallback:
+ The callback called when a client reads the value of the descriptor.
+
+ -
+successCallback [optional] [nullable]:
+ Callback function that is called when the readValueRequestCallback is registered successfully.
+
+ -
+errorCallback [optional] [nullable]:
+ Callback function that is called in case of failure of readValueRequestCallback registration.
+
+ -
+sendResponseSuccessCallback [optional] [nullable]:
+ Callback function that is called when responses returned from readValueRequestCallbacks are sent successfully.
+
+ -
+sendResponseErrorCallback [optional] [nullable]:
+ Callback function that is called when responses returned from readValueRequestCallbacks are not sent due to an error.
+
+
+
+
+Exceptions:
+ - WebAPIException
+
+ 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:
/* this example assumes that the local gatt server with at least one service which has at least one */
+/* characteristic with at least one descriptor already exists */
+var callback = function(clientAddress, offset)
+{
+ console.log(clientAddress + " requested to read characteristic's value with offset: " + offset);
+ return new tizen.GATTRequestReply(0, "0x1234");
+};
+server.services[0].characteristics[0].descriptors[0].setReadValueRequestCallback(callback);
+
+
+
+-
+
setWriteValueRequestCallback
+
+-
+
+ Registers the callback called when a remote client writes the value of the descriptor from the local GATT server.
+
+
void setWriteValueRequestCallback(WriteValueRequestCallback writeValueRequestCallback, optional SuccessCallback? successCallback,
+ optional ErrorCallback? errorCallback, optional SuccessCallback? sendResponseSuccessCallback,
+ optional ErrorCallback? sendResponseErrorCallback);
+Since:
+ 6.0
+
+
+
+The callback, registered with this function, is called when a remote client requests to write the value of the descriptor.
+The server can respond to such requests by returning a GATTRequestReply object from the callback.
+If WriteValueRequestCallback for the descriptor is not registered, or it does not return a GATTRequestReply, clients will not be able to get the value of this descriptor.
+
+A callback set with this function overwrites any previously set WriteValueRequestCallback.
+
+
+The errorCallback will be launched in the following situations:
+
+
+ -
+ NotSupportedError - If the feature is not supported.
+ -
+ AbortError - If any other error occurs.
+
+
+The sendResponseErrorCallback will be launched in the following situations:
+
+
+ -
+ NotSupportedError - If the feature is not supported.
+ -
+ InvalidValuesError - If GATTRequestReply::statusCode or GATTRequestReply::data is invalid.
+ -
+ AbortError - If any other error occurs.
+
+
+Privilege level:
+ public
+
+Privilege:
+ http://tizen.org/privilege/bluetooth
+
+
+Parameters:
+
+ -
+writeValueRequestCallback:
+ The callback called when a client writes the value of the descriptor.
+
+ -
+successCallback [optional] [nullable]:
+ Callback function that is called when the writeValueRequestCallback is registered successfully.
+
+ -
+errorCallback [optional] [nullable]:
+ Callback function that is called in case of failure of writeValueRequestCallback registration.
+
+ -
+sendResponseSuccessCallback [optional] [nullable]:
+ Callback function that is called when responses returned from writeValueRequestCallbacks are sent successfully.
+
+ -
+sendResponseErrorCallback [optional] [nullable]:
+ Callback function that is called when responses returned from writeValueRequestCallbacks are not sent due to an error.
+
+
+
+
+Exceptions:
+ - WebAPIException
+
+ 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:
/* this example assumes that the local gatt server with at least one service which has at least one */
+/* characteristic with at least one descriptor already exists */
+var callback = function(clientAddress, value, offset, replyRequired)
+{
+ console.log(clientAddress + " requested to write descriptor's value: " + value +
+ " with offset: " + offset);
+ return replyRequired ? new tizen.GATTRequestReply(0, "0x1234") : null;
+};
+server.services[0].characteristics[0].descriptors[0].setWriteValueRequestCallback(callback);
+
+
+
+
+
+
+
+2.18. BluetoothGATTServer
+
+ The BluetoothGATTServer interface provides access to control the local GATT server: starting and stopping it, registering and unregistering local GATT services, and getting the ATT MTU (Attribute Protocol Maximum Transmission Unit) values.
+
+ [NoInterfaceObject] interface BluetoothGATTServer {
+ readonly attribute boolean isRunning;
+ readonly attribute BluetoothGATTServerService[] services;
+ void start(optional SuccessCallback? successCallback, optional ErrorCallback? errorCallback) raises(WebAPIException);
+ void stop(optional SuccessCallback? successCallback, optional ErrorCallback? errorCallback) raises(WebAPIException);
+ void registerService(BluetoothGATTServerServiceInit service, optional SuccessCallback? successCallback,
+ optional ErrorCallback? errorCallback) raises(WebAPIException);
+ void unregisterAllServices(optional SuccessCallback? successCallback, optional ErrorCallback? errorCallback)
+ raises(WebAPIException);
+ void getConnectionMtu(BluetoothAddress clientAddress, ConnectionMtuCallback callback, optional ErrorCallback? errorCallback)
+ raises(WebAPIException);
+ };
+Since:
+ 6.0
+
+
+Attributes
+
+-
+ readonly
+boolean isRunning
+ The flag indicating if remote GATT clients can currently connect to the server, exposing services defined in BluetoothGATTServer::services. It is toggled on start() and stop() calls.
+
+
Since:
+ 6.0
+
+
+-
+ readonly
+BluetoothGATTServerService[]
+ services
+ The list of GATT services hosted on this server.
+
+
Since:
+ 6.0
+
+
+
+
+
+Methods
+
+-
+
start
+
+-
+
+ Starts the local GATT server. After it starts, it can conduct GATT server operations. Also, the remote clients can discover and use the services provided by the local Bluetooth GATT Server.
+
+
void start(optional SuccessCallback? successCallback, optional ErrorCallback? errorCallback);
+Since:
+ 6.0
+
+
+
+The ErrorCallback will be launched in the following situations:
+
+
+ -
+ InvalidStateError - If the server is already running.
+ -
+ NotSupportedError - If the feature is not supported.
+ -
+ AbortError - If any other error occurs.
+
+
+Privilege level:
+ public
+
+Privilege:
+ http://tizen.org/privilege/bluetooth
+
+
+Parameters:
+
+ -
+successCallback [optional] [nullable]:
+ Called when the server is started.
+
+ -
+errorCallback [optional] [nullable]:
+ The method to invoke when an error occurs.
+
+
+
+
+Exceptions:
+ - WebAPIException
+
+ with error type InvalidStateError, if the Bluetooth adapter is not enabled.
+
+
+ with error type TypeMismatchError, if any input attribute is not compatible with the expected type for this attribute.
+
+
+ with error type SecurityError, if the application does not have the privilege to call this method.
+
+
+ with error type AbortError, if any other error occurs.
+
+
+
+
+
+Code example:
var onSuccess = function()
+{
+ console.log("Server started successfully!");
+};
+
+var onError = function(e)
+{
+ console.error("Server didn't start, error: " + e);
+};
+
+var server = tizen.bluetooth.getGATTServer();
+
+server.start(onSuccess, onError);
+
+
+
+Output example:
Server started successfully!
+
+
+
+-
+
stop
+
+-
+
+ Stops GATT server operation.
+
+
void stop(optional SuccessCallback? successCallback, optional ErrorCallback? errorCallback);
+Since:
+ 6.0
+
+
+
+After the stop, remote clients will not be able to discover the local GATT server's services.
+
+
+The ErrorCallback will be launched in the following situations:
+
+
+ -
+ InvalidStateError - If the server is not running.
+ -
+ NotSupportedError - If the feature is not supported.
+ -
+ AbortError - If any other error occurs.
+
+
+Privilege level:
+ public
+
+Privilege:
+ http://tizen.org/privilege/bluetooth
+
Parameters:
-
-successCallback:
- Callback function that is called when the descriptor value is read successfully.
+successCallback [optional] [nullable]:
+ Called when the server is stopped.
-
errorCallback [optional] [nullable]:
- Callback function that is called in case of failure.
+ The method to invoke when an error occurs.
@@ -3599,72 +5331,70 @@ Methods
Exceptions:
- WebAPIException
- with error type TypeMismatchError, if the input parameter is not compatible with the expected type for that parameter.
+ with error type InvalidStateError, if the Bluetooth adapter is not enabled.
- with error type InvalidStateError, if the local Bluetooth le adapter is currently not enabled.
+ with error type TypeMismatchError, if any input attribute is not compatible with the expected type for this attribute.
with error type SecurityError, if the application does not have the privilege to call this method.
+
+ with error type AbortError, if any other error occurs.
+
-Code example:
function onerror(e)
+Code example:
/* this example assumes that local gatt server already exists and it is started */
+var onSuccess = function()
{
- console.log("Failed to connect to device: " + e.message);
-}
+ console.log("Server stopped successfully!");
+};
-function proccessDevice(device)
+var onError = function(e)
{
- 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();
- });
- }
- }
-}
+ console.error("Server didn't stop, error: " + e);
+};
-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);
- }
-});
+server.stop(onSuccess, onError);
+
+
+
+Output example:
Server stopped successfully!
--
-
writeValue
+-
+
registerService
-
- Writes the descriptor value to the remote device.
+ Registers a primary service in the local GATT server.
-
void writeValue(Bytes value, optional SuccessCallback? successCallback, optional ErrorCallback? errorCallback);
+void registerService(BluetoothGATTServerServiceInit service, optional SuccessCallback? successCallback,
+ optional ErrorCallback? errorCallback);
Since:
- 2.3.1
+ 6.0
+
+
+
+The service is available for clients after BluetoothGATTServer::start() call.
+
The ErrorCallback is launched with these error types:
-
-UnknownError - If any other error occurs
+ InvalidStateError - If the service cannot be registered in the current state of the server.
+ -
+ NotSupportedError - If the feature is not supported.
+ -
+ InvalidValuesError - If any of the input parameters contains an invalid value
+ -
+ AbortError - If any other error occurs.
Privilege level:
@@ -3673,20 +5403,23 @@
Methods
Privilege:
http://tizen.org/privilege/bluetooth
+Remark:
+ Services can only be registered before starting server.
+
Parameters:
-
-value:
- The descriptor value to write.
+service:
+ The definition of a service to be registered in the local GATT server.
-
successCallback [optional] [nullable]:
- Callback function that is called when the descriptor value is written successfully.
+ Called when the local GATT server's services are successfully registered.
-
errorCallback [optional] [nullable]:
- Callback function that is called in case of failure.
+ The method to invoke when an error occurs.
@@ -3694,10 +5427,10 @@ Methods
Exceptions:
- WebAPIException
- with error type TypeMismatchError, if the input parameter is not compatible with the expected type for that parameter.
+ with error type InvalidStateError, if the Bluetooth adapter is not enabled.
- with error type InvalidStateError, if the local Bluetooth le adapter is currently not enabled.
+ with error type TypeMismatchError, if any input attribute is not compatible with the expected type for this attribute.
with error type SecurityError, if the application does not have the privilege to call this method.
@@ -3706,45 +5439,185 @@
Methods
-Code example:
function onerror(e)
+Code example:
var gattService = {serviceUuid: "0955", isPrimary: false, services: [], characteristics: []};
+
+var successCB = function()
{
- console.log("Failed to connect to device: " + e.message);
-}
+ console.log("Service successfully registered!");
+};
-function proccessDevice(device)
+var errorCB = function(e)
{
- 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);
- });
- }
- }
-}
+ console.log("Service not registered, error: " + e);
+};
-var adapter = tizen.bluetooth.getLEAdapter();
-adapter.startScan(function onsuccess(device)
+var server = tizen.bluetooth.getGATTServer();
+
+server.registerService(gattService, successCB, errorCB);
+
+
+
+Output example:
Service successfully registered!
+
+
+
+-
+
unregisterAllServices
+
+-
+
+ Unregisters all services from the local GATT server.
+
+
void unregisterAllServices(optional SuccessCallback? successCallback, optional ErrorCallback? errorCallback);
+Since:
+ 6.0
+
+
+
+This method unregisters all services and all their characteristics from the local GATT server.
+
+
+
+
+The ErrorCallback is launched with these error types:
+
+
+ -
+ InvalidStateError - If the service cannot be unregistered in the current state of the GATT server.
+ -
+ AbortError - If any other error occurs
+
+
+Privilege level:
+ public
+
+Privilege:
+ http://tizen.org/privilege/bluetooth
+
+Remark:
+ Currently running local GATT server is stopped after calling this method.
+
+
+Parameters:
+
+ -
+successCallback [optional] [nullable]:
+ Callback function that is called when services are successfully unregistered from the local GATT server.
+
+ -
+errorCallback [optional] [nullable]:
+ Callback function that is called in case of failure.
+
+
+
+
+Exceptions:
+ - WebAPIException
+
+ 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:
/* this example assumes that the local gatt server already exists */
+var successCB = function()
{
- if (device.address == "11:22:33:44:55:66")
- {
- console.log("Found device: " + device.name);
- proccessDevice(device);
- }
-});
+ console.log("Services successfully unregistered!");
+};
+
+var errorCB = function(e)
+{
+ console.log("Services not unregistered, error: " + e);
+};
+
+server.unregisterAllServices(successCB, errorCB);
+
+
+
+Output example:
Services successfully unregistered!
+
+
+
+-
+
getConnectionMtu
+
+-
+
+ Gets the ATT MTU for the connection with a client.
+
+
void getConnectionMtu(BluetoothAddress clientAddress, ConnectionMtuCallback callback, optional ErrorCallback? errorCallback);
+Since:
+ 6.0
+
+
+
+The ErrorCallback is launched with these error types:
+
+
+ -
+ InvalidStateError - If the server is not running.
+ -
+ NotSupportedError - If the feature is not supported.
+ -
+ AbortError - If any other error occurs.
+
+
+Privilege level:
+ public
+
+Privilege:
+ http://tizen.org/privilege/bluetooth
+
+
+Parameters:
+
+ -
+clientAddress:
+ MAC address of the client, for connection with whom the MTU is to be retrieved.
+
+ -
+callback:
+ Callback functions that are called when the connection state changes.
+
+ -
+errorCallback [optional] [nullable]:
+ Callback function that is called when getting MTU of a connection fails.
+
+
+
+
+Exceptions:
+ - WebAPIException
+
+ 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:
/* this example assumes that the local gatt server already exists */
+var successCB = function(mtu)
+{
+ console.log("ATT MTU value is: " + mtu);
+};
+
+var errorCB = function(e)
+{
+ console.log("Cannot retrieve the ATT MTU, error: " + e);
+};
+
+server.getConnectionMtu("12:34:56:78:90:ab", successCB, errorCB);
+
+
+
+Output example:
ATT MTU value is: 123
@@ -3752,7 +5625,7 @@ Methods
[Constructor(long statusCode = 0, optional Bytes data)] + interface GATTRequestReply { + attribute long statusCode; + attribute Bytes? data; + };+
Since: + 6.0 +
+Since: + 6.0 +
+Since: + 6.0 +
+ [Callback=FunctionOnly, NoInterfaceObject] interface ReadValueRequestCallback {
+ GATTRequestReply? onreadrequest(BluetoothAddress clientAddress, long offset);
+ };
+Since: + 6.0 +
+Remark: + Example of using can be found at BluetoothGATTServerCharacteristic.setReadValueRequestCallback() and BluetoothGATTServerDescriptor.setReadValueRequestCallback() code examples. +
+onreadrequest
+GATTRequestReply? onreadrequest(BluetoothAddress clientAddress, long offset);
Since: + 6.0 +
++The server should reply to requests by returning a GATTRequestReply object with requested data and a proper status code. +If the callback does not return a GATTRequestReply, the client will not receive a response. +
+Parameters:
+Return value:
+ [Callback=FunctionOnly, NoInterfaceObject] interface WriteValueRequestCallback {
+ GATTRequestReply? onwriterequest(BluetoothAddress clientAddress, byte[] value, long offset, boolean replyRequired);
+ };
+Since: + 6.0 +
+Remark: + Example of using can be found at BluetoothGATTServerCharacteristic.setWriteValueRequestCallback() and BluetoothGATTServerDescriptor.setWriteValueRequestCallback() code examples. +
+onwriterequest
+GATTRequestReply? onwriterequest(BluetoothAddress clientAddress, byte[] value, long offset, boolean replyRequired);
Since: + 6.0 +
++The server should reply to requests by returning a GATTRequestReply object with a status code. +If the callback does not return a GATTRequestReply, the client will not receive a response. +
+Parameters:
+ [Callback=FunctionOnly, NoInterfaceObject] interface NotificationCallback {
+ void onnotificationsuccess(BluetoothAddress clientAddress);
+ void onnotificationfail(BluetoothAddress clientAddress, WebAPIException error);
+ void onnotificationfinish(BluetoothAddress clientAddress);
+ };
+Since: + 6.0 +
+Remark: + Example of using can be found at BluetoothGATTServerCharacteristic.notifyAboutValueChange() code examples. +
+onnotificationsuccess
+void onnotificationsuccess(BluetoothAddress clientAddress);
Since: + 6.0 +
+Parameters:
+onnotificationfail
+void onnotificationfail(BluetoothAddress clientAddress, WebAPIException error);
Since: + 6.0 +
+Parameters:
+onnotificationfinish
+void onnotificationfinish(BluetoothAddress clientAddress);
Since: + 6.0 +
+Parameters:
+ [Callback=FunctionOnly, NoInterfaceObject] interface ConnectionMtuCallback {
+ void onsuccess(long mtu);
+ };
+Since: + 6.0 +
+Remark: + Example of using can be found at BluetoothGATTServer.getConnectionMtu() code example. +
+ +Since: 2.3.1 @@ -4314,6 +6491,8 @@
Since: 2.3.1
+Remark: + This value will be set to null, if the object is obtained from BluetoothLEConnectChangeCallback. +
Code example:
var adapter = tizen.bluetooth.getLEAdapter(); adapter.startScan(function onsuccess(device) @@ -4366,6 +6548,9 @@Attributes
Since: 2.3.1
+Remark: + This value will be set to null, if the object is obtained from BluetoothLEConnectChangeCallback. +
Code example:
var adapter = tizen.bluetooth.getLEAdapter(); adapter.startScan(function onsuccess(device) @@ -4383,6 +6568,9 @@Attributes
Since: 2.3.1
+Remark: + This value will be set to null, if the object is obtained from BluetoothLEConnectChangeCallback. +
Code example:
var adapter = tizen.bluetooth.getLEAdapter(); adapter.startScan(function onsuccess(device) @@ -4401,6 +6589,9 @@Attributes
Since: 2.3.1
+Remark: + This value will be set to null, if the object is obtained from BluetoothLEConnectChangeCallback. +
Code example:
var adapter = tizen.bluetooth.getLEAdapter(); adapter.startScan(function onsuccess(device) @@ -4425,6 +6616,9 @@Attributes
Since: 2.3.1
+Remark: + This value will be set to null, if the object is obtained from BluetoothLEConnectChangeCallback. +
Code example:
var adapter = tizen.bluetooth.getLEAdapter(); adapter.startScan(function onsuccess(device) @@ -4452,6 +6646,9 @@Attributes
Remark: On devices prior to Tizen 6.0, service data is found only when its BluetoothLEServiceData::uuid is 16-bit. Finding service data with 128-bit BluetoothLEServiceData::uuid is supported since Tizen 6.0.
+Remark: + This value will be set to null, if the object is obtained from BluetoothLEConnectChangeCallback. +
Code example:
var adapter = tizen.bluetooth.getLEAdapter(); adapter.startScan(function onsuccess(device) @@ -4475,6 +6672,9 @@Attributes
Since: 2.3.1
+Remark: + This value will be set to null, if the object is obtained from BluetoothLEConnectChangeCallback. +
Code example:
var adapter = tizen.bluetooth.getLEAdapter(); @@ -4513,7 +6713,7 @@Attributes
- readonly -long rssi
+long rssi [nullable]The received signal strength indicator in dBm (decibel-milliwatts) units.@@ -4524,6 +6724,9 @@+Attributes
Since: 3.0
+Remark: + Since Tizen 6.0, this value can be a null, but only if the object is obtained from BluetoothLEConnectChangeCallback. +
+ +Code example:
var adapter = tizen.bluetooth.getLEAdapter(); adapter.startScan(function onsuccess(device) @@ -4694,15 +6897,76 @@+Methods
device.disconnect(ondisconnect, onerror); } - if (device.address == "11:22:33:44:55:66") - { - console.log("Found device: " + device.name); - device.connect(onconnected, onerror); - } + if (device.address == "11:22:33:44:55:66") + { + console.log("Found device: " + device.name); + device.connect(onconnected, onerror); + } +} + +var adapter = tizen.bluetooth.getLEAdapter(); +adapter.startScan(onDeviceFound, onerror); +- +
+isConnected+- +
@@ -4887,7 +7151,7 @@+ Checks if Bluetooth Low Energy device is currently connected. +++boolean isConnected();Since: + 6.0 +
+++Return value:
++boolean: + true if the device is currently connected, false otherwise. +
+++Exceptions:
++
- WebAPIException
+
+ with error type UnknownError, if any error occurs. +
++Code example:
var dev; + +function onerror(e) +{ + console.log("Failed to connect to device: " + e.message); +} + +function onconnected() +{ + console.log("Connected to device: " + dev.isConnected()); } var adapter = tizen.bluetooth.getLEAdapter(); -adapter.startScan(onDeviceFound, onerror); +adapter.startScan(function onsuccess(device) +{ + if (device.address == "11:22:33:44:55:66") + { + adapter.stopScan(); + dev = device; + var connected = dev.isConnected(); + console.log("Found device: " + device.name + ", connected: " + connected); + if (!connected) + { + device.connect(onconnected, onerror); + } + } +}); +++Output example:
Found device: TestDevice, connected: false +Connected to device: trueMethods
@@ -4984,11 +7248,282 @@Exceptions:
- WebAPIException
- with error type UnknownError, if any other error occurs. + with error type TypeMismatchError, if the input parameter is not compatible with the expected type for that parameter.
Methods
- +
+getAttMtu+- +
++ Gets the current value of Attribute Protocol(ATT) Maximum Transmission Unit(MTU) from the connected device. +++unsigned long getAttMtu();Since: + 6.0 +
+++Return value:
++unsigned long: + Current ATT MTU value. +
+++Exceptions:
++
- WebAPIException
+
+- +
+ with error type InvalidStateError, if the remote device is not connected. +
- +
+ with error type UnknownError, if any other error occurs. +
++Code example:
var dev; + +function onerror(e) +{ + console.log("Failed to connect to device: " + e.message); +} + +function onconnected() +{ + console.log("Connected to device, ATT MTU: " + dev.getAttMtu()); +} + +var adapter = tizen.bluetooth.getLEAdapter(); +adapter.startScan(function onsuccess(device) +{ + if (device.address == "11:22:33:44:55:66") + { + dev = device; + console.log("Found device: " + device.name); + device.connect(onconnected, onerror); + } +}); ++++Output example:
Found device: TestDevice +Connected to device, ATT MTU: 23 ++- +
+requestAttMtuChange+- +
++ Requests the GATT server to change the Attribute Protocol (ATT) Maximum Transmission Unit (MTU) value. +++void requestAttMtuChange(unsigned long newAttMtu);Since: + 6.0 +
+Remark: + ATT MTU value is determined between two connected devices and change will be successful only if both devices support the given value of ATT MTU. +
+++Parameters:
++
+- +newAttMtu: + The new ATT MTU value, that will be sent to GATT server. +
+++Exceptions:
++
- WebAPIException
+
+ with error type UnknownError, if any error occurs. +
++Code example:
function proccessDevice(device) +{ + function onConnected() + { + var attMtu = device.getAttMtu(); + console.log("Initial ATT MTU value: " + attMtu); + watchID = device.addAttMtuChangeListener(function(value) + { + console.log("ATT MTU changed to: " + value); + device.removeAttMtuChangeListener(watchID); + device.disconnect(); + }); + device.requestAttMtuChange(64); + } + 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); + } +}); ++++Output example:
Found device: TestDevice +Initial ATT MTU value: 31 +ATT MTU changed to: 64 ++- +
+addAttMtuChangeListener+- +
++ Registers a listener to be called when ATT MTU value is changed. +++long addAttMtuChangeListener(ConnectionMtuCallback callback);Since: + 6.0 +
+Remark: + ATT MTU value is determined between two connected devices and change takes place after both devices agrees to new value, both connected devices can initiate the ATT MTU value change by sending the request. +
+++Parameters:
++
+- +callback: + Listener function that is called when the connection's ATT MTU changes. +
+++Return value:
++long: + The watchID to be used to unregister the listener. +
+++Exceptions:
++
- WebAPIException
+
+- +
+ with error type TypeMismatchError, if an input attribute is not compatible with the expected type for this attribute. +
- +
+ with error type UnknownError, if any other error occurs. +
++Code example:
function proccessDevice(device) +{ + function onConnected() + { + var attMtu = device.getAttMtu(); + console.log("Initial ATT MTU value: " + attMtu); + watchID = device.addAttMtuChangeListener(function(value) + { + console.log("ATT MTU changed to: " + value); + device.removeAttMtuChangeListener(watchID); + device.disconnect(); + }); + device.requestAttMtuChange(64); + } + 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); + } +}); ++++Output example:
Found device: TestDevice +Initial ATT MTU value: 31 +ATT MTU changed to: 64 ++- +
+removeAttMtuChangeListener+- +
+ Unregisters the ATT MTU value change listener. +++void removeAttMtuChangeListener(long watchId);Since: + 6.0 +
+++Parameters:
++
+- +watchId: + The watchID identifier returned by the addAttMtuChangeListener() method. +
+++Exceptions:
++
- WebAPIException
+
+ with error type UnknownError, if any error occurs. +
++Code example:
function proccessDevice(device) +{ + function onConnected() + { + var attMtu = device.getAttMtu(); + console.log("Initial ATT MTU value: " + attMtu); + watchID = device.addAttMtuChangeListener(function(value) + { + console.log("ATT MTU changed to: " + value); + device.removeAttMtuChangeListener(watchID); + device.disconnect(); + }); + device.requestAttMtuChange(64); + } + 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); + } +}); ++++Output example:
Found device: TestDevice +Initial ATT MTU value: 31 +ATT MTU changed to: 64 ++-2.20. BluetoothClassDeviceMajor
+2.32. BluetoothClassDeviceMajor
The BluetoothClassDeviceMajor interface holds the identifiers for major device classes of Bluetooth CoD.@@ -5680,7 +8215,7 @@Methods
-2.21. BluetoothClassDeviceMinor
+2.33. BluetoothClassDeviceMinor
The BluetoothClassDeviceMinor interface holds the identifiers for minor device classes of Bluetooth CoD.@@ -5763,7 +8298,7 @@Methods
+To guarantee that the Bluetooth Low Energy application runs on a device with Bluetooth Low Energy GATT Server feature, declare the following feature requirements in the config file: +
+For more information on the Bluetooth features, see Bluetooth Guide. @@ -67,6 +69,15 @@
typedef (BluetoothGATTService or BluetoothGATTServerService) BluetoothGATTServiceVariant;+
Since: + 6.0 +
+typedef (BluetoothGATTCharacteristic or BluetoothGATTServerCharacteristic) BluetoothGATTCharacteristicVariant;+
Since: + 6.0 +
+typedef (BluetoothGATTDescriptor or BluetoothGATTServerDescriptor) BluetoothGATTDescriptorVariant;+
Since: + 6.0 +
+Since: @@ -680,7 +822,7 @@
Since: @@ -816,20 +958,26 @@
Since: 6.0
Remark: - Only 16-bit BluetoothLEServiceData::uuid values can be advertised. + Only 16-bit BluetoothLEServiceData::uuid values can be advertised. Duplicated uuid values in servicesData are not allowed for advertising. +
+Remark: + If this attribute is in neither null nor undefined, the value of deprecated BluetoothLEAdvertiseData::serviceData attribute is ignored.
Code example:
var advertise = new tizen.BluetoothLEAdvertiseData();
-var service = new tizen.BluetoothLEServiceData("11e5", "0x1811");
-advertise.serviceData = service;
+
+var firstService = new tizen.BluetoothLEServiceData("11e5", "0x1811");
+var secondService = new tizen.BluetoothLEServiceData("a5e8", "0x1815");
+advertise.servicesData = [firstService, secondService];
getGATTServer
+BluetoothGATTServer getGATTServer();
Since: + 6.0 +
+Privilege level: + public +
+Privilege: + http://tizen.org/privilege/bluetooth +
+Return value:
+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 AbortError, if any other error occurs. +
Code example:
var server = tizen.bluetooth.getGATTServer(); ++
toByteArray
Code example:
var dataInt8Array = new Int8Array([-21, 31]);
var dataUint8Array = new Uint8Array([240, 129]);
var dataString = "0x18b1";
-console.log("converted from Int8Array: " + tizen.bluetooth.toByteArray(dataInt8Array));
-console.log("converted from Uint8Array: " + tizen.bluetooth.toByteArray(dataUint8Array));
-console.log("converted from DOMString: " + tizen.bluetooth.toByteArray(dataString));
+
+var fromInt8Array = tizen.bluetooth.toByteArray(dataInt8Array);
+var fromUint8Array = tizen.bluetooth.toByteArray(dataUint8Array);
+var fromString = tizen.bluetooth.toByteArray(dataString);
+
+console.log("converted from Int8Array: " + JSON.stringify(fromInt8Array));
+console.log("converted from Uint8Array: " + JSON.stringify(fromUint8Array));
+console.log("converted from DOMString: " + JSON.stringify(fromString));
Output example:
converted from Int8Array: Int8Array(2) [-21, 31] -converted from Uint8Array: Int8Array(2) [-16, -127] -converted from DOMString: Int8Array(2) [24, -79] +Output example:
converted from Int8Array: [235, 31] +converted from Uint8Array: [240, 129] +converted from DOMString: [244, 177]
Code example:
var dataInt8Array = new Int8Array([-21, 31]);
var dataUint8Array = new Uint8Array([240, 129]);
var dataString = "0x18b1";
-console.log("converted from Int8Array: " + tizen.bluetooth.toUint8Array(dataInt8Array));
-console.log("converted from Uint8Array: " + tizen.bluetooth.toUint8Array(dataUint8Array));
-console.log("converted from DOMString: " + tizen.bluetooth.toUint8Array(dataString));
+
+var fromInt8Array = tizen.bluetooth.toUint8Array(dataInt8Array);
+var fromUint8Array = tizen.bluetooth.toUint8Array(dataUint8Array);
+var fromString = tizen.bluetooth.toUint8Array(dataString);
+
+console.log("converted from Int8Array: " + JSON.stringify(fromInt8Array));
+console.log("converted from Uint8Array: " + JSON.stringify(fromUint8Array));
+console.log("converted from DOMString: " + JSON.stringify(fromString));
Output example:
converted from Int8Array: Uint8Array(2) [235, 31] -converted from Uint8Array: Uint8Array(2) [240, 129] -converted from DOMString: Uint8Array(2) [24, 177] +Output example:
converted from Int8Array: {"0":235, "1":31} +converted from Uint8Array: {"0":240, "1":129} +converted from DOMString: {"0":24, "1":177}
Code example:
tizen.bluetooth.uuidTo128bit("1234");
-tizen.bluetooth.uuidTo128bit("ab5690ef");
-tizen.bluetooth.uuidTo128bit("abcdef01-2345-6789-abcd-ef0123456789");
+Code example:
var uuidFrom16bits = tizen.bluetooth.uuidTo128bit("1234");
+var uuidFrom32bits = tizen.bluetooth.uuidTo128bit("ab5690ef");
+var uuidFrom128bits = tizen.bluetooth.uuidTo128bit("abcdef01-2345-6789-abcd-ef0123456789");
+
+console.log(uuidFrom16bits);
+console.log(uuidFrom32bits);
+console.log(uuidFrom128bits);
[NoInterfaceObject] interface BluetoothLEAdapter {
void startScan(BluetoothLEScanCallback successCallback, optional ErrorCallback? errorCallback) raises(WebAPIException);
void stopScan() raises(WebAPIException);
+ boolean isScanning() 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);
+ long addConnectStateChangeListener(BluetoothLEConnectChangeCallback listener) raises(WebAPIException);
+ void removeConnectStateChangeListener(long watchID);
};
Since: 6.0 @@ -2677,6 +2887,56 @@
isScanning
+boolean isScanning();
Since: + 6.0 +
+Return value:
+Exceptions:
++ with error type NotSupportedError, if the device does not support this functionality. +
+ with error type UnknownError, if any other error occurs. +
Code example:
var adapter = tizen.bluetooth.getLEAdapter();
+var scanningStarted = adapter.isScanning();
+console.log("Scanning status: " + scanningStarted);
+if (!scanningStarted)
+{
+ adapter.startScan(function onsuccess(device)
+ {
+ console.log("Scanning status: " + adapter.isScanning());
+ adapter.stopScan();
+ });
+}
+
+Output example:
Scanning status: false +Scanning status: true ++
startAdvertise
with error type QuotaExceededError, if any input attribute is not compatible with the maximum data size for this attribute.
+ with error type InvalidValuesError, if advertising services data contains duplicated UUIDs. +
with error type InvalidStateError, if device is currently in progress of advertising, if the local Bluetooth le adapter is currently not enabled.
addConnectStateChangeListener
+long addConnectStateChangeListener(BluetoothLEConnectChangeCallback listener);
Since: + 6.0 +
++The BluetoothLEConnectChangeCallback, registered with this function, is called in the following cases: +
+Parameters:
+Return value:
+Exceptions:
++ with error type TypeMismatchError, if the input parameter is not compatible with the expected type for that parameter. +
Code example:
/* This application is running the local GATT Server and does not connect to remote GATT servers. */
+/* To be able to notify connected clients about characteristic values' changes, it saves their data. */
+var connectedClients = [];
+
+function onConnected(device)
+{
+ console.log("A client connected: " + device.address);
+ connectedClients.push(device);
+}
+
+function onDisconnected(device)
+{
+ console.log("A client disconnected: " + device.address);
+ connectedClients = connectedClients.filter(function(connectedClient)
+ {
+ return connectedClient.address !== device.address;
+ });
+}
+
+tizen.bluetooth.getLEAdapter().addConnectStateChangeListener(
+ {onconnected: onConnected, ondisconnected: onDisconnected});
+
+Output example:
A client connected: 6A:33:B1:17:D4:81 +A client connected: 4B:1F:DD:35:41:19 +A client connected: CC:D4:11:E5:72:4B +A client disconnected: 6A:33:B1:17:D4:81 ++
removeConnectStateChangeListener
+void removeConnectStateChangeListener(long watchID);
Since: + 6.0 +
++This function unregisters a BluetoothLEConnectChangeCallback registered with BluetoothLEAdapter.addConnectStateChangeListener() method. +
+Parameters:
+Code example:
/* This application is running the local GATT Server and does not connect to remote GATT servers. */
+function onConnected(device)
+{
+ console.log("A client connected: " + device.address);
+}
+
+function onDisconnected(device)
+{
+ console.log("A client disconnected: " + device.address);
+}
+
+/* Save watchId to be able to remove the listener later */
+var watchId = tizen.bluetooth.getLEAdapter().addConnectStateChangeListener(
+ {onconnected: onConnected, ondisconnected: onDisconnected});
+
+/* A little later, the listener is no longer needed, and can be removed with */
+/* removeConnectStateChangeListener(watchId) method */
+
+Output example:
A client connected: 6A:33:B1:17:D4:81 +A client connected: 4B:1F:DD:35:41:19 +A client connected: CC:D4:11:E5:72:4B +A client disconnected: 6A:33:B1:17:D4:81 ++
[NoInterfaceObject] interface BluetoothGATTService {
readonly attribute BluetoothUUID? serviceUuid;
- readonly attribute BluetoothGATTService[] services;
- readonly attribute BluetoothGATTCharacteristic[] characteristics;
+ readonly attribute BluetoothGATTServiceVariant[] services;
+ readonly attribute BluetoothGATTCharacteristicVariant[] characteristics;
};
Since: 6.0 @@ -2917,13 +3310,16 @@
Since: 6.0
+Remark: + It can be either type BluetoothGATTService for services retrieved from remote GATT servers or type BluetoothGATTServerService for services retrieved from the local GATT server. +
Code example:
var service = device.getService(device.uuids[0]); for (var i = 0; i < service.services.length; ++i) @@ -2935,13 +3331,16 @@Attributes
Since: 6.0
+Remark: + It can be either type BluetoothGATTCha racteristic for characteristics retrieved from services of remote GATT servers or type BluetoothGATTServerCharacteristic for characteristics retrieved from services of local GATT server. +
Code example:
var service = device.getService(device.uuids[0]); for (var i = 0; i < service.characteristics.length; ++i) @@ -2954,14 +3353,155 @@Attributes
[NoInterfaceObject] interface BluetoothGATTCharacteristic {
- readonly attribute BluetoothGATTDescriptor[] descriptors;
- readonly attribute boolean isBroadcast;
+ dictionary BluetoothGATTServerServiceInit {
+ BluetoothUUID serviceUuid;
+ boolean isPrimary = true;
+ BluetoothGATTServerServiceInit[]? includedServices = null;
+ BluetoothGATTServerCharacteristicInit[]? characteristics = null;
+ };
+Since:
+ 6.0
+
+
+
+This dictionary defines the GATT services to be registered to the local GATT server.
+
+
+
+Code example:
/* serviceA and serviceB are objects of type BluetoothGATTServerServiceInit. */
+/* hrmCharacteristic is a BluetoothGATTServerCharacteristicInit object. */
+var serviceParameters =
+{
+ serviceUuid: "4b102e75",
+ isPrimary: true,
+ includedServices: [serviceA, serviceB],
+ characteristics: [hrmCharacteristic]
+};
+
+
+[NoInterfaceObject] interface BluetoothGATTServerService : BluetoothGATTService { + readonly attribute boolean isPrimary; + void unregister(optional SuccessCallback? successCallback, optional ErrorCallback? errorCallback) raises(WebAPIException); + };+
Since: + 6.0 +
+ +Since: + 6.0 +
+unregister
+void unregister(optional SuccessCallback? successCallback, optional ErrorCallback? errorCallback);
Since: + 6.0 +
++The ErrorCallback is launched with these error types: +
+Privilege level: + public +
+Privilege: + http://tizen.org/privilege/bluetooth +
+Remark: + GATT services included in other GATT services cannot be unregistered. +
+Remark: + If this method is called for the only GATT service, currently registered in the local running GATT server, the server stops running. +
+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. +
+ with error type AbortError, if any other error occurs. +
Code example:
/* The service has been registered in the GATT server for a while. Now it is no longer needed. */
+function onsuccess()
+{
+ console.log("Service unregistered");
+}
+
+function onerror(error)
+{
+ console.log("Failed to unregister service: " + error.message);
+}
+
+tizen.bluetooth.getGATTServer().services[0].unregister(onsuccess, onerror);
+
+ [NoInterfaceObject] interface BluetoothGATTCharacteristic {
+ readonly attribute BluetoothGATTDescriptorVariant[] descriptors;
+ readonly attribute boolean isBroadcast;
readonly attribute boolean hasExtendedProperties;
readonly attribute boolean isNotify;
readonly attribute boolean isIndication;
@@ -2984,13 +3524,16 @@ Attributes
Since: 6.0
+Remark: + The type of this field is BluetoothGATTDescriptor for descriptors of characteristics retrieved from services of remote GATT servers and BluetoothGATTServerDescriptor for descriptors of characteristics retrieved from the services of local GATT server. +
Privilege: http://tizen.org/privilege/bluetooth
+Remark: + BluetothGATTServerCharacteristic objects do not support this function. An attempt to call it for such an object will result in an exception. +
Parameters:
with error type SecurityError, if the application does not have the privilege to call this method.
+ with error type NotSupportedError, if the method is called for BluetoothGATTServerCharacteristic. +
Privilege: http://tizen.org/privilege/bluetooth
+Remark: + BluetothGATTServerCharacteristic objects do not support this function. An attempt to call it for such an object will result in an exception. +
Parameters:
with error type SecurityError, if the application does not have the privilege to call this method.
+ with error type NotSupportedError, if the method is called for BluetoothGATTServerCharacteristic. +
Privilege: http://tizen.org/privilege/bluetooth
+Remark: + BluetothGATTServerCharacteristic objects do not support this function. An attempt to call it for such an object will result in an exception. +
Parameters:
Exceptions:
-+
with error type SecurityError, if the application does not have the privilege to call this method. -
+ with error type NotSupportedError, if the method is called for BluetoothGATTServerCharacteristic. +
Remark: Example of using can be find at addValueChangeListener code example.
+Remark: + Value change listeners cannot be registered and thus unregistered for BluetothGATTServerCharacteristic objects. An attempt to remove value change listener for such an object will result in no operation. +
Parameters:
[NoInterfaceObject] interface BluetoothGATTDescriptor {
- readonly attribute BluetoothUUID? uuid;
- void readValue(ReadValueSuccessCallback successCallback, optional ErrorCallback? errorCallback) raises(WebAPIException);
- void writeValue(Bytes value, optional SuccessCallback? successCallback, optional ErrorCallback? errorCallback)
- raises(WebAPIException);
+ dictionary BluetoothGATTServerCharacteristicInit {
+ BluetoothUUID uuid;
+ BluetoothGATTServerDescriptorInit[]? descriptors = null;
+ boolean isBroadcast = false;
+ boolean hasExtendedProperties = false;
+ boolean isNotify = false;
+ boolean isIndication = false;
+ boolean isReadable = false;
+ boolean isSignedWrite = false;
+ boolean isWritable = false;
+ boolean isWriteNoResponse = false;
+ boolean readPermission = false;
+ boolean writePermission = false;
+ boolean encryptedReadPermission = false;
+ boolean encryptedWritePermission = false;
+ boolean encryptedSignedReadPermission = false;
+ boolean encryptedSignedWritePermission = false;
+ ReadValueRequestCallback? readValueRequestCallback = null;
+ SuccessCallback? readValueSendResponseSuccessCallback = null;
+ ErrorCallback? readValueSendResponseErrorCallback = null;
+ WriteValueRequestCallback? writeValueRequestCallback = null;
+ SuccessCallback? writeValueSendResponseSuccessCallback = null;
+ ErrorCallback? writeValueSendResponseErrorCallback = null;
};
Since:
6.0
-
+
+
+This dictionary is used as a definition of a characteristic to be registered in a service of the local GATT server.
readValueRequestCallback and writeValueRequestCallback are callbacks called when a client reads or writes the value of the characteristic respectively. They can be set or replaced with another functions, after registering the service containing the characteristic, with BluetoothGATTServerCharacteristic.setReadValueRequestCallback() and BluetoothGATTServerCharacteristic.setWriteValueRequestCallback().
readValueSendResponseSuccessCallback and writeValueSendResponseSuccessCallback are success callbacks called when a response sent from readValueRequestCallback or writeValueRequestCallback reaches client. They can be set or replaced with another functions, after registering the service containing the characteristic, with BluetoothGATTServerCharacteristic.setReadValueRequestCallback() and BluetoothGATTServerCharacteristic.setWriteValueRequestCallback().
readValueSendResponseErrorCallback and writeValueSendResponseErrorCallback are error callbacks called when an attempt to send a response to a client from readValueRequestCallback or writeValueRequestCallback fails. They can be set or replaced with another functions, after registering the service containing the characteristic, with BluetoothGATTServerCharacteristic.setReadValueRequestCallback() and BluetoothGATTServerCharacteristic.setWriteValueRequestCallback().
+
+
+
+Code example:
/* nameDescriptor, placeDescriptor are BluetoothGATTServerDescriptorInit objects */
+/* readValueCallback, writeValueCallback are read/write request callbacks */
+/* readValueSendResponseSuccessCallback and writeValueSendResponseSuccessCallback */
+/* are success callbacks */
+/* and writeValueSendResponseErrorCallback and readValueSendResponseErrorCallback */
+/* are error callbacks */
+var characteristicParameters =
+{
+ uuid: "0180",
+ descriptors: [nameDescriptor, placeDescriptor],
+ /* Characteristic's properties */
+ isBroadcast: false,
+ hasExtendedProperties: false,
+ isNotify: false,
+ isIndication: false,
+ isReadable: true,
+ isSignedWrite: false,
+ isWritable: true,
+ isWriteNoResponse: false,
+ /* Characteristic's permissions */
+ readPermission: true,
+ writePermission: true,
+ encryptedReadPermission: false,
+ encryptedWritePermission: false,
+ encryptedSignedReadPermission: false,
+ encryptedSignedWritePermission: false,
+ readValueRequestCallback: readValueCallback,
+ readValueSendResponseSuccessCallback: readValueSendResponseSuccessCallback,
+ readValueSendResponseErrorCallback: readValueSendResponseErrorCallback,
+ writeValueRequestCallback: writeValueCallback,
+ writeValueSendResponseSuccessCallback: writeValueSendResponseSuccessCallback,
+ writeValueSendResponseErrorCallback: writeValueSendResponseErrorCallback
+};
+
+
+
+
+2.14. BluetoothGATTServerCharacteristic
+
+ A subclass representing GATT characteristic used to construct a service of the local Bluetooth GATT server.
+It extends BluetoothGATTCharacteristic with permissions and methods implementing interactions of the characteristic with remote clients.
+
+ [NoInterfaceObject] interface BluetoothGATTServerCharacteristic : BluetoothGATTCharacteristic {
+ readonly attribute boolean readPermission;
+ readonly attribute boolean writePermission;
+ readonly attribute boolean encryptedReadPermission;
+ readonly attribute boolean encryptedWritePermission;
+ readonly attribute boolean encryptedSignedReadPermission;
+ readonly attribute boolean encryptedSignedWritePermission;
+ void notifyAboutValueChange(Bytes value, BluetoothAddress? clientAddress, optional NotificationCallback? notificationCallback,
+ optional ErrorCallback? errorCallback) raises(WebAPIException);
+ void setReadValueRequestCallback(ReadValueRequestCallback readValueRequestCallback, optional SuccessCallback? successCallback,
+ optional ErrorCallback? errorCallback, optional SuccessCallback? sendResponseSuccessCallback,
+ optional ErrorCallback? sendResponseErrorCallback) raises(WebAPIException);
+ void setWriteValueRequestCallback(WriteValueRequestCallback writeValueRequestCallback, optional SuccessCallback? successCallback,
+ optional ErrorCallback? errorCallback, optional SuccessCallback? sendResponseSuccessCallback,
+ optional ErrorCallback? sendResponseErrorCallback) raises(WebAPIException);
+ };
+Since:
+ 6.0
+
+
+
Attributes
--
+
+-
readonly
-BluetoothUUID uuid [nullable]
- UUID of the descriptor.
+boolean readPermission
+ Indicates if clients have the permission to read the value of the characteristic.
Since:
6.0
-Remark:
- uuid is set to null, if the value cannot be retrieved.
+
+
-
+ readonly
+boolean writePermission
+ Indicates if clients have the permission to write the value of the characteristic.
+
+
Since:
+ 6.0
-
+
+-
+ readonly
+boolean encryptedReadPermission
+ Indicates if clients have the permission to read the value of the characteristic through encrypted connections.
+
+
Since:
+ 6.0
+
+
+-
+ readonly
+boolean encryptedWritePermission
+ Indicates if clients have the permission to write the value of the characteristic through encrypted connections.
+
+
Since:
+ 6.0
+
+
+-
+ readonly
+boolean encryptedSignedReadPermission
+ Indicates if clients have the permission to perform signed reads of the characteristic's value.
+
+
Since:
+ 6.0
+
+
+-
+ readonly
+boolean encryptedSignedWritePermission
+ Indicates if clients have the permission to perform signed writes of the characteristic's value.
+
+
Since:
+ 6.0
+
+
+
Methods
--
-
readValue
+-
+
notifyAboutValueChange
-
- Reads descriptor value from remote device. Updates descriptor value attribute.
+ Notifies the clients of the local GATT server of the changes in the characteristic.
-
void readValue(ReadValueSuccessCallback successCallback, optional ErrorCallback? errorCallback);
+void notifyAboutValueChange(Bytes value, BluetoothAddress? clientAddress, optional NotificationCallback? notificationCallback,
+ optional ErrorCallback? errorCallback);
Since:
6.0
+This function sends a BLE notification or indication about a change of characteristic's value to clients that registered for it. If a particular client is specified, only he gets the update.
+Otherwise it is sent to all clients connected to the local GATT server, who registered for the updates.
+
+Clients can only register for characteristic's notifications or indications, if the characteristic defines a Client Characteristic Configuration Descriptor (CCCD), as described in the Bluetooth standard.
+CCCD has to be defined as any other descriptor, using BluetoothGATTServerDescriptorInit.
+
+
+
+
The ErrorCallback is launched with these error types:
-
-UnknownError - If any other error occurs
+ InvalidValuesError - If any of the parameters is invalid.
+ -
+ NotSupportedError - If the feature is not supported.
+ -
+ AbortError - If any other error occurs.
Privilege level:
@@ -3436,16 +4146,27 @@
Methods
Privilege:
http://tizen.org/privilege/bluetooth
+Remark:
+ To notify the clients the service with current characteristic must be registered (see BluetoothGATTServer::registerService()) and available for clients (see BluetoothGATTServer::start()).
+
Parameters:
-
-successCallback:
- Callback function that is called when the descriptor value is read successfully.
+value:
+ The new value of the characteristic.
+
+ -
+clientAddress [nullable]:
+ The address of the client to be notified about the value change. If a null is passed, all clients will be notified.
+
+ -
+notificationCallback [optional] [nullable]:
+ The callback called for each attempt of a client notification.
-
errorCallback [optional] [nullable]:
- Callback function that is called in case of failure.
+ Callback function that is called in case of failure of sending notification.
@@ -3455,9 +4176,6 @@ Methods
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.
@@ -3465,179 +4183,1613 @@ Methods
-Code example:
function onerror(e)
-{
- console.log("Failed to connect to device: " + e.message);
-}
-
-function proccessDevice(device)
+Code example:
/* this example assumes that the local gatt server with at least one service which has at least one */
+/* characteristic already exists */
+var callback =
{
- device.connect(onConnected, onerror);
- function onConnected()
+ onnotificationsuccess: function(clientAddress)
{
- 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();
- });
- }
+ console.log(clientAddress + " notified about change.");
+ },
+ onnotificationfail: function(clientAddress, error)
+ {
+ console.error("Couldn't notify " + clientAddress + " about change:" + error.name);
+ },
+ onnotificationfinish: function(clientAddress)
+ {
+ console.log("Finished notifying about change.");
}
-}
+};
-var adapter = tizen.bluetooth.getLEAdapter();
-adapter.startScan(function onsuccess(device)
+function errorCallback(error)
{
- if (device.address == "11:22:33:44:55:66")
- {
- console.log("Found device: " + device.name);
- proccessDevice(device);
- }
-});
+ console.error("Failed to notify about value change: " + error.name + ": " + error.message);
+}
+
+server.services[0].characteristics[0].notifyAboutValueChange("1234", null, callback, errorCallback);
-
--
-
writeValue
+
+-
+
setReadValueRequestCallback
+
+ -
+
+ Registers the callback called when a client reads the value of the characteristic from the local GATT server.
+
+
void setReadValueRequestCallback(ReadValueRequestCallback readValueRequestCallback, optional SuccessCallback? successCallback,
+ optional ErrorCallback? errorCallback, optional SuccessCallback? sendResponseSuccessCallback,
+ optional ErrorCallback? sendResponseErrorCallback);
+Since:
+ 6.0
+
+
+
+The callback, registered with this function, is called when a remote client requests to read the value of the characteristic.
+The server can respond to such requests by returning a GATTRequestReply object from the callback.
+If ReadValueRequestCallback for the characteristic is not registered, or it does not return a GATTRequestReply, clients will not be able to get the value of this characteristic.
+
+A callback set with this function overwrites any previously set ReadValueRequestCallback.
+
+
+The errorCallback will be launched in the following situations:
+
+
+ -
+ NotSupportedError - If the feature is not supported.
+ -
+ AbortError - If any other error occurs.
+
+
+The sendResponseErrorCallback will be launched in the following situations:
+
+
+ -
+ NotSupportedError - If the feature is not supported.
+ -
+ InvalidValuesError - If GATTRequestReply::statusCode or GATTRequestReply::data is invalid.
+ -
+ AbortError - If any other error occurs.
+
+
+Privilege level:
+ public
+
+Privilege:
+ http://tizen.org/privilege/bluetooth
+
+
+Parameters:
+
+ -
+readValueRequestCallback:
+ The callback called when a client reads the value of the characteristic.
+
+ -
+successCallback [optional] [nullable]:
+ Callback function that is called when the readValueRequestCallback is registered successfully.
+
+ -
+errorCallback [optional] [nullable]:
+ Callback function that is called in case of failure of readValueRequestCallback registration.
+
+ -
+sendResponseSuccessCallback [optional] [nullable]:
+ Callback function that is called when responses returned from readValueRequestCallbacks are sent successfully.
+
+ -
+sendResponseErrorCallback [optional] [nullable]:
+ Callback function that is called when responses returned from readValueRequestCallbacks are not sent due to an error.
+
+
+
+
+Exceptions:
+ - WebAPIException
+
+ 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:
/* this example assumes that the local gatt server with at least one service which has at least one */
+/* characteristic already exists */
+var callback = function(clientAddress, offset)
+{
+ console.log(clientAddress + " requested to read characteristic's value with offset: " + offset);
+ return new tizen.GATTRequestReply(0, "0x1234");
+};
+
+server.services[0].characteristics[0].setReadValueRequestCallback(callback);
+
+
+
+-
+
setWriteValueRequestCallback
+
+-
+
+ Registers the callback called when a client writes the value of the characteristic of the local GATT server.
+
+
void setWriteValueRequestCallback(WriteValueRequestCallback writeValueRequestCallback, optional SuccessCallback? successCallback,
+ optional ErrorCallback? errorCallback, optional SuccessCallback? sendResponseSuccessCallback,
+ optional ErrorCallback? sendResponseErrorCallback);
+Since:
+ 6.0
+
+
+
+The callback, registered with this function, is called when a remote client requests to write the value of the characteristic.
+The server can respond to such requests by returning a GATTRequestReply object from the callback.
+If WriteValueRequestCallback for the characteristic is not registered, or it does not return a GATTRequestReply, clients will not be able to get the value of this characteristic.
+
+A callback set with this function overwrites any previously set WriteValueRequestCallback.
+
+
+The errorCallback will be launched in the following situations:
+
+
+ -
+ NotSupportedError - If the feature is not supported.
+ -
+ AbortError - If any other error occurs.
+
+
+The sendResponseErrorCallback will be launched in the following situations:
+
+
+ -
+ NotSupportedError - If the feature is not supported.
+ -
+ InvalidValuesError - If GATTRequestReply::statusCode or GATTRequestReply::data is invalid.
+ -
+ AbortError - If any other error occurs.
+
+
+Privilege level:
+ public
+
+Privilege:
+ http://tizen.org/privilege/bluetooth
+
+
+Parameters:
+
+ -
+writeValueRequestCallback:
+ The callback called when a client writes the value of the characteristic.
+
+ -
+successCallback [optional] [nullable]:
+ Callback function that is called when the writeValueRequestCallback is registered successfully.
+
+ -
+errorCallback [optional] [nullable]:
+ Callback function that is called in case of failure of writeValueRequestCallback registration.
+
+ -
+sendResponseSuccessCallback [optional] [nullable]:
+ Callback function that is called when responses returned from writeValueRequestCallbacks are sent successfully.
+
+ -
+sendResponseErrorCallback [optional] [nullable]:
+ Callback function that is called when responses returned from writeValueRequestCallbacks are not sent due to an error.
+
+
+
+
+Exceptions:
+ - WebAPIException
+
+ 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:
/* this example assumes that the local gatt server with at least one service which has at least one */
+/* characteristic already exists */
+var callback = function(clientAddress, value, offset, replyRequired)
+{
+ console.log(clientAddress + " requested to write characteristic's value: " + value +
+ " with offset: " + offset);
+ return replyRequired ? new tizen.GATTRequestReply(0, "0x1234") : null;
+};
+
+server.services[0].characteristics[0].setWriteValueRequestCallback(callback);
+
+
+
+
+
+
+
+2.15. BluetoothGATTDescriptor
+
+ Bluetooth Low Energy descriptor.
+
+ [NoInterfaceObject] interface BluetoothGATTDescriptor {
+ readonly attribute BluetoothUUID? uuid;
+ void readValue(ReadValueSuccessCallback successCallback, optional ErrorCallback? errorCallback) raises(WebAPIException);
+ void writeValue(Bytes value, optional SuccessCallback? successCallback, optional ErrorCallback? errorCallback)
+ raises(WebAPIException);
+ };
+Since:
+ 6.0
+
+
+Attributes
+-
+ readonly
+BluetoothUUID uuid [nullable]
+ UUID of the descriptor.
+
+
Since:
+ 6.0
+
+Remark:
+ uuid is set to null, if the value cannot be retrieved.
+
+
+
+
+Methods
+
+-
+
readValue
+
+-
+
+ Reads descriptor value from remote device. Updates descriptor value attribute.
+
+
void readValue(ReadValueSuccessCallback successCallback, optional ErrorCallback? errorCallback);
+Since:
+ 6.0
+
+
+
+The ErrorCallback is launched with these error types:
+
+
+ -
+ UnknownError - If any other error occurs
+
+
+Privilege level:
+ public
+
+Privilege:
+ http://tizen.org/privilege/bluetooth
+
+Remark:
+ BluetothGATTServerDescriptor objects do not support this function. An attempt to call it for such an object will result in an exception.
+
+
+Parameters:
+
+ -
+successCallback:
+ Callback function that is called when the descriptor value is read successfully.
+
+ -
+errorCallback [optional] [nullable]:
+ Callback function that is called in case of failure.
+
+
+
+
+Exceptions:
+ - WebAPIException
+
+ 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.
+
+
+ with error type NotSupportedError, if the method is called for BluetoothGATTServerDescriptor.
+
+
+
+
+
+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
+
+-
+
+ Writes the descriptor value to the remote device.
+
+
void writeValue(Bytes value, optional SuccessCallback? successCallback, optional ErrorCallback? errorCallback);
+Since:
+ 6.0
+
+
+
+The ErrorCallback is launched with these error types:
+
+
+ -
+UnknownError - If any other error occurs
+
+
+Privilege level:
+ public
+
+Privilege:
+ http://tizen.org/privilege/bluetooth
+
+Remark:
+ BluetothGATTServerDescriptor objects do not support this function. An attempt to call it for such an object will result in an exception.
+
+
+Parameters:
+
+ -
+value:
+ The descriptor value to write.
+
+ -
+successCallback [optional] [nullable]:
+ Callback function that is called when the descriptor value is written successfully.
+
+ -
+errorCallback [optional] [nullable]:
+ Callback function that is called in case of failure.
+
+
+
+
+Exceptions:
+ - WebAPIException
+
+ 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.
+
+
+ with error type NotSupportedError, if the method is called for BluetoothGATTServerDescriptor.
+
+
+
+
+
+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);
+ }
+});
+
+
+
+
+
+
+
+2.16. BluetoothGATTServerDescriptorInit
+
+ A dictionary for specifying GATT descriptor parameters.
+
+ dictionary BluetoothGATTServerDescriptorInit {
+ BluetoothUUID uuid;
+ boolean readPermission = false;
+ boolean writePermission = false;
+ boolean encryptedReadPermission = false;
+ boolean encryptedWritePermission = false;
+ boolean encryptedSignedReadPermission = false;
+ boolean encryptedSignedWritePermission = false;
+ ReadValueRequestCallback? readValueRequestCallback = null;
+ SuccessCallback? readValueSendResponseSuccessCallback = null;
+ ErrorCallback? readValueSendResponseErrorCallback = null;
+ WriteValueRequestCallback? writeValueRequestCallback = null;
+ SuccessCallback? writeValueSendResponseSuccessCallback = null;
+ ErrorCallback? writeValueSendResponseErrorCallback = null;
+ };
+Since:
+ 6.0
+
+
+
+This dictionary is used as a definition of a descriptor to be registered in a characteristic of the local GATT server.
readValueRequestCallback and writeValueRequestCallback are callbacks called when a client reads or writes the value of the descriptor respectively. They can be set or replaced with another functions after registering the service containing the descriptor with BluetoothGATTServerDescriptor.setReadValueRequestCallback() and BluetoothGATTServerDescriptor.setWriteValueRequestCallback().
readValueSendResponseSuccessCallback and writeValueSendResponseSuccessCallback are success callbacks called when a response sent from readValueRequestCallback or writeValueRequestCallback reaches client. They can be set or replaced with another functions, after registering the service containing the characteristic, with BluetoothGATTServerDescriptor.setReadValueRequestCallback() and BluetoothGATTServerDescriptor.setWriteValueRequestCallback().
readValueSendResponseErrorCallback and writeValueSendResponseErrorCallback are error callbacks called when an attempt to send a response to a client from readValueRequestCallback or writeValueRequestCallback fails. They can be set or replaced with another functions, after registering the service containing the characteristic, with BluetoothGATTServerDescriptor.setReadValueRequestCallback() and BluetoothGATTServerDescriptor.setWriteValueRequestCallback().
+
+
+
+Code example:
/* readValueCallback, writeValueCallback are read/write request callbacks */
+/* readValueSendResponseSuccessCallback and writeValueSendResponseSuccessCallback are success */
+/* callbacks */
+/* and writeValueSendResponseErrorCallback and readValueSendResponseErrorCallback are error */
+/* callbacks */
+var descriptorProperties =
+{
+ uuid: "0180",
+ /* Descriptor's permissions */
+ readPermission: true,
+ writePermission: true,
+ encryptedReadPermission: false,
+ encryptedWritePermission: false,
+ encryptedSignedReadPermission: false,
+ encryptedSignedWritePermission: false,
+ /* Read/write value callbacks */
+ readValueRequestCallback: readValueCallback,
+ readValueSendResponseSuccessCallback: readValueSendResponseSuccessCallback,
+ readValueSendResponseErrorCallback: readValueSendResponseErrorCallback,
+ writeValueRequestCallback: writeValueCallback,
+ writeValueSendResponseSuccessCallback: writeValueSendResponseSuccessCallback,
+ writeValueSendResponseErrorCallback: writeValueSendResponseErrorCallback
+};
+
+
+
+
+2.17. BluetoothGATTServerDescriptor
+
+ A subclass representing GATT descriptors of characteristics registered in services of the local server.
+It extends BluetoothGATTDescriptor with permissions and methods implementing interactions of the descriptor with remote clients.
+
+ [NoInterfaceObject] interface BluetoothGATTServerDescriptor : BluetoothGATTDescriptor {
+ readonly attribute boolean readPermission;
+ readonly attribute boolean writePermission;
+ readonly attribute boolean encryptedReadPermission;
+ readonly attribute boolean encryptedWritePermission;
+ readonly attribute boolean encryptedSignedReadPermission;
+ readonly attribute boolean encryptedSignedWritePermission;
+ void setReadValueRequestCallback(ReadValueRequestCallback readValueRequestCallback, optional SuccessCallback? successCallback,
+ optional ErrorCallback? errorCallback, optional SuccessCallback? sendResponseSuccessCallback,
+ optional ErrorCallback? sendResponseErrorCallback) raises(WebAPIException);
+ void setWriteValueRequestCallback(WriteValueRequestCallback writeValueRequestCallback, optional SuccessCallback? successCallback,
+ optional ErrorCallback? errorCallback, optional SuccessCallback? sendResponseSuccessCallback,
+ optional ErrorCallback? sendResponseErrorCallback) raises(WebAPIException);
+ };
+Since:
+ 6.0
+
+
+
+Attributes
+
+-
+ readonly
+boolean readPermission
+ Indicates if clients have the permission to read the value of the descriptor.
+
+
Since:
+ 6.0
+
+
+-
+ readonly
+boolean writePermission
+ Indicates if clients have the permission to write the value of the descriptor.
+
+
Since:
+ 6.0
+
+
+-
+ readonly
+boolean encryptedReadPermission
+ Indicates if clients have the permission to read the value of the descriptor through encrypted connections.
+
+
Since:
+ 6.0
+
+
+-
+ readonly
+boolean encryptedWritePermission
+ Indicates if clients have the permission to write the value of the descriptor through encrypted connections.
+
+
Since:
+ 6.0
+
+
+-
+ readonly
+boolean encryptedSignedReadPermission
+ Indicates if clients have the permission to perform signed reads of the charactersitic's value.
+
+
Since:
+ 6.0
+
+
+-
+ readonly
+boolean encryptedSignedWritePermission
+ Indicates if clients have the permission to perform signed writes of the charactersitic's value.
+
+
Since:
+ 6.0
+
+
+
+
+
+Methods
+
+-
+
setReadValueRequestCallback
+
+-
+
+ Registers the callback called when a client reads the value of the descriptor from the local GATT server.
+
+
void setReadValueRequestCallback(ReadValueRequestCallback readValueRequestCallback, optional SuccessCallback? successCallback,
+ optional ErrorCallback? errorCallback, optional SuccessCallback? sendResponseSuccessCallback,
+ optional ErrorCallback? sendResponseErrorCallback);
+Since:
+ 6.0
+
+
+
+The callback, registered with this function, is called when a remote client requests to read the value of the descriptor.
+The server can respond to such requests by returning a GATTRequestReply object from the callback.
+If ReadValueRequestCallback for the descriptor is not registered, or it does not return a GATTRequestReply, clients will not be able to get the value of this descriptor.
+
+A callback set with this function overwrites any previously set ReadValueRequestCallback.
+
+
+The errorCallback will be launched in the following situations:
+
+
+ -
+ NotSupportedError - If the feature is not supported.
+ -
+ AbortError - If any other error occurs.
+
+
+The sendResponseErrorCallback will be launched in the following situations:
+
+
+ -
+ NotSupportedError - If the feature is not supported.
+ -
+ InvalidValuesError - If GATTRequestReply::statusCode or GATTRequestReply::data is invalid.
+ -
+ AbortError - If any other error occurs.
+
+
+Privilege level:
+ public
+
+Privilege:
+ http://tizen.org/privilege/bluetooth
+
+
+Parameters:
+
+ -
+readValueRequestCallback:
+ The callback called when a client reads the value of the descriptor.
+
+ -
+successCallback [optional] [nullable]:
+ Callback function that is called when the readValueRequestCallback is registered successfully.
+
+ -
+errorCallback [optional] [nullable]:
+ Callback function that is called in case of failure of readValueRequestCallback registration.
+
+ -
+sendResponseSuccessCallback [optional] [nullable]:
+ Callback function that is called when responses returned from readValueRequestCallbacks are sent successfully.
+
+ -
+sendResponseErrorCallback [optional] [nullable]:
+ Callback function that is called when responses returned from readValueRequestCallbacks are not sent due to an error.
+
+
+
+
+Exceptions:
+ - WebAPIException
+
+ 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:
/* this example assumes that the local gatt server with at least one service which has at least one */
+/* characteristic with at least one descriptor already exists */
+var callback = function(clientAddress, offset)
+{
+ console.log(clientAddress + " requested to read characteristic's value with offset: " + offset);
+ return new tizen.GATTRequestReply(0, "0x1234");
+};
+server.services[0].characteristics[0].descriptors[0].setReadValueRequestCallback(callback);
+
+
+
+-
+
setWriteValueRequestCallback
+
+-
+
+ Registers the callback called when a remote client writes the value of the descriptor from the local GATT server.
+
+
void setWriteValueRequestCallback(WriteValueRequestCallback writeValueRequestCallback, optional SuccessCallback? successCallback,
+ optional ErrorCallback? errorCallback, optional SuccessCallback? sendResponseSuccessCallback,
+ optional ErrorCallback? sendResponseErrorCallback);
+Since:
+ 6.0
+
+
+
+The callback, registered with this function, is called when a remote client requests to write the value of the descriptor.
+The server can respond to such requests by returning a GATTRequestReply object from the callback.
+If WriteValueRequestCallback for the descriptor is not registered, or it does not return a GATTRequestReply, clients will not be able to get the value of this descriptor.
+
+A callback set with this function overwrites any previously set WriteValueRequestCallback.
+
+
+The errorCallback will be launched in the following situations:
+
+
+ -
+ NotSupportedError - If the feature is not supported.
+ -
+ AbortError - If any other error occurs.
+
+
+The sendResponseErrorCallback will be launched in the following situations:
+
+
+ -
+ NotSupportedError - If the feature is not supported.
+ -
+ InvalidValuesError - If GATTRequestReply::statusCode or GATTRequestReply::data is invalid.
+ -
+ AbortError - If any other error occurs.
+
+
+Privilege level:
+ public
+
+Privilege:
+ http://tizen.org/privilege/bluetooth
+
+
+Parameters:
+
+ -
+writeValueRequestCallback:
+ The callback called when a client writes the value of the descriptor.
+
+ -
+successCallback [optional] [nullable]:
+ Callback function that is called when the writeValueRequestCallback is registered successfully.
+
+ -
+errorCallback [optional] [nullable]:
+ Callback function that is called in case of failure of writeValueRequestCallback registration.
+
+ -
+sendResponseSuccessCallback [optional] [nullable]:
+ Callback function that is called when responses returned from writeValueRequestCallbacks are sent successfully.
+
+ -
+sendResponseErrorCallback [optional] [nullable]:
+ Callback function that is called when responses returned from writeValueRequestCallbacks are not sent due to an error.
+
+
+
+
+Exceptions:
+ - WebAPIException
+
+ 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:
/* this example assumes that the local gatt server with at least one service which has at least one */
+/* characteristic with at least one descriptor already exists */
+var callback = function(clientAddress, value, offset, replyRequired)
+{
+ console.log(clientAddress + " requested to write descriptor's value: " + value +
+ " with offset: " + offset);
+ return replyRequired ? new tizen.GATTRequestReply(0, "0x1234") : null;
+};
+server.services[0].characteristics[0].descriptors[0].setWriteValueRequestCallback(callback);
+
+
+
+
+
+
+
+2.18. BluetoothGATTServer
+
+ The BluetoothGATTServer interface provides access to control the local GATT server: starting and stopping it, registering and unregistering local GATT services, and getting the ATT MTU (Attribute Protocol Maximum Transmission Unit) values.
+
+ [NoInterfaceObject] interface BluetoothGATTServer {
+ readonly attribute boolean isRunning;
+ readonly attribute BluetoothGATTServerService[] services;
+ void start(optional SuccessCallback? successCallback, optional ErrorCallback? errorCallback) raises(WebAPIException);
+ void stop(optional SuccessCallback? successCallback, optional ErrorCallback? errorCallback) raises(WebAPIException);
+ void registerService(BluetoothGATTServerServiceInit service, optional SuccessCallback? successCallback,
+ optional ErrorCallback? errorCallback) raises(WebAPIException);
+ void unregisterAllServices(optional SuccessCallback? successCallback, optional ErrorCallback? errorCallback)
+ raises(WebAPIException);
+ void getConnectionMtu(BluetoothAddress clientAddress, ConnectionMtuCallback callback, optional ErrorCallback? errorCallback)
+ raises(WebAPIException);
+ };
+Since:
+ 6.0
+
+
+Attributes
+
+-
+ readonly
+boolean isRunning
+ The flag indicating if remote GATT clients can currently connect to the server, exposing services defined in BluetoothGATTServer::services. It is toggled on start() and stop() calls.
+
+
Since:
+ 6.0
+
+
+-
+ readonly
+BluetoothGATTServerService[]
+ services
+ The list of GATT services hosted on this server.
+
+
Since:
+ 6.0
+
+
+
+
+
+Methods
+
+-
+
start
+
+-
+
+ Starts the local GATT server. After it starts, it can conduct GATT server operations. Also, the remote clients can discover and use the services provided by the local Bluetooth GATT Server.
+
+
void start(optional SuccessCallback? successCallback, optional ErrorCallback? errorCallback);
+Since:
+ 6.0
+
+
+
+The ErrorCallback will be launched in the following situations:
+
+
+ -
+ InvalidStateError - If the server is already running.
+ -
+ NotSupportedError - If the feature is not supported.
+ -
+ AbortError - If any other error occurs.
+
+
+Privilege level:
+ public
+
+Privilege:
+ http://tizen.org/privilege/bluetooth
+
+
+Parameters:
+
+ -
+successCallback [optional] [nullable]:
+ Called when the server is started.
+
+ -
+errorCallback [optional] [nullable]:
+ The method to invoke when an error occurs.
+
+
+
+
+Exceptions:
+ - WebAPIException
+
+ with error type InvalidStateError, if the Bluetooth adapter is not enabled.
+
+
+ with error type TypeMismatchError, if any input attribute is not compatible with the expected type for this attribute.
+
+
+ with error type SecurityError, if the application does not have the privilege to call this method.
+
+
+ with error type AbortError, if any other error occurs.
+
+
+
+
+
+Code example:
var onSuccess = function()
+{
+ console.log("Server started successfully!");
+};
+
+var onError = function(e)
+{
+ console.error("Server didn't start, error: " + e);
+};
+
+var server = tizen.bluetooth.getGATTServer();
+
+server.start(onSuccess, onError);
+
+
+
+Output example:
Server started successfully!
+
+
+
+-
+
stop
+
+-
+
+ Stops GATT server operation.
+
+
void stop(optional SuccessCallback? successCallback, optional ErrorCallback? errorCallback);
+Since:
+ 6.0
+
+
+
+After the stop, remote clients will not be able to discover the local GATT server's services.
+
+
+The ErrorCallback will be launched in the following situations:
+
+
+ -
+ InvalidStateError - If the server is not running.
+ -
+ NotSupportedError - If the feature is not supported.
+ -
+ AbortError - If any other error occurs.
+
+
+Privilege level:
+ public
+
+Privilege:
+ http://tizen.org/privilege/bluetooth
+
+
+Parameters:
+
+ -
+successCallback [optional] [nullable]:
+ Called when the server is stopped.
+
+ -
+errorCallback [optional] [nullable]:
+ The method to invoke when an error occurs.
+
+
+
+
+Exceptions:
+ - WebAPIException
+
+ with error type InvalidStateError, if the Bluetooth adapter is not enabled.
+
+
+ with error type TypeMismatchError, if any input attribute is not compatible with the expected type for this attribute.
+
+
+ with error type SecurityError, if the application does not have the privilege to call this method.
+
+
+ with error type AbortError, if any other error occurs.
+
+
+
+
+
+Code example:
/* this example assumes that local gatt server already exists and it is started */
+var onSuccess = function()
+{
+ console.log("Server stopped successfully!");
+};
+
+var onError = function(e)
+{
+ console.error("Server didn't stop, error: " + e);
+};
+
+server.stop(onSuccess, onError);
+
+
+
+Output example:
Server stopped successfully!
+
+
+
+-
+
registerService
+
+-
+
+ Registers a primary service in the local GATT server.
+
+
void registerService(BluetoothGATTServerServiceInit service, optional SuccessCallback? successCallback,
+ optional ErrorCallback? errorCallback);
+Since:
+ 6.0
+
+
+
+The service is available for clients after BluetoothGATTServer::start() call.
+
+
+
+
+The ErrorCallback is launched with these error types:
+
+
+ -
+ InvalidStateError - If the service cannot be registered in the current state of the server.
+ -
+ NotSupportedError - If the feature is not supported.
+ -
+ InvalidValuesError - If any of the input parameters contains an invalid value
+ -
+ AbortError - If any other error occurs.
+
+
+Privilege level:
+ public
+
+Privilege:
+ http://tizen.org/privilege/bluetooth
+
+Remark:
+ Services can only be registered before starting server.
+
+
+Parameters:
+
+ -
+service:
+ The definition of a service to be registered in the local GATT server.
+
+ -
+successCallback [optional] [nullable]:
+ Called when the local GATT server's services are successfully registered.
+
+ -
+errorCallback [optional] [nullable]:
+ The method to invoke when an error occurs.
+
+
+
+
+Exceptions:
+ - WebAPIException
+
+ with error type InvalidStateError, if the Bluetooth adapter is not enabled.
+
+
+ with error type TypeMismatchError, if any input attribute is not compatible with the expected type for this attribute.
+
+
+ with error type SecurityError, if the application does not have the privilege to call this method.
+
+
+
+
+
+Code example:
var gattService = {serviceUuid: "0955", isPrimary: false, services: [], characteristics: []};
+
+var successCB = function()
+{
+ console.log("Service successfully registered!");
+};
+
+var errorCB = function(e)
+{
+ console.log("Service not registered, error: " + e);
+};
+
+var server = tizen.bluetooth.getGATTServer();
+
+server.registerService(gattService, successCB, errorCB);
+
+
+
+Output example:
Service successfully registered!
+
+
+
+-
+
unregisterAllServices
+
+-
+
+ Unregisters all services from the local GATT server.
+
+
void unregisterAllServices(optional SuccessCallback? successCallback, optional ErrorCallback? errorCallback);
+Since:
+ 6.0
+
+
+
+This method unregisters all services and all their characteristics from the local GATT server.
+
+
+
+
+The ErrorCallback is launched with these error types:
+
+
+ -
+ InvalidStateError - If the service cannot be unregistered in the current state of the GATT server.
+ -
+ AbortError - If any other error occurs
+
+
+Privilege level:
+ public
+
+Privilege:
+ http://tizen.org/privilege/bluetooth
+
+Remark:
+ Currently running local GATT server is stopped after calling this method.
+
+
+Parameters:
+
+ -
+successCallback [optional] [nullable]:
+ Callback function that is called when services are successfully unregistered from the local GATT server.
+
+ -
+errorCallback [optional] [nullable]:
+ Callback function that is called in case of failure.
+
+
+
+
+Exceptions:
+ - WebAPIException
+
+ 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:
/* this example assumes that the local gatt server already exists */
+var successCB = function()
+{
+ console.log("Services successfully unregistered!");
+};
+
+var errorCB = function(e)
+{
+ console.log("Services not unregistered, error: " + e);
+};
+
+server.unregisterAllServices(successCB, errorCB);
+
+
+
+Output example:
Services successfully unregistered!
+
+
+
+-
+
getConnectionMtu
+
+-
+
+ Gets the ATT MTU for the connection with a client.
+
+
void getConnectionMtu(BluetoothAddress clientAddress, ConnectionMtuCallback callback, optional ErrorCallback? errorCallback);
+Since:
+ 6.0
+
+
+
+The ErrorCallback is launched with these error types:
+
+
+ -
+ InvalidStateError - If the server is not running.
+ -
+ NotSupportedError - If the feature is not supported.
+ -
+ AbortError - If any other error occurs.
+
+
+Privilege level:
+ public
+
+Privilege:
+ http://tizen.org/privilege/bluetooth
+
+
+Parameters:
+
+ -
+clientAddress:
+ MAC address of the client, for connection with whom the MTU is to be retrieved.
+
+ -
+callback:
+ Callback functions that are called when the connection state changes.
+
+ -
+errorCallback [optional] [nullable]:
+ Callback function that is called when getting MTU of a connection fails.
+
+
+
+
+Exceptions:
+ - WebAPIException
+
+ 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:
/* this example assumes that the local gatt server already exists */
+var successCB = function(mtu)
+{
+ console.log("ATT MTU value is: " + mtu);
+};
+
+var errorCB = function(e)
+{
+ console.log("Cannot retrieve the ATT MTU, error: " + e);
+};
+
+server.getConnectionMtu("12:34:56:78:90:ab", successCB, errorCB);
+
+
+
+Output example:
ATT MTU value is: 123
+
+
+
+
+
+
+
+2.19. BluetoothLEScanCallback
+
+ Bluetooth scanning process interface that defines the success callback for BluetoothLEAdapter.startScan()
+ [Callback=FunctionOnly, NoInterfaceObject] interface BluetoothLEScanCallback {
+ void onsuccess(BluetoothLEDevice device);
+ };
+Since:
+ 6.0
+
+Remark:
+ Example of using can be find at startScan code example.
+
+
+Methods
+
+-
+
onsuccess
+
+-
+
+ Called when a new device is successfully discovered in the process of scanning.
+
+
void onsuccess(BluetoothLEDevice device);
+Since:
+ 6.0
+
+
+Parameters:
+
+ -
+device:
+ Device that is found.
+
+
+
+
+
+
+
+
+2.20. BluetoothLEAdvertiseCallback
+
+ Bluetooth advertising process interface that defines the success callback for BluetoothLEAdapter.startAdvertise()
+ [Callback=FunctionOnly, NoInterfaceObject] interface BluetoothLEAdvertiseCallback {
+ void onstate(BluetoothAdvertisingState state);
+ };
+Since:
+ 6.0
+
+Remark:
+ Example of using can be find at startAdvertise code example.
+
+
+Methods
+
+-
+
onstate
+
+-
+
+ Called when the advertising state is changed.
+
+
void onstate(BluetoothAdvertisingState state);
+Since:
+ 6.0
+
+
+Parameters:
+
+ -
+state:
+ State that is Advertising process.
+
+
+
+
+
+
+
+
+2.21. BluetoothLEConnectChangeCallback
+
+ Bluetooth LE connecting process interface that defines callbacks for getting notified about changes of connect to a specific LE based service on a remote Bluetooth LE device.
+
+ [Callback, NoInterfaceObject] interface BluetoothLEConnectChangeCallback {
+ void onconnected(BluetoothLEDevice device);
+ void ondisconnected(BluetoothLEDevice device);
+ };
+Since:
+ 6.0
+
+Remark:
+ Example of using can be find at addConnectStateChangeListener code example.
+
+
+Methods
+
+-
+
onconnected
+
+-
+
+ Called at the beginning of connect to a specific LE based service on a remote Bluetooth LE device.
+
+
void onconnected(BluetoothLEDevice device);
+Since:
+ 6.0
+
+
+-
+
ondisconnected
+
+-
+
+ Called at the beginning of disconnect to a specific LE based service on a remote Bluetooth LE device.
+
+
void ondisconnected(BluetoothLEDevice device);
+Since:
+ 6.0
+
+
+
+
+
+
+2.22. ReadValueSuccessCallback
+
+ The ReadValueSuccessCallback interface implements the callback for
+BluetoothGATTCharacteristic.readValue() and
+BluetoothGATTDescriptor.readValue() methods.
+
+ [Callback=FunctionOnly, NoInterfaceObject] interface ReadValueSuccessCallback {
+ void onread(byte[] value);
+ };
+Since:
+ 6.0
+
+Remark:
+ Example of using can be find at BluetoothGATTCharacteristic.readValue() and BluetoothGATTDescriptor.readValue() code examples.
+
+
+
+
+2.23. GATTRequestReply
+
+ Representation of the local GATT server's response to request read/write to characteristic/descriptor.
+
+ [Constructor(long statusCode = 0, optional Bytes data)]
+ interface GATTRequestReply {
+ attribute long statusCode;
+ attribute Bytes? data;
+ };
+Since:
+ 6.0
+
+
+Constructors
+
+
+
+Attributes
+
+-
+long statusCode
+ Reply status code.
+
+
Since:
+ 6.0
+
+
+-
+Bytes data [nullable]
+ Response data. It is only relevant for read value requests. It will be ignored in replies to write requests and thus can be uninitialized in such replies.
+
+
Since:
+ 6.0
+
+
+
+
+
+
+2.24. ReadValueRequestCallback
+
+ The ReadValueRequestCallback interface implements the callback for
+BluetoothGATTServerCharacteristicInit.readValueRequestCallback(),
+BluetoothGATTServerCharacteristic.setReadValueRequestCallback(),
+BluetoothGATTServerDescriptorInit.readValueRequestCallback() and
+BluetoothGATTServerDescriptor.setReadValueRequestCallback().
+
+ [Callback=FunctionOnly, NoInterfaceObject] interface ReadValueRequestCallback {
+ GATTRequestReply? onreadrequest(BluetoothAddress clientAddress, long offset);
+ };
+Since:
+ 6.0
+
+Remark:
+ Example of using can be found at BluetoothGATTServerCharacteristic.setReadValueRequestCallback() and BluetoothGATTServerDescriptor.setReadValueRequestCallback() code examples.
+
+
+Methods
+
+-
+
onreadrequest
-
- Writes the descriptor value to the remote device.
+ Called when a client makes a read request for GATT characteristic to the connected local GATT server.
-
void writeValue(Bytes value, optional SuccessCallback? successCallback, optional ErrorCallback? errorCallback);
+GATTRequestReply? onreadrequest(BluetoothAddress clientAddress, long offset);
Since:
6.0
-The ErrorCallback is launched with these error types:
+The server should reply to requests by returning a GATTRequestReply object with requested data and a proper status code.
+If the callback does not return a GATTRequestReply, the client will not receive a response.
-
- -
-UnknownError - If any other error occurs
-
-Privilege level:
- public
-
-Privilege:
- http://tizen.org/privilege/bluetooth
-
Parameters:
-
-value:
- The descriptor value to write.
-
- -
-successCallback [optional] [nullable]:
- Callback function that is called when the descriptor value is written successfully.
+clientAddress:
+ MAC address of the client that requested the value read of the GATT entity.
-
-errorCallback [optional] [nullable]:
- Callback function that is called in case of failure.
+offset:
+ The offset given for the value of characteristic to read.
-
-Exceptions:
- - WebAPIException
-
- 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);
- }
-});
-
+
+Return value:
+
+GATTRequestReply [nullable]:
+ GATTRequestReply object with a status code and requested data.
+
-
-2.12. BluetoothLEScanCallback
+
+2.25. WriteValueRequestCallback
- Bluetooth scanning process interface that defines the success callback for BluetoothLEAdapter.startScan()
- [Callback=FunctionOnly, NoInterfaceObject] interface BluetoothLEScanCallback {
- void onsuccess(BluetoothLEDevice device);
+ The WriteValueRequestCallback interface implements the callback for
+BluetoothGATTServerCharacteristicInit.writeValueRequestCallback(),
+BluetoothGATTServerCharacteristic.setWriteValueRequestCallback(),
+BluetoothGATTServerDescriptorInit.writeValueRequestCallback() and
+BluetoothGATTServerDescriptor.setWriteValueRequestCallback().
+
+ [Callback=FunctionOnly, NoInterfaceObject] interface WriteValueRequestCallback {
+ GATTRequestReply? onwriterequest(BluetoothAddress clientAddress, byte[] value, long offset, boolean replyRequired);
};
Since:
6.0
Remark:
- Example of using can be find at startScan code example.
+ Example of using can be found at BluetoothGATTServerCharacteristic.setWriteValueRequestCallback() and BluetoothGATTServerDescriptor.setWriteValueRequestCallback() code examples.
Methods
--
-
onsuccess
+-
+
onwriterequest
-
- Called when a new device is successfully discovered in the process of scanning.
+ Called when a client connected to the local GATT server requests characteristic's value write.
-
void onsuccess(BluetoothLEDevice device);
+GATTRequestReply? onwriterequest(BluetoothAddress clientAddress, byte[] value, long offset, boolean replyRequired);
Since:
6.0
+
+
+The server should reply to requests by returning a GATTRequestReply object with a status code.
+If the callback does not return a GATTRequestReply, the client will not receive a response.
+
+
Parameters:
-
-device:
- Device that is found.
+clientAddress:
+ MAC address of the client that requested the value write of the GATT entity.
+
+ -
+value:
+ Value to be written to the GATT entity.
+
+ -
+offset:
+ Offset from which the value is to be written.
+
+ -
+replyRequired:
+ Flag indicating whether the client requested an answer to the request. If it's false, the client preforms the write without response operation defined in Bluetooth Core Specification.
@@ -3645,30 +5797,33 @@ Methods
-
-2.13. BluetoothLEAdvertiseCallback
+
+2.26. NotificationCallback
- Bluetooth advertising process interface that defines the success callback for BluetoothLEAdapter.startAdvertise()
- [Callback=FunctionOnly, NoInterfaceObject] interface BluetoothLEAdvertiseCallback {
- void onstate(BluetoothAdvertisingState state);
+ The NotificationCallback interface implements the success callback for BluetoothGATTServerCharacteristic.notifyAboutValueChange().
+
+ [Callback=FunctionOnly, NoInterfaceObject] interface NotificationCallback {
+ void onnotificationsuccess(BluetoothAddress clientAddress);
+ void onnotificationfail(BluetoothAddress clientAddress, WebAPIException error);
+ void onnotificationfinish(BluetoothAddress clientAddress);
};
Since:
6.0
Remark:
- Example of using can be find at startAdvertise code example.
+ Example of using can be found at BluetoothGATTServerCharacteristic.notifyAboutValueChange() code examples.
Methods
--
-
onstate
+-
+
onnotificationsuccess
-
- Called when the advertising state is changed.
+ Called when the local GATT server successfully notifies a client of a characteristic's value change.
-
void onstate(BluetoothAdvertisingState state);
+void onnotificationsuccess(BluetoothAddress clientAddress);
Since:
6.0
@@ -3676,87 +5831,86 @@ Methods
Parameters:
-
-state:
- State that is Advertising process.
+clientAddress:
+ MAC address of the client that was notified.
-
-
-
-
-2.14. BluetoothLEConnectChangeCallback
-
- Bluetooth LE connecting process interface that defines callbacks for getting notified about changes of connect to a specific LE based service on a remote Bluetooth LE device.
-
- [Callback, NoInterfaceObject] interface BluetoothLEConnectChangeCallback {
- void onconnected(BluetoothLEDevice device);
- void ondisconnected(BluetoothLEDevice device);
- };
-Since:
- 6.0
-
-Remark:
- Example of using can be find at addConnectStateChangeListener code example.
-
-
-Methods
-
--
-
onconnected
+-
+
onnotificationfail
-
- Called at the beginning of connect to a specific LE based service on a remote Bluetooth LE device.
+ Called when the local GATT server fails to notify a client of a characteristic's value change.
-
void onconnected(BluetoothLEDevice device);
+void onnotificationfail(BluetoothAddress clientAddress, WebAPIException error);
Since:
6.0
+
+Parameters:
+
+ -
+clientAddress:
+ MAC address of the client that was notified.
+
+ -
+error:
+ The error type and an error message from Tizen's Bluetooth LE stack.
+
+
+
--
-
ondisconnected
+-
+
onnotificationfinish
-
- Called at the beginning of disconnect to a specific LE based service on a remote Bluetooth LE device.
+ Called when the last of all client notifications was sent.
-
void ondisconnected(BluetoothLEDevice device);
+void onnotificationfinish(BluetoothAddress clientAddress);
Since:
6.0
+
+Parameters:
+
+ -
+clientAddress:
+ MAC address of the last client that was notified.
+
+
+
-
-2.15. ReadValueSuccessCallback
+
+2.27. ConnectionMtuCallback
- The ReadValueSuccessCallback interface implements the callback for
-BluetoothGATTCharacteristic.readValue() and
-BluetoothGATTDescriptor.readValue() methods.
+ The ConnectionMtuCallback interface implements the callback for BluetoothGATTServer.getConnectionMtU().
- [Callback=FunctionOnly, NoInterfaceObject] interface ReadValueSuccessCallback {
- void onread(byte[] value);
+ [Callback=FunctionOnly, NoInterfaceObject] interface ConnectionMtuCallback {
+ void onsuccess(long mtu);
};
Since:
6.0
Remark:
- Example of using can be find at BluetoothGATTCharacteristic.readValue() and BluetoothGATTDescriptor.readValue() code examples.
+ Example of using can be found at BluetoothGATTServer.getConnectionMtu() code example.
Methods
--
-
onread
+-
+
onsuccess
-
- Called when a characteristic value has been read.
+ Called when the requested ATT MTU size for a connection is ready.
-
void onread(byte[] value);
+void onsuccess(long mtu);
Since:
6.0
@@ -3764,8 +5918,8 @@ Methods
Parameters:
-
-value:
- Read characteristic value.
+mtu:
+ The requested ATT MTU value for the connection with another Bluetooth LE device.
@@ -3774,7 +5928,7 @@ Methods
Since: 6.0 @@ -4168,6 +6327,8 @@
Since: 6.0
+Remark: + This value will be set to null, if the object is obtained from BluetoothLEConnectChangeCallback. +
Code example:
var adapter = tizen.bluetooth.getLEAdapter(); adapter.startScan(function onsuccess(device) @@ -4220,6 +6384,9 @@Attributes
Since: 6.0
+Remark: + This value will be set to null, if the object is obtained from BluetoothLEConnectChangeCallback. +
Code example:
var adapter = tizen.bluetooth.getLEAdapter(); adapter.startScan(function onsuccess(device) @@ -4237,6 +6404,9 @@Attributes
Since: 6.0
+Remark: + This value will be set to null, if the object is obtained from BluetoothLEConnectChangeCallback. +
Code example:
var adapter = tizen.bluetooth.getLEAdapter(); adapter.startScan(function onsuccess(device) @@ -4255,6 +6425,9 @@Attributes
Since: 6.0
+Remark: + This value will be set to null, if the object is obtained from BluetoothLEConnectChangeCallback. +
Code example:
var adapter = tizen.bluetooth.getLEAdapter(); adapter.startScan(function onsuccess(device) @@ -4279,6 +6452,9 @@Attributes
Since: 6.0
+Remark: + This value will be set to null, if the object is obtained from BluetoothLEConnectChangeCallback. +
Code example:
var adapter = tizen.bluetooth.getLEAdapter(); adapter.startScan(function onsuccess(device) @@ -4306,6 +6482,9 @@Attributes
Remark: On devices prior to Tizen 6.0, service data is found only when its BluetoothLEServiceData::uuid is 16-bit. Finding service data with 128-bit BluetoothLEServiceData::uuid is supported since Tizen 6.0.
+Remark: + This value will be set to null, if the object is obtained from BluetoothLEConnectChangeCallback. +
Code example:
var adapter = tizen.bluetooth.getLEAdapter(); adapter.startScan(function onsuccess(device) @@ -4329,6 +6508,9 @@Attributes
Since: 6.0
+Remark: + This value will be set to null, if the object is obtained from BluetoothLEConnectChangeCallback. +
Code example:
var adapter = tizen.bluetooth.getLEAdapter(); @@ -4367,7 +6549,7 @@Attributes
- readonly -long rssi
+long rssi [nullable]The received signal strength indicator in dBm (decibel-milliwatts) units.@@ -4378,6 +6560,9 @@+Attributes
Since: 6.0
+Remark: + Since Tizen 6.0, this value can be a null, but only if the object is obtained from BluetoothLEConnectChangeCallback. +
+ +Code example:
var adapter = tizen.bluetooth.getLEAdapter(); adapter.startScan(function onsuccess(device) @@ -4542,21 +6727,82 @@+Methods
console.log("Disconnected"); } - function onconnected() - { - console.log("Connected to device"); - device.disconnect(ondisconnect, onerror); - } + 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); +- +
+isConnected+- +
@@ -4741,7 +6987,7 @@+ Checks if Bluetooth Low Energy device is currently connected. +++boolean isConnected();Since: + 6.0 +
+++Return value:
++boolean: + true if the device is currently connected, false otherwise. +
+++Exceptions:
++
- WebAPIException
+
+ with error type UnknownError, if any error occurs. +
++Code example:
var dev; + +function onerror(e) +{ + console.log("Failed to connect to device: " + e.message); +} + +function onconnected() +{ + console.log("Connected to device: " + dev.isConnected()); +} +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); + adapter.stopScan(); + dev = device; + var connected = dev.isConnected(); + console.log("Found device: " + device.name + ", connected: " + connected); + if (!connected) + { + device.connect(onconnected, onerror); + } } -} - -var adapter = tizen.bluetooth.getLEAdapter(); -adapter.startScan(onDeviceFound, onerror); +}); +++Output example:
Found device: TestDevice, connected: false +Connected to device: trueMethods
@@ -4838,11 +7084,282 @@Exceptions:
- WebAPIException
- with error type UnknownError, if any other error occurs. + with error type TypeMismatchError, if the input parameter is not compatible with the expected type for that parameter.
Methods
- +
+getAttMtu+- +
++ Gets the current value of Attribute Protocol(ATT) Maximum Transmission Unit(MTU) from the connected device. +++unsigned long getAttMtu();Since: + 6.0 +
+++Return value:
++unsigned long: + Current ATT MTU value. +
+++Exceptions:
++
- WebAPIException
+
+- +
+ with error type InvalidStateError, if the remote device is not connected. +
- +
+ with error type UnknownError, if any other error occurs. +
++Code example:
var dev; + +function onerror(e) +{ + console.log("Failed to connect to device: " + e.message); +} + +function onconnected() +{ + console.log("Connected to device, ATT MTU: " + dev.getAttMtu()); +} + +var adapter = tizen.bluetooth.getLEAdapter(); +adapter.startScan(function onsuccess(device) +{ + if (device.address == "11:22:33:44:55:66") + { + dev = device; + console.log("Found device: " + device.name); + device.connect(onconnected, onerror); + } +}); ++++Output example:
Found device: TestDevice +Connected to device, ATT MTU: 23 ++- +
+requestAttMtuChange+- +
++ Requests the GATT server to change the Attribute Protocol (ATT) Maximum Transmission Unit (MTU) value. +++void requestAttMtuChange(unsigned long newAttMtu);Since: + 6.0 +
+Remark: + ATT MTU value is determined between two connected devices and change will be successful only if both devices support the given value of ATT MTU. +
+++Parameters:
++
+- +newAttMtu: + The new ATT MTU value, that will be sent to GATT server. +
+++Exceptions:
++
- WebAPIException
+
+ with error type UnknownError, if any error occurs. +
++Code example:
function proccessDevice(device) +{ + function onConnected() + { + var attMtu = device.getAttMtu(); + console.log("Initial ATT MTU value: " + attMtu); + watchID = device.addAttMtuChangeListener(function(value) + { + console.log("ATT MTU changed to: " + value); + device.removeAttMtuChangeListener(watchID); + device.disconnect(); + }); + device.requestAttMtuChange(64); + } + 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); + } +}); ++++Output example:
Found device: TestDevice +Initial ATT MTU value: 31 +ATT MTU changed to: 64 ++- +
+addAttMtuChangeListener+- +
++ Registers a listener to be called when ATT MTU value is changed. +++long addAttMtuChangeListener(ConnectionMtuCallback callback);Since: + 6.0 +
+Remark: + ATT MTU value is determined between two connected devices and change takes place after both devices agrees to new value, both connected devices can initiate the ATT MTU value change by sending the request. +
+++Parameters:
++
+- +callback: + Listener function that is called when the connection's ATT MTU changes. +
+++Return value:
++long: + The watchID to be used to unregister the listener. +
+++Exceptions:
++
- WebAPIException
+
+- +
+ with error type TypeMismatchError, if an input attribute is not compatible with the expected type for this attribute. +
- +
+ with error type UnknownError, if any other error occurs. +
++Code example:
function proccessDevice(device) +{ + function onConnected() + { + var attMtu = device.getAttMtu(); + console.log("Initial ATT MTU value: " + attMtu); + watchID = device.addAttMtuChangeListener(function(value) + { + console.log("ATT MTU changed to: " + value); + device.removeAttMtuChangeListener(watchID); + device.disconnect(); + }); + device.requestAttMtuChange(64); + } + 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); + } +}); ++++Output example:
Found device: TestDevice +Initial ATT MTU value: 31 +ATT MTU changed to: 64 ++- +
+removeAttMtuChangeListener+- +
+ Unregisters the ATT MTU value change listener. +++void removeAttMtuChangeListener(long watchId);Since: + 6.0 +
+++Parameters:
++
+- +watchId: + The watchID identifier returned by the addAttMtuChangeListener() method. +
+++Exceptions:
++
- WebAPIException
+
+ with error type UnknownError, if any error occurs. +
++Code example:
function proccessDevice(device) +{ + function onConnected() + { + var attMtu = device.getAttMtu(); + console.log("Initial ATT MTU value: " + attMtu); + watchID = device.addAttMtuChangeListener(function(value) + { + console.log("ATT MTU changed to: " + value); + device.removeAttMtuChangeListener(watchID); + device.disconnect(); + }); + device.requestAttMtuChange(64); + } + 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); + } +}); ++++Output example:
Found device: TestDevice +Initial ATT MTU value: 31 +ATT MTU changed to: 64 ++-2.20. BluetoothClassDeviceMajor
+2.32. BluetoothClassDeviceMajor
The BluetoothClassDeviceMajor interface holds the identifiers for major device classes of Bluetooth CoD.@@ -5534,7 +8051,7 @@Methods
-2.21. BluetoothClassDeviceMinor
+2.33. BluetoothClassDeviceMinor
The BluetoothClassDeviceMinor interface holds the identifiers for minor device classes of Bluetooth CoD.@@ -5617,7 +8134,7 @@Methods
-2.25. BluetoothDeviceSuccessCallback
+2.37. BluetoothDeviceSuccessCallback
The BluetoothDeviceSuccessCallback interface implements the success callback BluetoothAdapter.getDevice() and BluetoothAdapter.createBonding().@@ -5975,7 +8492,7 @@Methods
-2.26. BluetoothDeviceArraySuccessCallback
+2.38. BluetoothDeviceArraySuccessCallback
The BluetoothDeviceArraySuccessCallback interface that defines the success callback for BluetoothAdapter.getKnownDevices().@@ -6017,7 +8534,7 @@Methods
+To guarantee that the Bluetooth Low Energy application runs on a device with Bluetooth Low Energy GATT Server feature, declare the following feature requirements in the config file: +
+For more information on the Bluetooth features, see Bluetooth Guide. @@ -73,6 +75,15 @@
typedef (BluetoothGATTService or BluetoothGATTServerService) BluetoothGATTServiceVariant;+
Since: + 6.0 +
+typedef (BluetoothGATTCharacteristic or BluetoothGATTServerCharacteristic) BluetoothGATTCharacteristicVariant;+
Since: + 6.0 +
+typedef (BluetoothGATTDescriptor or BluetoothGATTServerDescriptor) BluetoothGATTDescriptorVariant;+
Since: + 6.0 +
+Since: @@ -740,8 +882,9 @@
Since: 2.3.1 @@ -876,16 +1019,39 @@
Since: + 6.0 +
+Remark: + Only 16-bit BluetoothLEServiceData::uuid values can be advertised. Duplicated uuid values in servicesData are not allowed for advertising. +
+Remark: + If this attribute is in neither null nor undefined, the value of deprecated BluetoothLEAdvertiseData::serviceData attribute is ignored. +
+Code example:
var advertise = new tizen.BluetoothLEAdvertiseData();
+
+var firstService = new tizen.BluetoothLEServiceData("11e5", "0x1811");
+var secondService = new tizen.BluetoothLEServiceData("a5e8", "0x1815");
+advertise.servicesData = [firstService, secondService];
+
+Deprecated. + Deprecated since 6.0. Instead, use BluetoothLEAdvertiseData::servicesData. +
Since: 2.3.1
-Remark: - Only 16-bit BluetoothLEServiceData::uuid values can be advertised. -
Code example:
var advertise = new tizen.BluetoothLEAdvertiseData();
var service = new tizen.BluetoothLEServiceData("11e5", "0x1811");
@@ -922,6 +1088,7 @@ Attributes
readonly attribute BluetoothClassDeviceService deviceService;
BluetoothAdapter getDefaultAdapter() raises(WebAPIException);
BluetoothLEAdapter getLEAdapter() raises(WebAPIException);
+ BluetoothGATTServer getGATTServer() raises(WebAPIException);
byte[] toByteArray(Bytes data) raises(WebAPIException);
DOMString toDOMString(Bytes data) raises(WebAPIException);
Uint8Array toUint8Array(Bytes data) raises(WebAPIException);
@@ -1093,6 +1260,50 @@ Methods
getGATTServer
+BluetoothGATTServer getGATTServer();
Since: + 6.0 +
+Privilege level: + public +
+Privilege: + http://tizen.org/privilege/bluetooth +
+Return value:
+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 AbortError, if any other error occurs. +
Code example:
var server = tizen.bluetooth.getGATTServer(); ++
toByteArray
Code example:
var dataInt8Array = new Int8Array([-21, 31]);
var dataUint8Array = new Uint8Array([240, 129]);
var dataString = "0x18b1";
-console.log("converted from Int8Array: " + tizen.bluetooth.toByteArray(dataInt8Array));
-console.log("converted from Uint8Array: " + tizen.bluetooth.toByteArray(dataUint8Array));
-console.log("converted from DOMString: " + tizen.bluetooth.toByteArray(dataString));
+
+var fromInt8Array = tizen.bluetooth.toByteArray(dataInt8Array);
+var fromUint8Array = tizen.bluetooth.toByteArray(dataUint8Array);
+var fromString = tizen.bluetooth.toByteArray(dataString);
+
+console.log("converted from Int8Array: " + JSON.stringify(fromInt8Array));
+console.log("converted from Uint8Array: " + JSON.stringify(fromUint8Array));
+console.log("converted from DOMString: " + JSON.stringify(fromString));
Output example:
converted from Int8Array: Int8Array(2) [-21, 31] -converted from Uint8Array: Int8Array(2) [-16, -127] -converted from DOMString: Int8Array(2) [24, -79] +Output example:
converted from Int8Array: [235, 31] +converted from Uint8Array: [240, 129] +converted from DOMString: [244, 177]
Code example:
var dataInt8Array = new Int8Array([-21, 31]);
var dataUint8Array = new Uint8Array([240, 129]);
var dataString = "0x18b1";
-console.log("converted from Int8Array: " + tizen.bluetooth.toUint8Array(dataInt8Array));
-console.log("converted from Uint8Array: " + tizen.bluetooth.toUint8Array(dataUint8Array));
-console.log("converted from DOMString: " + tizen.bluetooth.toUint8Array(dataString));
+
+var fromInt8Array = tizen.bluetooth.toUint8Array(dataInt8Array);
+var fromUint8Array = tizen.bluetooth.toUint8Array(dataUint8Array);
+var fromString = tizen.bluetooth.toUint8Array(dataString);
+
+console.log("converted from Int8Array: " + JSON.stringify(fromInt8Array));
+console.log("converted from Uint8Array: " + JSON.stringify(fromUint8Array));
+console.log("converted from DOMString: " + JSON.stringify(fromString));
Output example:
converted from Int8Array: Uint8Array(2) [235, 31] -converted from Uint8Array: Uint8Array(2) [240, 129] -converted from DOMString: Uint8Array(2) [24, 177] +Output example:
converted from Int8Array: {"0":235, "1":31} +converted from Uint8Array: {"0":240, "1":129} +converted from DOMString: {"0":24, "1":177}
Code example:
tizen.bluetooth.uuidTo128bit("1234");
-tizen.bluetooth.uuidTo128bit("ab5690ef");
-tizen.bluetooth.uuidTo128bit("abcdef01-2345-6789-abcd-ef0123456789");
+Code example:
var uuidFrom16bits = tizen.bluetooth.uuidTo128bit("1234");
+var uuidFrom32bits = tizen.bluetooth.uuidTo128bit("ab5690ef");
+var uuidFrom128bits = tizen.bluetooth.uuidTo128bit("abcdef01-2345-6789-abcd-ef0123456789");
+
+console.log(uuidFrom16bits);
+console.log(uuidFrom32bits);
+console.log(uuidFrom128bits);
[NoInterfaceObject] interface BluetoothLEAdapter {
void startScan(BluetoothLEScanCallback successCallback, optional ErrorCallback? errorCallback) raises(WebAPIException);
void stopScan() raises(WebAPIException);
+ boolean isScanning() 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);
+ long addConnectStateChangeListener(BluetoothLEConnectChangeCallback listener) raises(WebAPIException);
+ void removeConnectStateChangeListener(long watchID);
};
Since: 2.3.1 @@ -2802,6 +3030,56 @@
isScanning
+boolean isScanning();
Since: + 6.0 +
+Return value:
+Exceptions:
++ with error type NotSupportedError, if the device does not support this functionality. +
+ with error type UnknownError, if any other error occurs. +
Code example:
var adapter = tizen.bluetooth.getLEAdapter();
+var scanningStarted = adapter.isScanning();
+console.log("Scanning status: " + scanningStarted);
+if (!scanningStarted)
+{
+ adapter.startScan(function onsuccess(device)
+ {
+ console.log("Scanning status: " + adapter.isScanning());
+ adapter.stopScan();
+ });
+}
+
+Output example:
Scanning status: false +Scanning status: true ++
startAdvertise
with error type QuotaExceededError, if any input attribute is not compatible with the maximum data size for this attribute.
+ with error type InvalidValuesError, if advertising services data contains duplicated UUIDs. +
with error type InvalidStateError, if device is currently in progress of advertising, if the local Bluetooth le adapter is currently not enabled.
addConnectStateChangeListener
+ [NoInterfaceObject] interface BluetoothGATTService {
- readonly attribute BluetoothUUID uuid;
- readonly attribute BluetoothUUID? serviceUuid;
- readonly attribute BluetoothGATTService[] services;
- readonly attribute BluetoothGATTCharacteristic[] characteristics;
- };
+ Registers a listener that is called whenever a GATT connection with another device is established or terminated.
+ long addConnectStateChangeListener(BluetoothLEConnectChangeCallback listener);
Since: - 2.3.1 -
+ 6.0 + ++The BluetoothLEConnectChangeCallback, registered with this function, is called in the following cases: +
+Parameters:
+Return value:
+Exceptions:
++ with error type TypeMismatchError, if the input parameter is not compatible with the expected type for that parameter. +
Code example:
function onconnected(device) +Code example:
/* This application is running the local GATT Server and does not connect to remote GATT servers. */ +/* To be able to notify connected clients about characteristic values' changes, it saves their data. */ +var connectedClients = []; + +function onConnected(device) { - console.log("Connected to device"); - var service = device.getService(device.uuids[0]); - console.log("Service got"); + console.log("A client connected: " + device.address); + connectedClients.push(device); } -var adapter = tizen.bluetooth.getLEAdapter(); -adapter.startScan(function onsuccess(device) +function onDisconnected(device) { - console.log("[Found device] address: " + device.address); - device.connect(onconnected.bind(null, device), onerror); -}); + console.log("A client disconnected: " + device.address); + connectedClients = connectedClients.filter(function(connectedClient) + { + return connectedClient.address !== device.address; + }); +} + +tizen.bluetooth.getLEAdapter().addConnectStateChangeListener( + {onconnected: onConnected, ondisconnected: onDisconnected});
Output example:
A client connected: 6A:33:B1:17:D4:81 +A client connected: 4B:1F:DD:35:41:19 +A client connected: CC:D4:11:E5:72:4B +A client disconnected: 6A:33:B1:17:D4:81 ++
removeConnectStateChangeListener
+Deprecated. - Deprecated since 6.0. Instead, use BluetoothGATTService::serviceUuid. -
+void removeConnectStateChangeListener(long watchID);
Since: - 2.3.1 + 6.0 +
++This function unregisters a BluetoothLEConnectChangeCallback registered with BluetoothLEAdapter.addConnectStateChangeListener() method. +
+Parameters:
+Code example:
/* This application is running the local GATT Server and does not connect to remote GATT servers. */
+function onConnected(device)
+{
+ console.log("A client connected: " + device.address);
+}
+
+function onDisconnected(device)
+{
+ console.log("A client disconnected: " + device.address);
+}
+
+/* Save watchId to be able to remove the listener later */
+var watchId = tizen.bluetooth.getLEAdapter().addConnectStateChangeListener(
+ {onconnected: onConnected, ondisconnected: onDisconnected});
+
+/* A little later, the listener is no longer needed, and can be removed with */
+/* removeConnectStateChangeListener(watchId) method */
+
+Output example:
A client connected: 6A:33:B1:17:D4:81 +A client connected: 4B:1F:DD:35:41:19 +A client connected: CC:D4:11:E5:72:4B +A client disconnected: 6A:33:B1:17:D4:81 ++
[NoInterfaceObject] interface BluetoothGATTService {
+ readonly attribute BluetoothUUID uuid;
+ readonly attribute BluetoothUUID? serviceUuid;
+ readonly attribute BluetoothGATTServiceVariant[] services;
+ readonly attribute BluetoothGATTCharacteristicVariant[] characteristics;
+ };
+Since: + 2.3.1 +
+Code example:
function onconnected(device)
+{
+ console.log("Connected to device");
+ var service = device.getService(device.uuids[0]);
+ console.log("Service got");
+}
+
+var adapter = tizen.bluetooth.getLEAdapter();
+adapter.startScan(function onsuccess(device)
+{
+ console.log("[Found device] address: " + device.address);
+ device.connect(onconnected.bind(null, device), onerror);
+});
+
+Deprecated. + Deprecated since 6.0. Instead, use BluetoothGATTService::serviceUuid. +
+Since: + 2.3.1
Remark: uuid is set to "0xFFFF", if the value cannot be retrieved. @@ -3063,13 +3474,16 @@
Since: 2.3.1
+Remark: + It can be either type BluetoothGATTService for services retrieved from remote GATT servers or type BluetoothGATTServerService for services retrieved from the local GATT server. +
Code example:
var service = device.getService(device.uuids[0]); for (var i = 0; i < service.services.length; ++i) @@ -3081,13 +3495,16 @@Attributes
Since: 2.3.1
+Remark: + It can be either type BluetoothGATTCha racteristic for characteristics retrieved from services of remote GATT servers or type BluetoothGATTServerCharacteristic for characteristics retrieved from services of local GATT server. +
Code example:
var service = device.getService(device.uuids[0]); for (var i = 0; i < service.characteristics.length; ++i) @@ -3100,13 +3517,154 @@Attributes
dictionary BluetoothGATTServerServiceInit {
+ BluetoothUUID serviceUuid;
+ boolean isPrimary = true;
+ BluetoothGATTServerServiceInit[]? includedServices = null;
+ BluetoothGATTServerCharacteristicInit[]? characteristics = null;
+ };
+Since: + 6.0 +
++This dictionary defines the GATT services to be registered to the local GATT server. +
+Code example:
/* serviceA and serviceB are objects of type BluetoothGATTServerServiceInit. */
+/* hrmCharacteristic is a BluetoothGATTServerCharacteristicInit object. */
+var serviceParameters =
+{
+ serviceUuid: "4b102e75",
+ isPrimary: true,
+ includedServices: [serviceA, serviceB],
+ characteristics: [hrmCharacteristic]
+};
+
+[NoInterfaceObject] interface BluetoothGATTServerService : BluetoothGATTService { + readonly attribute boolean isPrimary; + void unregister(optional SuccessCallback? successCallback, optional ErrorCallback? errorCallback) raises(WebAPIException); + };+
Since: + 6.0 +
+ +Since: + 6.0 +
+unregister
+void unregister(optional SuccessCallback? successCallback, optional ErrorCallback? errorCallback);
Since: + 6.0 +
++The ErrorCallback is launched with these error types: +
+Privilege level: + public +
+Privilege: + http://tizen.org/privilege/bluetooth +
+Remark: + GATT services included in other GATT services cannot be unregistered. +
+Remark: + If this method is called for the only GATT service, currently registered in the local running GATT server, the server stops running. +
+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. +
+ with error type AbortError, if any other error occurs. +
Code example:
/* The service has been registered in the GATT server for a while. Now it is no longer needed. */
+function onsuccess()
+{
+ console.log("Service unregistered");
+}
+
+function onerror(error)
+{
+ console.log("Failed to unregister service: " + error.message);
+}
+
+tizen.bluetooth.getGATTServer().services[0].unregister(onsuccess, onerror);
+
+ [NoInterfaceObject] interface BluetoothGATTCharacteristic {
- readonly attribute BluetoothGATTDescriptor[] descriptors;
+ readonly attribute BluetoothGATTDescriptorVariant[] descriptors;
readonly attribute boolean isBroadcast;
readonly attribute boolean hasExtendedProperties;
readonly attribute boolean isNotify;
@@ -3130,13 +3688,16 @@ Attributes
Since: 2.3.1
+Remark: + The type of this field is BluetoothGATTDescriptor for descriptors of characteristics retrieved from services of remote GATT servers and BluetoothGATTServerDescriptor for descriptors of characteristics retrieved from the services of local GATT server. +
Privilege: http://tizen.org/privilege/bluetooth
+Remark: + BluetothGATTServerCharacteristic objects do not support this function. An attempt to call it for such an object will result in an exception. +
Parameters:
with error type SecurityError, if the application does not have the privilege to call this method.
+ with error type NotSupportedError, if the method is called for BluetoothGATTServerCharacteristic. +
Privilege: http://tizen.org/privilege/bluetooth
+Remark: + BluetothGATTServerCharacteristic objects do not support this function. An attempt to call it for such an object will result in an exception. +
Parameters:
with error type SecurityError, if the application does not have the privilege to call this method.
+ with error type NotSupportedError, if the method is called for BluetoothGATTServerCharacteristic. +
Privilege: http://tizen.org/privilege/bluetooth
+Remark: + BluetothGATTServerCharacteristic objects do not support this function. An attempt to call it for such an object will result in an exception. +
Parameters:
Exceptions:
-+
with error type SecurityError, if the application does not have the privilege to call this method. -
+ with error type NotSupportedError, if the method is called for BluetoothGATTServerCharacteristic. +
Remark: Example of using can be find at addValueChangeListener code example.
+Remark: + Value change listeners cannot be registered and thus unregistered for BluetothGATTServerCharacteristic objects. An attempt to remove value change listener for such an object will result in no operation. +
Parameters:
[NoInterfaceObject] interface BluetoothGATTDescriptor {
- readonly attribute BluetoothUUID? uuid;
- void readValue(ReadValueSuccessCallback successCallback, optional ErrorCallback? errorCallback) raises(WebAPIException);
- void writeValue(Bytes value, optional SuccessCallback? successCallback, optional ErrorCallback? errorCallback)
- raises(WebAPIException);
+ dictionary BluetoothGATTServerCharacteristicInit {
+ BluetoothUUID uuid;
+ BluetoothGATTServerDescriptorInit[]? descriptors = null;
+ boolean isBroadcast = false;
+ boolean hasExtendedProperties = false;
+ boolean isNotify = false;
+ boolean isIndication = false;
+ boolean isReadable = false;
+ boolean isSignedWrite = false;
+ boolean isWritable = false;
+ boolean isWriteNoResponse = false;
+ boolean readPermission = false;
+ boolean writePermission = false;
+ boolean encryptedReadPermission = false;
+ boolean encryptedWritePermission = false;
+ boolean encryptedSignedReadPermission = false;
+ boolean encryptedSignedWritePermission = false;
+ ReadValueRequestCallback? readValueRequestCallback = null;
+ SuccessCallback? readValueSendResponseSuccessCallback = null;
+ ErrorCallback? readValueSendResponseErrorCallback = null;
+ WriteValueRequestCallback? writeValueRequestCallback = null;
+ SuccessCallback? writeValueSendResponseSuccessCallback = null;
+ ErrorCallback? writeValueSendResponseErrorCallback = null;
};
Since:
- 2.3.1
+ 6.0
-
+
+
+This dictionary is used as a definition of a characteristic to be registered in a service of the local GATT server.
readValueRequestCallback and writeValueRequestCallback are callbacks called when a client reads or writes the value of the characteristic respectively. They can be set or replaced with another functions, after registering the service containing the characteristic, with BluetoothGATTServerCharacteristic.setReadValueRequestCallback() and BluetoothGATTServerCharacteristic.setWriteValueRequestCallback().
readValueSendResponseSuccessCallback and writeValueSendResponseSuccessCallback are success callbacks called when a response sent from readValueRequestCallback or writeValueRequestCallback reaches client. They can be set or replaced with another functions, after registering the service containing the characteristic, with BluetoothGATTServerCharacteristic.setReadValueRequestCallback() and BluetoothGATTServerCharacteristic.setWriteValueRequestCallback().
readValueSendResponseErrorCallback and writeValueSendResponseErrorCallback are error callbacks called when an attempt to send a response to a client from readValueRequestCallback or writeValueRequestCallback fails. They can be set or replaced with another functions, after registering the service containing the characteristic, with BluetoothGATTServerCharacteristic.setReadValueRequestCallback() and BluetoothGATTServerCharacteristic.setWriteValueRequestCallback().
+
+
+
+Code example:
/* nameDescriptor, placeDescriptor are BluetoothGATTServerDescriptorInit objects */
+/* readValueCallback, writeValueCallback are read/write request callbacks */
+/* readValueSendResponseSuccessCallback and writeValueSendResponseSuccessCallback */
+/* are success callbacks */
+/* and writeValueSendResponseErrorCallback and readValueSendResponseErrorCallback */
+/* are error callbacks */
+var characteristicParameters =
+{
+ uuid: "0180",
+ descriptors: [nameDescriptor, placeDescriptor],
+ /* Characteristic's properties */
+ isBroadcast: false,
+ hasExtendedProperties: false,
+ isNotify: false,
+ isIndication: false,
+ isReadable: true,
+ isSignedWrite: false,
+ isWritable: true,
+ isWriteNoResponse: false,
+ /* Characteristic's permissions */
+ readPermission: true,
+ writePermission: true,
+ encryptedReadPermission: false,
+ encryptedWritePermission: false,
+ encryptedSignedReadPermission: false,
+ encryptedSignedWritePermission: false,
+ readValueRequestCallback: readValueCallback,
+ readValueSendResponseSuccessCallback: readValueSendResponseSuccessCallback,
+ readValueSendResponseErrorCallback: readValueSendResponseErrorCallback,
+ writeValueRequestCallback: writeValueCallback,
+ writeValueSendResponseSuccessCallback: writeValueSendResponseSuccessCallback,
+ writeValueSendResponseErrorCallback: writeValueSendResponseErrorCallback
+};
+
+
+
+
+2.14. BluetoothGATTServerCharacteristic
+
+ A subclass representing GATT characteristic used to construct a service of the local Bluetooth GATT server.
+It extends BluetoothGATTCharacteristic with permissions and methods implementing interactions of the characteristic with remote clients.
+
+ [NoInterfaceObject] interface BluetoothGATTServerCharacteristic : BluetoothGATTCharacteristic {
+ readonly attribute boolean readPermission;
+ readonly attribute boolean writePermission;
+ readonly attribute boolean encryptedReadPermission;
+ readonly attribute boolean encryptedWritePermission;
+ readonly attribute boolean encryptedSignedReadPermission;
+ readonly attribute boolean encryptedSignedWritePermission;
+ void notifyAboutValueChange(Bytes value, BluetoothAddress? clientAddress, optional NotificationCallback? notificationCallback,
+ optional ErrorCallback? errorCallback) raises(WebAPIException);
+ void setReadValueRequestCallback(ReadValueRequestCallback readValueRequestCallback, optional SuccessCallback? successCallback,
+ optional ErrorCallback? errorCallback, optional SuccessCallback? sendResponseSuccessCallback,
+ optional ErrorCallback? sendResponseErrorCallback) raises(WebAPIException);
+ void setWriteValueRequestCallback(WriteValueRequestCallback writeValueRequestCallback, optional SuccessCallback? successCallback,
+ optional ErrorCallback? errorCallback, optional SuccessCallback? sendResponseSuccessCallback,
+ optional ErrorCallback? sendResponseErrorCallback) raises(WebAPIException);
+ };
+Since:
+ 6.0
+
+
+
Attributes
--
+
+-
readonly
-BluetoothUUID uuid [nullable]
- UUID of the descriptor.
+boolean readPermission
+ Indicates if clients have the permission to read the value of the characteristic.
Since:
6.0
-Remark:
- uuid is set to null, if the value cannot be retrieved.
-
-
-
-
-Methods
-
--
-
readValue
-
--
-
- Reads descriptor value from remote device. Updates descriptor value attribute.
+
+
-
+ readonly
+boolean writePermission
+ Indicates if clients have the permission to write the value of the characteristic.
-
void readValue(ReadValueSuccessCallback successCallback, optional ErrorCallback? errorCallback);
Since:
- 2.3.1
+ 6.0
-
-
-The ErrorCallback is launched with these error types:
+
+
-
+ readonly
+boolean encryptedReadPermission
+ Indicates if clients have the permission to read the value of the characteristic through encrypted connections.
+
+
Since:
+ 6.0
-
- -
+
+-
+ readonly
+boolean encryptedWritePermission
+ Indicates if clients have the permission to write the value of the characteristic through encrypted connections.
+
+
Since:
+ 6.0
+
+
+-
+ readonly
+boolean encryptedSignedReadPermission
+ Indicates if clients have the permission to perform signed reads of the characteristic's value.
+
+
Since:
+ 6.0
+
+
+-
+ readonly
+boolean encryptedSignedWritePermission
+ Indicates if clients have the permission to perform signed writes of the characteristic's value.
+
+
Since:
+ 6.0
+
+
+
+
+
+Methods
+
+-
+
notifyAboutValueChange
+
+-
+
+ Notifies the clients of the local GATT server of the changes in the characteristic.
+
+
void notifyAboutValueChange(Bytes value, BluetoothAddress? clientAddress, optional NotificationCallback? notificationCallback,
+ optional ErrorCallback? errorCallback);
+Since:
+ 6.0
+
+
+
+This function sends a BLE notification or indication about a change of characteristic's value to clients that registered for it. If a particular client is specified, only he gets the update.
+Otherwise it is sent to all clients connected to the local GATT server, who registered for the updates.
+
+Clients can only register for characteristic's notifications or indications, if the characteristic defines a Client Characteristic Configuration Descriptor (CCCD), as described in the Bluetooth standard.
+CCCD has to be defined as any other descriptor, using BluetoothGATTServerDescriptorInit.
+
+
+
+
+The ErrorCallback is launched with these error types:
+
+
+ -
+ InvalidValuesError - If any of the parameters is invalid.
+ -
+ NotSupportedError - If the feature is not supported.
+ -
+ AbortError - If any other error occurs.
+
+
+Privilege level:
+ public
+
+Privilege:
+ http://tizen.org/privilege/bluetooth
+
+Remark:
+ To notify the clients the service with current characteristic must be registered (see BluetoothGATTServer::registerService()) and available for clients (see BluetoothGATTServer::start()).
+
+
+Parameters:
+
+ -
+value:
+ The new value of the characteristic.
+
+ -
+clientAddress [nullable]:
+ The address of the client to be notified about the value change. If a null is passed, all clients will be notified.
+
+ -
+notificationCallback [optional] [nullable]:
+ The callback called for each attempt of a client notification.
+
+ -
+errorCallback [optional] [nullable]:
+ Callback function that is called in case of failure of sending notification.
+
+
+
+
+Exceptions:
+ - WebAPIException
+
+ 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:
/* this example assumes that the local gatt server with at least one service which has at least one */
+/* characteristic already exists */
+var callback =
+{
+ onnotificationsuccess: function(clientAddress)
+ {
+ console.log(clientAddress + " notified about change.");
+ },
+ onnotificationfail: function(clientAddress, error)
+ {
+ console.error("Couldn't notify " + clientAddress + " about change:" + error.name);
+ },
+ onnotificationfinish: function(clientAddress)
+ {
+ console.log("Finished notifying about change.");
+ }
+};
+
+function errorCallback(error)
+{
+ console.error("Failed to notify about value change: " + error.name + ": " + error.message);
+}
+
+server.services[0].characteristics[0].notifyAboutValueChange("1234", null, callback, errorCallback);
+
+
+
+-
+
setReadValueRequestCallback
+
+-
+
+ Registers the callback called when a client reads the value of the characteristic from the local GATT server.
+
+
void setReadValueRequestCallback(ReadValueRequestCallback readValueRequestCallback, optional SuccessCallback? successCallback,
+ optional ErrorCallback? errorCallback, optional SuccessCallback? sendResponseSuccessCallback,
+ optional ErrorCallback? sendResponseErrorCallback);
+Since:
+ 6.0
+
+
+
+The callback, registered with this function, is called when a remote client requests to read the value of the characteristic.
+The server can respond to such requests by returning a GATTRequestReply object from the callback.
+If ReadValueRequestCallback for the characteristic is not registered, or it does not return a GATTRequestReply, clients will not be able to get the value of this characteristic.
+
+A callback set with this function overwrites any previously set ReadValueRequestCallback.
+
+
+The errorCallback will be launched in the following situations:
+
+
+ -
+ NotSupportedError - If the feature is not supported.
+ -
+ AbortError - If any other error occurs.
+
+
+The sendResponseErrorCallback will be launched in the following situations:
+
+
+ -
+ NotSupportedError - If the feature is not supported.
+ -
+ InvalidValuesError - If GATTRequestReply::statusCode or GATTRequestReply::data is invalid.
+ -
+ AbortError - If any other error occurs.
+
+
+Privilege level:
+ public
+
+Privilege:
+ http://tizen.org/privilege/bluetooth
+
+
+Parameters:
+
+ -
+readValueRequestCallback:
+ The callback called when a client reads the value of the characteristic.
+
+ -
+successCallback [optional] [nullable]:
+ Callback function that is called when the readValueRequestCallback is registered successfully.
+
+ -
+errorCallback [optional] [nullable]:
+ Callback function that is called in case of failure of readValueRequestCallback registration.
+
+ -
+sendResponseSuccessCallback [optional] [nullable]:
+ Callback function that is called when responses returned from readValueRequestCallbacks are sent successfully.
+
+ -
+sendResponseErrorCallback [optional] [nullable]:
+ Callback function that is called when responses returned from readValueRequestCallbacks are not sent due to an error.
+
+
+
+
+Exceptions:
+ - WebAPIException
+
+ 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:
/* this example assumes that the local gatt server with at least one service which has at least one */
+/* characteristic already exists */
+var callback = function(clientAddress, offset)
+{
+ console.log(clientAddress + " requested to read characteristic's value with offset: " + offset);
+ return new tizen.GATTRequestReply(0, "0x1234");
+};
+
+server.services[0].characteristics[0].setReadValueRequestCallback(callback);
+
+
+
+-
+
setWriteValueRequestCallback
+
+-
+
+ Registers the callback called when a client writes the value of the characteristic of the local GATT server.
+
+
void setWriteValueRequestCallback(WriteValueRequestCallback writeValueRequestCallback, optional SuccessCallback? successCallback,
+ optional ErrorCallback? errorCallback, optional SuccessCallback? sendResponseSuccessCallback,
+ optional ErrorCallback? sendResponseErrorCallback);
+Since:
+ 6.0
+
+
+
+The callback, registered with this function, is called when a remote client requests to write the value of the characteristic.
+The server can respond to such requests by returning a GATTRequestReply object from the callback.
+If WriteValueRequestCallback for the characteristic is not registered, or it does not return a GATTRequestReply, clients will not be able to get the value of this characteristic.
+
+A callback set with this function overwrites any previously set WriteValueRequestCallback.
+
+
+The errorCallback will be launched in the following situations:
+
+
+ -
+ NotSupportedError - If the feature is not supported.
+ -
+ AbortError - If any other error occurs.
+
+
+The sendResponseErrorCallback will be launched in the following situations:
+
+
+ -
+ NotSupportedError - If the feature is not supported.
+ -
+ InvalidValuesError - If GATTRequestReply::statusCode or GATTRequestReply::data is invalid.
+ -
+ AbortError - If any other error occurs.
+
+
+Privilege level:
+ public
+
+Privilege:
+ http://tizen.org/privilege/bluetooth
+
+
+Parameters:
+
+ -
+writeValueRequestCallback:
+ The callback called when a client writes the value of the characteristic.
+
+ -
+successCallback [optional] [nullable]:
+ Callback function that is called when the writeValueRequestCallback is registered successfully.
+
+ -
+errorCallback [optional] [nullable]:
+ Callback function that is called in case of failure of writeValueRequestCallback registration.
+
+ -
+sendResponseSuccessCallback [optional] [nullable]:
+ Callback function that is called when responses returned from writeValueRequestCallbacks are sent successfully.
+
+ -
+sendResponseErrorCallback [optional] [nullable]:
+ Callback function that is called when responses returned from writeValueRequestCallbacks are not sent due to an error.
+
+
+
+
+Exceptions:
+ - WebAPIException
+
+ 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:
/* this example assumes that the local gatt server with at least one service which has at least one */
+/* characteristic already exists */
+var callback = function(clientAddress, value, offset, replyRequired)
+{
+ console.log(clientAddress + " requested to write characteristic's value: " + value +
+ " with offset: " + offset);
+ return replyRequired ? new tizen.GATTRequestReply(0, "0x1234") : null;
+};
+
+server.services[0].characteristics[0].setWriteValueRequestCallback(callback);
+
+
+
+
+
+
+
+2.15. BluetoothGATTDescriptor
+
+ Bluetooth Low Energy descriptor.
+
+ [NoInterfaceObject] interface BluetoothGATTDescriptor {
+ readonly attribute BluetoothUUID? uuid;
+ void readValue(ReadValueSuccessCallback successCallback, optional ErrorCallback? errorCallback) raises(WebAPIException);
+ void writeValue(Bytes value, optional SuccessCallback? successCallback, optional ErrorCallback? errorCallback)
+ raises(WebAPIException);
+ };
+Since:
+ 2.3.1
+
+
+Attributes
+-
+ readonly
+BluetoothUUID uuid [nullable]
+ UUID of the descriptor.
+
+
Since:
+ 6.0
+
+Remark:
+ uuid is set to null, if the value cannot be retrieved.
+
+
+
+
+Methods
+
+-
+
readValue
+
+-
+
+ Reads descriptor value from remote device. Updates descriptor value attribute.
+
+
void readValue(ReadValueSuccessCallback successCallback, optional ErrorCallback? errorCallback);
+Since:
+ 2.3.1
+
+
+
+The ErrorCallback is launched with these error types:
+
+
+ -
+ UnknownError - If any other error occurs
+
+
+Privilege level:
+ public
+
+Privilege:
+ http://tizen.org/privilege/bluetooth
+
+Remark:
+ BluetothGATTServerDescriptor objects do not support this function. An attempt to call it for such an object will result in an exception.
+
+
+Parameters:
+
+ -
+successCallback:
+ Callback function that is called when the descriptor value is read successfully.
+
+ -
+errorCallback [optional] [nullable]:
+ Callback function that is called in case of failure.
+
+
+
+
+Exceptions:
+ - WebAPIException
+
+ 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.
+
+
+ with error type NotSupportedError, if the method is called for BluetoothGATTServerDescriptor.
+
+
+
+
+
+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
+
+-
+
+ Writes the descriptor value to the remote device.
+
+
void writeValue(Bytes value, optional SuccessCallback? successCallback, optional ErrorCallback? errorCallback);
+Since:
+ 2.3.1
+
+
+
+The ErrorCallback is launched with these error types:
+
+
+ -
UnknownError - If any other error occurs
@@ -3582,16 +4729,601 @@ Methods
Privilege:
http://tizen.org/privilege/bluetooth
+Remark:
+ BluetothGATTServerDescriptor objects do not support this function. An attempt to call it for such an object will result in an exception.
+
+
+Parameters:
+
+ -
+value:
+ The descriptor value to write.
+
+ -
+successCallback [optional] [nullable]:
+ Callback function that is called when the descriptor value is written successfully.
+
+ -
+errorCallback [optional] [nullable]:
+ Callback function that is called in case of failure.
+
+
+
+
+Exceptions:
+ - WebAPIException
+
+ 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.
+
+
+ with error type NotSupportedError, if the method is called for BluetoothGATTServerDescriptor.
+
+
+
+
+
+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);
+ }
+});
+
+
+
+
+
+
+
+2.16. BluetoothGATTServerDescriptorInit
+
+ A dictionary for specifying GATT descriptor parameters.
+
+ dictionary BluetoothGATTServerDescriptorInit {
+ BluetoothUUID uuid;
+ boolean readPermission = false;
+ boolean writePermission = false;
+ boolean encryptedReadPermission = false;
+ boolean encryptedWritePermission = false;
+ boolean encryptedSignedReadPermission = false;
+ boolean encryptedSignedWritePermission = false;
+ ReadValueRequestCallback? readValueRequestCallback = null;
+ SuccessCallback? readValueSendResponseSuccessCallback = null;
+ ErrorCallback? readValueSendResponseErrorCallback = null;
+ WriteValueRequestCallback? writeValueRequestCallback = null;
+ SuccessCallback? writeValueSendResponseSuccessCallback = null;
+ ErrorCallback? writeValueSendResponseErrorCallback = null;
+ };
+Since:
+ 6.0
+
+
+
+This dictionary is used as a definition of a descriptor to be registered in a characteristic of the local GATT server.
readValueRequestCallback and writeValueRequestCallback are callbacks called when a client reads or writes the value of the descriptor respectively. They can be set or replaced with another functions after registering the service containing the descriptor with BluetoothGATTServerDescriptor.setReadValueRequestCallback() and BluetoothGATTServerDescriptor.setWriteValueRequestCallback().
readValueSendResponseSuccessCallback and writeValueSendResponseSuccessCallback are success callbacks called when a response sent from readValueRequestCallback or writeValueRequestCallback reaches client. They can be set or replaced with another functions, after registering the service containing the characteristic, with BluetoothGATTServerDescriptor.setReadValueRequestCallback() and BluetoothGATTServerDescriptor.setWriteValueRequestCallback().
readValueSendResponseErrorCallback and writeValueSendResponseErrorCallback are error callbacks called when an attempt to send a response to a client from readValueRequestCallback or writeValueRequestCallback fails. They can be set or replaced with another functions, after registering the service containing the characteristic, with BluetoothGATTServerDescriptor.setReadValueRequestCallback() and BluetoothGATTServerDescriptor.setWriteValueRequestCallback().
+
+
+
+Code example:
/* readValueCallback, writeValueCallback are read/write request callbacks */
+/* readValueSendResponseSuccessCallback and writeValueSendResponseSuccessCallback are success */
+/* callbacks */
+/* and writeValueSendResponseErrorCallback and readValueSendResponseErrorCallback are error */
+/* callbacks */
+var descriptorProperties =
+{
+ uuid: "0180",
+ /* Descriptor's permissions */
+ readPermission: true,
+ writePermission: true,
+ encryptedReadPermission: false,
+ encryptedWritePermission: false,
+ encryptedSignedReadPermission: false,
+ encryptedSignedWritePermission: false,
+ /* Read/write value callbacks */
+ readValueRequestCallback: readValueCallback,
+ readValueSendResponseSuccessCallback: readValueSendResponseSuccessCallback,
+ readValueSendResponseErrorCallback: readValueSendResponseErrorCallback,
+ writeValueRequestCallback: writeValueCallback,
+ writeValueSendResponseSuccessCallback: writeValueSendResponseSuccessCallback,
+ writeValueSendResponseErrorCallback: writeValueSendResponseErrorCallback
+};
+
+
+
+
+2.17. BluetoothGATTServerDescriptor
+
+ A subclass representing GATT descriptors of characteristics registered in services of the local server.
+It extends BluetoothGATTDescriptor with permissions and methods implementing interactions of the descriptor with remote clients.
+
+ [NoInterfaceObject] interface BluetoothGATTServerDescriptor : BluetoothGATTDescriptor {
+ readonly attribute boolean readPermission;
+ readonly attribute boolean writePermission;
+ readonly attribute boolean encryptedReadPermission;
+ readonly attribute boolean encryptedWritePermission;
+ readonly attribute boolean encryptedSignedReadPermission;
+ readonly attribute boolean encryptedSignedWritePermission;
+ void setReadValueRequestCallback(ReadValueRequestCallback readValueRequestCallback, optional SuccessCallback? successCallback,
+ optional ErrorCallback? errorCallback, optional SuccessCallback? sendResponseSuccessCallback,
+ optional ErrorCallback? sendResponseErrorCallback) raises(WebAPIException);
+ void setWriteValueRequestCallback(WriteValueRequestCallback writeValueRequestCallback, optional SuccessCallback? successCallback,
+ optional ErrorCallback? errorCallback, optional SuccessCallback? sendResponseSuccessCallback,
+ optional ErrorCallback? sendResponseErrorCallback) raises(WebAPIException);
+ };
+Since:
+ 6.0
+
+
+
+Attributes
+
+-
+ readonly
+boolean readPermission
+ Indicates if clients have the permission to read the value of the descriptor.
+
+
Since:
+ 6.0
+
+
+-
+ readonly
+boolean writePermission
+ Indicates if clients have the permission to write the value of the descriptor.
+
+
Since:
+ 6.0
+
+
+-
+ readonly
+boolean encryptedReadPermission
+ Indicates if clients have the permission to read the value of the descriptor through encrypted connections.
+
+
Since:
+ 6.0
+
+
+-
+ readonly
+boolean encryptedWritePermission
+ Indicates if clients have the permission to write the value of the descriptor through encrypted connections.
+
+
Since:
+ 6.0
+
+
+-
+ readonly
+boolean encryptedSignedReadPermission
+ Indicates if clients have the permission to perform signed reads of the charactersitic's value.
+
+
Since:
+ 6.0
+
+
+-
+ readonly
+boolean encryptedSignedWritePermission
+ Indicates if clients have the permission to perform signed writes of the charactersitic's value.
+
+
Since:
+ 6.0
+
+
+
+
+
+Methods
+
+-
+
setReadValueRequestCallback
+
+-
+
+ Registers the callback called when a client reads the value of the descriptor from the local GATT server.
+
+
void setReadValueRequestCallback(ReadValueRequestCallback readValueRequestCallback, optional SuccessCallback? successCallback,
+ optional ErrorCallback? errorCallback, optional SuccessCallback? sendResponseSuccessCallback,
+ optional ErrorCallback? sendResponseErrorCallback);
+Since:
+ 6.0
+
+
+
+The callback, registered with this function, is called when a remote client requests to read the value of the descriptor.
+The server can respond to such requests by returning a GATTRequestReply object from the callback.
+If ReadValueRequestCallback for the descriptor is not registered, or it does not return a GATTRequestReply, clients will not be able to get the value of this descriptor.
+
+A callback set with this function overwrites any previously set ReadValueRequestCallback.
+
+
+The errorCallback will be launched in the following situations:
+
+
+ -
+ NotSupportedError - If the feature is not supported.
+ -
+ AbortError - If any other error occurs.
+
+
+The sendResponseErrorCallback will be launched in the following situations:
+
+
+ -
+ NotSupportedError - If the feature is not supported.
+ -
+ InvalidValuesError - If GATTRequestReply::statusCode or GATTRequestReply::data is invalid.
+ -
+ AbortError - If any other error occurs.
+
+
+Privilege level:
+ public
+
+Privilege:
+ http://tizen.org/privilege/bluetooth
+
+
+Parameters:
+
+ -
+readValueRequestCallback:
+ The callback called when a client reads the value of the descriptor.
+
+ -
+successCallback [optional] [nullable]:
+ Callback function that is called when the readValueRequestCallback is registered successfully.
+
+ -
+errorCallback [optional] [nullable]:
+ Callback function that is called in case of failure of readValueRequestCallback registration.
+
+ -
+sendResponseSuccessCallback [optional] [nullable]:
+ Callback function that is called when responses returned from readValueRequestCallbacks are sent successfully.
+
+ -
+sendResponseErrorCallback [optional] [nullable]:
+ Callback function that is called when responses returned from readValueRequestCallbacks are not sent due to an error.
+
+
+
+
+Exceptions:
+ - WebAPIException
+
+ 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:
/* this example assumes that the local gatt server with at least one service which has at least one */
+/* characteristic with at least one descriptor already exists */
+var callback = function(clientAddress, offset)
+{
+ console.log(clientAddress + " requested to read characteristic's value with offset: " + offset);
+ return new tizen.GATTRequestReply(0, "0x1234");
+};
+server.services[0].characteristics[0].descriptors[0].setReadValueRequestCallback(callback);
+
+
+
+-
+
setWriteValueRequestCallback
+
+-
+
+ Registers the callback called when a remote client writes the value of the descriptor from the local GATT server.
+
+
void setWriteValueRequestCallback(WriteValueRequestCallback writeValueRequestCallback, optional SuccessCallback? successCallback,
+ optional ErrorCallback? errorCallback, optional SuccessCallback? sendResponseSuccessCallback,
+ optional ErrorCallback? sendResponseErrorCallback);
+Since:
+ 6.0
+
+
+
+The callback, registered with this function, is called when a remote client requests to write the value of the descriptor.
+The server can respond to such requests by returning a GATTRequestReply object from the callback.
+If WriteValueRequestCallback for the descriptor is not registered, or it does not return a GATTRequestReply, clients will not be able to get the value of this descriptor.
+
+A callback set with this function overwrites any previously set WriteValueRequestCallback.
+
+
+The errorCallback will be launched in the following situations:
+
+
+ -
+ NotSupportedError - If the feature is not supported.
+ -
+ AbortError - If any other error occurs.
+
+
+The sendResponseErrorCallback will be launched in the following situations:
+
+
+ -
+ NotSupportedError - If the feature is not supported.
+ -
+ InvalidValuesError - If GATTRequestReply::statusCode or GATTRequestReply::data is invalid.
+ -
+ AbortError - If any other error occurs.
+
+
+Privilege level:
+ public
+
+Privilege:
+ http://tizen.org/privilege/bluetooth
+
+
+Parameters:
+
+ -
+writeValueRequestCallback:
+ The callback called when a client writes the value of the descriptor.
+
+ -
+successCallback [optional] [nullable]:
+ Callback function that is called when the writeValueRequestCallback is registered successfully.
+
+ -
+errorCallback [optional] [nullable]:
+ Callback function that is called in case of failure of writeValueRequestCallback registration.
+
+ -
+sendResponseSuccessCallback [optional] [nullable]:
+ Callback function that is called when responses returned from writeValueRequestCallbacks are sent successfully.
+
+ -
+sendResponseErrorCallback [optional] [nullable]:
+ Callback function that is called when responses returned from writeValueRequestCallbacks are not sent due to an error.
+
+
+
+
+Exceptions:
+ - WebAPIException
+
+ 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:
/* this example assumes that the local gatt server with at least one service which has at least one */
+/* characteristic with at least one descriptor already exists */
+var callback = function(clientAddress, value, offset, replyRequired)
+{
+ console.log(clientAddress + " requested to write descriptor's value: " + value +
+ " with offset: " + offset);
+ return replyRequired ? new tizen.GATTRequestReply(0, "0x1234") : null;
+};
+server.services[0].characteristics[0].descriptors[0].setWriteValueRequestCallback(callback);
+
+
+
+
+
+
+
+2.18. BluetoothGATTServer
+
+ The BluetoothGATTServer interface provides access to control the local GATT server: starting and stopping it, registering and unregistering local GATT services, and getting the ATT MTU (Attribute Protocol Maximum Transmission Unit) values.
+
+ [NoInterfaceObject] interface BluetoothGATTServer {
+ readonly attribute boolean isRunning;
+ readonly attribute BluetoothGATTServerService[] services;
+ void start(optional SuccessCallback? successCallback, optional ErrorCallback? errorCallback) raises(WebAPIException);
+ void stop(optional SuccessCallback? successCallback, optional ErrorCallback? errorCallback) raises(WebAPIException);
+ void registerService(BluetoothGATTServerServiceInit service, optional SuccessCallback? successCallback,
+ optional ErrorCallback? errorCallback) raises(WebAPIException);
+ void unregisterAllServices(optional SuccessCallback? successCallback, optional ErrorCallback? errorCallback)
+ raises(WebAPIException);
+ void getConnectionMtu(BluetoothAddress clientAddress, ConnectionMtuCallback callback, optional ErrorCallback? errorCallback)
+ raises(WebAPIException);
+ };
+Since:
+ 6.0
+
+
+Attributes
+
+-
+ readonly
+boolean isRunning
+ The flag indicating if remote GATT clients can currently connect to the server, exposing services defined in BluetoothGATTServer::services. It is toggled on start() and stop() calls.
+
+
Since:
+ 6.0
+
+
+-
+ readonly
+BluetoothGATTServerService[]
+ services
+ The list of GATT services hosted on this server.
+
+
Since:
+ 6.0
+
+
+
+
+
+Methods
+
+-
+
start
+
+-
+
+ Starts the local GATT server. After it starts, it can conduct GATT server operations. Also, the remote clients can discover and use the services provided by the local Bluetooth GATT Server.
+
+
void start(optional SuccessCallback? successCallback, optional ErrorCallback? errorCallback);
+Since:
+ 6.0
+
+
+
+The ErrorCallback will be launched in the following situations:
+
+
+ -
+ InvalidStateError - If the server is already running.
+ -
+ NotSupportedError - If the feature is not supported.
+ -
+ AbortError - If any other error occurs.
+
+
+Privilege level:
+ public
+
+Privilege:
+ http://tizen.org/privilege/bluetooth
+
+
+Parameters:
+
+ -
+successCallback [optional] [nullable]:
+ Called when the server is started.
+
+ -
+errorCallback [optional] [nullable]:
+ The method to invoke when an error occurs.
+
+
+
+
+Exceptions:
+ - WebAPIException
+
+ with error type InvalidStateError, if the Bluetooth adapter is not enabled.
+
+
+ with error type TypeMismatchError, if any input attribute is not compatible with the expected type for this attribute.
+
+
+ with error type SecurityError, if the application does not have the privilege to call this method.
+
+
+ with error type AbortError, if any other error occurs.
+
+
+
+
+
+Code example:
var onSuccess = function()
+{
+ console.log("Server started successfully!");
+};
+
+var onError = function(e)
+{
+ console.error("Server didn't start, error: " + e);
+};
+
+var server = tizen.bluetooth.getGATTServer();
+
+server.start(onSuccess, onError);
+
+
+
+Output example:
Server started successfully!
+
+
+
+-
+
stop
+
+-
+
+ Stops GATT server operation.
+
+
void stop(optional SuccessCallback? successCallback, optional ErrorCallback? errorCallback);
+Since:
+ 6.0
+
+
+
+After the stop, remote clients will not be able to discover the local GATT server's services.
+
+
+The ErrorCallback will be launched in the following situations:
+
+
+ -
+ InvalidStateError - If the server is not running.
+ -
+ NotSupportedError - If the feature is not supported.
+ -
+ AbortError - If any other error occurs.
+
+
+Privilege level:
+ public
+
+Privilege:
+ http://tizen.org/privilege/bluetooth
+
Parameters:
-
-successCallback:
- Callback function that is called when the descriptor value is read successfully.
+successCallback [optional] [nullable]:
+ Called when the server is stopped.
-
errorCallback [optional] [nullable]:
- Callback function that is called in case of failure.
+ The method to invoke when an error occurs.
@@ -3599,72 +5331,70 @@ Methods
Exceptions:
- WebAPIException
- with error type TypeMismatchError, if the input parameter is not compatible with the expected type for that parameter.
+ with error type InvalidStateError, if the Bluetooth adapter is not enabled.
- with error type InvalidStateError, if the local Bluetooth le adapter is currently not enabled.
+ with error type TypeMismatchError, if any input attribute is not compatible with the expected type for this attribute.
with error type SecurityError, if the application does not have the privilege to call this method.
+
+ with error type AbortError, if any other error occurs.
+
-Code example:
function onerror(e)
+Code example:
/* this example assumes that local gatt server already exists and it is started */
+var onSuccess = function()
{
- console.log("Failed to connect to device: " + e.message);
-}
+ console.log("Server stopped successfully!");
+};
-function proccessDevice(device)
+var onError = function(e)
{
- 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();
- });
- }
- }
-}
+ console.error("Server didn't stop, error: " + e);
+};
-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);
- }
-});
+server.stop(onSuccess, onError);
+
+
+
+Output example:
Server stopped successfully!
--
-
writeValue
+-
+
registerService
-
- Writes the descriptor value to the remote device.
+ Registers a primary service in the local GATT server.
-
void writeValue(Bytes value, optional SuccessCallback? successCallback, optional ErrorCallback? errorCallback);
+void registerService(BluetoothGATTServerServiceInit service, optional SuccessCallback? successCallback,
+ optional ErrorCallback? errorCallback);
Since:
- 2.3.1
+ 6.0
+
+
+
+The service is available for clients after BluetoothGATTServer::start() call.
+
The ErrorCallback is launched with these error types:
-
-UnknownError - If any other error occurs
+ InvalidStateError - If the service cannot be registered in the current state of the server.
+ -
+ NotSupportedError - If the feature is not supported.
+ -
+ InvalidValuesError - If any of the input parameters contains an invalid value
+ -
+ AbortError - If any other error occurs.
Privilege level:
@@ -3673,20 +5403,23 @@
Methods
Privilege:
http://tizen.org/privilege/bluetooth
+Remark:
+ Services can only be registered before starting server.
+
Parameters:
-
-value:
- The descriptor value to write.
+service:
+ The definition of a service to be registered in the local GATT server.
-
successCallback [optional] [nullable]:
- Callback function that is called when the descriptor value is written successfully.
+ Called when the local GATT server's services are successfully registered.
-
errorCallback [optional] [nullable]:
- Callback function that is called in case of failure.
+ The method to invoke when an error occurs.
@@ -3694,10 +5427,10 @@ Methods
Exceptions:
- WebAPIException
- with error type TypeMismatchError, if the input parameter is not compatible with the expected type for that parameter.
+ with error type InvalidStateError, if the Bluetooth adapter is not enabled.
- with error type InvalidStateError, if the local Bluetooth le adapter is currently not enabled.
+ with error type TypeMismatchError, if any input attribute is not compatible with the expected type for this attribute.
with error type SecurityError, if the application does not have the privilege to call this method.
@@ -3706,45 +5439,185 @@
Methods
-Code example:
function onerror(e)
+Code example:
var gattService = {serviceUuid: "0955", isPrimary: false, services: [], characteristics: []};
+
+var successCB = function()
{
- console.log("Failed to connect to device: " + e.message);
-}
+ console.log("Service successfully registered!");
+};
-function proccessDevice(device)
+var errorCB = function(e)
{
- 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);
- });
- }
- }
-}
+ console.log("Service not registered, error: " + e);
+};
-var adapter = tizen.bluetooth.getLEAdapter();
-adapter.startScan(function onsuccess(device)
+var server = tizen.bluetooth.getGATTServer();
+
+server.registerService(gattService, successCB, errorCB);
+
+
+
+Output example:
Service successfully registered!
+
+
+
+-
+
unregisterAllServices
+
+-
+
+ Unregisters all services from the local GATT server.
+
+
void unregisterAllServices(optional SuccessCallback? successCallback, optional ErrorCallback? errorCallback);
+Since:
+ 6.0
+
+
+
+This method unregisters all services and all their characteristics from the local GATT server.
+
+
+
+
+The ErrorCallback is launched with these error types:
+
+
+ -
+ InvalidStateError - If the service cannot be unregistered in the current state of the GATT server.
+ -
+ AbortError - If any other error occurs
+
+
+Privilege level:
+ public
+
+Privilege:
+ http://tizen.org/privilege/bluetooth
+
+Remark:
+ Currently running local GATT server is stopped after calling this method.
+
+
+Parameters:
+
+ -
+successCallback [optional] [nullable]:
+ Callback function that is called when services are successfully unregistered from the local GATT server.
+
+ -
+errorCallback [optional] [nullable]:
+ Callback function that is called in case of failure.
+
+
+
+
+Exceptions:
+ - WebAPIException
+
+ 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:
/* this example assumes that the local gatt server already exists */
+var successCB = function()
{
- if (device.address == "11:22:33:44:55:66")
- {
- console.log("Found device: " + device.name);
- proccessDevice(device);
- }
-});
+ console.log("Services successfully unregistered!");
+};
+
+var errorCB = function(e)
+{
+ console.log("Services not unregistered, error: " + e);
+};
+
+server.unregisterAllServices(successCB, errorCB);
+
+
+
+Output example:
Services successfully unregistered!
+
+
+
+-
+
getConnectionMtu
+
+-
+
+ Gets the ATT MTU for the connection with a client.
+
+
void getConnectionMtu(BluetoothAddress clientAddress, ConnectionMtuCallback callback, optional ErrorCallback? errorCallback);
+Since:
+ 6.0
+
+
+
+The ErrorCallback is launched with these error types:
+
+
+ -
+ InvalidStateError - If the server is not running.
+ -
+ NotSupportedError - If the feature is not supported.
+ -
+ AbortError - If any other error occurs.
+
+
+Privilege level:
+ public
+
+Privilege:
+ http://tizen.org/privilege/bluetooth
+
+
+Parameters:
+
+ -
+clientAddress:
+ MAC address of the client, for connection with whom the MTU is to be retrieved.
+
+ -
+callback:
+ Callback functions that are called when the connection state changes.
+
+ -
+errorCallback [optional] [nullable]:
+ Callback function that is called when getting MTU of a connection fails.
+
+
+
+
+Exceptions:
+ - WebAPIException
+
+ 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:
/* this example assumes that the local gatt server already exists */
+var successCB = function(mtu)
+{
+ console.log("ATT MTU value is: " + mtu);
+};
+
+var errorCB = function(e)
+{
+ console.log("Cannot retrieve the ATT MTU, error: " + e);
+};
+
+server.getConnectionMtu("12:34:56:78:90:ab", successCB, errorCB);
+
+
+
+Output example:
ATT MTU value is: 123
@@ -3752,7 +5625,7 @@ Methods
[Constructor(long statusCode = 0, optional Bytes data)] + interface GATTRequestReply { + attribute long statusCode; + attribute Bytes? data; + };+
Since: + 6.0 +
+Since: + 6.0 +
+Since: + 6.0 +
+ [Callback=FunctionOnly, NoInterfaceObject] interface ReadValueRequestCallback {
+ GATTRequestReply? onreadrequest(BluetoothAddress clientAddress, long offset);
+ };
+Since: + 6.0 +
+Remark: + Example of using can be found at BluetoothGATTServerCharacteristic.setReadValueRequestCallback() and BluetoothGATTServerDescriptor.setReadValueRequestCallback() code examples. +
+onreadrequest
+GATTRequestReply? onreadrequest(BluetoothAddress clientAddress, long offset);
Since: + 6.0 +
++The server should reply to requests by returning a GATTRequestReply object with requested data and a proper status code. +If the callback does not return a GATTRequestReply, the client will not receive a response. +
+Parameters:
+Return value:
+ [Callback=FunctionOnly, NoInterfaceObject] interface WriteValueRequestCallback {
+ GATTRequestReply? onwriterequest(BluetoothAddress clientAddress, byte[] value, long offset, boolean replyRequired);
+ };
+Since: + 6.0 +
+Remark: + Example of using can be found at BluetoothGATTServerCharacteristic.setWriteValueRequestCallback() and BluetoothGATTServerDescriptor.setWriteValueRequestCallback() code examples. +
+onwriterequest
+GATTRequestReply? onwriterequest(BluetoothAddress clientAddress, byte[] value, long offset, boolean replyRequired);
Since: + 6.0 +
++The server should reply to requests by returning a GATTRequestReply object with a status code. +If the callback does not return a GATTRequestReply, the client will not receive a response. +
+Parameters:
+ [Callback=FunctionOnly, NoInterfaceObject] interface NotificationCallback {
+ void onnotificationsuccess(BluetoothAddress clientAddress);
+ void onnotificationfail(BluetoothAddress clientAddress, WebAPIException error);
+ void onnotificationfinish(BluetoothAddress clientAddress);
+ };
+Since: + 6.0 +
+Remark: + Example of using can be found at BluetoothGATTServerCharacteristic.notifyAboutValueChange() code examples. +
+onnotificationsuccess
+void onnotificationsuccess(BluetoothAddress clientAddress);
Since: + 6.0 +
+Parameters:
+onnotificationfail
+void onnotificationfail(BluetoothAddress clientAddress, WebAPIException error);
Since: + 6.0 +
+Parameters:
+onnotificationfinish
+void onnotificationfinish(BluetoothAddress clientAddress);
Since: + 6.0 +
+Parameters:
+ [Callback=FunctionOnly, NoInterfaceObject] interface ConnectionMtuCallback {
+ void onsuccess(long mtu);
+ };
+Since: + 6.0 +
+Remark: + Example of using can be found at BluetoothGATTServer.getConnectionMtu() code example. +
+ +Since: 2.3.1 @@ -4314,6 +6491,8 @@
Since: 2.3.1
+Remark: + This value will be set to null, if the object is obtained from BluetoothLEConnectChangeCallback. +
Code example:
var adapter = tizen.bluetooth.getLEAdapter(); adapter.startScan(function onsuccess(device) @@ -4366,6 +6548,9 @@Attributes
Since: 2.3.1
+Remark: + This value will be set to null, if the object is obtained from BluetoothLEConnectChangeCallback. +
Code example:
var adapter = tizen.bluetooth.getLEAdapter(); adapter.startScan(function onsuccess(device) @@ -4383,6 +6568,9 @@Attributes
Since: 2.3.1
+Remark: + This value will be set to null, if the object is obtained from BluetoothLEConnectChangeCallback. +
Code example:
var adapter = tizen.bluetooth.getLEAdapter(); adapter.startScan(function onsuccess(device) @@ -4401,6 +6589,9 @@Attributes
Since: 2.3.1
+Remark: + This value will be set to null, if the object is obtained from BluetoothLEConnectChangeCallback. +
Code example:
var adapter = tizen.bluetooth.getLEAdapter(); adapter.startScan(function onsuccess(device) @@ -4425,6 +6616,9 @@Attributes
Since: 2.3.1
+Remark: + This value will be set to null, if the object is obtained from BluetoothLEConnectChangeCallback. +
Code example:
var adapter = tizen.bluetooth.getLEAdapter(); adapter.startScan(function onsuccess(device) @@ -4452,6 +6646,9 @@Attributes
Remark: On devices prior to Tizen 6.0, service data is found only when its BluetoothLEServiceData::uuid is 16-bit. Finding service data with 128-bit BluetoothLEServiceData::uuid is supported since Tizen 6.0.
+Remark: + This value will be set to null, if the object is obtained from BluetoothLEConnectChangeCallback. +
Code example:
var adapter = tizen.bluetooth.getLEAdapter(); adapter.startScan(function onsuccess(device) @@ -4475,6 +6672,9 @@Attributes
Since: 2.3.1
+Remark: + This value will be set to null, if the object is obtained from BluetoothLEConnectChangeCallback. +
Code example:
var adapter = tizen.bluetooth.getLEAdapter(); @@ -4513,7 +6713,7 @@Attributes
- readonly -long rssi
+long rssi [nullable]The received signal strength indicator in dBm (decibel-milliwatts) units.@@ -4524,6 +6724,9 @@+Attributes
Since: 3.0
+Remark: + Since Tizen 6.0, this value can be a null, but only if the object is obtained from BluetoothLEConnectChangeCallback. +
+ +Code example:
var adapter = tizen.bluetooth.getLEAdapter(); adapter.startScan(function onsuccess(device) @@ -4694,15 +6897,76 @@+Methods
device.disconnect(ondisconnect, onerror); } - if (device.address == "11:22:33:44:55:66") - { - console.log("Found device: " + device.name); - device.connect(onconnected, onerror); - } + if (device.address == "11:22:33:44:55:66") + { + console.log("Found device: " + device.name); + device.connect(onconnected, onerror); + } +} + +var adapter = tizen.bluetooth.getLEAdapter(); +adapter.startScan(onDeviceFound, onerror); +- +
+isConnected+- +
@@ -4887,7 +7151,7 @@+ Checks if Bluetooth Low Energy device is currently connected. +++boolean isConnected();Since: + 6.0 +
+++Return value:
++boolean: + true if the device is currently connected, false otherwise. +
+++Exceptions:
++
- WebAPIException
+
+ with error type UnknownError, if any error occurs. +
++Code example:
var dev; + +function onerror(e) +{ + console.log("Failed to connect to device: " + e.message); +} + +function onconnected() +{ + console.log("Connected to device: " + dev.isConnected()); } var adapter = tizen.bluetooth.getLEAdapter(); -adapter.startScan(onDeviceFound, onerror); +adapter.startScan(function onsuccess(device) +{ + if (device.address == "11:22:33:44:55:66") + { + adapter.stopScan(); + dev = device; + var connected = dev.isConnected(); + console.log("Found device: " + device.name + ", connected: " + connected); + if (!connected) + { + device.connect(onconnected, onerror); + } + } +}); +++Output example:
Found device: TestDevice, connected: false +Connected to device: trueMethods
@@ -4984,11 +7248,282 @@Exceptions:
- WebAPIException
- with error type UnknownError, if any other error occurs. + with error type TypeMismatchError, if the input parameter is not compatible with the expected type for that parameter.
Methods
- +
+getAttMtu+- +
++ Gets the current value of Attribute Protocol(ATT) Maximum Transmission Unit(MTU) from the connected device. +++unsigned long getAttMtu();Since: + 6.0 +
+++Return value:
++unsigned long: + Current ATT MTU value. +
+++Exceptions:
++
- WebAPIException
+
+- +
+ with error type InvalidStateError, if the remote device is not connected. +
- +
+ with error type UnknownError, if any other error occurs. +
++Code example:
var dev; + +function onerror(e) +{ + console.log("Failed to connect to device: " + e.message); +} + +function onconnected() +{ + console.log("Connected to device, ATT MTU: " + dev.getAttMtu()); +} + +var adapter = tizen.bluetooth.getLEAdapter(); +adapter.startScan(function onsuccess(device) +{ + if (device.address == "11:22:33:44:55:66") + { + dev = device; + console.log("Found device: " + device.name); + device.connect(onconnected, onerror); + } +}); ++++Output example:
Found device: TestDevice +Connected to device, ATT MTU: 23 ++- +
+requestAttMtuChange+- +
++ Requests the GATT server to change the Attribute Protocol (ATT) Maximum Transmission Unit (MTU) value. +++void requestAttMtuChange(unsigned long newAttMtu);Since: + 6.0 +
+Remark: + ATT MTU value is determined between two connected devices and change will be successful only if both devices support the given value of ATT MTU. +
+++Parameters:
++
+- +newAttMtu: + The new ATT MTU value, that will be sent to GATT server. +
+++Exceptions:
++
- WebAPIException
+
+ with error type UnknownError, if any error occurs. +
++Code example:
function proccessDevice(device) +{ + function onConnected() + { + var attMtu = device.getAttMtu(); + console.log("Initial ATT MTU value: " + attMtu); + watchID = device.addAttMtuChangeListener(function(value) + { + console.log("ATT MTU changed to: " + value); + device.removeAttMtuChangeListener(watchID); + device.disconnect(); + }); + device.requestAttMtuChange(64); + } + 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); + } +}); ++++Output example:
Found device: TestDevice +Initial ATT MTU value: 31 +ATT MTU changed to: 64 ++- +
+addAttMtuChangeListener+- +
++ Registers a listener to be called when ATT MTU value is changed. +++long addAttMtuChangeListener(ConnectionMtuCallback callback);Since: + 6.0 +
+Remark: + ATT MTU value is determined between two connected devices and change takes place after both devices agrees to new value, both connected devices can initiate the ATT MTU value change by sending the request. +
+++Parameters:
++
+- +callback: + Listener function that is called when the connection's ATT MTU changes. +
+++Return value:
++long: + The watchID to be used to unregister the listener. +
+++Exceptions:
++
- WebAPIException
+
+- +
+ with error type TypeMismatchError, if an input attribute is not compatible with the expected type for this attribute. +
- +
+ with error type UnknownError, if any other error occurs. +
++Code example:
function proccessDevice(device) +{ + function onConnected() + { + var attMtu = device.getAttMtu(); + console.log("Initial ATT MTU value: " + attMtu); + watchID = device.addAttMtuChangeListener(function(value) + { + console.log("ATT MTU changed to: " + value); + device.removeAttMtuChangeListener(watchID); + device.disconnect(); + }); + device.requestAttMtuChange(64); + } + 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); + } +}); ++++Output example:
Found device: TestDevice +Initial ATT MTU value: 31 +ATT MTU changed to: 64 ++- +
+removeAttMtuChangeListener+- +
+ Unregisters the ATT MTU value change listener. +++void removeAttMtuChangeListener(long watchId);Since: + 6.0 +
+++Parameters:
++
+- +watchId: + The watchID identifier returned by the addAttMtuChangeListener() method. +
+++Exceptions:
++
- WebAPIException
+
+ with error type UnknownError, if any error occurs. +
++Code example:
function proccessDevice(device) +{ + function onConnected() + { + var attMtu = device.getAttMtu(); + console.log("Initial ATT MTU value: " + attMtu); + watchID = device.addAttMtuChangeListener(function(value) + { + console.log("ATT MTU changed to: " + value); + device.removeAttMtuChangeListener(watchID); + device.disconnect(); + }); + device.requestAttMtuChange(64); + } + 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); + } +}); ++++Output example:
Found device: TestDevice +Initial ATT MTU value: 31 +ATT MTU changed to: 64 ++-2.20. BluetoothClassDeviceMajor
+2.32. BluetoothClassDeviceMajor
The BluetoothClassDeviceMajor interface holds the identifiers for major device classes of Bluetooth CoD.@@ -5680,7 +8215,7 @@Methods
-2.21. BluetoothClassDeviceMinor
+2.33. BluetoothClassDeviceMinor
The BluetoothClassDeviceMinor interface holds the identifiers for minor device classes of Bluetooth CoD.@@ -5763,7 +8298,7 @@Methods
+To guarantee that the Bluetooth Low Energy application runs on a device with Bluetooth Low Energy GATT Server feature, declare the following feature requirements in the config file: +
+