Appearance
Device
Electric quantity
getBatteryInfoSync
getBatteryInfoSync()
ft.getBatteryInfo The synchronous version of
Return value
Object res
attribute | type | Introductions |
---|---|---|
level | string | Equipment power, range 1 - 100 |
isCharging | boolean | Is it charging? |
getBatteryInfo
getBatteryInfo(Object object)
attribute | type | Default values | Required | Introductions |
---|---|---|---|---|
success | function | no | Interface calls the successful callback function | |
fail | function | no | Interface calls failed callback functions | |
complete | function | no | Callback function at the end of an interface call (both successful and unsuccessful calls are executed) |
object.success callback
parameter
Object object
attribute | type | Introductions |
---|---|---|
level | string | Equipment power, range 1 - 100 |
isCharging | boolean | Is it charging? |
clipboard
setClipboardData
Supported from base library 1.3.9, iOS version 2.1.23, Android version 2.1.38, dependency extension SDK Since iOS version 2.35.13, Android version 2.35.9, this API requires the host app to be injected into the implementation and has been removed from the SDK.
setClipboardData(Object object)
Sets the contents of the system clipboard. When called successfully, it pops up toast Cue "Content copied "Continue 1.5s
parameter
Object object
attribute | type | Default values | Required | Introductions |
---|---|---|---|---|
data | string | yes | Clipboard content | |
success | function | no | Interface calls the successful callback function | |
fail | function | no | Interface calls failed callback functions | |
complete | function | no | Callback function at the end of an interface call (both successful and unsuccessful calls are executed) |
sample code
javascript
ft.setClipboardData({
data: 'data',
success(res) {
ft.getClipboardData({
success(res) {
console.log(res.data) // data
}
})
}
})
getClipboardData
Supported from base library 1.3.9, iOS version 2.1.23, Android version 2.1.38, dependency extension SDK Since iOS version 2.35.13, Android version 2.35.9, this API requires the host app to be injected into the implementation and has been removed from the SDK.
getClipboardData(Object object)
Get the contents of the system clipboard
parameter
Object object
attribute | type | Default values | Required | Introductions |
---|---|---|---|---|
success | function | no | Interface calls the successful callback function | |
fail | function | no | Interface calls failed callback functions | |
complete | function | no | Callback function at the end of an interface call (both successful and unsuccessful calls are executed) |
object.success callback
parameter
Object object
attribute | type | Introductions |
---|---|---|
data | string | Clipboard content |
sample code
javascript
ft.getClipboardData({
success(res) {
console.log(res.data)
}
})
network
onNetworkStatusChange
Base library support from 1.3.9, iOS version 2.1.23, Android version 2.1.38
onNetworkStatusChange(function callback)
Base library support from 1.3.9, iOS version 2.1.23, Android version 2.1.38
parameter
function callback
Callback function for network state change events
parameter
Object res
attribute | type | Introductions |
---|---|---|
isConnected | boolean | Are you currently connected to a network? |
networkType | string | Network type |
res.networkType Legal value
value | Introductions |
---|---|
wifi | wifi network |
2g | 2g network |
3g | 3g network |
4g | 4g network |
unknown | wifi network |
none | 无network |
sample code
javascript
ft.onNetworkStatusChange(function (res) {
console.log(res.isConnected)
console.log(res.networkType)
})
offNetworkStatusChange
offNetworkStatusChange(function callback)
Cancel monitoring of network state changes. If the parameter is null, cancel all event monitoring
parameter
function callback
Callback function for network state change events
getNetworkType
Base library support from 1.3.9, iOS version 2.1.23, Android version 2.1.38
getNetworkType(Object object)
Get network type
parameter
Object object
attribute | type | Default values | Required | Introductions |
---|---|---|---|---|
success | function | no | Interface calls the successful callback function | |
fail | function | no | Interface calls failed callback functions | |
complete | function | no | Callback function at the end of an interface call (both successful and unsuccessful calls are executed) |
object.success callback
parameter
Object res
attribute | type | Introductions |
---|---|---|
networkType | string | network type |
res.networkType Legal value
value | Introductions |
---|---|
wifi | wifi network |
2g | 2g network |
3g | 3g network |
4g | 4g network |
unknown | wifi network |
none | No network |
sample code
javascript
ft.getNetworkType({
success(res) {
const networkType = res.networkType
}
})
crypto
getRandomValues
Obtaining cryptographically secure random numbers
parameter
Object object
attribute | type | Default values | Required | Introductions |
---|---|---|---|---|
length | number | yes | Integer, number of bytes to generate random numbers, maximum 1048576 | |
success | function | no | Interface calls the successful callback function | |
fail | function | no | Interface calls failed callback functions | |
complete | function | no | Callback function at the end of an interface call (both successful and unsuccessful calls are executed) |
object.success callback
parameter
Object res
attribute | type | Introductions |
---|---|---|
randomValues | ArrayBuffer | Random number content, length is the number of bytes passed in |
sample code
javascript
wx.getRandomValues({
length: 6 // Generation 6 A random number of bytes in length,
success: res => {
console.log(wx.arrayBufferToBase64(res.randomValues)) // Convert to base64 Print after string
}
})
screen
setVisualEffectOnCapture
Base library support from 2.12.16, Android version 2.37.1
setVisualEffectOnCapture(Object object)
Set the screen performance during screen capture/recording(Android Only)
parameter
Object object
attribute | type | Default values | Required | Introductions |
---|---|---|---|---|
visualEffect | string | none | yes | Screen capture/recording performance, only none / hidden is supported, pass hidden to hide the screen when taking screenshots/recording |
success | function | no | Interface calls the successful callback function | |
fail | function | no | Interface calls failed callback functions | |
complete | function | no | Callback function at the end of an interface call (both successful and unsuccessful calls are executed) |
setScreenBrightness
Base library support from 1.3.9, iOS version 2.1.23, Android version 2.1.38
setScreenBrightness(Object object)
Set the screen brightness.
parameter
Object object
attribute | type | Default values | Required | Introductions |
---|---|---|---|---|
value | number | yes | Screen brightness value, range 0 1。0 Darkest, 1 Brightest | |
success | function | no | Interface calls the successful callback function | |
fail | function | no | Interface calls failed callback functions | |
complete | function | no | Callback function at the end of an interface call (both successful and unsuccessful calls are executed) |
setKeepScreenOn
Base library support from 1.3.9, iOS version 2.1.23, Android version 2.1.38
setKeepScreenOn(Object object)
Sets whether or not to always light. Only the current Mini Program is in effect and the settings are disabled after leaving the Mini Program
parameter
Object object
attribute | type | Default values | Required | Introductions |
---|---|---|---|---|
keepScreenOn | boolean | yes | Keep the screen bright | |
success | function | no | Interface calls the successful callback function | |
fail | function | no | Interface calls failed callback functions | |
complete | function | no | Callback function at the end of an interface call (both successful and unsuccessful calls are executed) |
sample code
javascript
ft.setKeepScreenOn({
keepScreenOn: true
})
onUserCaptureScreen
onUserCaptureScreen(function callback)
Monitor the user active screenshot event. Users use the system screenshot on when the trigger screen capture, can only register a monitor
parameter
function callback
Callback function for user active screenshot event
sample code
javascript
ft.onUserCaptureScreen(function (res) {
console.log('User screenshot taken')
})
onScreenRecordingStateChanged
onScreenRecordingStateChanged(function callback)
Listening for user recording events, triggered when the user records the screen(iOS only)
parameter
function callback
Callback function for user-initiated screen recording events
parameter
Object res
attribute | type | Introductions |
---|---|---|
state | string | The value is start or stop, start: start recording; stop: stop recording |
sample code
javascript
ft.onScreenRecordingStateChanged(function (res) {
console.log(res.state)
})
offUserCaptureScreen
offUserCaptureScreen(function callback)
User active screenshot event. Cancel event listening
parameter
function callback
Callback function for user active screenshot event
offScreenRecordingStateChanged
offScreenRecordingStateChanged(function callback)
Remove listening to user recording events
parameter
function callback
Callback for user-initiated screenshot events
parameter is the listener function passed in by onScreenRecordingStateChanged, if no parameter is passed, all listeners are removed
getScreenRecordingState
Base library support from 2.12.16, iOS version 2.37.1, Android version 2.37.1
getScreenRecordingState(Object object)
Check if the user is recording
parameter
Object object
attribute | type | Default values | Required | Introductions |
---|---|---|---|---|
success | function | no | Interface calls the successful callback function | |
fail | function | no | Interface calls failed callback functions | |
complete | function | no | Callback function at the end of an interface call (both successful and unsuccessful calls are executed) |
object.success callback
parameter
Object res
attribute | type | Introductions |
---|---|---|
state | string | Screen recording status, value is on or off |
getScreenBrightness
Base library support from 1.3.9, iOS version 2.1.23, Android version 2.1.38
getScreenBrightness(Object object)
Get the screen brightness.
parameter
Object object
attribute | type | Default values | Required | Introductions |
---|---|---|---|---|
success | function | no | Interface calls the successful callback function | |
fail | function | no | Interface calls failed callback functions | |
complete | function | no | Callback function at the end of an interface call (both successful and unsuccessful calls are executed) |
object.success callback
parameter
Object res
attribute | type | Introductions |
---|---|---|
value | number | Screen brightness value, range 0 ~ 1, 0 darkest, 1 brightest |
keyboard
onKeyboardHeightChange
onKeyboardHeightChange(function callback)
Monitor keyboard height changes
parameter
function callback
parameter
object res
attribute | type | Introductions |
---|---|---|
height | number | Keyboard height |
sample code
javascript
ft.onKeyboardHeightChange(res => {
console.log(res.height)
})
offKeyboardHeightChange
offKeyboardHeightChange(function callback)
Unlisten for keyboard height change events
parameter
function callback
Callback function for keyboard height change events
hideKeyboard
hideKeyboard(Object object)
After input, textarea, etc., focus pulls up the keyboard, manually invoke this interface to close the keyboard
parameter
Object object
attribute | type | Default values | Required | Introductions |
---|---|---|---|---|
success | function | no | Interface calls the successful callback function | |
fail | function | no | Interface calls failed callback functions | |
complete | function | no | Callback function at the end of an interface call (both successful and unsuccessful calls are executed) |
sample code
javascript
ft.hideKeyboard({
complete: res => {
console.log('hideKeyboard res', res)
}
})
getSelectedTextRange
getSelectedTextRange(Object object)
After input, text area, and so on, get the cursor position of the input box. Note: This interface is only valid when called with focus.
parameter
Object object
attribute | type | Default values | Required | Introductions |
---|---|---|---|---|
success | function | no | Interface calls the successful callback function | |
fail | function | no | Interface calls failed callback functions | |
complete | function | no | Callback function at the end of an interface call (both successful and unsuccessful calls are executed) |
object.success callback
parameter
Object res
attribute | type | Introductions |
---|---|---|
start | number | Input box cursor start position |
end | number | Input Box Cursor End Position |
sample code
javascript
ft.getSelectedTextRange({
complete: res => {
console.log('getSelectedTextRange res', res.start, res.end)
}
})
})
telephone
makePhoneCall
Base library support from 1.3.9, iOS version 2.1.23, Android version 2.1.38
makePhoneCall(Object object)
Make a call
parameter
Object object
attribute | type | Default values | Required | Introductions |
---|---|---|---|---|
phoneNumber | string | yes | The number you need to dial | |
success | function | no | Interface calls the successful callback function | |
fail | function | no | Interface calls failed callback functions | |
complete | function | no | Callback function at the end of an interface call (both successful and unsuccessful calls are executed) |
sample code
javascript
ft.makePhoneCall({
phoneNumber: '1340000' // Example only, not a real phone number
})
Accelerometer
stopAccelerometer
stopAccelerometer(Object object)
Stop listening for acceleration data
parameter
Object object
attribute | type | Default values | Required | Introductions |
---|---|---|---|---|
success | function | no | Interface calls the successful callback function | |
fail | function | no | Interface calls failed callback functions | |
complete | function | no | Callback function at the end of an interface call (both successful and unsuccessful calls are executed) |
sample code
javascript
ft.stopAccelerometer()
startAccelerometer
startAccelerometer(Object object)
Start monitoring the acceleration data
parameter
Object object
attribute | type | Default values | Required | Introductions |
---|---|---|---|---|
interval | string | normal | no | Monitor the execution frequency of the acceleration data callback function |
success | function | no | Interface calls the successful callback function | |
fail | function | no | Interface calls failed callback functions | |
complete | function | no | Callback function at the end of an interface call (both successful and unsuccessful calls are executed) |
object.interval Legal value
value | Introductions |
---|---|
game | The callback frequency for updating the game, in 20ms/second About |
ui | Apply to update UI Callback frequency of 60ms/second About |
normal | Normal callback frequency, in the 200ms/second About |
sample code
javascript
ft.startAccelerometer({
interval: 'game'
})
onAccelerometerChange
onAccelerometerChange(function callback)
Listen for acceleration data events. Frequency basis ft.startAccelerometer() of interval Parameters, Interface calls automatically start listening
parameter
function callback
Acceleration Data Event Callback Function
parameter
Object res
attribute | type | Introductions |
---|---|---|
x | number | X axis |
y | number | Y axis |
z | number | Z axis |
sample code
javascript
ft.onAccelerometerChange(callback)
offAccelerometerChange
offAccelerometerChange(function callback)
Cancel monitoring of acceleration data events. If the parameter is null, cancel all event monitoring
parameter
function callback
Acceleration Data Event Callback Function
Compass
stopCompass
stopCompass(Object object)
Stop listening to compass data
parameter
Object object
attribute | type | Default values | Required | Introductions |
---|---|---|---|---|
success | function | no | Interface calls the successful callback function | |
fail | function | no | Interface calls failed callback functions | |
complete | function | no | Callback function at the end of an interface call (both successful and unsuccessful calls are executed) |
sample code
javascript
ft.stopCompass()
startCompass
startCompass(Object object)
Start monitoring compass data
parameter
Object object
attribute | type | Default values | Required | Introductions |
---|---|---|---|---|
success | function | no | Interface calls the successful callback function | |
fail | function | no | Interface calls failed callback functions | |
complete | function | no | Callback function at the end of an interface call (both successful and unsuccessful calls are executed) |
sample code
javascript
ft.startCompass()
onCompassChange
onCompassChange(function callback)
Monitor compass data changes. Frequency: 5 second/Seconds, the interface will automatically start listening after the call, you can use the ft.stopCompass Stop listening
parameter
function callback
Callback function for compass data change events
parameter
Object object
attribute | type | Introductions |
---|---|---|
direction | number | Degree of direction faced |
accuracy | number/string | accuracy |
sample code
javascript
ft.onCompassChange(callback)
accuracy in iOS/Android Difference
Due to platform differences, accuracy in iOS/Android Has different values.
iOS:accuracy It's a... number Represents a deviation from the magnetic north pole. 0 Indicates device pointing magnetic north, 90 It points east, 180. Point south, and so on.
Android:accuracy It's a... string Is an enumerated value of the.
value | Introductions |
---|---|
high | high precision |
medium | Medium precision |
low | Low precision |
no-contact | Untrusted. Sensor lost connection. |
unreliable | Not credible, reason unknown |
unknow ${value} | An unknown precision enumeration value, that is, the Android Representing the precision returned by the system at this time value Is not a standard precision enumeration value |
offCompassChange
offCompassChange(function callback)
Cancel listening compass data change event, the parameter is empty, then cancel all the event listening.
parameter
function callback
Callback function for compass data change events
Equipment direction
stopDeviceMotionListening
stopDeviceMotionListening(Object object)
Stop listening for changes in device direction
parameter
Object object
attribute | type | Default values | Required | Introductions |
---|---|---|---|---|
success | function | no | Interface calls the successful callback function | |
fail | function | no | Interface calls failed callback functions | |
complete | function | no | Callback function at the end of an interface call (both successful and unsuccessful calls are executed) |
startDeviceMotionListening
startDeviceMotionListening(Object object)
Start listening for changes in device orientation
parameter
Object object
attribute | type | Default values | Required | Introductions |
---|---|---|---|---|
interval | string | normal | no | Monitor device direction change callback function execution frequency |
success | function | no | Interface calls the successful callback function | |
fail | function | no | Interface calls failed callback functions | |
complete | function | no | Callback function at the end of an interface call (both successful and unsuccessful calls are executed) |
object.interval Legal value
value | Introductions |
---|---|
game | The callback frequency for updating the game, in 20ms/second About |
ui | Apply to update UI Callback frequency of 60ms/second About |
normal | Normal callback frequency, in the 200ms/second About |
onDeviceMotionChange
onDeviceMotionChange(function callback)
Listen for device direction change events. Frequency basis ft.startDeviceMotionListening() of interval Parameters. Can be used ft.stopDeviceMotionListening() Stop listening
parameter
function callback
Callback function for device orientation change event
parameter
Object res
attribute | type | Introductions |
---|---|---|
alpha | number | when Cell phone coordinates X/And and Earth X/And When overlapped, around. With |
The angle at which the axis rotates is Alpha, with a range value of [0, 2*PI). Turning counterclockwise is positive. | ||
beta | number | When the phone coordinates And/WithAnd the Earth And/With When overlapped, around. X The angle at which the axis rotates is beta。 Range values are [-1PI, PI) The top is turned positive towards the Earth's surface. It is also possible to be positive towards the user. |
gamma | number | When the phone X/Z coincides with the Earth X/Z, the angle of rotation around the Y-axis is gamma. the range of values is [-1*PI/2, PI/2). The rotation of the right side towards the Earth's surface is positive. |
offDeviceMotionChange
offDeviceMotionChange(function callback)
Cancels listening device direction change event, parameter is null, then cancels all event monitoring
parameter
function callback
Callback function for device orientation change event
gyroscope
stopGyroscope
stopGyroscope(Object object)
Stop monitoring the gyroscope data
parameter
Object object
attribute | type | Default values | Required | Introductions |
---|---|---|---|---|
success | function | no | Interface calls the successful callback function | |
fail | function | no | Interface calls failed callback functions | |
complete | function | no | Callback function at the end of an interface call (both successful and unsuccessful calls are executed) |
startGyroscope
startGyroscope(Object object)
Start monitoring the gyroscope data.
parameter
Object object
attribute | type | Default values | Required | Introductions |
---|---|---|---|---|
interval | string | normal | no | Monitor the execution frequency of the gyro data callback function |
success | function | no | Interface calls the successful callback function | |
fail | function | no | Interface calls failed callback functions | |
complete | function | no | Callback function at the end of an interface call (both successful and unsuccessful calls are executed) |
object.interval Legal value
value | Introductions |
---|---|
game | The callback frequency for updating the game, in 20ms/second About |
ui | Apply to update UI Callback frequency of 60ms/second About |
normal | Normal callback frequency, in the 200ms/second About |
onGyroscopeChange
onGyroscopeChange(function callback)
Monitor gyro data change events. Frequency basis ft.startGyroscope() of interval Parameters. Can be used ft.stopGyroscope() Stop listening
parameter
function callback
A callback function for gyro data change events
parameter
Object res
attribute | type | Introductions |
---|---|---|
x | number | x Angular velocity of shaft |
y | number | y Angular velocity of shaft |
z | number | z Angular velocity of shaft |
offGyroscopeChange
offGyroscopeChange(function callback)
Unlisten for gyro data change events.
parameter
function callback
A callback function for gyro data change events
Memory
onMemoryWarning
onMemoryWarning(function callback)
Listening for insufficient memory alarm events
parameter
function listener
Listening function for insufficient memory alarm events
parameter
Object res
attribute | type | Introductions |
---|---|---|
level | number | Memory alarm level, only implemented on Android |
res.level
value | Introductions |
---|---|
5 | TRIM_MEMORY_RUNNING_MODERATE |
10 | TRIM_MEMORY_RUNNING_LOW |
15 | TRIM_MEMORY_RUNNING_CRITICAL |
offMemoryWarning
** offMemoryWarning(function callback)**
Remove the function to listen for low memory alarm events
parameter
function listener
Listening function for insufficient memory alarm events
Scan code
scanCode
Base library support from 1.3.9, iOS version 2.1.23, Android version 2.1.38
scanCode(Object object)
Set up the client scan interface to scan the code
parameter
Object object
attribute | type | Default values | Required | Introductions |
---|---|---|---|---|
onlyFromCamera | boolean | false | no | Whether you can only scan the code from the camera, not allow you to select pictures from the album |
success | function | no | Interface calls the successful callback function | |
fail | function | no | Interface calls the successful callback function | |
complete | function | no | Callback function at the end of an interface call (both successful and unsuccessful calls are executed) |
object.success callback
parameter
Object res
sample code
javascript
// Allow scanning from camera and photo album
ft.scanCode({
success(res) {
console.log(res)
}
})
// Scan code only from camera
ft.scanCode({
onlyFromCamera: true,
success(res) {
console.log(res)
}
})
Note
- Interface authorization failure (iOS). 1:
- the user refuses to authorize, the error message: unauthorized, the user has not granted the camera permission
- The host app disables the mini program from actively requesting permissions, an error message is returned: unauthorized disableauthorized, the SDK is disabled from requesting camera permissions.
- Interface authorization failure (Android).
- the user refuses to authorize, an error message is returned: fail unauthorized, the user has not granted camera privileges
- the host app prohibits the mini program from initiating permission requests, the error message is returned: unauthorized disableauthorized SDK is prohibited from initiating permission requests
vibration
vibrateShort
Base library support from 1.3.9, iOS version 2.1.23, Android version 2.1.38
vibrateShort(Object object)
Make the mobile phone vibrate for a short time (15 ms)。 Only in iPhone 7 / 7 More Above and Android Model entry into force
parameter
Object object
attribute | type | Default values | Required | Introductions |
---|---|---|---|---|
success | function | no | Interface calls the successful callback function | |
fail | function | no | Interface calls failed callback functions | |
complete | function | no | Callback function at the end of an interface call (both successful and unsuccessful calls are executed) |
Note
- Interface authorization failure (Android): 1.
- the user refuses to authorise, an error message is returned: unauthorized user not granted permission to vibrate
- the host app prohibits the mini program from initiating permission requests, the error message is returned: unauthorized disableauthorized SDK is prohibited from initiating permission requests
vibrateLong
Base library support from 1.3.9, iOS version 2.1.23, Android version 2.1.38
vibrateLong(Object object)
Make the phone vibrate for a longer time (400 ms)
parameter
Object object
attribute | type | Default values | Required | Introductions |
---|---|---|---|---|
success | function | no | Interface calls the successful callback function | |
fail | function | no | Interface calls failed callback functions(When authorization fails, an error message is returned: fail unauthorized user has not been granted vibrate permission) | |
complete | function | no | Callback function at the end of an interface call (both successful and unsuccessful calls are executed) |
Note
- Interface authorization failure (Android): 1.
- the user refuses to authorise, an error message is returned: unauthorized user not granted permission to vibrate
- the host app prohibits the mini program from initiating permission requests, the error message is returned: unauthorized disableauthorized SDK is prohibited from initiating permission requests
Bluetooth - Universal
stopBluetoothDevicesDiscovery
Supported from base library 2.11.2, iOS version 2.34.1, Android version 2.34.1, dependency on extension SDK. From 2.35.7 onwards, the Bluetooth module is independent and requires a separate dependency on the FinClipBluetoothSDK
stopBluetoothDevicesDiscovery(Object object)
Stop searching for nearby Bluetooth peripherals. If you have found the Bluetooth device and do not need to continue to search, it is recommended to call the interface to stop Bluetooth search
parameter
Object object
attribute | type | Default values | Required | Introductions |
---|---|---|---|---|
success | function | no | Interface calls the successful callback function | |
fail | function | no | Interface calls failed callback functions | |
complete | function | no | Interface calls the end of the callback function (call success or failure will be executed) |
error
Error code | Error message | Introductions |
---|---|---|
0 | ok | normal |
-1 | already connet | Connected |
10000 | not init | Uninitialized Bluetooth adapter |
10001 | not available | The current Bluetooth adapter is not available |
10002 | no device | Specified device not found |
10003 | connection fail | Connection failure |
10004 | no service | Specified service not found |
10005 | no characteristic | Did not find the specified signature. |
10006 | no connection | Current connection disconnected |
10007 | property not support | Current feature does not support this operation |
10008 | system error | All other system reported anomalies |
10009 | system not support | Android System specific, system version below 4.3 Not supported WAS |
10012 | operate time out | Connection Timeout |
10013 | invalid_data | Connect deviceId Is empty or incorrectly formatted |
startBluetoothDevicesDiscovery
Base library support from 2.11.2, iOS version 2.34.1, Android version 2.34.1, dependency extension SDK
startBluetoothDevicesDiscovery(Object object)
Start searching for nearby Bluetooth peripherals.
This operation is more costly system resources, please search to the required equipment after the timely call ft.stopBluetoothDevicesDiscovery Stop the search
parameter
Object object
attribute | type | Default values | Required | Introductions |
---|---|---|---|---|
services | Array.string | no | To search for the Bluetooth device master service UUID List support 16/32/128 position UUID)。 Some Bluetooth devices broadcast their own host service of UUID。 If this parameter is set, only the broadcast packets are searched for UUID The main service of the Bluetooth device. This parameter is recommended to filter out other Bluetooth devices that do not need to be handled around | |
allowDuplicatesKey | boolean | false | no | Whether duplicate reporting of the same device is allowed. If duplicate reporting is allowed, the ft.onBlueToothDeviceFound Method will report to the same device multiple times, but RSSI Values will vary. |
interval | number | 0 | no | Reporting Equipment Interval, Unit ms。 0 Indicates that the new device is reported as soon as it is found, and other values are reported according to the incoming interval. |
powerLevel | string | medium | no | Scan mode, the higher the scan faster, the more power consumption. Android WeChat client only 7.0.12 And above support. |
success | function | no | Interface calls the successful callback function | |
fail | function | no | Interface calls failed callback functions | |
complete | function | no | Interface calls the end of the callback function (call success or failure will be executed) |
object.powerLevel Legal value
value | Introductions | Minimum version |
---|---|---|
low | low | |
medium | in | |
high | high |
error
Error code | Error message | Introductions |
---|---|---|
0 | ok | normal |
-1 | already connet | Connected |
10000 | not init | Uninitialized Bluetooth adapter |
10001 | not available | The current Bluetooth adapter is not available |
10002 | no device | Specified device not found |
10003 | connection fail | Connection failure |
10004 | no service | Specified service not found |
10005 | no characteristic | Did not find the specified signature. |
10006 | no connection | Current connection disconnected |
10007 | property not support | Current feature does not support this operation |
10008 | system error | All other system reported anomalies |
10009 | system not support | Android System specific, system version below 4.3 Not supported WAS |
10012 | operate time out | Connection Timeout |
10013 | invalid_data | Connect deviceId Is empty or incorrectly formatted |
openBluetoothAdapter
Base library support from 2.11.2, iOS version 2.34.1, Android version 2.34.1, dependency extension SDK
openBluetoothAdapter(Object object)
Initialize the Bluetooth module. iOS Up-on host/Is called each time in slave (peripheral) mode, and the corresponding mode。
parameter
Object object
attribute | type | Default values | Required | Introductions | Minimum version |
---|---|---|---|---|---|
mode | string | central | no | Bluetooth mode, available as master/From equipment, only iOS Need | |
success | function | no | Interface calls the successful callback function | ||
fail | function | no | Interface calls failed callback functions | ||
complete | function | no | Interface calls the end of the callback function (call success or failure will be executed) |
object.mode Legal value
value | Introductions | Minimum version |
---|---|---|
central | Host mode | |
peripheral | Slave (peripheral) mode |
error
Error code | Error message | Introductions |
---|---|---|
0 | ok | normal |
-1 | already connet | Connected |
10000 | not init | Uninitialized Bluetooth adapter |
10001 | not available | The current Bluetooth adapter is not available |
10002 | no device | Specified device not found |
10003 | connection fail | Connection failure |
10004 | no service | Specified service not found |
10005 | no characteristic | Did not find the specified signature. |
10006 | no connection | Current connection disconnected |
10007 | property not support | Current feature does not support this operation |
10008 | system error | All other system reported anomalies |
10009 | system not support | Android System specific, system version below 4.3 Not supported WAS |
10012 | operate time out | Connection Timeout |
10013 | invalid_data | Connect deviceId Is empty or incorrectly formatted |
object.fail Callback function returns state Parameters only iOS)
Status code | Introductions |
---|---|
0 | Unknown |
1 | Reset |
2 | Not supported |
3 | Not authorized |
4 | Not open |
Be careful
- Other Bluetooth related API Must be ft.openBluetoothAdapter Used after the call. otherwise API Returns an error (errCode = 10000).
- When the user's Bluetooth switch is not turned on or the phone does not support Bluetooth, call the ft.openBluetoothAdapter An error is returned (errCode = 10001) indicating that the phone's Bluetooth feature is not available. At this time the Mini Program bluetooth module has been initialized, you can use ft.onBluetoothAdapterStateChange Monitor the phone's Bluetooth status change, you can also call all the API of Bluetooth module
Note
- Interface authorization failure (iOS):
- The host app disables the mini program from actively requesting permissions and returns the Error message: unauthorized disableauthorized, the SDK is disabled from requesting Bluetooth permissions
onBluetoothDeviceFound
Base library support from 2.11.2, iOS version 2.34.1, Android version 2.34.1, dependency extension SDK onBluetoothDeviceFound(function callback) Listen for events that search for new devices
parameter
function callback
A callback function that searches for events on a new device
parameter
object res
attribute | type | Introductions |
---|---|---|
devices | Array.Object | List of newly searched devices |
res.devices Structure
attribute | type | Introductions |
---|---|---|
name | string | Bluetooth device name, which some devices may not have |
deviceId | string | Bluetooth Device id |
RSSI | number | Current Bluetooth Device Signal Strength, Unit dBm |
advertisData | ArrayBuffer | In the broadcast data segment of the current bluetooth device ManufacturerData Data segment |
advertisServiceUUIDs | Array.string | In the broadcast data segment of the current bluetooth device ServiceUUIDs data segment |
localName | string | In the broadcast data segment of the current bluetooth device LocalName data segment |
serviceData | Object | In the broadcast data segment of the current bluetooth device ServiceData data segment |
Be careful
- If a device is called in the onBluetoothDeviceFound callback, it will be added to the array obtained from the getBluetoothDevices interface.
- Some Android models require location permission to search for devices, so please note that yesno is enabled.
- Repeated calls will overwrite the previous callbacks.
onBluetoothAdapterStateChange
Base library support from 2.11.2, iOS version 2.34.1, Android version 2.34.1, dependency extension SDK onBluetoothAdapterStateChange(function callback)
Monitor Bluetooth Adapter State Change Event
parameter
function callback
Callback function for Bluetooth adapter state change event
parameter
Object res
attribute | type | Introductions |
---|---|---|
available | boolean | Is the Bluetooth adapter available? |
discovering | boolean | Is the Bluetooth adapter in a search state? |
Be careful Repeated calls will overwrite previous callbacks
offBluetoothDeviceFound
Base library support from 2.11.2, iOS version 2.34.1, Android version 2.34.1, dependency extension SDK
Cancel listening for events that find new devices
offBluetoothAdapterStateChange
Base library support from 2.11.2, iOS version 2.34.1, Android version 2.34.1, dependency extension SDK
Callback function to find events for new devices
makeBluetoothPair
Base library support from 2.11.2, iOS version 2.34.1, Android version 2.34.1, dependency extension SDK
makeBluetoothPair(Object object)
Bluetooth pairing interface, Android only support.
Typically, you need to specify pin The system takes over the pairing process and calls the ft.createBLEConnection You can. This interface should be used only when the developer does not want the user to enter manually pin Code and real machine verification confirmation can be used in normal working conditions
parameter
Object object
attribute | type | Default values | Required | Introductions |
---|---|---|---|---|
deviceId | string | yes | Bluetooth Device id | |
pin | string | yes | pin Yards, Base 64. Format. | |
timeout | number | 20000 | no | Timeout, units ms |
success | function | no | Interface calls the successful callback function | |
fail | function | no | Interface calls failed callback functions | |
complete | function | no | Interface calls the end of the callback function (call success or failure will be executed) |
getConnectedBluetoothDevices
Base library support from 2.11.2, iOS version 2.34.1, Android version 2.34.1, dependency extension SDK
getConnectedBluetoothDevices(Object object)
According to Master Service UUID Gets the connected Bluetooth device
parameter
Object object
attribute | type | Default values | Required | Introductions |
---|---|---|---|---|
services | Array.string | yes | Bluetooth Device Master Service UUID List support 16/32/128 position UUID) | |
success | function | no | Interface calls the successful callback function | |
fail | function | no | Interface calls failed callback functions | |
complete | function | no | Interface calls the end of the callback function (call success or failure will be executed) |
object.success callback
parameter
Object res
attribute | type | Introductions |
---|---|---|
devices | Array.Object | List of devices found |
res.devices Structure
attribute | type | Introductions |
---|---|---|
name | string | Bluetooth device name, which some devices may not have |
deviceId | string | Used to distinguish equipment id |
error
Error code | Error message | Introductions |
---|---|---|
0 | ok | normal |
-1 | already connet | Connected |
10000 | not init | Uninitialized Bluetooth adapter |
10001 | not available | The current Bluetooth adapter is not available |
10002 | no device | Specified device not found |
10003 | connection fail | Connection failure |
10004 | no service | Specified service not found |
10005 | no characteristic | Did not find the specified signature. |
10006 | no connection | Current connection disconnected |
10007 | property not support | Current feature does not support this operation |
10008 | system error | All other system reported anomalies |
10009 | system not support | Android System specific, system version below 4.3 Not supported WAS |
10012 | operate time out | Connection Timeout |
10013 | invalid_data | Connect deviceId Is empty or incorrectly formatted |
getBluetoothDevices
getBluetoothDevices(Object object)
Gets all Bluetooth devices searched for while the Bluetooth module is active. Includes devices that are already connected to the machine
parameter
Object object
attribute | type | Default values | Required | Introductions |
---|---|---|---|---|
success | function | no | Interface calls the successful callback function | |
fail | function | no | Interface calls failed callback functions | |
complete | function | no | Interface calls the end of the callback function (call success or failure will be executed) |
object.success callback
parameter
Object res
attribute | type | Introductions |
---|---|---|
devices | Array.Object | UUID List of connected devices |
res.devices Structure
attribute | type | Introductions |
---|---|---|
name | string | Bluetooth device name, which some devices may not have |
deviceId | string | Bluetooth Device id |
RSSI | number | Current Bluetooth Device Signal Strength, Unit dBm |
advertisData | ArrayBuffer | In the broadcast data segment of the current bluetooth device ManufacturerData Data segment |
advertisServiceUUIDs | Array.string | In the broadcast data segment of the current bluetooth device ServiceUUIDs data segment |
localName | string | In the broadcast data segment of the current bluetooth device LocalName data segment |
serviceData | Object | In the broadcast data segment of the current bluetooth device ServiceData data segment |
error
Error code | Error message | Introductions |
---|---|---|
0 | ok | normal |
-1 | already connet | Connected |
10000 | not init | Uninitialized Bluetooth adapter |
10001 | not available | The current Bluetooth adapter is not available |
10002 | no device | Specified device not found |
10003 | connection fail | Connection failure |
10004 | no service | Specified service not found |
10005 | no characteristic | Did not find the specified signature. |
10006 | no connection | Current connection disconnected |
10007 | property not support | Current feature does not support this operation |
10008 | system error | All other system reported anomalies |
10009 | system not support | Android System specific, system version below 4.3 Not supported WAS |
10012 | operate time out | Connection Timeout |
10013 | invalid_data | Connect deviceId Is empty or incorrectly formatted |
getBluetoothAdapterState
Base library support from 2.11.2, iOS version 2.34.1, Android version 2.34.1, dependency extension SDK
getBluetoothAdapterState(Object object)
Gets the status of the native Bluetooth adapter
parameter
Object object
attribute | type | Default values | Required | Introductions |
---|---|---|---|---|
success | function | no | Interface calls the successful callback function | |
fail | function | no | Interface calls failed callback functions | |
complete | function | no | Interface calls the end of the callback function (call success or failure will be executed) |
object.success callback
parameter
Object res
attribute | type | Introductions |
---|---|---|
discovering | boolean | Are you searching for devices? |
available | boolean | Is the Bluetooth adapter available? |
error
Error code | Error message | Introductions |
---|---|---|
0 | ok | normal |
-1 | already connet | Connected |
10000 | not init | Uninitialized Bluetooth adapter |
10001 | not available | The current Bluetooth adapter is not available |
10002 | no device | Specified device not found |
10003 | connection fail | Connection failure |
10004 | no service | Specified service not found |
10005 | no characteristic | Did not find the specified signature. |
10006 | no connection | Current connection disconnected |
10007 | property not support | Current feature does not support this operation |
10008 | system error | All other system reported anomalies |
10009 | system not support | Android System specific, system version below 4.3 Not supported WAS |
10012 | operate time out | Connection Timeout |
10013 | invalid_data | Connect deviceId Is empty or incorrectly formatted |
closeBluetoothAdapter
Base library support from 2.11.2, iOS version 2.34.1, Android version 2.34.1, dependency extension SDK
closeBluetoothAdapter(Object object)
Turn off the Bluetooth module. Calling this method disconnects all established connections and frees system resources. It is recommended that after using the Bluetooth process, the ft.openBluetoothAdapter Call in pairs
parameter
Object object
attribute | type | Default values | Required | Introductions |
---|---|---|---|---|
success | function | no | Interface calls the successful callback function | |
fail | function | no | Interface calls failed callback functions | |
complete | function | no | Interface calls the end of the callback function (call success or failure will be executed) |
error
Error code | Error message | Introductions |
---|---|---|
0 | ok | normal |
-1 | already connet | Connected |
10000 | not init | Uninitialized Bluetooth adapter |
10001 | not available | The current Bluetooth adapter is not available |
10002 | no device | Specified device not found |
10003 | connection fail | Connection failure |
10004 | no service | Specified service not found |
10005 | no characteristic | Did not find the specified signature. |
10006 | no connection | Current connection disconnected |
10007 | property not support | Current feature does not support this operation |
10008 | system error | All other system reported anomalies |
10009 | system not support | Android System specific, system version below 4.3 Not supported WAS |
10012 | operate time out | Connection Timeout |
10013 | invalid_data | Connect deviceId Is empty or incorrectly formatted |
Bluetooth-Low-Power Central Device
writeBLECharacteristicValue
Base library support from 2.11.2, iOS version 2.34.1, Android version 2.34.1, dependency extension SDK
writeBLECharacteristicValue(Object object)
Writes binary data to a Bluetooth low-power device characteristic value. Note: Features of the device must support write Before it can be successfully invoked
parameter
Object object
attribute | type | Default values | Required | Introductions |
---|---|---|---|---|
deviceId | string | yes | Bluetooth Device id | |
serviceId | string | yes | Bluetooth Feature Corresponding Service UUID | |
characteristicId | string | yes | Bluetooth characteristic UUID | |
value | ArrayBuffer | yes | Binary Values for Bluetooth Device Features | |
writeType | string | yes | Bluetooth feature value write mode setting, there are two modes, iOS priority write, Android priority writeNoResponse | |
success | function | no | Interface calls the successful callback function | |
fail | function | no | Interface calls failed callback functions | |
complete | function | no | Interface calls the end of the callback function (call success or failure will be executed) |
writeType
Legal value | type |
---|---|
write | Forced reply writing, error reporting not supported |
writeNoResponse | Forced no-reply writing, no error reporting support |
error
Error code | Error message | Introductions |
---|---|---|
0 | ok | normal |
-1 | already connet | Connected |
10000 | not init | Uninitialized Bluetooth adapter |
10001 | not available | The current Bluetooth adapter is not available |
10002 | no device | Specified device not found |
10003 | connection fail | Connection failure |
10004 | no service | Specified service not found |
10005 | no characteristic | Did not find the specified signature. |
10006 | no connection | Current connection disconnected |
10007 | property not support | Current feature does not support this operation |
10008 | system error | All other system reported anomalies |
10009 | system not support | Android System specific, system version below 4.3 Not supported WAS |
10012 | operate time out | Connection Timeout |
10013 | invalid_data | Connect deviceId Is empty or incorrectly formatted |
setBLEMTU
Base library support from 2.11.2, iOS version 2.34.1, Android version 2.34.1, dependency extension SDK
setBLEMTU(Object object)
Negotiating Bluetooth Low Power Maximum Transmission Unit (Maximum Transmission Unit, MAN)Need in. ft.createBLEConnection Called after successful invocation. Android only 5.1 The above version is valid, iOS Not supported due to system limitations
parameter
Object object
attribute | type | Default values | Required | Introductions |
---|---|---|---|---|
deviceId | string | yes | Bluetooth Device id | |
mtu | number | yes | Maximum transmission unit. Set the scope to (22,512) Interval, unit bytes | |
success | function | no | Interface calls the successful callback function | |
fail | function | no | Interface calls failed callback functions | |
complete | function | no | Interface calls the end of the callback function (call success or failure will be executed) |
object.success callback
parameter
Object res
attribute | type | Introductions |
---|---|---|
mtu | number | Final negotiated MAN Value, consistent with the passed parameter. Android Client 8.0.9 Start supporting |
object.fail callback
parameter
Object res
attribute | type | Introductions |
---|---|---|
mtu | number | Final negotiated MAN Value. This parameter is not available if the negotiation fails. Android Client 8.0.9 Start supporting |
readBLECharacteristicValue
Base library support from 2.11.2, iOS version 2.34.1, Android version 2.34.1, dependency extension SDK
readBLECharacteristicValue(Object object)
Reads the binary data of the characteristic value of a Bluetooth low-power device. Note: Features of the device must support read Before it can be successfully invoked
parameter
Object object
attribute | type | Default values | Required | Introductions |
---|---|---|---|---|
deviceId | string | yes | Bluetooth Device id | |
serviceId | string | yes | Bluetooth Feature Corresponding Service UUID | |
characteristicId | string | yes | Bluetooth characteristic UUID | |
success | function | no | Interface calls the successful callback function | |
fail | function | no | Interface calls failed callback functions | |
complete | function | no | Interface calls the end of the callback function (call success or failure will be executed) |
error
Error code | Error message | Introductions |
---|---|---|
0 | ok | normal |
-1 | already connet | Connected |
10000 | not init | Uninitialized Bluetooth adapter |
10001 | not available | The current Bluetooth adapter is not available |
10002 | no device | Specified device not found |
10003 | connection fail | Connection failure |
10004 | no service | Specified service not found |
10005 | no characteristic | Did not find the specified signature. |
10006 | no connection | Current connection disconnected |
10007 | property not support | Current feature does not support this operation |
10008 | system error | All other system reported anomalies |
10009 | system not support | Android System specific, system version below 4.3 Not supported WAS |
10012 | operate time out | Connection Timeout |
10013 | invalid_data | Connect deviceId Is empty or incorrectly formatted |
Be careful
- Multiple parallel calls have the possibility of read failure.
- The information read by the interface needs to be stored in the ft.onBLECharacteristicValueChange Method to get the callback registered with the
onBLEConnectionStateChange
Base library support from 2.11.2, iOS version 2.34.1, Android version 2.34.1, dependency extension SDK
onBLEConnectionStateChange(function callback)
Listens for Bluetooth low-power connection state change events. Including developers active connection or disconnect, device loss, abnormal connection disconnection, etc
parameter
function callback
Callback function for Bluetooth low power connection state change event
parameter
Object res
attribute | type | Introductions |
---|---|---|
deviceId | string | Bluetooth Device id |
connected | boolean | Are you connected? |
Be careful
Repeated calls will overwrite the original callback
onBLECharacteristicValueChange
Base library support from 2.11.2, iOS version 2.34.1, Android version 2.34.1, dependency extension SDK
onBLECharacteristicValueChange(function callback)
Monitor eigenvalue change events for Bluetooth low-power devices. Must be invoked first ft.notifyBLECharacteristicValueChange Interface to receive the device push notification
parameter
function callback
Callback Functions for Eigenvalue Change Events of Bluetooth Low Power Devices
parameter
Object res
attribute | type | Introductions |
---|---|---|
deviceId | string | Bluetooth Device id |
serviceId | string | Bluetooth Feature Corresponding Service UUID |
characteristicId | string | Bluetooth characteristic UUID |
value | ArrayBuffer | Characteristic latest value |
Be careful
Repeated calls will overwrite the original callback
offBLEConnectionStateChange
Base library support from 2.11.2, iOS version 2.34.1, Android version 2.34.1, dependency extension SDK
Cancel listening for Bluetooth low energy connection state change events
offBLECharacteristicValueChange
Base library support from 2.11.2, iOS version 2.34.1, Android version 2.34.1, dependency extension SDK
Cancels listening for eigenvalue change events on Bluetooth low-power devices.
notifyBLECharacteristicValueChange
Base library support from 2.11.2, iOS version 2.34.1, Android version 2.34.1, dependency extension SDK
notifyBLECharacteristicValueChange(Object object)
Enables a Bluetooth low-power device when its eigenvalue changes notify Features, subscription features. Note: Features of the device must support notify or indicate Before it can be successfully invoked.
Also, you must first enable ft.notifyBLECharacteristicValueChange To listen to the device. characteristicValueChange event
parameter
Object res
attribute | type | Default values | Required | Introductions |
---|---|---|---|---|
deviceId | string | yes | Bluetooth Device id | |
serviceId | string | yes | Bluetooth Feature Corresponding Service UUID | |
characteristicId | string | yes | Bluetooth characteristic UUID | |
state | boolean | yes | Enable notify | |
type | string | indication | no | Sets the characteristic subscription type with a valid value of notification and indication |
success | function | no | Interface calls the successful callback function | |
fail | function | no | Interface calls failed callback functions | |
complete | function | no | Interface calls the end of the callback function (call success or failure will be executed) |
error
Error code | Error message | Introductions |
---|---|---|
0 | ok | normal |
-1 | already connet | Connected |
10000 | not init | Uninitialized Bluetooth adapter |
10001 | not available | The current Bluetooth adapter is not available |
10002 | no device | Specified device not found |
10003 | connection fail | Connection failure |
10004 | no service | Specified service not found |
10005 | no characteristic | Did not find the specified signature. |
10006 | no connection | Current connection disconnected |
10007 | property not support | Current feature does not support this operation |
10008 | system error | All other system reported anomalies |
10009 | system not support | Android System specific, system version below 4.3 Not supported WAS |
10012 | operate time out | Connection Timeout |
10013 | invalid_data | Connect deviceId Is empty or incorrectly formatted |
Be careful
- Requires the device to actively update features after a successful subscription operation Value will trigger ft.onBLECharacteristicValueChange Callback.
- On Android platform, call immediately after this interface is successfully invoked ft.writeBLECharacteristicValue Interface, which occurs on some models 10008 System error
getBLEDeviceServices
Base library support from 2.11.2, iOS version 2.34.1, Android version 2.34.1, dependency extension SDK
getBLEDeviceServices(Object object)
Get all Bluetooth Low Power Device Services (service)
parameter
Object object
attribute | type | Default values | Required | Introductions |
---|---|---|---|---|
deviceId | string | yes | Bluetooth Device id。 Need has passed ft.createBLEConnection Establish a connection | |
success | function | no | Interface calls the successful callback function | |
fail | function | no | Interface calls failed callback functions | |
complete | function | no | Interface calls the end of the callback function (call success or failure will be executed) |
object.success callback
parameter
Object res
attribute | type | Introductions |
---|---|---|
services | Array.Object | Device Service List |
结构attribute | type | Introductions |
---|---|---|
uuid | string | Bluetooth Device Service UUID |
isPrimary | boolean | Whether this service is a master service |
error
Error code | Error message | Introductions |
---|---|---|
0 | ok | normal |
-1 | already connet | Connected |
10000 | not init | Uninitialized Bluetooth adapter |
10001 | not available | The current Bluetooth adapter is not available |
10002 | no device | Specified device not found |
10003 | connection fail | Connection failure |
10004 | no service | Specified service not found |
10005 | no characteristic | Did not find the specified signature. |
10006 | no connection | Current connection disconnected |
10007 | property not support | Current feature does not support this operation |
10008 | system error | All other system reported anomalies |
10009 | system not support | Android System specific, system version below 4.3 Not supported WAS |
10012 | operate time out | Connection Timeout |
10013 | invalid_data | Connect deviceId Is empty or incorrectly formatted |
getBLEDeviceRSSI
Base library support from 2.11.2, iOS version 2.34.1, Android version 2.34.1, dependency extension SDK
getBLEDeviceRSSI(Object object)
Get the signal strength of a Bluetooth low-power device (Received Signal Strength Indication, RSSI)
parameter
Object object
attribute | type | Default values | Required | Introductions |
---|---|---|---|---|
deviceId | string | yes | Bluetooth Device id | |
success | function | no | Interface calls the successful callback function | |
fail | function | no | Interface calls failed callback functions | |
complete | function | no | Interface calls the end of the callback function (call success or failure will be executed) |
object.success callback
parameter
Object res
attribute | type | Introductions |
---|---|---|
RSSI | Number | Signal strength, unit dBm |
getBLEDeviceCharacteristics
Base library support from 2.11.2, iOS version 2.34.1, Android version 2.34.1, dependency extension SDK
getBLEDeviceCharacteristics(Object object)
Get all the features of a service on a Bluetooth low-power device (characteristic)
parameter
Object object
attribute | type | Default values | Required | Introductions |
---|---|---|---|---|
deviceId | string | yes | Bluetooth Device id。 Need has passed ft.createBLEConnection Establish a connection | |
serviceId | string | yes | Bluetooth Service UUID。 Need to call first ft.getBLEDeviceServices Obtain | |
success | function | no | Interface calls the successful callback function | |
fail | function | no | Interface calls failed callback functions | |
complete | function | no | Interface calls the end of the callback function (call success or failure will be executed) |
object.success callback
parameter
Object res
attribute | type | Introductions |
---|---|---|
characteristics | Array.Object | Equipment Feature List |
characteristics
Structure attribute | type | Introductions |
---|---|---|
uuid | string | Bluetooth device feature UUID |
properties | Object | Type of operation supported by this feature |
properties
Structure attribute | type | Introductions |
---|---|---|
read | boolean | Does this feature support read operation |
write | boolean | Does this feature support write operation |
notify | boolean | Does this feature support notify operation |
indicate | boolean | Does this feature support indicate operation |
writeNoResponse | boolean | Does the feature support no-reply write operations |
writeDefault | boolean | Does the feature support no-reply write operations |
error
Error code | Error message | Introductions |
---|---|---|
0 | ok | normal |
-1 | already connet | Connected |
10000 | not init | Uninitialized Bluetooth adapter |
10001 | not available | The current Bluetooth adapter is not available |
10002 | no device | Specified device not found |
10003 | connection fail | Connection failure |
10004 | no service | Specified service not found |
10005 | no characteristic | Did not find the specified signature. |
10006 | no connection | Current connection disconnected |
10007 | property not support | Current feature does not support this operation |
10008 | system error | All other system reported anomalies |
10009 | system not support | Android System specific, system version below 4.3 Not supported WAS |
10012 | operate time out | Connection Timeout |
10013 | invalid_data | Connect deviceId Is empty or incorrectly formatted |
createBLEConnection
Base library support from 2.11.2, iOS version 2.34.1, Android version 2.34.1, dependency extension SDK
createBLEConnection(Object object)
Connect to a Bluetooth low-power device.
If the Mini Program in the previous search has been a Bluetooth device, and successfully established a connection, can be directly passed before the search access deviceId Try to connect the device directly without the need to search again
parameter
Object object
attribute | type | Default values | Required | Introductions |
---|---|---|---|---|
deviceId | string | yes | Bluetooth Device id | |
timeout | number | no | Timeout, units Ms, no fill means no timeout | |
success | function | no | Interface calls the successful callback function | |
fail | function | no | Interface calls failed callback functions | |
complete | function | no | Interface calls the end of the callback function (call success or failure will be executed) |
error
Error code | Error message | Introductions |
---|---|---|
0 | ok | normal |
-1 | already connet | Connected |
10000 | not init | Uninitialized Bluetooth adapter |
10001 | not available | The current Bluetooth adapter is not available |
10002 | no device | Specified device not found |
10003 | connection fail | Connection failure |
10004 | no service | Specified service not found |
10005 | no characteristic | Did not find the specified signature. |
10006 | no connection | Current connection disconnected |
10007 | property not support | Current feature does not support this operation |
10008 | system error | All other system reported anomalies |
10009 | system not support | Android System specific, system version below 4.3 Not supported WAS |
10012 | operate time out | Connection Timeout |
10013 | invalid_data | Connect deviceId Is empty or incorrectly formatted |
Be careful
- Make sure to call as many pairs as possible ft.createBLEConnection and ft.closeBLEConnection Interface. Android, if repeated ft.createBLEConnection Creating connections that can cause the system to hold multiple instances of connections on the same device, causing a call to the closeBLEConnection When the device does not really disconnect from the connection.
- Bluetooth connection may be disconnected at any time. Monitor advised. ft.onBLEConnectionStateChange Callback event to perform on-demand reconnect when the Bluetooth device is disconnected
- To invoke an interface for a data read or write operation on an unconnected device or a disconnected device, the 10006 Error, reconnection is recommended
closeBLEConnection
Base library support from 2.11.2, iOS version 2.34.1, Android version 2.34.1, dependency extension SDK
closeBLEConnection(Object object)
Disconnect from the Bluetooth low-power device
parameter
Object object
attribute | type | Default values | Required | Introductions |
---|---|---|---|---|
deviceId | string | yes | Bluetooth Device id | |
success | function | no | Interface calls the successful callback function | |
fail | function | no | Interface calls failed callback functions | |
complete | function | no | Interface calls the end of the callback function (call success or failure will be executed) |
error
Error code | Error message | Introductions |
---|---|---|
0 | ok | normal |
-1 | already connet | Connected |
10000 | not init | Uninitialized Bluetooth adapter |
10001 | not available | The current Bluetooth adapter is not available |
10002 | no device | Specified device not found |
10003 | connection fail | Connection failure |
10004 | no service | Specified service not found |
10005 | no characteristic | Did not find the specified signature. |
10006 | no connection | Current connection disconnected |
10007 | property not support | Current feature does not support this operation |
10008 | system error | All other system reported anomalies |
10009 | system not support | Android System specific, system version below 4.3 Not supported WAS |
10012 | operate time out | Connection Timeout |
10013 | invalid_data | Connect deviceId Is empty or incorrectly formatted |
Bluetooth - low power peripheral
onBLEPeripheralConnectionStateChanged
Base library support from 2.11.2, iOS version 2.34.1, Android version 2.34.1, dependency extension SDK
onBLEPeripheralConnectionStateChanged(function callback)
Listen for the current peripheral device connection or disconnection event
parameter
Object object
Callback function for the current peripheral connected or disconnected event
parameter
Object res
attribute | type | Introductions |
---|---|---|
deviceId | String | Device with changed state of connection id |
serverId | String | server of UUID |
connected | Boolean | Connection Current Status |
offBLEPeripheralConnectionStateChanged
Base library support from 2.11.2, iOS version 2.34.1, Android version 2.34.1, dependency extension SDK
Unlistens for current peripheral connection or disconnection events
createBLEPeripheralServer
Base library support from 2.11.2, iOS version 2.34.1, Android version 2.34.1, dependency extension SDK
createBLEPeripheralServer(Object object)
Set up locally as a Bluetooth low-power peripheral server, can create multiple
parameter
Object object
attribute | type | Default values | Required | Introductions |
---|---|---|---|---|
success | function | no | Interface calls the successful callback function | |
fail | function | no | Interface calls failed callback functions | |
complete | function | no | Interface calls the end of the callback function (call success or failure will be executed) |
object.success callback
parameter
Object res
attribute | type | Introductions |
---|---|---|
server | BLEPeripheralServer | The server side of a peripheral device |
BLEPeripheralServer.addService
Base library support from 2.11.2, iOS version 2.34.1, Android version 2.34.1, dependency extension SDK
BLEPeripheralServer.addService(Object object)
Peripheral Server
parameter
Object object
attribute | type | Default values | Required | Introductions |
---|---|---|---|---|
service | Object | yes | Object describing service | |
success | function | no | Interface calls the successful callback function | |
fail | function | no | Interface calls failed callback functions | |
complete | function | no | Interface calls the end of the callback function (call success or failure will be executed) |
object.service Structure
attribute | type | Default values | Required | Introductions |
---|---|---|---|---|
uuid | String | yes | Bluetooth Service UUID | |
characteristics | Array.Object | yes | Charateristics list |
characteristics Structure
attribute | type | Default values | Required | Introductions |
---|---|---|---|---|
uuid | String | yes | characteristic of UUID | |
properties | Object | no | Feature supported operation | |
permission | Object | no | Feature permission | |
value | ArrayBuffer | no | Binary value corresponding to feature | |
descriptors | Array.Object | no | Descriptor data |
properties Structure
attribute | type | Default values | Required | Introductions |
---|---|---|---|---|
write | Boolean | false | no | write |
writeNoResponse | Boolean | false | no | No Reply Write |
read | Boolean | false | no | read |
notify | Boolean | false | no | Subscribe |
indicate | Boolean | false | no | Pack |
permission Structure
attribute | type | Default values | Required | Introductions |
---|---|---|---|---|
readable | Boolean | false | no | Readable |
writeable | Boolean | false | no | Writable |
readEncryptionRequired | Boolean | false | no | Encrypted read request |
writeEncryptionRequired | Boolean | false | no | Encrypted write request |
descriptors Structure
attribute | type | Default values | Required | Introductions |
---|---|---|---|---|
uuid | String | yes | Descriptor of UUID | |
permission | Object | no | Descriptor permissions | |
value | ArrayBuffer | no | Descriptor data |
permission Structure
attribute | type | Default values | Required | Introductions |
---|---|---|---|---|
write | Boolean | false | no | write |
read | Boolean | false | no | read |
BLEPeripheralServer.close
Base library support from 2.11.2, iOS version 2.34.1, Android version 2.34.1, dependency extension SDK
BLEPeripheralServer.close(Object object)
Close the current server
parameter
Object object
attribute | type | Default values | Required | Introductions |
---|---|---|---|---|
success | function | no | Interface calls the successful callback function | |
fail | function | no | Interface calls failed callback functions | |
complete | function | no | Interface calls the end of the callback function (call success or failure will be executed) |
BLEPeripheralServer.offCharacteristicReadRequest
BLEPeripheralServer.offCharacteristicReadRequest()
Cancels listening for connected device requests to read current peripheral device eigenvalue events
BLEPeripheralServer.offCharacteristicSubscribed
BLEPeripheralServer.offCharacteristicSubscribed()
Unsubscribe from listening feature
BLEPeripheralServer.offCharacteristicUnsubscribed
BLEPeripheralServer.offCharacteristicUnsubscribed()
Unlistening Uncharacteristic Subscription Event
BLEPeripheralServer.offCharacteristicWriteRequest
BLEPeripheralServer.offCharacteristicWriteRequest()
Unlisten for connected device requests to write current peripheral feature events
BLEPeripheralServer.onCharacteristicReadRequest
BLEPeripheralServer.onCharacteristicReadRequest(function callback)
parameter
function callback
A callback function for the current peripheral's eigenvalue event is requested by the connected device
parameter
Object res
attribute | type | Introductions |
---|---|---|
serviceId | String | Bluetooth Feature Corresponding Service UUID |
characteristicId | String | Bluetooth characteristic UUID |
callbackId | Number | Unique identifier, calling writeCharacteristicValue Use when |
Be careful Repeated calls will overwrite the original callback
BLEPeripheralServer.onCharacteristicSubscribed
Base library support from 2.11.2, iOS version 2.34.1, Android version 2.34.1, dependency extension SDK
BLEPeripheralServer.onCharacteristicSubscribed(function callback)
Listen for feature subscription events, only iOS Support
parameter
function callback
Callback function for characteristic subscription events
parameter
Object res
attribute | type | Introductions |
---|---|---|
serviceId | String | Bluetooth Feature Corresponding Service UUID |
characteristicId | String | Bluetooth characteristic UUID |
Be careful Repeated calls will overwrite the original callback
BLEPeripheralServer.onCharacteristicUnsubscribed
Base library support from 2.11.2, iOS version 2.34.1, Android version 2.34.1, dependency extension SDK
BLEPeripheralServer.onCharacteristicUnsubscribed(function callback)
Listen to uncharacteristic subscription events, only iOS Support
parameter
function callback
Callback function to unsubscribe from characteristic events
parameter
Object res
attribute | type | Introductions |
---|---|---|
serviceId | String | Bluetooth Feature Corresponding Service UUID |
characteristicId | String | Bluetooth characteristic UUID |
Be careful Repeated calls will overwrite the original callback
BLEPeripheralServer.onCharacteristicWriteRequest
Base library support from 2.11.2, iOS version 2.34.1, Android version 2.34.1, dependency extension SDK
BLEPeripheralServer.onCharacteristicWriteRequest(function callback)
Listen for connected device requests to write the current peripheral's eigenvalue event. You need to call the writeCharacteristicValue Write back the data or the host will not receive the response
parameter
function callback
A callback function for the current peripheral's eigenvalue event is requested by the connected device
parameter
Object res
attribute | type | Introductions |
---|---|---|
serviceId | String | Bluetooth Feature Corresponding Service UUID |
characteristicId | String | Bluetooth characteristic UUID |
Be careful Repeated calls will overwrite the original callback
BLEPeripheralServer.removeService
Base library support from 2.11.2, iOS version 2.34.1, Android version 2.34.1, dependency extension SDK
BLEPeripheralServer.removeService(Object object)
Remove service
parameter
Object object
attribute | type | Default values | Required | Introductions |
---|---|---|---|---|
serviceId | String | yes | service of UUID | |
success | function | no | Interface calls the successful callback function | |
fail | function | no | Interface calls failed callback functions | |
complete | function | no | Interface calls the end of the callback function (call success or failure will be executed) |
BLEPeripheralServer.startAdvertising
Base library support from 2.11.2, iOS version 2.34.1, Android version 2.34.1, dependency extension SDK
BLEPeripheralServer.startAdvertising(Object Object)
Begins broadcasting a locally created peripheral.
parameter
Object object
attribute | type | Default values | Required | Introductions |
---|---|---|---|---|
advertiseRequest | Object | yes | Broadcast custom parameters | |
powerLevel | String | medium | no | Broadcast power |
success | function | no | Interface calls the successful callback function | |
fail | function | no | Interface calls failed callback functions | |
complete | function | no | Interface calls the end of the callback function (call success or failure will be executed) |
Object.advertiseRequest Structure
attribute | type | Default values | Required | Introductions |
---|---|---|---|---|
connectable | Boolean | true | no | Whether the current device can be connected |
deviceName | String | no | On the radio. deviceName Field, default empty | |
serviceUuids | Array.String | no | Service to be broadcast UUID List. use 16/32 position UUID Please refer to the points for attention | |
manufacturerData | Array.Object | no | Manufacturer information for the broadcast. Android only support, iOS Unable to customize due to system limitations. |
manufacturerData Structure
attribute | type | Default values | Required | Introductions |
---|---|---|---|---|
manufacturerId | String | yes | Manufacturer ID, 0x Beginning hexadecimal | |
manufacturerSpecificData | ArrayBuffer | no | Manufacturer Information |
Object.powerLevel Legal value
value | Introductions | Minimum version |
---|---|---|
low | Low power | |
medium | Moderate power | |
high | High power |
Be careful
- Android 8.0.9 Start, support direct use 16/32/128 position UUID
- Android 8.0.9 The following versions only support 128 position UUID, using 16/32 Bit UUID The system will automatically identify whether it belongs to the pre-allocation interval, you can refer toBluetooth Guide
- iOS Must be used directly 16 Bit UUUID cannot be filled to 128 Bit, or the system will still group packages according to the 128 Bit transmission. iOS Temporary support 32 position UUID。
- iOS Only one broadcast can be launched at the same time. Android supports multiple broadcasts simultaneously.
BLEPeripheralServer.stopAdvertising
Base library support from 2.11.2, iOS version 2.34.1, Android version 2.34.1, dependency extension SDK
BLEPeripheralServer.stopAdvertising(Object object)
Stop broadcasting
parameter
Object object
attribute | type | Default values | Required | Introductions |
---|---|---|---|---|
success | function | no | Interface calls the successful callback function | |
fail | function | no | Interface calls failed callback functions | |
complete | function | no | Interface calls the end of the callback function (call success or failure will be executed) |
BLEPeripheralServer.writeCharacteristicValue
Base library support from 2.11.2, iOS version 2.34.1, Android version 2.34.1, dependency extension SDK
BLEPeripheralServer.writeCharacteristicValue(Object Object)
Writes a binary data value to the specified feature, notifying the connected host that the slave's characteristic value has changed, and the interface handles whether to walk back to the packet or to subscribe
parameter
Object object
attribute | type | Default values | Required | Introductions |
---|---|---|---|---|
serviceId | String | yes | Bluetooth Feature Corresponding Service UUID | |
characteristicId | String | yes | Bluetooth characteristic UUID | |
value | ArrayBuffer | yes | characteristic Corresponding binary value | |
needNotify | Boolean | yes | Do you need to notify the host value Updated | |
callbackId | Number | no | Optionally, use the | |
success | function | no | Interface calls the successful callback function | |
fail | function | no | Interface calls failed callback functions | |
complete | function | no | Interface calls the end of the callback function (call success or failure will be executed) |
Bluetooth-Beacons(Beacon)
stopBeaconDiscovery
Base Library 2.11.2 support started, iOS version 2.34.1, relies on Extensions SDK, Android version 2.35.9, relies on BluetoothSDK> Base Library 2.11.2 support started, iOS version 2.34.1, relies on Extensions SDK, Android version 2.35.9, relies on BluetoothSDK> Base Library 2.11.2
stopBeaconDiscovery(Object object)
Stop searching the area. Beacon equipment
parameter
Object object
attribute | type | Default values | Required | Introductions |
---|---|---|---|---|
success | function | no | Interface calls the successful callback function | |
fail | function | no | Interface calls failed callback functions | |
complete | function | no | Interface calls the end of the callback function (call success or failure will be executed) |
error
Error code | Error message | Introductions |
---|---|---|
0 | ok | normal |
11000 | unsupport | System or device does not support |
11001 | bluetooth service unavailable | Bluetooth service not available |
11002 | location service unavailable | Location service unavailable |
11003 | already start | The search has begun. |
11004 | not startBeaconDiscovery | Search hasn't started yet. |
11005 | system error | System error |
11006 | invalid data | Incorrect parameters |
startBeaconDiscovery
Base Library 2.11.2 support started, iOS version 2.34.1, relies on Extensions SDK, Android version 2.35.9, relies on BluetoothSDK> Base Library 2.11.2 support started, iOS version 2.34.1, relies on Extensions SDK, Android version 2.35.9, relies on BluetoothSDK> Base Library 2.11.2
startBeaconDiscovery(Object object)
Start searching nearby. Beacon equipment
parameter
Object object
attribute | type | Default values | Required | Introductions |
---|---|---|---|---|
uuids | Array.<string> | yes | Beacon Device broadcast UUID list | |
ignoreBluetoothAvailable | boolean | false | no | Verify the Bluetooth switch, only in the iOS Under effective. iOS 11 Turn off the bluetooth in the control panel, or you can still use it. Beacon Service. |
success | function | no | Interface calls the successful callback function | |
fail | function | no | Interface calls failed callback functions | |
complete | function | no | Interface calls the end of the callback function (call success or failure will be executed) |
error
Error code | Error message | Introductions |
---|---|---|
0 | ok | normal |
11000 | unsupport | System or device does not support |
11001 | bluetooth service unavailable | Bluetooth service not available |
11002 | location service unavailable | Location service unavailable |
11003 | already start | The search has begun. |
11004 | not startBeaconDiscovery | Search hasn't started yet. |
11005 | system error | System error |
11006 | invalid data | Incorrect parameters |
Note
- Interface authorization failure (iOS):
- The host app disables the mini program from actively requesting permissions and returns the Error message: unauthorized disableauthorized, the SDK is disabled from requesting Bluetooth permissions
onBeaconUpdate
Base library supported since 2.11.2, iOS version 2.34.1, relies on extension SDK, Beacon-related interfaces not supported for Android yet
onBeaconUpdate(function callback)
to monitor Beacon Device update event, only one listener can be registered
parameter
function callback
Beacon Callback function for device update event
parameter
Object res
attribute | type | Introductions |
---|---|---|
beacons | Array.BeaconInfo | All currently searched Beacon Equipment list |
onBeaconServiceChange
Base library supported since 2.11.2, iOS version 2.34.1, relies on extension SDK, Beacon-related interfaces not supported for Android yet
onBeaconServiceChange(function callback)
to monitor Beacon Service state change events, only one listener can be registered
parameter
function callback
Beacon Callback functions for service state change events
parameter
Object res
attribute | type | Introductions |
---|---|---|
available | boolean | Service is currently available |
discovering | boolean | Is the current search status |
offBeaconUpdate
Base library supported since 2.11.2, iOS version 2.34.1, relies on extension SDK, Beacon-related interfaces not supported for Android yet
Cancel the wiretap. Beacon Device Update Event
getBeacons
Base library supported since 2.11.2, iOS version 2.34.1, relies on extension SDK, Beacon-related interfaces not supported for Android yet
getBeacons(Object object)
Gets all searched Beacon equipment
parameter
Object object
Callback for Beacon service state change events
parameter
Object res
attribute | type | Default values | Required | Introductions |
---|---|---|---|---|
success | function | no | Interface calls the successful callback function | |
fail | function | no | Interface calls failed callback functions | |
complete | function | no | Interface calls the end of the callback function (call success or failure will be executed) |
object.success callback
parameter
Object res
attribute | type | Introductions |
---|---|---|
beacons | Array.BeaconInfo | Beacon list |
error
Error code | Error message | Introductions |
---|---|---|
0 | ok | normal |
11000 | unsupport | System or device does not support |
11001 | bluetooth service unavailable | Bluetooth service not available |
11002 | location service unavailable | Location service unavailable |
11003 | already start | The search has begun. |
11004 | not startBeaconDiscovery | Search hasn't started yet. |
11005 | system error | System error |
11006 | invalid data | Incorrect parameters |
BeaconInfo
Beacon equipment
attribute
string uuid
Beacon Device broadcast UUID
number major
Beacon Master of equipment ID
number minor
Beacon Device times ID
number proximity
Enumeration value representing device distance (iOS only)
proximity Legal value
value | Introductions | Minimum version |
---|---|---|
0 | Signal too weak to calculate distance, or not iOS equipment | |
1 | Very close | |
2 | Relatively recent | |
3 | far |
number accuracy
Beacon Distance of equipment, unit m。iOS On, limit for 0 When, accuracy for -1
number rssi
Signal strength of a device, unit dBm
offBeaconServiceChange
Base library supported since 2.11.2, iOS version 2.34.1, relies on extension SDK, Beacon-related interfaces not supported for Android yet
Unlisten to Beacon service status change events
Contact person
addPhoneContact
Add cell phone contacts.
parameter
Object object
attribute | type | Default values | Required | Introductions |
---|---|---|---|---|
firstName | string | yes | name | |
photoFilePath | string | no | Avatar local file path | |
nickName | string | no | nickname | |
lastName | string | no | Surname | |
middleName | string | no | middle name | |
remark | string | no | Remarks | |
mobilePhoneNumber | string | no | Phone number. | |
weChatNumber | string | no | WeChat account | |
addressCountry | string | no | Contact address country | |
addressState | string | no | Contact Address Province | |
addressCity | string | no | Contact Address City | |
addressStreet | string | no | Contact Address Street | |
addressPostalCode | string | no | Contact address postal code | |
organization | string | no | company | |
title | string | no | position | |
workFaxNumber | string | no | Work fax | |
workPhoneNumber | string | no | Work phone | |
hostNumber | string | no | Company telephone | |
string | no | |||
url | string | no | website | |
workAddressCountry | string | no | Country of work address | |
workAddressState | string | no | Work Address Province | |
workAddressCity | string | no | Work Address City | |
workAddressStreet | string | no | Work Address Street | |
workAddressPostalCode | string | no | Address of work post code | |
homeFaxNumber | string | no | Residential facsimile | |
homePhoneNumber | string | no | Residential telephone | |
homeAddressCountry | string | no | Residential address country | |
homeAddressState | string | no | Residential address provinces | |
homeAddressCity | string | no | Residential address city | |
homeAddressStreet | string | no | Residential address street | |
homeAddressPostalCode | string | no | Residential address postcode | |
success | function | no | Interface calls the successful callback function | |
fail | function | no | Interface calls failed callback functions | |
complete | function | no | Callback function at the end of an interface call (both successful and unsuccessful calls are executed) |
chooseContact
Pull up your phone contacts and select contacts
parameter
Object res
attribute | type | Default values | Required | Introductions |
---|---|---|---|---|
success | function | no | Interface calls the successful callback function | |
fail | function | no | Interface calls failed callback functions | |
complete | function | no | Interface calls the end of the callback function (call success or failure will be executed) |
object.success callback
parameter
Object res
attribute | type | Introductions |
---|---|---|
phoneNumber | string | Phone number. |
displayName | string | Contact Name |
phoneNumberList | string | All mobile phone numbers of the selected contact Android The system can only select the contact but not the specific phone number) |
Accessibility
checkIsOpenAccessibility
Foundation Library support from 2.12.1
checkIsOpenAccessibility(Object object)
Detect whether the visual accessibility function is turned on
parameter
Object object
attribute | type | Default values | Required | Introductions |
---|---|---|---|---|
success | function | no | Interface calls the successful callback function | |
fail | function | no | Interface calls failed callback functions | |
complete | function | no | Interface calls the end of the callback function (call success or failure will be executed) |
object.success callback
parameter
Object res
attribute | type | Introductions |
---|---|---|
open | Boolean | iOS Turn on the auxiliary function voice-over on Android talkback Return when true |