This API is used via wx.onBLEPeripheralConnectionStateChanged(function listener).
Attribute | Type | Description |
deviceId | String | Device ID with changing connection status |
serverId | String | Server's UUID |
connected | Boolean | Current Connection Status |
This API is used via wx.offBLEPeripheralConnectionStateChanged(function listener).
const listener = function (res) { console.log(res) }wx.onBLEPeripheralConnectionStateChanged(listener)wx.offBLEPeripheralConnectionStateChanged(listener) // The same function object as the listener must be passed in.
This API is used via wx.createBLEPeripheralServer(Object object).
Attribute | Type | Default value | Required | Description |
success | function | - | No | Callback Function of Successful Interface Call |
fail | function | - | No | Callback Function of Failing Interface Call |
complete | function | - | No | Callback function executed upon the completion of the interface invocation (both successful and unsuccessful invocations) |
Attribute | Type | Description |
server | BLEPeripheralServer | Server of a peripheral device |
This method is used via BLEPeripheralServer.addService(Object object).
Attribute | Type | Required | Description |
service | Object | Yes | Object describing the service |
success | function | No | Callback Function of Successful Interface Call |
fail | function | No | Callback Function of Failing Interface Call |
complete | function | No | Callback function executed upon the completion of the interface invocation (both successful and unsuccessful invocations) |
Structure attributes | Type | Required | Description |
uuid | string | Yes | Bluetooth service UUID |
characteristics | Array.<Object> | Yes | List of Characteristics |
Structure attributes | Type | Required | Description |
uuid | string | Yes | UUID of characteristic |
properties | Object | No | Operations Supported by the Characteristic |
permission | Object | No | Permission of characteristic |
value | Array.<Object> | No | Binary data corresponding to the characteristic |
descriptors | Array.<Object> | No | File descriptor data |
Structure attributes | Type | Default value | Required | Description |
write | boolean | false | No | Write |
writeNoResponse | boolean | false | No | Write Without Response |
read | boolean | false | No | Read |
notify | boolean | false | No | Subscribe |
indicate | boolean | false | No | Return packet |
Structure attributes | Type | Default value | Required | Description |
readable | boolean | false | No | Readable |
writeable | boolean | false | No | Writable |
readEncryptionRequired | boolean | false | No | Encrypted Read Request |
writeEncryptionRequired | boolean | false | No | Encrypted Write Request |
Structure attributes | Type | Required | Description |
uuid | string | Yes | UUID of Descriptors |
permission | Object | No | Permissions of descriptors |
value | ArrayBuffer | No | File descriptor data |
Structure attributes | Type | Default value | Required | Description |
write | boolean | false | No | Write |
read | boolean | false | No | Read |
This method is used via BLEPeripheralServer.removeService(Object object).
Attribute | Type | Default value | Required | Description |
serviceId | String | - | Yes | UUID of service |
success | function | - | No | Callback Function of Successful Interface Call |
fail | function | - | No | Callback Function of Failing Interface Call |
complete | function | - | No | Callback function executed upon the completion of the interface invocation (both successful and unsuccessful invocations) |
This method is used via BLEPeripheralServer.startAdvertising(Object Object).
Attribute | Type | Default value | Required | Description |
advertiseRequest | object | - | Yes | //Custom parameters of broadcasting |
powerLevel | string | medium | No | Broadcasting power, whose valid values are: Low: Low power Medium: Moderate power High: High power |
success | function | - | No | Callback Function of Successful Interface Call |
fail | function | - | No | Callback Function of Failing Interface Call |
complete | function | - | No | Callback function executed upon the completion of the interface invocation (both successful and unsuccessful invocations) |
Structure attributes | Type | Default value | Required | Description |
connectable | boolean | true | No | Current device's connectivity status |
deviceName | string | - | No | The deviceName field in the broadcasting, which is empty by default. |
serviceUuids | Array.<string> | - | No | List of service UUIDs to be broadcast. Follow the notes when using 16/32 bit UUIDs. |
manufactureData | Array.<Object> | - | No | Broadcasting manufacturer information. Customization is supported on Android only and not possible on iOS due to system limitations. |
beacon | object | - | No | Parameters broadcast in the form of a beacon device. |
Structure attributes | Type | Required | Description |
manufacturerId | String | Yes | Manufacturer ID, a hexadecimal beginning with 0x. |
manufacturerSpecificData | ArrayBuffer | No | Manufacturer information |
Structure attributes | Type | Required | Description |
uuid | number | Yes | UUID broadcast by a beacon device. |
major | number | Yes | Primary ID of beacon device |
minor | number | Yes | Secondary ID of beacon device |
measurePower | number | Yes | Reference value for determining the RSSI size when the distance to the device is 1 meter. |
This method is used via BLEPeripheralServer.stopAdvertising().
Attribute | Type | Default value | Required | Description |
success | function | - | No | Callback Function of Successful Interface Call |
fail | function | - | No | Callback Function of Failing Interface Call |
complete | function | - | No | Callback function executed upon the completion of the interface invocation (both successful and unsuccessful invocations) |
This method is used via BLEPeripheralServer.writeCharacteristicValue(Object Object).
Attribute | Type | Default value | Required | Description |
serviceId | string | - | Yes | UUID corresponding to the Bluetooth characteristic service |
characteristicId | string | - | Yes | Bluetooth characteristic UUID |
value | ArrayBuffer | - | Yes | Binary data corresponding to the characteristic |
needNotify | boolean | - | Yes | Whether it is necessary to notify the host that the value has been updated. |
callbackId | number | - | No | Optional, used when handling return packets. |
success | function | - | No | Callback Function of Successful Interface Call |
fail | function | - | No | Callback Function of Failing Interface Call |
complete | function | - | No | Callback function executed upon the completion of the interface invocation (both successful and unsuccessful invocations) |
This method is used via BLEPeripheralServer.onCharacteristicWriteRequest(function listener).
Attribute | Type | Description |
serviceId | String | UUID corresponding to the Bluetooth characteristic service |
characteristicId | String | Bluetooth characteristic UUID |
callbackId | Number | |
value | ArrayBuffer | Binary data value requested for characteristic write. |
This method is used via BLEPeripheralServer.offCharacteristicWriteRequest(function listener).
const listener = function (res) { console.log(res) }BLEPeripheralServer.onCharacteristicWriteRequest(listener)BLEPeripheralServer.offCharacteristicWriteRequest(listener) // You need to pass the same function object as when you were listening.
This method is used via BLEPeripheralServer.onCharacteristicReadRequest(function listener).
Attribute | Type | Description |
serviceId | String | UUID corresponding to the Bluetooth characteristic service |
characteristicId | String | Bluetooth characteristic UUID |
callbackId | Number |
This method is used via BLEPeripheralServer.offCharacteristicReadRequest(function listener).
const listener = function (res) { console.log(res) }BLEPeripheralServer.onCharacteristicReadRequest(listener)BLEPeripheralServer.offCharacteristicReadRequest(listener) // The same function object as the listener must be passed in.
This method is used via BLEPeripheralServer.onCharacteristicSubscribed(function listener).
Attribute | Type | Description |
serviceId | String | UUID corresponding to the Bluetooth characteristic service |
characteristicId | String | Bluetooth characteristic UUID |
This method is used via BLEPeripheralServer.offCharacteristicSubscribed(function listener).
const listener = function (res) { console.log(res) }BLEPeripheralServer.onCharacteristicSubscribed(listener)BLEPeripheralServer.offCharacteristicSubscribed(listener) // The same function object as the listener must be passed in.
This method is used via BLEPeripheralServer.onCharacteristicUnsubscribed(function listener).
Attribute | Type | Description |
serviceId | String | UUID corresponding to the Bluetooth characteristic service |
characteristicId | String | Bluetooth characteristic UUID |
This method is used via BLEPeripheralServer.offCharacteristicUnsubscribed(function listener).
const listener = function (res) { console.log(res) }BLEPeripheralServer.onCharacteristicUnsubscribed(listener)BLEPeripheralServer.offCharacteristicUnsubscribed(listener) // The same function object as the listener must be passed in.
Was this page helpful?