Constructor
new Adapter(bleDriver, adapter, instanceId, port, serialNumberopt, notSupportedMessageopt)
- Source:
Parameters:
Name |
Type |
Attributes |
Description |
bleDriver |
Object
|
|
The driver to use for getting constants from the pc-ble-driver-js AddOn.
|
adapter |
Object
|
|
The adapter to use. The adapter is an object received from the pc-ble-driver-js AddOn.
|
instanceId |
string
|
|
The unique Id that identifies this Adapter instance.
|
port |
string
|
|
The port this adapter uses. For example it can be 'COM1', '/dev/ttyUSB0' or similar.
|
serialNumber |
string
|
<optional>
|
The serial number of hardware device this adapter is controlling via serial.
|
notSupportedMessage |
string
|
<optional>
|
Message displayed to developer if this adapter is not supported on platform.
|
Fires:
Members
driver
Get the driver of this adapter.
- Source:
instanceId
Get the instanceId of this adapter.
- Source:
notSupportedMessage
Get the `notSupportedMessage` of this adapter.
- Source:
state
Get the state of this adapter. @ref: ./adapterState.js
- Source:
Methods
authenticate(deviceInstanceId, secParams, callbackopt) → {void}
Initiate the GAP Authentication procedure.
In the central role, this function will send an SMP Pairing Request (or an SMP Pairing Failed if rejected),
otherwise in the peripheral role, an SMP Security Request will be sent.
- Source:
Parameters:
Name |
Type |
Attributes |
Description |
deviceInstanceId |
string
|
|
The device's unique Id.
|
secParams |
object
|
|
The security parameters to be used during the pairing or bonding procedure.
In the peripheral role, only the bond, mitm, lesc and keypress fields of this Object are used.
In the central role, this pointer may be NULL to reject a Security Request.
Available GAP security parameters:
- {boolean} bond Perform bonding.
- {boolean} lesc Enable LE Secure Connection pairing.
- {boolean} keypress Enable generation of keypress notifications.
- {Object} io_caps IO capabilities, see @ref BLE_GAP_IO_CAPS.
- {boolean} oob Out Of Band data available.
- {number} min_key_size Minimum encryption key size in octets between 7 and 16. If 0 then not applicable in this instance.
- {number} max_key_size Maximum encryption key size in octets between min_key_size and 16.
- {Object} kdist_own Key distribution bitmap: keys that the local device will distribute.
- {boolean} enc Long Term Key and Master Identification.
- {boolean} id Identity Resolving Key and Identity Address Information.
- {boolean} sign Connection Signature Resolving Key.
- {boolean} link Derive the Link Key from the LTK.
- {Object} kdist_peer Key distribution bitmap: keys that the remote device will distribute.
- ^^ Same as properties as `kdist_own` above. ^^
|
callback |
function
|
<optional>
|
Callback signature: err => {}.
|
cancelConnect(callbackopt) → {void}
Cancel a connection establishment.
- Source:
Parameters:
Name |
Type |
Attributes |
Description |
callback |
function
|
<optional>
|
Callback signature: err => {}.
|
close(callbackopt) → {void}
Close the adapter.
This function will close the serial port, release allocated resources and remove event listeners.
Before closing, a reset command is issued to set the connectivity device to idle state.
- Source:
Parameters:
Name |
Type |
Attributes |
Description |
callback |
function
|
<optional>
|
Callback signature: err => {}.
|
computePublicKey() → {string}
Compute public key.
- Source:
Returns:
-
Type:
-
string
The public key generated from this adapter's key-pair.
computeSharedSecret(peerPublicKeyopt) → {string}
Compute shared secret.
- Source:
Parameters:
Name |
Type |
Attributes |
Description |
peerPublicKey |
string
|
<optional>
|
Peer public key.
|
Returns:
-
Type:
-
string
The computed shared secret generated from this adapter's key-pair.
connect(deviceAddress, options, callbackopt) → {void}
Create a connection (GAP Link Establishment).
If a scanning procedure is currently in progress it will be automatically stopped when calling this function.
The application will be informed of a connection being established with a event:DeviceConnectedEvent.
- Source:
Parameters:
Name |
Type |
Attributes |
Description |
deviceAddress |
string
|
Object
|
|
The peer address. If the use_whitelist bit is set in scanParams,
then this is ignored. If given as a string,
`address.type='BLE_GAP_ADDR_TYPE_RANDOM_STATIC'` by default. Else,
an Object with members: { address: {string}, type: {string} } must be given.
|
options |
Object
|
|
The scan and connection parameters.
Available options:
- {Object} scanParams:
- {boolean} active: If 1, perform active scanning (scan requests).
- {number} interval: Scan interval between 0x0004 and 0x4000 in 0.625ms units (2.5ms to 10.24s).
- {number} window: Scan window between 0x0004 and 0x4000 in 0.625ms units (2.5ms to 10.24s).
- {number} timeout: Scan timeout between 0x0001 and 0xFFFF in seconds, 0x0000 disables timeout.
- {number} use_whitelist: If 1, filter advertisers using current active whitelist.
- {number} adv_dir_report: If 1, also report directed advertisements where the initiator field is set to a
private resolvable address, even if the address did not resolve to an entry in the
device identity list. A report will be generated even if the peer is not in the whitelist.
- {Object} connParams:
- {number} min_conn_interval: Minimum Connection Interval in 1.25 ms units.
- {number} max_conn_interval: Maximum Connection Interval in 1.25 ms units.
- {number} slave_latency: Slave Latency in number of connection events.
- {number} conn_sup_timeout: Connection Supervision Timeout in 10 ms units.
|
callback |
function
|
<optional>
|
Callback signature: err => {}.
|
connReset(callbackopt) → {void}
Reset the connectivity device
This function will issue a reset command to the connectivity device.
- Source:
Parameters:
Name |
Type |
Attributes |
Description |
callback |
function
|
<optional>
|
Callback signature: err => {}.
|
deleteKeys() → {void}
Deletes any previously generated key-pair.
The next time `computeSharedSecret` or `computePublicKey` is invoked, a new key-pair will be generated and used.
- Source:
disconnect(deviceInstanceId, callbackopt) → {void}
Disconnect (GAP Link Termination).
This call initiates the disconnection procedure, and its completion will be communicated to the application
with a `BLE_GAP_EVT_DISCONNECTED` event upon which `callback` will be called.
- Source:
Parameters:
Name |
Type |
Attributes |
Description |
deviceInstanceId |
string
|
|
The device's unique Id.
|
callback |
function
|
<optional>
|
Callback signature: err => {}.
|
enableBLE(optionsopt, callbackopt) → {void}
Enable the BLE stack.
This call initializes the BLE stack, no other BLE related function can be called before this one.
- Source:
Parameters:
Name |
Type |
Attributes |
Description |
options |
Object
|
<optional>
|
BLE Initialization parameters. If `undefined` or `null` the BLE stack will be
initialized with default options (see code for `enableBLE()` below for default values).
Available BLE enable parameters:
- {Object} gap_enable_params: GAP init parameters
- {number} periph_conn_count: Number of connections acting as a peripheral.
- {number} central_conn_count: Number of connections acting as a central.
- {number} central_sec_count: Number of SMP instances for all connections acting as a central.
- {Object} gatts_enable_params: GATTS init parameters
- {boolean} service_changed: Include the Service Changed characteristic in the Attribute Table.
- {number} attr_tab_size: Attribute Table size in bytes. The size must be a multiple of 4.
- {Object} common_enable_params: Common init parameters
- {null|number} conn_bw_counts: Bandwidth configuration parameters or null for defaults.
- {number} vs_uuid_count: Maximum number of 128-bit, Vendor Specific UUID bases to allocate.
- {Object} gatt_enable_params: GATT init parameters
- {number} att_mtu: Maximum size of ATT packet the SoftDevice can send or receive.
If it is 0 then @ref GATT_MTU_SIZE_DEFAULT will be used.
Otherwise @ref GATT_MTU_SIZE_DEFAULT is the minimum value.
|
callback |
function
|
<optional>
|
Callback signature: (err, parameters, app_ram_base) => {}
where `parameters` is the BLE initialization parameters as
described above and `app_ram_base` is the minimum start address
of the application RAM region required by the SoftDevice for
this configuration.
|
encrypt(deviceInstanceId, masterId, encInfo, callbackopt) → {void}
Initiate GAP Encryption procedure.
In the central role, this function will initiate the encryption procedure using the encryption information provided.
- Source:
Parameters:
Name |
Type |
Attributes |
Description |
deviceInstanceId |
string
|
|
The device's unique Id.
|
masterId |
Object
|
|
Master identification structure. TODO
|
encInfo |
Object
|
|
Encryption information structure. TODO
|
callback |
function
|
<optional>
|
Callback signature: err => {}.
|
getAttributes(deviceInstanceId, callbackopt) → {void}
Discovers information about a range of attributes on a GATT server.
- Source:
Parameters:
Name |
Type |
Attributes |
Description |
deviceInstanceId |
string
|
|
The device's unique Id.
|
callback |
function
|
<optional>
|
Callback signature: (err, attributes) => {} where `attributes` contains
the device's GATT attributes (services, characteristics and
descriptors).
|
getCharacteristic(characteristicId) → {Characteristic}
Get a `Characteristic` instance by its instanceId.
- Source:
Parameters:
Name |
Type |
Description |
characteristicId |
string
|
The unique Id of this characteristic.
|
getCharacteristics(serviceId, callbackopt) → {void}
Initiate or continue a GATT Characteristic Discovery procedure.
- Source:
Parameters:
Name |
Type |
Attributes |
Description |
serviceId |
string
|
|
Unique ID of of the GATT service.
|
callback |
function
|
<optional>
|
Callback signature: (err, characteristics) => {} where
`characteristics` is an array of `Characteristic` instances
corresponding to the discovered GATT characteristics attached to
the service.
|
getCurrentAttMtu(deviceInstanceId) → {undefined|number}
Get the current ATT_MTU size.
- Source:
Parameters:
Name |
Type |
Description |
deviceInstanceId |
string
|
The device's unique Id.
|
Returns:
-
Type:
-
undefined
|
number
The current ATT_MTU size.
getDescriptor(descriptorId) → {Descriptor}
Get a `Descriptor` instance by its instanceId.
- Source:
Parameters:
Name |
Type |
Description |
descriptorId |
string
|
The unique Id of this descriptor.
|
getDescriptors(characteristicId, callbackopt) → {void}
Initiate or continue a GATT Characteristic Descriptor Discovery procedure.
- Source:
Parameters:
Name |
Type |
Attributes |
Description |
characteristicId |
string
|
|
Unique ID of of the GATT characteristic.
|
callback |
function
|
<optional>
|
Callback signature: (err, descriptors) => {} where
`descriptors` is an array of `Descriptor` instances corresponding to the
discovered GATT descriptors attached to the characteristic.
|
getDevice(deviceInstanceId) → {null|Device}
Get a device connected to this adapter by its instanceId.
- Source:
Parameters:
Name |
Type |
Description |
deviceInstanceId |
string
|
The device's unique Id.
|
Returns:
-
Type:
-
null
|
Device
The device connected to this adapter corresponding to `deviceInstanceId`.
getDevices() → {Array.<Device>}
Get this adapter's connected device/devices.
- Source:
Returns:
-
Type:
-
Array.<Device>
An array of this adapter's connected device/devices.
getLescOobData(deviceInstanceId, ownPublicKey, callbackopt) → {void}
Generate a set of OOB data to send to a peer out of band.
The `ble_gap_addr_t` included in the OOB data returned will be the currently active one (or, if a connection has already been established,
the one used during connection setup). The application may manually overwrite it with an updated value.
- Source:
Parameters:
Name |
Type |
Attributes |
Description |
deviceInstanceId |
string
|
|
The device's unique Id.
|
ownPublicKey |
string
|
|
LE Secure Connections local P-256 Public Key.
|
callback |
function
|
<optional>
|
Callback signature: err => {}.
|
getService(serviceInstanceId) → {Service}
Get a `Service` instance by its instanceId.
- Source:
Parameters:
Name |
Type |
Description |
serviceInstanceId |
string
|
The unique Id of this service.
|
Returns:
-
Type:
-
Service
The service.
getServices(deviceInstanceId, callbackopt) → {void}
Initiate or continue a GATT Primary Service Discovery procedure.
- Source:
Parameters:
Name |
Type |
Attributes |
Description |
deviceInstanceId |
string
|
|
The device's unique Id.
|
callback |
function
|
<optional>
|
Callback signature: (err, services) => {} where `services` is an
array of `Service` instances corresponding to the discovered GATT
primary services.
|
getState(callbackopt) → {void}
Gets and updates this adapter's state.
- Source:
Parameters:
Name |
Type |
Attributes |
Description |
callback |
function
|
<optional>
|
Callback signature: (err, state) => {} where `state` is an
instance of `AdapterState` corresponding to this adapter's
stored state.
|
getStats() → {Object}
This function is for debugging purposes. It will return an object with these members:
- {number} eventCallbackTotalTime
- {number} eventCallbackTotalCount
- {number} eventCallbackBatchMaxCount
- {number} eventCallbackBatchAvgCount
- Source:
Returns:
-
Type:
-
Object
This adapters stats.
notifyKeypress(deviceInstanceId, notificationType, callbackopt) → {void}
Notify the peer of a local keypress.
This function can only be used when an authentication procedure using LE Secure Connection is in progress. Calling it at other times will result in an `NRF_ERROR_INVALID_STATE`.
- Source:
Parameters:
Name |
Type |
Attributes |
Description |
deviceInstanceId |
string
|
|
The device's unique Id.
|
notificationType |
number
|
|
See `adapter.driver.BLE_GAP_KP_NOT_TYPES`.
|
callback |
function
|
<optional>
|
Callback signature: err => {}.
|
open(options, callbackopt) → {void}
Initialize the adapter.
The serial port will be attempted to be opened with the configured serial port settings in
adapterOptions
.
- Source:
Parameters:
Name |
Type |
Attributes |
Description |
options |
Object
|
|
Options to initialize/open this adapter with.
Available adapter open options:
- {number} [baudRate=115200]: The baud rate this adapter's serial port should be configured with.
- {string} [parity='none']: The parity this adapter's serial port should be configured with.
- {string} [flowControl='none']: Whether flow control should be configured with this adapter's serial port.
- {number} [eventInterval=0]: Interval to use for sending BLE driver events to JavaScript.
If `0`, events will be sent as soon as they are received from the BLE driver.
- {string} [logLevel='info']: The verbosity of logging the developer wants with this adapter.
- {number} [retransmissionInterval=250]: The time interval to wait between retransmitted packets.
- {number} [responseTimeout=1500]: Response timeout of the data link layer.
- {boolean} [enableBLE=true]: Whether the BLE stack should be initialized and enabled.
|
callback |
function
|
<optional>
|
Callback signature: err => {}.
|
readCharacteristicValue(characteristicId, callbackopt) → {void}
Reads the value of a GATT characteristic.
- Source:
Parameters:
Name |
Type |
Attributes |
Description |
characteristicId |
string
|
|
Unique ID of of the GATT characteristic.
|
callback |
function
|
<optional>
|
Callback signature: (err, readBytes) => {} where `readBytes` is an
array of numbers corresponding to the value of the GATT
characteristic.
|
readDescriptorValue(descriptorId, callbackopt) → {void}
Reads the value of a GATT descriptor.
- Source:
Parameters:
Name |
Type |
Attributes |
Description |
descriptorId |
string
|
|
Unique ID of of the GATT descriptor.
|
callback |
function
|
<optional>
|
Callback signature: (err, readBytes) => {} where `readBytes` is an
array of numbers corresponding to the value of the GATT
descriptor.
|
rejectConnParams(deviceInstanceId, callbackopt) → {void}
Reject a GAP connection parameters update request.
- Source:
Parameters:
Name |
Type |
Attributes |
Description |
deviceInstanceId |
string
|
|
The device's unique Id.
|
callback |
function
|
<optional>
|
Callback signature: err => {}.
|
replyAuthKey(deviceInstanceId, keyType, key, callbackopt) → {void}
Reply with an authentication key.
This function is only used to reply to a `BLE_GAP_EVT_AUTH_KEY_REQUEST `or a `BLE_GAP_EVT_PASSKEY_DISPLAY`, calling it at other times will result in an `NRF_ERROR_INVALID_STATE`.
If the call returns an error code, the request is still pending, and the reply call may be repeated with corrected parameters.
- Source:
Parameters:
Name |
Type |
Attributes |
Description |
deviceInstanceId |
string
|
|
The device's unique Id.
|
keyType |
Object
|
|
No key, 6-digit Passkey or Out Of Band data.
|
key |
null
|
Array
|
string
|
|
If key type is `BLE_GAP_AUTH_KEY_TYPE_NONE`, then null.
If key type is `BLE_GAP_AUTH_KEY_TYPE_PASSKEY`, then a 6-byte array (digit 0..9 only)
or null when confirming LE Secure Connections Numeric Comparison.
If key type is `BLE_GAP_AUTH_KEY_TYPE_OOB`, then a 16-byte OOB key value in Little Endian format.
|
callback |
function
|
<optional>
|
Callback signature: err => {}.
|
replyLescDhkey(deviceInstanceId, dhkey, callbackopt) → {void}
Reply with an LE Secure connections DHKey.
This function is only used to reply to a `BLE_GAP_EVT_LESC_DHKEY_REQUEST`, calling it at other times will result in an `NRF_ERROR_INVALID_STATE`.
If the call returns an error code, the request is still pending, and the reply call may be repeated with corrected parameters.
- Source:
Parameters:
Name |
Type |
Attributes |
Description |
deviceInstanceId |
string
|
|
The device's unique Id.
|
dhkey |
Object
|
|
LE Secure Connections DHKey.
|
callback |
function
|
<optional>
|
Callback signature: err => {}.
|
replySecParams(deviceInstanceId, secStatus, secParams, secKeyset, callbackopt) → {void}
Reply with GAP security parameters.
This function is only used to reply to a `BLE_GAP_EVT_SEC_PARAMS_REQUEST`, calling it at other times will result in an `NRF_ERROR_INVALID_STATE`.
If the call returns an error code, the request is still pending, and the reply call may be repeated with corrected parameters.
- Source:
Parameters:
Name |
Type |
Attributes |
Description |
deviceInstanceId |
string
|
|
The device's unique Id.
|
secStatus |
string
|
|
Security status, see `BLE_GAP_SEC_STATUS`.
|
secParams |
Object
|
|
Security parameters object. In the central role this must be set to null, as the parameters have
already been provided during a previous call to `this.authenticate()`.
|
secKeyset |
Object
|
|
security key set object.
- {Object} kdist_own Key distribution bitmap: keys that the local device will distribute.
- {boolean} enc Long Term Key and Master Identification.
- {boolean} id Identity Resolving Key and Identity Address Information.
- {boolean} sign Connection Signature Resolving Key.
- {boolean} link Derive the Link Key from the LTK.
- {Object} kdist_peer Key distribution bitmap: keys that the remote device will distribute.
- ^^ Same as properties as `kdist_own` above. ^^
|
callback |
function
|
<optional>
|
Callback signature: (err, secKeyset) => {} where `secKeyset` is a
security key set object as described above.
|
requestAttMtu(deviceInstanceId, mtu, callbackopt) → {void}
Start an ATT_MTU exchange by sending an Exchange MTU Request to the server.
The SoftDevice sets ATT_MTU to the minimum of:
- The Client RX MTU value, and
- The Server RX MTU value from `BLE_GATTC_EVT_EXCHANGE_MTU_RSP`.
However, the SoftDevice never sets ATT_MTU lower than `GATT_MTU_SIZE_DEFAULT` == 23.
- Source:
Parameters:
Name |
Type |
Attributes |
Description |
deviceInstanceId |
string
|
|
The device's unique Id.
|
mtu |
number
|
|
Requested ATT_MTU. Default ATT_MTU is 23. Valid range is between 24 and 247.
|
callback |
function
|
<optional>
|
Callback signature: (err, mtu) => {} where `mtu` is the updated
ATT_MTU value.
|
secInfoReply(deviceInstanceId, encInfo, idInfo, signInfo, callbackopt) → {void}
Reply with GAP security information.
This function is only used to reply to a `BLE_GAP_EVT_SEC_INFO_REQUEST`, calling it at other times will result in `NRF_ERROR_INVALID_STATE`.
If the call returns an error code, the request is still pending, and the reply call may be repeated with corrected parameters.
Data signing is not yet supported, and signInfo must therefore be null.
- Source:
Parameters:
Name |
Type |
Attributes |
Description |
deviceInstanceId |
string
|
|
The device's unique Id.
|
encInfo |
Object
|
|
Encryption information structure. May be null to signal none is available.
|
idInfo |
Object
|
|
Identity information structure. May be null to signal none is available.
|
signInfo |
Object
|
|
Pointer to a signing information structure. May be null to signal none is available.
|
callback |
function
|
<optional>
|
Callback signature: err => {}.
|
setAddress(address, type, callbackopt) → {void}
Sets this adapter's BLE device's local Bluetooth identity address.
The local Bluetooth identity address is the address that identifies this device to other peers.
The address type must be either `BLE_GAP_ADDR_TYPE_PUBLIC` or 'BLE_GAP_ADDR_TYPE_RANDOM_STATIC'.
The identity address cannot be changed while roles are running.
- Source:
Parameters:
Name |
Type |
Attributes |
Description |
address |
string
|
|
The local Bluetooth identity address.
|
type |
string
|
|
The address type. 'BLE_GAP_ADDR_TYPE_RANDOM_STATIC' or `BLE_GAP_ADDR_TYPE_PUBLIC`.
|
callback |
function
|
<optional>
|
Callback signature: err => {}.
|
setAdvertisingData(advData, scanRespData, callbackopt) → {void}
Set, clear or update advertising and scan response data.
The format of the advertising data will be checked by this call to ensure interoperability.
Limitations imposed by this API call to the data provided include having a flags data type in the scan response data and
duplicating the local name in the advertising data and scan response data.
To clear the advertising data and set it to a 0-length packet, simply provide a null `advData`/`scanRespData` parameter.
The call will fail if `advData` and `scanRespData` are both null since this would have no effect.
See @ref: ./util/adType.js for possible advertisement object parameters.
Note: should multiple custom properties be required in the advData or scanRespData,
it is possible to append 'custom' key with colon plus anything, like 'custom:1'.
- Source:
Parameters:
Name |
Type |
Attributes |
Description |
advData |
Object
|
|
Advertising packet
|
scanRespData |
Object
|
|
Scan response packet.
|
callback |
function
|
<optional>
|
Callback signature: err => {}.
|
setLescOobData(deviceInstanceId, ownOobData, peerOobData, callbackopt) → {void}
Provide the OOB data sent/received out of band.
At least one of the 2 data objects provided must not be null.
An authentication procedure with OOB selected as an algorithm must be in progress when calling this function.
A `BLE_GAP_EVT_LESC_DHKEY_REQUEST` event with the oobd_req set to 1 must have been received prior to calling this function.
- Source:
Parameters:
Name |
Type |
Attributes |
Description |
deviceInstanceId |
string
|
|
The device's unique Id.
|
ownOobData |
string
|
|
The OOB data sent out of band to a peer or NULL if none sent.
|
peerOobData |
string
|
|
The OOB data received out of band from a peer or NULL if none received.
|
callback |
function
|
<optional>
|
Callback signature: err => {}.
|
setName(name, callbackopt) → {void}
Sets this adapter's BLE device's GAP name.
- Source:
Parameters:
Name |
Type |
Attributes |
Description |
name |
string
|
|
GAP device name.
|
callback |
function
|
<optional>
|
Callback signature: err => {}.
|
setServices(services, callbackopt) → {void}
Set the services in the BLE peripheral device's GATT attribute table.
- Source:
Parameters:
Name |
Type |
Attributes |
Description |
services |
Array.<Service>
|
|
An array of `Service` objects to be set.
|
callback |
function
|
<optional>
|
Callback signature: err => {}.
|
startAdvertising(options, callbackopt) → {void}
Start advertising (GAP Discoverable, Connectable modes, Broadcast Procedure).
An application can start an advertising procedure for broadcasting purposes while a connection
is active. After a BLE_GAP_EVT_CONNECTED event is received, this function may therefore
be called to start a broadcast advertising procedure. The advertising procedure
cannot however be connectable (it must be of type BLE_GAP_ADV_TYPE_ADV_SCAN_IND or
BLE_GAP_ADV_TYPE_ADV_NONCONN_IND).
Only one advertiser may be active at any time.
- Source:
Parameters:
Name |
Type |
Attributes |
Description |
options |
Object
|
|
GAP advertising parameters.
Available GAP advertising parameters:
- {number} channelMask: Channel mask for RF channels used in advertising. Default: all channels on.
- {number} interval: GAP Advertising interval. Required: an interval must be provided.
- {number} timeout: Maximum advertising time in limited discoverable mode. Required: a timeout must be provided.
- {boolean} connectable: GAP Advertising type connectable. Default: The device is connectable.
- {boolean} scannable: GAP Advertising type scannable. Default: The device is undirected.
|
callback |
function
|
<optional>
|
Callback signature: err => {}.
|
startCharacteristicsNotifications(characteristicId, requireAck, callbackopt) → {void}
Starts notifications on a GATT characteristic.
Only for GATT central role.
- Source:
Parameters:
Name |
Type |
Attributes |
Description |
characteristicId |
string
|
|
Unique ID of the GATT characteristic.
|
requireAck |
boolean
|
|
Require all notifications to ack.
|
callback |
function
|
<optional>
|
Callback signature: err => {}.
(not called until ack is received if `requireAck`).
|
startScan(options, callbackopt) → {void}
Start scanning (GAP Discovery procedure, Observer Procedure).
- Source:
Parameters:
Name |
Type |
Attributes |
Description |
options |
Object
|
|
The GAP scanning parameters.
Available scan parameters:
- {boolean} active If 1, perform active scanning (scan requests).
- {number} interval Scan interval between 0x0004 and 0x4000 in 0.625ms units (2.5ms to 10.24s).
- {number} window Scan window between 0x0004 and 0x4000 in 0.625ms units (2.5ms to 10.24s).
- {number} timeout Scan timeout between 0x0001 and 0xFFFF in seconds, 0x0000 disables timeout.
- {number} use_whitelist If 1, filter advertisers using current active whitelist.
- {number} adv_dir_report If 1, also report directed advertisements where the initiator field is set to a
private resolvable address, even if the address did not resolve to an entry in the
device identity list. A report will be generated even if the peer is not in the whitelist.
|
callback |
function
|
<optional>
|
Callback signature: err => {}.
|
stopAdvertising(callbackopt) → {void}
Stop advertising (GAP Discoverable, Connectable modes, Broadcast Procedure).
- Source:
Parameters:
Name |
Type |
Attributes |
Description |
callback |
function
|
<optional>
|
Callback signature: err => {}.
|
stopCharacteristicsNotifications(characteristicId, callbackopt) → {void}
Disables notifications on a GATT characteristic.
- Source:
Parameters:
Name |
Type |
Attributes |
Description |
characteristicId |
string
|
|
Unique ID of the GATT characteristic.
|
callback |
function
|
<optional>
|
Callback signature: err => {}.
|
stopScan(callbackopt) → {void}
Stop scanning (GAP Discovery procedure, Observer Procedure).
- Source:
Parameters:
Name |
Type |
Attributes |
Description |
callback |
function
|
<optional>
|
Callback signature: err => {}.
|
updateConnectionParameters(deviceInstanceId, options, callbackopt) → {void}
Update connection parameters.
In the central role this will initiate a Link Layer connection parameter update procedure,
otherwise in the peripheral role, this will send the corresponding L2CAP request and wait for
the central to perform the procedure. In both cases, and regardless of success or failure, the application
will be informed of the result with a event:connParamUpdateEvent.
- Source:
Parameters:
Name |
Type |
Attributes |
Description |
deviceInstanceId |
string
|
|
The device's unique Id.
|
options |
Object
|
|
GAP Connection Parameters.
Available GAP Connection Parameters:
- {number} min_conn_interval: Minimum Connection Interval in 1.25 ms units.
- {number} max_conn_interval: Maximum Connection Interval in 1.25 ms units.
- {number} slave_latency: Slave Latency in number of connection events.
- {number} conn_sup_timeout: Connection Supervision Timeout in 10 ms units.
|
callback |
function
|
<optional>
|
Callback signature: err => {}.
|
writeCharacteristicValue(characteristicId, value, ack, completeCallback, deviceNotifiedOrIndicated) → {void}
Writes the value of a GATT characteristic.
- Source:
Parameters:
Name |
Type |
Description |
characteristicId |
string
|
Unique ID of the GATT characteristic.
|
value |
array
|
The value (array of bytes) to be written.
|
ack |
boolean
|
Require acknowledge from device, irrelevant in GATTS role.
|
completeCallback |
function
|
Callback signature: err => {}
|
deviceNotifiedOrIndicated |
function
|
TODO
|
writeDescriptorValue(descriptorId, value, ack, callbackopt) → {void}
Writes the value of a GATT descriptor.
- Source:
Parameters:
Name |
Type |
Attributes |
Description |
descriptorId |
string
|
|
Unique ID of the GATT descriptor.
|
value |
array
|
|
The value (array of bytes) to be written.
|
ack |
boolean
|
|
Require acknowledge from device, irrelevant in GATTS role.
|
callback |
function
|
<optional>
|
Callback signature: err => {}.
(not called until ack is received if `requireAck`).
options: {ack, long, offset}
|
Events
advertiseTimedOut
BLE peripheral timed out advertising.
- Source:
attMtuChanged
Exchange MTU Response event.
Properties:
Name |
Type |
Description |
device |
Device
|
The Device instance representing the BLE peer we've connected to. |
newMtu |
number
|
Server RX MTU size. |
- Source:
authKeyRequest
Request to provide an authentication key.
Properties:
Name |
Type |
Description |
device |
Device
|
The Device instance representing the BLE peer we're connected to. |
event.key_type |
string
|
The GAP Authentication Key Types. |
- Source:
authStatus
Authentication procedure completed with status.
Properties:
Name |
Type |
Description |
device |
Device
|
The Device instance representing the BLE peer we're connected to. |
_ |
Object
|
Authentication status and corresponding parameters. |
- Source:
characteristicAdded
Characteristic was successfully added to the Adapter
's GATT attribute table.
Properties:
Name |
Type |
Description |
attribute |
Service
|
The new added characteristic. |
- Source:
characteristicValueChanged
The value of a characteristic in the Adapter
's GATT attribute table changed.
Properties:
Name |
Type |
Description |
attribute |
Characteristic
|
The changed characteristic. |
- Source:
closed
Adapter closed event.
Properties:
Name |
Type |
Description |
this |
Adapter
|
An instance of the closed Adapter . |
- Source:
connectTimedOut
BLE peer timed out in connection.
Properties:
Name |
Type |
Description |
deviceAddress |
Device
|
The device address of the BLE peer our connection timed-out with. |
- Source:
connParamUpdate
Connection parameter update event.
Properties:
Name |
Type |
Description |
device |
Device
|
The Device instance representing the BLE peer we're connected to. |
connectionParameters |
Object
|
The updated connection parameters. |
- Source:
connParamUpdateRequest
Connection Parameter Update Request.
Properties:
Name |
Type |
Description |
device |
Device
|
The Device instance representing the BLE peer we're connected to. |
connectionParameters |
Object
|
GAP Connection Parameters. |
- Source:
connSecUpdate
Connection security updated.
Properties:
Name |
Type |
Description |
device |
Device
|
The Device instance representing the BLE peer we're connected to. |
event.conn_sec |
Object
|
Connection security level. |
- Source:
dataLengthChanged
Link layer PDU length changed.
Properties:
Name |
Type |
Description |
remoteDevice |
Device
|
The Device instance representing the BLE peer we've connected to. |
event.max_tx_octets |
number
|
The maximum number of payload octets in a Link Layer Data Channel
PDU that the local Controller will send. Range: 27-251 |
- Source:
descriptorAdded
Descriptor was successfully added to the Adapter
's GATT attribute table.
Properties:
Name |
Type |
Description |
attribute |
Service
|
The new added descriptor. |
- Source:
descriptorValueChanged
The value of a descriptor in the Adapter
's GATT attribute table changed.
Properties:
Name |
Type |
Description |
attribute |
Descriptor
|
The changed descriptor. |
- Source:
deviceConnected
Connection established.
Properties:
Name |
Type |
Description |
device |
Device
|
The Device instance representing the BLE peer we've connected to. |
- Source:
deviceDisconnected
Disconnected from peer.
Properties:
Name |
Type |
Description |
device |
Device
|
The Device instance representing the BLE peer we've disconnected
from. |
event.reason_name |
string
|
Human-readable reason for disconnection. |
event.reason |
string
|
HCI status code. |
- Source:
deviceDiscovered
Discovered a peripheral BLE device.
Properties:
Name |
Type |
Description |
discoveredDevice |
Device
|
The Device instance representing the BLE peer we've
discovered. |
- Source:
deviceNotifiedOrIndicated
Handle Value Notification or Indication event.
Properties:
Name |
Type |
Description |
remoteDevice |
Device
|
The Device instance representing the BLE peer we've connected to. |
characteristic |
Characteristic
|
Characteristic to which the HVx operation applies. |
- Source:
error
Error event.
Properties:
Name |
Type |
Description |
error |
Error
|
Provides information related to an error that occurred. |
- Source:
keyPressed
Notify of a key press during an authentication procedure.
Properties:
Name |
Type |
Description |
device |
Device
|
The Device instance representing the BLE peer we're connected to. |
event.kp_not |
string
|
The Key press notification type. |
- Source:
lescDhkeyRequest
Request to calculate an LE Secure Connections DHKey.
Properties:
Name |
Type |
Description |
device |
Device
|
The Device instance representing the BLE peer we're connected to. |
event.pk_peer |
Object
|
LE Secure Connections remote P-256 Public Key. |
event.oobd_req |
Object
|
LESC OOB data required. A call to replyLescDhkey is
required to complete the procedure. |
- Source:
logMessage
Log message event.
Properties:
Name |
Type |
Description |
severity |
string
|
Severity of the log event. |
message |
string
|
Human-readable log message. |
- Source:
opened
Adapter opened event.
Properties:
Name |
Type |
Description |
this |
Adapter
|
An instance of the opened Adapter . |
- Source:
passkeyDisplay
Request to display a passkey to the user.
Properties:
Name |
Type |
Description |
device |
Device
|
The Device instance representing the BLE peer we're connected to. |
event.match_request |
number
|
If 1 requires the application to report the match using
replyAuthKey . |
event.passkey |
string
|
6 digit passkey in ASCII ('0'-'9' digits only). |
- Source:
scanTimedOut
BLE central timed out scanning.
- Source:
secInfoRequest
Request to provide security information.
Properties:
Name |
Type |
Description |
device |
Device
|
The Device instance representing the BLE peer we're connected to. |
event |
Object
|
Security Information Request Event Parameters |
- Source:
secParamsRequest
Request to provide security parameters.
Properties:
Name |
Type |
Description |
device |
Device
|
The Device instance representing the BLE peer we're connected to. |
event.peer_params |
Object
|
Initiator Security Parameters. |
- Source:
securityChanged
Connection security updated.
Properties:
Name |
Type |
Description |
device |
Device
|
The Device instance representing the BLE peer we're connected to. |
authParamters |
Object
|
Connection security level. |
- Source:
securityRequest
Security Request.
Properties:
Name |
Type |
Description |
device |
Device
|
The Device instance representing the BLE peer we're connected to. |
event |
Object
|
Security Request Event Parameters. |
- Source:
securityRequestTimedOut
BLE peer timed out while waiting for a security request response.
Properties:
Name |
Type |
Description |
device |
Device
|
The Device instance representing the BLE peer we're connected to. |
- Source:
serviceAdded
Service was successfully added to the Adapter
's GATT attribute table.
Properties:
Name |
Type |
Description |
newService |
Service
|
The new added service. |
- Source:
stateChanged
Adapter state changed event.
Properties:
Name |
Type |
Description |
this._state |
AdapterState
|
The updated adapter's state store. |
- Source:
status
Status event.
Properties:
Name |
Type |
Description |
status |
string
|
Human-readable status message. |
- Source:
txComplete
Transmission Complete.
Properties:
Name |
Type |
Description |
remoteDevice |
Device
|
The Device instance representing the BLE peer we've connected to. |
event.count |
number
|
Number of packets transmitted. |
- Source:
warning
Warning event.
Properties:
Name |
Type |
Description |
error |
Error
|
A non fatal Error. |
- Source: