| OLD | NEW |
| (Empty) |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 // The <code>chrome.bluetoothLowEnergy</code> API is used to communicate with | |
| 6 // Bluetooth Smart (Low Energy) devices using the | |
| 7 // <a href="https://developer.bluetooth.org/TechnologyOverview/Pages/GATT.aspx"> | |
| 8 // Generic Attribute Profile (GATT)</a>. | |
| 9 namespace bluetoothLowEnergy { | |
| 10 // Values representing the possible properties of a characteristic. | |
| 11 // Characteristic permissions are inferred from these properties. | |
| 12 // Please see the Bluetooth 4.x spec to see the meaning of each individual | |
| 13 // property. | |
| 14 enum CharacteristicProperty { | |
| 15 broadcast, read, writeWithoutResponse, write, notify, indicate, | |
| 16 authenticatedSignedWrites, extendedProperties, reliableWrite, | |
| 17 writableAuxiliaries, encryptRead, encryptWrite, encryptAuthenticatedRead, | |
| 18 encryptAuthenticatedWrite | |
| 19 }; | |
| 20 | |
| 21 // Values representing possible permissions for a descriptor. | |
| 22 // Please see the Bluetooth 4.x spec to see the meaning of each individual | |
| 23 // permission. | |
| 24 enum DescriptorPermission { | |
| 25 read, write, encryptedRead, encryptedWrite, encryptedAuthenticatedRead, | |
| 26 encryptedAuthenticatedWrite | |
| 27 }; | |
| 28 | |
| 29 // Type of advertisement. If 'broadcast' is chosen, the sent advertisement | |
| 30 // type will be ADV_NONCONN_IND and the device will broadcast with a random | |
| 31 // MAC Address. If set to 'peripheral', the advertisement type will be | |
| 32 // ADV_IND or ADV_SCAN_IND and the device will broadcast with real Bluetooth | |
| 33 // Adapter's MAC Address. | |
| 34 enum AdvertisementType {broadcast, peripheral}; | |
| 35 | |
| 36 // Represents a bluetooth central device that is connected to the local GATT | |
| 37 // server. | |
| 38 dictionary Device { | |
| 39 // The address of the device, in the format 'XX:XX:XX:XX:XX:XX'. | |
| 40 DOMString address; | |
| 41 | |
| 42 // The human-readable name of the device. | |
| 43 DOMString? name; | |
| 44 | |
| 45 // The class of the device, a bit-field defined by | |
| 46 // http://www.bluetooth.org/en-us/specification/assigned-numbers/baseband. | |
| 47 long? deviceClass; | |
| 48 }; | |
| 49 | |
| 50 // Represents a peripheral's Bluetooth GATT Service, a collection of | |
| 51 // characteristics and relationships to other services that encapsulate | |
| 52 // the behavior of part of a device. | |
| 53 dictionary Service { | |
| 54 // The UUID of the service, e.g. 0000180d-0000-1000-8000-00805f9b34fb. | |
| 55 DOMString uuid; | |
| 56 | |
| 57 // Indicates whether the type of this service is primary or secondary. | |
| 58 boolean isPrimary; | |
| 59 | |
| 60 // Returns the identifier assigned to this service. Use the instance ID to | |
| 61 // distinguish between services from a peripheral with the same UUID and | |
| 62 // to make function calls that take in a service identifier. Present, if | |
| 63 // this instance represents a remote service. | |
| 64 DOMString? instanceId; | |
| 65 | |
| 66 // The device address of the remote peripheral that the GATT service belongs | |
| 67 // to. Present, if this instance represents a remote service. | |
| 68 DOMString? deviceAddress; | |
| 69 }; | |
| 70 | |
| 71 // Represents a GATT characteristic, which is a basic data element that | |
| 72 // provides further information about a peripheral's service. | |
| 73 dictionary Characteristic { | |
| 74 // The UUID of the characteristic, e.g. | |
| 75 // 00002a37-0000-1000-8000-00805f9b34fb. | |
| 76 DOMString uuid; | |
| 77 | |
| 78 // The GATT service this characteristic belongs to. | |
| 79 Service? service; | |
| 80 | |
| 81 // The properties of this characteristic. | |
| 82 CharacteristicProperty[] properties; | |
| 83 | |
| 84 // Returns the identifier assigned to this characteristic. Use the instance | |
| 85 // ID to distinguish between characteristics from a peripheral with the same | |
| 86 // UUID and to make function calls that take in a characteristic identifier. | |
| 87 // Present, if this instance represents a remote characteristic. | |
| 88 DOMString? instanceId; | |
| 89 | |
| 90 // The currently cached characteristic value. This value gets updated when | |
| 91 // the value of the characteristic is read or updated via a notification | |
| 92 // or indication. | |
| 93 ArrayBuffer? value; | |
| 94 }; | |
| 95 | |
| 96 // Represents a GATT characteristic descriptor, which provides further | |
| 97 // information about a characteristic's value. | |
| 98 dictionary Descriptor { | |
| 99 // The UUID of the characteristic descriptor, e.g. | |
| 100 // 00002902-0000-1000-8000-00805f9b34fb. | |
| 101 DOMString uuid; | |
| 102 | |
| 103 // The GATT characteristic this descriptor belongs to. | |
| 104 Characteristic? characteristic; | |
| 105 | |
| 106 // The permissions of this descriptor. | |
| 107 DescriptorPermission[] permissions; | |
| 108 | |
| 109 // Returns the identifier assigned to this descriptor. Use the instance ID | |
| 110 // to distinguish between descriptors from a peripheral with the same UUID | |
| 111 // and to make function calls that take in a descriptor identifier. Present, | |
| 112 // if this instance represents a remote characteristic. | |
| 113 DOMString? instanceId; | |
| 114 | |
| 115 // The currently cached descriptor value. This value gets updated when | |
| 116 // the value of the descriptor is read. | |
| 117 ArrayBuffer? value; | |
| 118 }; | |
| 119 | |
| 120 // The connection properties specified during a call to $(ref:connect). | |
| 121 dictionary ConnectProperties { | |
| 122 // Flag indicating whether a connection to the device is left open when the | |
| 123 // event page of the application is unloaded (see <a | |
| 124 // href="http://developer.chrome.com/apps/app_lifecycle.html">Manage App | |
| 125 // Lifecycle</a>). The default value is <code>false.</code> | |
| 126 boolean persistent; | |
| 127 }; | |
| 128 | |
| 129 // Optional characteristic notification session properties specified during a | |
| 130 // call to $(ref:startCharacteristicNotifications). | |
| 131 dictionary NotificationProperties { | |
| 132 // Flag indicating whether the app should receive notifications when the | |
| 133 // event page of the application is unloaded (see <a | |
| 134 // href="http://developer.chrome.com/apps/app_lifecycle.html">Manage App | |
| 135 // Lifecycle</a>). The default value is <code>false</code>. | |
| 136 boolean persistent; | |
| 137 }; | |
| 138 | |
| 139 // Represents an entry of the "Manufacturer Specific Data" field of Bluetooth | |
| 140 // LE advertisement data. | |
| 141 dictionary ManufacturerData { | |
| 142 long id; | |
| 143 long[] data; | |
| 144 }; | |
| 145 | |
| 146 // Represents an entry of the "Service Data" field of Bluetooth LE advertiseme
nt | |
| 147 // data. | |
| 148 dictionary ServiceData { | |
| 149 DOMString uuid; | |
| 150 long[] data; | |
| 151 }; | |
| 152 | |
| 153 // Represents a Bluetooth LE advertisement instance. | |
| 154 dictionary Advertisement { | |
| 155 // Type of advertisement. | |
| 156 AdvertisementType type; | |
| 157 | |
| 158 // List of UUIDs to include in the "Service UUIDs" field of the Advertising | |
| 159 // Data. These UUIDs can be of the 16bit, 32bit or 128 formats. | |
| 160 DOMString[]? serviceUuids; | |
| 161 | |
| 162 // List of manufacturer specific data to be included in "Manufacturer Specif
ic | |
| 163 // Data" fields of the advertising data. | |
| 164 ManufacturerData[]? manufacturerData; | |
| 165 | |
| 166 // List of UUIDs to include in the "Solicit UUIDs" field of the Advertising | |
| 167 // Data. These UUIDs can be of the 16bit, 32bit or 128 formats. | |
| 168 DOMString[]? solicitUuids; | |
| 169 | |
| 170 // List of service data to be included in "Service Data" fields of the adver
tising | |
| 171 // data. | |
| 172 ServiceData[]? serviceData; | |
| 173 }; | |
| 174 | |
| 175 // Represents a an attribute read/write request. | |
| 176 dictionary Request { | |
| 177 // Unique ID for this request. Use this ID when responding to this request. | |
| 178 long requestId; | |
| 179 // Device that send this request. | |
| 180 Device device; | |
| 181 // Value to write (if this is a write request). | |
| 182 ArrayBuffer? value; | |
| 183 }; | |
| 184 | |
| 185 // Represents a response to an attribute read/write request. | |
| 186 dictionary Response { | |
| 187 // Id of the request this is a response to. | |
| 188 long requestId; | |
| 189 // If this is an error response, this should be true. | |
| 190 boolean isError; | |
| 191 // Response value. Write requests and error responses will ignore this | |
| 192 // parameter. | |
| 193 ArrayBuffer? value; | |
| 194 }; | |
| 195 | |
| 196 // Represents a notification to be sent to a remote device. | |
| 197 dictionary Notification { | |
| 198 // New value of the characteristic. | |
| 199 ArrayBuffer value; | |
| 200 // Optional flag for sending an indication instead of a notification. | |
| 201 boolean? shouldIndicate; | |
| 202 }; | |
| 203 | |
| 204 callback CharacteristicCallback = void(Characteristic result); | |
| 205 callback CreateCharacteristicCallback = void(DOMString characteristicId); | |
| 206 callback CharacteristicsCallback = void(Characteristic[] result); | |
| 207 callback DescriptorCallback = void(Descriptor result); | |
| 208 callback CreateDescriptorCallback = void(DOMString descriptorId); | |
| 209 callback DescriptorsCallback = void(Descriptor[] result); | |
| 210 callback ResultCallback = void(); | |
| 211 callback ServiceCallback = void(Service result); | |
| 212 callback CreateServiceCallback = void(DOMString serviceId); | |
| 213 callback ServicesCallback = void(Service[] result); | |
| 214 callback RegisterAdvertisementCallback = void (long advertisementId); | |
| 215 | |
| 216 // These functions all report failures via chrome.runtime.lastError. | |
| 217 interface Functions { | |
| 218 // Establishes a connection between the application and the device with the | |
| 219 // given address. A device may be already connected and its GATT services | |
| 220 // available without calling <code>connect</code>, however, an app that | |
| 221 // wants to access GATT services of a device should call this function to | |
| 222 // make sure that a connection to the device is maintained. If the device | |
| 223 // is not connected, all GATT services of the device will be discovered | |
| 224 // after a successful call to <code>connect</code>. | |
| 225 // |deviceAddress|: The Bluetooth address of the remote device to which a | |
| 226 // GATT connection should be opened. | |
| 227 // |properties|: Connection properties (optional). | |
| 228 // |callback|: Called when the connect request has completed. | |
| 229 static void connect(DOMString deviceAddress, | |
| 230 optional ConnectProperties properties, | |
| 231 ResultCallback callback); | |
| 232 | |
| 233 // Closes the app's connection to the device with the given address. Note | |
| 234 // that this will not always destroy the physical link itself, since there | |
| 235 // may be other apps with open connections. | |
| 236 // |deviceAddress|: The Bluetooth address of the remote device. | |
| 237 // |callback|: Called when the disconnect request has completed. | |
| 238 static void disconnect(DOMString deviceAddress, | |
| 239 optional ResultCallback callback); | |
| 240 | |
| 241 // Get the GATT service with the given instance ID. | |
| 242 // |serviceId|: The instance ID of the requested GATT service. | |
| 243 // |callback|: Called with the requested Service object. | |
| 244 static void getService(DOMString serviceId, ServiceCallback callback); | |
| 245 | |
| 246 // Create a locally hosted GATT service. This service can be registered | |
| 247 // to be available on a local GATT server. | |
| 248 // This function is only available if the app has both the | |
| 249 // bluetooth:low_energy and the bluetooth:peripheral permissions set to | |
| 250 // true. The peripheral permission may not be available to all apps. | |
| 251 // |service|: The service to create. | |
| 252 // |callback|: Called with the created services's unique ID. | |
| 253 static void createService(Service service, CreateServiceCallback callback); | |
| 254 | |
| 255 // Get all the GATT services that were discovered on the remote device with | |
| 256 // the given device address. | |
| 257 // |deviceAddress|: The Bluetooth address of the remote device whose GATT | |
| 258 // services should be returned. | |
| 259 // |callback|: Called with the list of requested Service objects. | |
| 260 static void getServices(DOMString deviceAddress, ServicesCallback callback); | |
| 261 | |
| 262 // Get the GATT characteristic with the given instance ID that belongs to | |
| 263 // the given GATT service, if the characteristic exists. | |
| 264 // |characteristicId|: The instance ID of the requested GATT | |
| 265 // characteristic. | |
| 266 // |callback|: Called with the requested Characteristic object. | |
| 267 static void getCharacteristic(DOMString characteristicId, | |
| 268 CharacteristicCallback callback); | |
| 269 | |
| 270 // Create a locally hosted GATT characteristic. This characteristic must | |
| 271 // be hosted under a valid service. If the service ID is not valid, the | |
| 272 // lastError will be set. | |
| 273 // This function is only available if the app has both the | |
| 274 // bluetooth:low_energy and the bluetooth:peripheral permissions set to | |
| 275 // true. The peripheral permission may not be available to all apps. | |
| 276 // |characteristic|: The characteristic to create. | |
| 277 // |serviceId|: ID of the service to create this characteristic for. | |
| 278 // |callback|: Called with the created characteristic's unique ID. | |
| 279 static void createCharacteristic(Characteristic characteristic, | |
| 280 DOMString serviceId, | |
| 281 CreateCharacteristicCallback callback); | |
| 282 | |
| 283 // Get a list of all discovered GATT characteristics that belong to the | |
| 284 // given service. | |
| 285 // |serviceId|: The instance ID of the GATT service whose characteristics | |
| 286 // should be returned. | |
| 287 // |callback|: Called with the list of characteristics that belong to the | |
| 288 // given service. | |
| 289 static void getCharacteristics(DOMString serviceId, | |
| 290 CharacteristicsCallback callback); | |
| 291 | |
| 292 // Get a list of GATT services that are included by the given service. | |
| 293 // |serviceId|: The instance ID of the GATT service whose included | |
| 294 // services should be returned. | |
| 295 // |callback|: Called with the list of GATT services included from the | |
| 296 // given service. | |
| 297 static void getIncludedServices(DOMString serviceId, | |
| 298 ServicesCallback callback); | |
| 299 | |
| 300 // Get the GATT characteristic descriptor with the given instance ID. | |
| 301 // |descriptorId|: The instance ID of the requested GATT characteristic | |
| 302 // descriptor. | |
| 303 // |callback|: Called with the requested Descriptor object. | |
| 304 static void getDescriptor(DOMString descriptorId, | |
| 305 DescriptorCallback callback); | |
| 306 | |
| 307 // Create a locally hosted GATT descriptor. This descriptor must | |
| 308 // be hosted under a valid characteristic. If the characteristic ID is not | |
| 309 // valid, the lastError will be set. | |
| 310 // This function is only available if the app has both the | |
| 311 // bluetooth:low_energy and the bluetooth:peripheral permissions set to | |
| 312 // true. The peripheral permission may not be available to all apps. | |
| 313 // |descriptor|: The descriptor to create. | |
| 314 // |characteristicId|: ID of the characteristic to create this descriptor | |
| 315 // for. | |
| 316 // |callback|: Called with the created descriptor's unique ID. | |
| 317 static void createDescriptor(Descriptor descriptor, | |
| 318 DOMString characteristicId, | |
| 319 CreateDescriptorCallback callback); | |
| 320 | |
| 321 // Get a list of GATT characteristic descriptors that belong to the given | |
| 322 // characteristic. | |
| 323 // |characteristicId|: The instance ID of the GATT characteristic whose | |
| 324 // descriptors should be returned. | |
| 325 // |callback|: Called with the list of descriptors that belong to the given | |
| 326 // characteristic. | |
| 327 static void getDescriptors(DOMString characteristicId, | |
| 328 DescriptorsCallback callback); | |
| 329 | |
| 330 // Retrieve the value of a specified characteristic from a remote | |
| 331 // peripheral. | |
| 332 // |characteristicId|: The instance ID of the GATT characteristic whose | |
| 333 // value should be read from the remote device. | |
| 334 // |callback|: Called with the Characteristic object whose value was | |
| 335 // requested. The <code>value</code> field of the returned Characteristic | |
| 336 // object contains the result of the read request. | |
| 337 static void readCharacteristicValue(DOMString characteristicId, | |
| 338 CharacteristicCallback callback); | |
| 339 | |
| 340 // Write the value of a specified characteristic from a remote peripheral. | |
| 341 // |characteristicId|: The instance ID of the GATT characteristic whose | |
| 342 // value should be written to. | |
| 343 // |value|: The value that should be sent to the remote characteristic as | |
| 344 // part of the write request. | |
| 345 // |callback|: Called when the write request has completed. | |
| 346 static void writeCharacteristicValue(DOMString characteristicId, | |
| 347 ArrayBuffer value, | |
| 348 ResultCallback callback); | |
| 349 | |
| 350 // Enable value notifications/indications from the specified characteristic. | |
| 351 // Once enabled, an application can listen to notifications using the | |
| 352 // $(ref:onCharacteristicValueChanged) event. | |
| 353 // |characteristicId|: The instance ID of the GATT characteristic that | |
| 354 // notifications should be enabled on. | |
| 355 // |properties|: Notification session properties (optional). | |
| 356 // |callback|: Called when the request has completed. | |
| 357 static void startCharacteristicNotifications( | |
| 358 DOMString characteristicId, | |
| 359 optional NotificationProperties properties, | |
| 360 ResultCallback callback); | |
| 361 | |
| 362 // Disable value notifications/indications from the specified | |
| 363 // characteristic. After a successful call, the application will stop | |
| 364 // receiving notifications/indications from this characteristic. | |
| 365 // |characteristicId|: The instance ID of the GATT characteristic on which | |
| 366 // this app's notification session should be stopped. | |
| 367 // |callback|: Called when the request has completed (optional). | |
| 368 static void stopCharacteristicNotifications( | |
| 369 DOMString characteristicId, | |
| 370 optional ResultCallback callback); | |
| 371 | |
| 372 // Notify a remote device of a new value for a characteristic. If the | |
| 373 // shouldIndicate flag in the notification object is true, an indication | |
| 374 // will be sent instead of a notification. Note, the characteristic needs | |
| 375 // to correctly set the 'notify' or 'indicate' property during creation for | |
| 376 // this call to succeed. | |
| 377 // This function is only available if the app has both the | |
| 378 // bluetooth:low_energy and the bluetooth:peripheral permissions set to | |
| 379 // true. The peripheral permission may not be available to all apps. | |
| 380 // |characteristicId|: The characteristic to send the notication for. | |
| 381 // |notifcation|: The notification to send. | |
| 382 // |callback|: Callback called once the notification or indication has | |
| 383 // been sent successfully. | |
| 384 static void notifyCharacteristicValueChanged(DOMString characteristicId, | |
| 385 Notification notification, | |
| 386 ResultCallback callback); | |
| 387 | |
| 388 // Retrieve the value of a specified characteristic descriptor from a remote | |
| 389 // peripheral. | |
| 390 // |descriptorId|: The instance ID of the GATT characteristic descriptor | |
| 391 // whose value should be read from the remote device. | |
| 392 // |callback|: Called with the Descriptor object whose value was requested. | |
| 393 // The <code>value</code> field of the returned Descriptor object contains | |
| 394 // the result of the read request. | |
| 395 static void readDescriptorValue(DOMString descriptorId, | |
| 396 DescriptorCallback callback); | |
| 397 | |
| 398 // Write the value of a specified characteristic descriptor from a remote | |
| 399 // peripheral. | |
| 400 // |descriptorId|: The instance ID of the GATT characteristic descriptor | |
| 401 // whose value should be written to. | |
| 402 // |value|: The value that should be sent to the remote descriptor as part | |
| 403 // of the write request. | |
| 404 // |callback|: Called when the write request has completed. | |
| 405 static void writeDescriptorValue(DOMString descriptorId, | |
| 406 ArrayBuffer value, | |
| 407 ResultCallback callback); | |
| 408 | |
| 409 // Register the given service with the local GATT server. If the service | |
| 410 // ID is invalid, the lastError will be set. | |
| 411 // This function is only available if the app has both the | |
| 412 // bluetooth:low_energy and the bluetooth:peripheral permissions set to | |
| 413 // true. The peripheral permission may not be available to all apps. | |
| 414 // |serviceId|: Unique ID of a created service. | |
| 415 // |callback|: Callback with the result of the register operation. | |
| 416 static void registerService( | |
| 417 DOMString serviceId, ResultCallback callback); | |
| 418 | |
| 419 // Unregister the given service with the local GATT server. If the service | |
| 420 // ID is invalid, the lastError will be set. | |
| 421 // This function is only available if the app has both the | |
| 422 // bluetooth:low_energy and the bluetooth:peripheral permissions set to | |
| 423 // true. The peripheral permission may not be available to all apps. | |
| 424 // |serviceId|: Unique ID of a current registered service. | |
| 425 // |callback|: Callback with the result of the register operation. | |
| 426 static void unregisterService( | |
| 427 DOMString serviceId, ResultCallback callback); | |
| 428 | |
| 429 // Remove the specified service, unregistering it if it was registered. | |
| 430 // If the service ID is invalid, the lastError will be set. | |
| 431 // This function is only available if the app has both the | |
| 432 // bluetooth:low_energy and the bluetooth:peripheral permissions set to | |
| 433 // true. The peripheral permission may not be available to all apps. | |
| 434 // |serviceId|: Unique ID of a current registered service. | |
| 435 // |callback|: Callback called once the service is removed. | |
| 436 static void removeService( | |
| 437 DOMString serviceId, optional ResultCallback callback); | |
| 438 | |
| 439 // Create an advertisement and register it for advertising. To call this | |
| 440 // function, the app must have the bluetooth:low_energy and | |
| 441 // bluetooth:peripheral permissions set to true. Additionally this API | |
| 442 // is only available to auto launched apps in Kiosk Mode of by setting | |
| 443 // the 'enable-ble-advertising-in-apps' flag. | |
| 444 // See https://developer.chrome.com/apps/manifest/bluetooth | |
| 445 // Note: On some hardware, central and peripheral modes at the same time is | |
| 446 // supported but on hardware that doesn't support this, making this call | |
| 447 // will switch the device to peripheral mode. In the case of hardware which | |
| 448 // does not support both central and peripheral mode, attempting to use the | |
| 449 // device in both modes will lead to undefined behavior or prevent other | |
| 450 // central-role applications from behaving correctly (including the | |
| 451 // discovery of Bluetooth Low Energy devices). | |
| 452 // |advertisement|: The advertisement to advertise. | |
| 453 // |callback|: Called once the registeration is done and we've started | |
| 454 // advertising. Returns the id of the created advertisement. | |
| 455 static void registerAdvertisement( | |
| 456 Advertisement advertisement, RegisterAdvertisementCallback callback); | |
| 457 | |
| 458 // Unregisters an advertisement and stops its advertising. If the | |
| 459 // advertisement fails to unregister the only way to stop advertising | |
| 460 // might be to restart the device. | |
| 461 // |advertisementId|: Id of the advertisement to unregister. | |
| 462 // |callback|: Called once the advertisement is unregistered and is no | |
| 463 // longer being advertised. | |
| 464 static void unregisterAdvertisement(long advertisementId, | |
| 465 ResultCallback callback); | |
| 466 | |
| 467 // Set's the interval betweeen two consecutive advertisements. Note: | |
| 468 // This is a best effort. The actual interval may vary non-trivially | |
| 469 // from the requested intervals. On some hardware, there is a minimum | |
| 470 // interval of 100ms. The minimum and maximum values cannot exceed the | |
| 471 // the range allowed by the Bluetooth 4.2 specification. | |
| 472 // |minInterval|: Minimum interval between advertisments (in | |
| 473 // milliseconds). This cannot be lower than 20ms (as per the spec). | |
| 474 // |maxInterval|: Maximum interval between advertisments (in | |
| 475 // milliseconds). This cannot be more than 10240ms (as per the spec). | |
| 476 // |callback|: Called once the interval has been set. | |
| 477 static void setAdvertisingInterval(long minInterval, long maxInterval, | |
| 478 ResultCallback callback); | |
| 479 | |
| 480 // Sends a response for a characteristic or descriptor read/write | |
| 481 // request. | |
| 482 // This function is only available if the app has both the | |
| 483 // bluetooth:low_energy and the bluetooth:peripheral permissions set to | |
| 484 // true. The peripheral permission may not be available to all apps. | |
| 485 // |response|: The response to the request. | |
| 486 static void sendRequestResponse(Response response); | |
| 487 }; | |
| 488 | |
| 489 interface Events { | |
| 490 // Fired whan a new GATT service has been discovered on a remote device. | |
| 491 // |service|: The GATT service that was added. | |
| 492 static void onServiceAdded(Service service); | |
| 493 | |
| 494 // Fired when the state of a remote GATT service changes. This involves any | |
| 495 // characteristics and/or descriptors that get added or removed from the | |
| 496 // service, as well as "ServiceChanged" notifications from the remote | |
| 497 // device. | |
| 498 // |service|: The GATT service whose state has changed. | |
| 499 static void onServiceChanged(Service service); | |
| 500 | |
| 501 // Fired when a GATT service that was previously discovered on a remote | |
| 502 // device has been removed. | |
| 503 // |service|: The GATT service that was removed. | |
| 504 static void onServiceRemoved(Service service); | |
| 505 | |
| 506 // Fired when the value of a remote GATT characteristic changes, either as | |
| 507 // a result of a read request, or a value change notification/indication | |
| 508 // This event will only be sent if the app has enabled notifications by | |
| 509 // calling $(ref:startCharacteristicNotifications). | |
| 510 // |characteristic|: The GATT characteristic whose value has changed. | |
| 511 static void onCharacteristicValueChanged(Characteristic characteristic); | |
| 512 | |
| 513 // Fired when the value of a remote GATT characteristic descriptor changes, | |
| 514 // usually as a result of a read request. This event exists | |
| 515 // mostly for convenience and will always be sent after a successful | |
| 516 // call to $(ref:readDescriptorValue). | |
| 517 // |descriptor|: The GATT characteristic descriptor whose value has | |
| 518 // changed. | |
| 519 static void onDescriptorValueChanged(Descriptor descriptor); | |
| 520 | |
| 521 // Fired when a connected central device requests to read the value of a | |
| 522 // characteristic registered on the local GATT server. Not responding | |
| 523 // to this request for a long time may lead to a disconnection. | |
| 524 // This event is only available if the app has both the | |
| 525 // bluetooth:low_energy and the bluetooth:peripheral permissions set to | |
| 526 // true. The peripheral permission may not be available to all apps. | |
| 527 // |request|: Request data for this request. | |
| 528 // |characteristic|: The GATT characteristic whose value is requested. | |
| 529 static void onCharacteristicReadRequest( | |
| 530 Request request, DOMString characteristicId); | |
| 531 | |
| 532 // Fired when a connected central device requests to write the value of a | |
| 533 // characteristic registered on the local GATT server. Not responding | |
| 534 // to this request for a long time may lead to a disconnection. | |
| 535 // This event is only available if the app has both the | |
| 536 // bluetooth:low_energy and the bluetooth:peripheral permissions set to | |
| 537 // true. The peripheral permission may not be available to all apps. | |
| 538 // |request|: Request data for this request. | |
| 539 // |characteristic|: The GATT characteristic whose value is being written. | |
| 540 static void onCharacteristicWriteRequest( | |
| 541 Request request, DOMString characteristicId); | |
| 542 | |
| 543 // Fired when a connected central device requests to read the value of a | |
| 544 // descriptor registered on the local GATT server. Not responding to | |
| 545 // this request for a long time may lead to a disconnection. | |
| 546 // This event is only available if the app has both the | |
| 547 // bluetooth:low_energy and the bluetooth:peripheral permissions set to | |
| 548 // true. The peripheral permission may not be available to all apps. | |
| 549 // |request|: Request data for this request. | |
| 550 // |descriptor|: The GATT descriptor whose value is requested. | |
| 551 static void onDescriptorReadRequest( | |
| 552 Request request, DOMString descriptorId); | |
| 553 | |
| 554 // Fired when a connected central device requests to write the value of a | |
| 555 // descriptor registered on the local GATT server. Not responding to | |
| 556 // this request for a long time may lead to a disconnection. | |
| 557 // This event is only available if the app has both the | |
| 558 // bluetooth:low_energy and the bluetooth:peripheral permissions set to | |
| 559 // true. The peripheral permission may not be available to all apps. | |
| 560 // |request|: Request data for this request. | |
| 561 // |descriptor|: The GATT descriptor whose value is being written. | |
| 562 static void onDescriptorWriteRequest( | |
| 563 Request request, DOMString descriptorId); | |
| 564 }; | |
| 565 }; | |
| OLD | NEW |