This API is called using wx.onBLEPeripheralConnectionStateChanged(function listener).
Property | Type | Note |
deviceId | String | The ID of the device whose connection state changes. |
serverId | String | The UUID of the server. |
connected | Boolean | The current connection state. |
This API is called using wx.offBLEPeripheralConnectionStateChanged(function listener).
const listener = function (res) { console.log(res) }wx.onBLEPeripheralConnectionStateChanged(listener)wx.offBLEPeripheralConnectionStateChanged(listener) // Must pass the same function object used in wx.onBLEPeripheralConnectionStateChanged(listener).
This API is called using wx.createBLEPeripheralServer(Object object).
Property | Type | Default value | Required | Description |
success | function | - | False | Callback function for successful API calls. |
fail | function | - | False | Callback function for failed API calls. |
complete | function | - | False | Callback function executed after API call ends (regardless of success or failure). |
Property | Type | Description |
Server | BLEPeripheralServer | The BLE peripheral server. |
This API is called using BLEPeripheralServer.addService(Object object).
Property | Type | Required | Description |
service | Object | Yes | The object describing the service. |
success | function | No | Callback function for successful API calls. |
fail | function | No | Callback function for failed API calls. |
complete | function | No | Callback function executed after API call ends (regardless of success or failure). |
Property | Type | Required | Description |
uuid | string | Yes | The UUID of the Bluetooth service. |
characteristics | Array.<Object> | Yes | The list of characteristics. |
Property | Type | Required | Description |
uuid | string | Yes | The UUID of the characteristic. |
properties | Object | No | The operations supported by the characteristic. |
permission | Object | No | The permissions of the characteristic. |
value | Array.<Object> | No | The binary value corresponding to the characteristic. |
descriptors | Array.<Object> | No | The descriptor data. |
Property | 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 | Notify (Subscribe). |
indicate | Boolean | false | No | Indicate (Response). |
Property | Type | Default value | Required | Description |
readable | Boolean | false | No | Readable. |
writeable | Boolean | false | No | Writeable. |
readEncryptionRequired | Boolean | false | No | Encrypted read request. |
writeEncryptionRequired | Boolean | false | No | Encrypted write request. |
Property | Type | Required | Description |
uuid | string | Yes | The UUID of the descriptor. |
permission | Object | No | The permissions of the descriptor. |
value | ArrayBuffer | No | The descriptor data. |
Property | Type | Default value | Required | Description |
write | Boolean | false | No | Write. |
read | Boolean | false | No | Read. |
This API is called using BLEPeripheralServer.removeService(Object object).
Property | Type | Default value | Required | Description |
serviceId | String | - | Yes | The UUID of the service. |
success | function | - | No | Callback function for successful API calls. |
fail | function | - | No | Callback function for failed API calls. |
complete | function | - | No | Callback function executed after API call ends (regardless of success or failure). |
This API is called using BLEPeripheralServer.startAdvertising(Object Object).
Property | Type | Default value | Required | Description |
advertiseRequest | object | - | Yes | The custom advertising parameters. |
powerLevel | string | medium | No | The advertising power. Valid values: low: Low power; medium: Medium power; high: High power. |
success | function | - | No | Callback function for successful API calls. |
fail | function | - | No | Callback function for failed API calls. |
complete | function | - | No | Callback function executed after API call ends (regardless of success or failure). |
Property | Type | Default value | Required | Description |
connectable | Boolean | true | No | Specifies whether the current device is connectable. |
deviceName | string | - | No | The deviceName field in the broadcast. Defaults to empty. |
serviceUuids | Array.<string> | - | No | The list of service UUIDs to advertise. See the notes when using 16-bit or 32-bit UUIDs. |
manufactureData | Array.<Object> | - | No | The manufacturer data in the advertisement. Supported only on Android. iOS does not support customization due to system restrictions. |
beacon | object | - | No | The parameters for advertising as a beacon device. |
Property | Type | Required | Description |
manufacturerId | String | Yes | The manufacturer ID in hexadecimal starting with 0x. |
manufacturerSpecificData | ArrayBuffer | No | The manufacturer-specific data. |
Property | Type | Required | Description |
uuid | number | Yes | The UUID advertised by the beacon device. |
major | number | Yes | The major ID of the beacon device. |
minor | number | Yes | The minor ID of the beacon device. |
measurePower | number | Yes | The reference value used to determine the RSSI when 1 meter away from the device. |
This API is called using BLEPeripheralServer.stopAdvertising().
Property | Type | Default value | Required | Description |
success | function | - | No | Callback function for successful API calls. |
fail | function | - | No | Callback function for failed API calls. |
complete | function | - | No | Callback function executed after API call ends (regardless of success or failure). |
This API is called using BLEPeripheralServer.writeCharacteristicValue(Object Object).
Property | Type | Default value | Required | Description |
serviceId | string | - | Yes | The UUID of the service corresponding to the Bluetooth characteristic. |
characteristicId | string | - | Yes | The UUID of the Bluetooth characteristic. |
value | ArrayBuffer | - | Yes | The binary value corresponding to the characteristic. |
needNotify | Boolean | - | Yes | Specifies whether to notify the central device that the value has been updated. |
callbackId | number | - | No | Optional. Used when processing indications (responses). |
success | function | - | No | Callback function for successful API calls. |
fail | function | - | No | Callback function for failed API calls. |
complete | function | - | No | Callback function executed after API call ends (regardless of success or failure). |
This API is called using BLEPeripheralServer.onCharacteristicWriteRequest(function listener).
Property | Type | Description |
serviceId | String | The UUID of the service corresponding to the Bluetooth characteristic. |
characteristicId | String | The UUID of the Bluetooth characteristic. |
callbackId | Number | |
value | ArrayBuffer | The binary data value requested to be written to the characteristic. |
This API is called using BLEPeripheralServer.offCharacteristicWriteRequest(function listener).
const listener = function (res) { console.log(res) }BLEPeripheralServer.onCharacteristicWriteRequest(listener)BLEPeripheralServer.offCharacteristicWriteRequest(listener) // Must pass the same function object used in BLEPeripheralServer.onCharacteristicWriteRequest(listener).
This API is called using BLEPeripheralServer.onCharacteristicReadRequest(function listener).
Property | Type | Description |
serviceId | String | The UUID of the service corresponding to the Bluetooth characteristic. |
characteristicId | String | The UUID of the Bluetooth characteristic. |
callbackId | Number |
This API is called using BLEPeripheralServer.offCharacteristicReadRequest(function listener).
const listener = function (res) { console.log(res) }BLEPeripheralServer.onCharacteristicReadRequest(listener)BLEPeripheralServer.offCharacteristicReadRequest(listener) // Must pass the same function object used in BLEPeripheralServer.onCharacteristicReadRequest(listener).
This API is called using BLEPeripheralServer.onCharacteristicSubscribed(function listener).
Property | Type | Description |
serviceId | String | The UUID of the service corresponding to the Bluetooth characteristic. |
characteristicId | String | The UUID of the Bluetooth characteristic. |
This API is called using BLEPeripheralServer.offCharacteristicSubscribed(function listener).
const listener = function (res) { console.log(res) }BLEPeripheralServer.onCharacteristicSubscribed(listener)BLEPeripheralServer.offCharacteristicSubscribed(listener) // Must pass the same function object used in BLEPeripheralServer.onCharacteristicSubscribed(listener).
This API is called using BLEPeripheralServer.onCharacteristicUnsubscribed(function listener).
Property | Type | Description |
serviceId | String | The UUID of the service corresponding to the Bluetooth characteristic. |
characteristicId | String | The UUID of the Bluetooth characteristic. |
This API is called using BLEPeripheralServer.offCharacteristicUnsubscribed(function listener).
const listener = function (res) { console.log(res) }BLEPeripheralServer.onCharacteristicUnsubscribed(listener)
Was this page helpful?
You can also Contact sales or Submit a Ticket for help.
Help us improve! Rate your documentation experience in 5 mins.
Feedback