Bluetooth-Beacon
stopBeaconDiscovery
TIP
The API usage is as follows: wx.stopBeaconDiscovery(Object object)
- Functional description: Stop searching for nearby Beacon devices.
- Parameters and descriptions: Object object。
Properties Type Default value Required Description success Function - No Callback function for successful interface call fail Function - No Callback function for failed interface call complete Function - No Callback function for interface call completion (executed regardless of success or failure) - Error code
Error code Error message Description 0 ok Normal 11000 unsupport System or device not supported 11001 bluetooth service unavailable Bluetooth service unavailable 11002 location service unavailable Location service unavailable 11003 already start Search has started 10004 not startBeaconDiscovery Search has not started 11005 system error System error 11006 invalid data Parameter incorrect
startBeaconDiscovery
TIP
The API usage is as follows: wx.startBeaconDiscovery(Object object)
Functional description: Search for nearby Beacon devices started.
Parameters and descriptions: Object object。
Properties Type Default value Required Description uuids Array.< string>- Yes List of UUIDs broadcast by Beacon devices ignoreBluetoothAvailable boolean false No Whether to check the Bluetooth switch is only valid in iOS. Starting from iOS 11, you can still use Beacon service even if you turn off Bluetooth in the control panel success Function - No Callback function for successful interface call fail Function - No Callback function for failed interface call complete Function - No Callback function for interface call completion (executed regardless of success or failure) Error code
Error code Error message Description 0 ok Normal 11000 unsupport System or device not supported 11001 bluetooth service unavailable Bluetooth service unavailable 11002 location service unavailable Location service unavailable 11003 already start Search has started 10004 not startBeaconDiscovery Search has not started 11005 system error System error 11006 invalid data Parameter incorrect Sample code:
wx.startBeaconDiscovery({
success(res) { }
})onBeaconUpdate
TIP
The API usage is as follows: wx.onBeaconUpdate(function listener)
Functional description: Listen for Beacon device update events, only one listener can be registered
Parameters and descriptions: function listener,Listening function of Beacon device update event, parameter Object res is as follows:
Properties Type Description beacons Array.<BeaconInfo> List of all Beacon devices currently searched Sample code:
wx.onBeaconUpdate(res => {
console.log(res.beacons)
})offBeaconUpdate
TIP
The API usage is as follows: wx.offBeaconUpdate()
Functional description: Remove all listening functions of Beacon device update event.
Sample code:
wx.offBeaconUpdate()onBeaconServiceChange
TIP
The API usage is as follows: wx.onBeaconServiceChange(function listener)
Functional description: Listening for Beacon service status change event, only one listening function can be registered.
Parameters and descriptions: function listener,Listening function of Beacon service status change event, parameter Object res is as follows:
Properties Type Description available boolean Is the service currently available discovering boolean Is it currently in search state Sample code:
wx.onBeaconServiceChange(res => {
console.log(res.available, res.discovering)
})offBeaconServiceChange
TIP
The API usage is as follows: wx.offBeaconServiceChange()
Functional description: Remove all listening functions of Beacon service status change event.
Sample code:
wx.offBeaconServiceChange()getBeacons
TIP
The API usage is as follows: wx.getBeacons(Object object)
Functional description: Get all Beacon devices that have been searched.
Parameters and descriptions: Object object。
Properties Type Default value Required Description success Function - No Callback function for successful interface call fail Function - No Callback function for failed interface call complete Function - No Callback function for interface call completion (executed regardless of success or failure) object.success callback function parameters: Object res。
Properties Type Description beacons Array.<BeaconInfo> List of Beacon devices Error code
Error code Error message Description 0 ok Normal 11000 unsupport System or device not supported 11001 bluetooth service unavailable Bluetooth service unavailable 11002 location service unavailable Location service unavailable 11003 already start Search has started 10004 not startBeaconDiscovery Search has not started 11005 system error System error 11006 invalid data Parameter incorrect
BeaconInfo
Functional description: Beacon device
Attributes and descriptions
Properties Type Description uuid string UUID broadcast by Beacon device major number Primary ID of Beacon device minor number Secondary ID of Beacon device proximity number Enumeration value indicating device distance (iOS only) accuracy number Distance of Beacon device, unit m. On iOS, when proximity is 0, accuracy is -3 rssi number Indicates the signal strength of the device, in dBm - Legal values
Value Description 0 The signal is too weak to calculate the distance, or it is not an iOS device 1 Very close 2 Relatively close 3 Far
- Legal values