Skip to content

Device

Electric quantity

getBatteryInfoSync

getBatteryInfoSync()

ft.getBatteryInfo The synchronous version of

Return value

Object res

attributetypeIntroductions
levelstringEquipment power, range 1 - 100
isChargingbooleanIs it charging?

getBatteryInfo

getBatteryInfo(Object object)

attributetypeDefault valuesRequiredIntroductions
successfunctionnoInterface calls the successful callback function
failfunctionnoInterface calls failed callback functions
completefunctionnoCallback function at the end of an interface call (both successful and unsuccessful calls are executed)

object.success callback

parameter

Object object

attributetypeIntroductions
levelstringEquipment power, range 1 - 100
isChargingbooleanIs 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 &#34Content copied &#34Continue 1.5s

parameter

Object object

attributetypeDefault valuesRequiredIntroductions
datastringyesClipboard content
successfunctionnoInterface calls the successful callback function
failfunctionnoInterface calls failed callback functions
completefunctionnoCallback 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

attributetypeDefault valuesRequiredIntroductions
successfunctionnoInterface calls the successful callback function
failfunctionnoInterface calls failed callback functions
completefunctionnoCallback function at the end of an interface call (both successful and unsuccessful calls are executed)

object.success callback

parameter

Object object

attributetypeIntroductions
datastringClipboard 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

attributetypeIntroductions
isConnectedbooleanAre you currently connected to a network?
networkTypestringNetwork type

res.networkType Legal value

valueIntroductions
wifiwifi network
2g2g network
3g3g network
4g4g network
unknownwifi 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

attributetypeDefault valuesRequiredIntroductions
successfunctionnoInterface calls the successful callback function
failfunctionnoInterface calls failed callback functions
completefunctionnoCallback function at the end of an interface call (both successful and unsuccessful calls are executed)

object.success callback

parameter

Object res

attributetypeIntroductions
networkTypestringnetwork type

res.networkType Legal value

valueIntroductions
wifiwifi network
2g2g network
3g3g network
4g4g network
unknownwifi network
noneNo network

sample code

javascript
ft.getNetworkType({
  success(res) {
    const networkType = res.networkType
  }
})

crypto

getRandomValues

Obtaining cryptographically secure random numbers

parameter

Object object

attributetypeDefault valuesRequiredIntroductions
lengthnumberyesInteger, number of bytes to generate random numbers, maximum 1048576
successfunctionnoInterface calls the successful callback function
failfunctionnoInterface calls failed callback functions
completefunctionnoCallback function at the end of an interface call (both successful and unsuccessful calls are executed)

object.success callback

parameter

Object res

attributetypeIntroductions
randomValuesArrayBufferRandom 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

attributetypeDefault valuesRequiredIntroductions
visualEffectstringnoneyesScreen capture/recording performance, only none / hidden is supported, pass hidden to hide the screen when taking screenshots/recording
successfunctionnoInterface calls the successful callback function
failfunctionnoInterface calls failed callback functions
completefunctionnoCallback 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

attributetypeDefault valuesRequiredIntroductions
valuenumberyesScreen brightness value, range 0 1。0 Darkest, 1 Brightest
successfunctionnoInterface calls the successful callback function
failfunctionnoInterface calls failed callback functions
completefunctionnoCallback 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

attributetypeDefault valuesRequiredIntroductions
keepScreenOnbooleanyesKeep the screen bright
successfunctionnoInterface calls the successful callback function
failfunctionnoInterface calls failed callback functions
completefunctionnoCallback 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

attributetypeIntroductions
statestringThe 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

attributetypeDefault valuesRequiredIntroductions
successfunctionnoInterface calls the successful callback function
failfunctionnoInterface calls failed callback functions
completefunctionnoCallback function at the end of an interface call (both successful and unsuccessful calls are executed)

object.success callback

parameter

Object res

attributetypeIntroductions
statestringScreen 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

attributetypeDefault valuesRequiredIntroductions
successfunctionnoInterface calls the successful callback function
failfunctionnoInterface calls failed callback functions
completefunctionnoCallback function at the end of an interface call (both successful and unsuccessful calls are executed)

object.success callback

parameter

Object res

attributetypeIntroductions
valuenumberScreen brightness value, range 0 ~ 1, 0 darkest, 1 brightest

keyboard

onKeyboardHeightChange

onKeyboardHeightChange(function callback)

Monitor keyboard height changes

parameter

function callback

parameter

object res

attributetypeIntroductions
heightnumberKeyboard 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

attributetypeDefault valuesRequiredIntroductions
successfunctionnoInterface calls the successful callback function
failfunctionnoInterface calls failed callback functions
completefunctionnoCallback 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

attributetypeDefault valuesRequiredIntroductions
successfunctionnoInterface calls the successful callback function
failfunctionnoInterface calls failed callback functions
completefunctionnoCallback function at the end of an interface call (both successful and unsuccessful calls are executed)

object.success callback

parameter

Object res

attributetypeIntroductions
startnumberInput box cursor start position
endnumberInput 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

attributetypeDefault valuesRequiredIntroductions
phoneNumberstringyesThe number you need to dial
successfunctionnoInterface calls the successful callback function
failfunctionnoInterface calls failed callback functions
completefunctionnoCallback 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

attributetypeDefault valuesRequiredIntroductions
successfunctionnoInterface calls the successful callback function
failfunctionnoInterface calls failed callback functions
completefunctionnoCallback 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

attributetypeDefault valuesRequiredIntroductions
intervalstringnormalnoMonitor the execution frequency of the acceleration data callback function
successfunctionnoInterface calls the successful callback function
failfunctionnoInterface calls failed callback functions
completefunctionnoCallback function at the end of an interface call (both successful and unsuccessful calls are executed)

object.interval Legal value

valueIntroductions
gameThe callback frequency for updating the game, in 20ms/second About
uiApply to update UI Callback frequency of 60ms/second About
normalNormal 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

attributetypeIntroductions
xnumberX axis
ynumberY axis
znumberZ 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

attributetypeDefault valuesRequiredIntroductions
successfunctionnoInterface calls the successful callback function
failfunctionnoInterface calls failed callback functions
completefunctionnoCallback 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

attributetypeDefault valuesRequiredIntroductions
successfunctionnoInterface calls the successful callback function
failfunctionnoInterface calls failed callback functions
completefunctionnoCallback 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

attributetypeIntroductions
directionnumberDegree of direction faced
accuracynumber/stringaccuracy

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.

valueIntroductions
highhigh precision
mediumMedium precision
lowLow precision
no-contactUntrusted. Sensor lost connection.
unreliableNot 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

attributetypeDefault valuesRequiredIntroductions
successfunctionnoInterface calls the successful callback function
failfunctionnoInterface calls failed callback functions
completefunctionnoCallback 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

attributetypeDefault valuesRequiredIntroductions
intervalstringnormalnoMonitor device direction change callback function execution frequency
successfunctionnoInterface calls the successful callback function
failfunctionnoInterface calls failed callback functions
completefunctionnoCallback function at the end of an interface call (both successful and unsuccessful calls are executed)

object.interval Legal value

valueIntroductions
gameThe callback frequency for updating the game, in 20ms/second About
uiApply to update UI Callback frequency of 60ms/second About
normalNormal 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

attributetypeIntroductions
alphanumberwhen 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.
betanumberWhen 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.
gammanumberWhen 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

attributetypeDefault valuesRequiredIntroductions
successfunctionnoInterface calls the successful callback function
failfunctionnoInterface calls failed callback functions
completefunctionnoCallback 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

attributetypeDefault valuesRequiredIntroductions
intervalstringnormalnoMonitor the execution frequency of the gyro data callback function
successfunctionnoInterface calls the successful callback function
failfunctionnoInterface calls failed callback functions
completefunctionnoCallback function at the end of an interface call (both successful and unsuccessful calls are executed)

object.interval Legal value

valueIntroductions
gameThe callback frequency for updating the game, in 20ms/second About
uiApply to update UI Callback frequency of 60ms/second About
normalNormal 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

attributetypeIntroductions
xnumberx Angular velocity of shaft
ynumbery Angular velocity of shaft
znumberz 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

attributetypeIntroductions
levelnumberMemory alarm level, only implemented on Android

res.level

valueIntroductions
5TRIM_MEMORY_RUNNING_MODERATE
10TRIM_MEMORY_RUNNING_LOW
15TRIM_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

attributetypeDefault valuesRequiredIntroductions
onlyFromCamerabooleanfalsenoWhether you can only scan the code from the camera, not allow you to select pictures from the album
successfunctionnoInterface calls the successful callback function
failfunctionnoInterface calls the successful callback function
completefunctionnoCallback 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:
  1. the user refuses to authorize, the error message: unauthorized, the user has not granted the camera permission
  2. 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).
  1. the user refuses to authorize, an error message is returned: fail unauthorized, the user has not granted camera privileges
  2. 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

attributetypeDefault valuesRequiredIntroductions
successfunctionnoInterface calls the successful callback function
failfunctionnoInterface calls failed callback functions
completefunctionnoCallback function at the end of an interface call (both successful and unsuccessful calls are executed)

Note

  • Interface authorization failure (Android): 1.
  1. the user refuses to authorise, an error message is returned: unauthorized user not granted permission to vibrate
  2. 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

attributetypeDefault valuesRequiredIntroductions
successfunctionnoInterface calls the successful callback function
failfunctionnoInterface calls failed callback functions(When authorization fails, an error message is returned: fail unauthorized user has not been granted vibrate permission)
completefunctionnoCallback function at the end of an interface call (both successful and unsuccessful calls are executed)

Note

  • Interface authorization failure (Android): 1.
  1. the user refuses to authorise, an error message is returned: unauthorized user not granted permission to vibrate
  2. 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

attributetypeDefault valuesRequiredIntroductions
successfunctionnoInterface calls the successful callback function
failfunctionnoInterface calls failed callback functions
completefunctionnoInterface calls the end of the callback function (call success or failure will be executed)

error

Error codeError messageIntroductions
0oknormal
-1already connetConnected
10000not initUninitialized Bluetooth adapter
10001not availableThe current Bluetooth adapter is not available
10002no deviceSpecified device not found
10003connection failConnection failure
10004no serviceSpecified service not found
10005no characteristicDid not find the specified signature.
10006no connectionCurrent connection disconnected
10007property not supportCurrent feature does not support this operation
10008system errorAll other system reported anomalies
10009system not supportAndroid System specific, system version below 4.3 Not supported WAS
10012operate time outConnection Timeout
10013invalid_dataConnect 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

attributetypeDefault valuesRequiredIntroductions
servicesArray.stringnoTo 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
allowDuplicatesKeybooleanfalsenoWhether 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.
intervalnumber0noReporting 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.
powerLevelstringmediumnoScan mode, the higher the scan faster, the more power consumption. Android WeChat client only 7.0.12 And above support.
successfunctionnoInterface calls the successful callback function
failfunctionnoInterface calls failed callback functions
completefunctionnoInterface calls the end of the callback function (call success or failure will be executed)

object.powerLevel Legal value

valueIntroductionsMinimum version
lowlow
mediumin
highhigh

error

Error codeError messageIntroductions
0oknormal
-1already connetConnected
10000not initUninitialized Bluetooth adapter
10001not availableThe current Bluetooth adapter is not available
10002no deviceSpecified device not found
10003connection failConnection failure
10004no serviceSpecified service not found
10005no characteristicDid not find the specified signature.
10006no connectionCurrent connection disconnected
10007property not supportCurrent feature does not support this operation
10008system errorAll other system reported anomalies
10009system not supportAndroid System specific, system version below 4.3 Not supported WAS
10012operate time outConnection Timeout
10013invalid_dataConnect 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

attributetypeDefault valuesRequiredIntroductionsMinimum version
modestringcentralnoBluetooth mode, available as master/From equipment, only iOS Need
successfunctionnoInterface calls the successful callback function
failfunctionnoInterface calls failed callback functions
completefunctionnoInterface calls the end of the callback function (call success or failure will be executed)

object.mode Legal value

valueIntroductionsMinimum version
centralHost mode
peripheralSlave (peripheral) mode

error


Error codeError messageIntroductions
0oknormal
-1already connetConnected
10000not initUninitialized Bluetooth adapter
10001not availableThe current Bluetooth adapter is not available
10002no deviceSpecified device not found
10003connection failConnection failure
10004no serviceSpecified service not found
10005no characteristicDid not find the specified signature.
10006no connectionCurrent connection disconnected
10007property not supportCurrent feature does not support this operation
10008system errorAll other system reported anomalies
10009system not supportAndroid System specific, system version below 4.3 Not supported WAS
10012operate time outConnection Timeout
10013invalid_dataConnect deviceId Is empty or incorrectly formatted

object.fail Callback function returns state Parameters only iOS)


Status codeIntroductions
0Unknown
1Reset
2Not supported
3Not authorized
4Not 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):
  1. 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

attributetypeIntroductions
devicesArray.ObjectList of newly searched devices

res.devices Structure

attributetypeIntroductions
namestringBluetooth device name, which some devices may not have
deviceIdstringBluetooth Device id
RSSInumberCurrent Bluetooth Device Signal Strength, Unit dBm
advertisDataArrayBufferIn the broadcast data segment of the current bluetooth device ManufacturerData Data segment
advertisServiceUUIDsArray.stringIn the broadcast data segment of the current bluetooth device ServiceUUIDs data segment
localNamestringIn the broadcast data segment of the current bluetooth device LocalName data segment
serviceDataObjectIn 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

attributetypeIntroductions
availablebooleanIs the Bluetooth adapter available?
discoveringbooleanIs 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

attributetypeDefault valuesRequiredIntroductions
deviceIdstringyesBluetooth Device id
pinstringyespin Yards, Base 64. Format.
timeoutnumber20000noTimeout, units ms
successfunctionnoInterface calls the successful callback function
failfunctionnoInterface calls failed callback functions
completefunctionnoInterface 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

attributetypeDefault valuesRequiredIntroductions
servicesArray.stringyesBluetooth Device Master Service UUID List support 16/32/128 position UUID)
successfunctionnoInterface calls the successful callback function
failfunctionnoInterface calls failed callback functions
completefunctionnoInterface calls the end of the callback function (call success or failure will be executed)

object.success callback

parameter

Object res

attributetypeIntroductions
devicesArray.ObjectList of devices found

res.devices Structure

attributetypeIntroductions
namestringBluetooth device name, which some devices may not have
deviceIdstringUsed to distinguish equipment id

error

Error codeError messageIntroductions
0oknormal
-1already connetConnected
10000not initUninitialized Bluetooth adapter
10001not availableThe current Bluetooth adapter is not available
10002no deviceSpecified device not found
10003connection failConnection failure
10004no serviceSpecified service not found
10005no characteristicDid not find the specified signature.
10006no connectionCurrent connection disconnected
10007property not supportCurrent feature does not support this operation
10008system errorAll other system reported anomalies
10009system not supportAndroid System specific, system version below 4.3 Not supported WAS
10012operate time outConnection Timeout
10013invalid_dataConnect 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

attributetypeDefault valuesRequiredIntroductions
successfunctionnoInterface calls the successful callback function
failfunctionnoInterface calls failed callback functions
completefunctionnoInterface calls the end of the callback function (call success or failure will be executed)

object.success callback

parameter

Object res

attributetypeIntroductions
devicesArray.ObjectUUID List of connected devices

res.devices Structure

attributetypeIntroductions
namestringBluetooth device name, which some devices may not have
deviceIdstringBluetooth Device id
RSSInumberCurrent Bluetooth Device Signal Strength, Unit dBm
advertisDataArrayBufferIn the broadcast data segment of the current bluetooth device ManufacturerData Data segment
advertisServiceUUIDsArray.stringIn the broadcast data segment of the current bluetooth device ServiceUUIDs data segment
localNamestringIn the broadcast data segment of the current bluetooth device LocalName data segment
serviceDataObjectIn the broadcast data segment of the current bluetooth device ServiceData data segment

error

Error codeError messageIntroductions
0oknormal
-1already connetConnected
10000not initUninitialized Bluetooth adapter
10001not availableThe current Bluetooth adapter is not available
10002no deviceSpecified device not found
10003connection failConnection failure
10004no serviceSpecified service not found
10005no characteristicDid not find the specified signature.
10006no connectionCurrent connection disconnected
10007property not supportCurrent feature does not support this operation
10008system errorAll other system reported anomalies
10009system not supportAndroid System specific, system version below 4.3 Not supported WAS
10012operate time outConnection Timeout
10013invalid_dataConnect 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

attributetypeDefault valuesRequiredIntroductions
successfunctionnoInterface calls the successful callback function
failfunctionnoInterface calls failed callback functions
completefunctionnoInterface calls the end of the callback function (call success or failure will be executed)

object.success callback

parameter

Object res

attributetypeIntroductions
discoveringbooleanAre you searching for devices?
availablebooleanIs the Bluetooth adapter available?

error

Error codeError messageIntroductions
0oknormal
-1already connetConnected
10000not initUninitialized Bluetooth adapter
10001not availableThe current Bluetooth adapter is not available
10002no deviceSpecified device not found
10003connection failConnection failure
10004no serviceSpecified service not found
10005no characteristicDid not find the specified signature.
10006no connectionCurrent connection disconnected
10007property not supportCurrent feature does not support this operation
10008system errorAll other system reported anomalies
10009system not supportAndroid System specific, system version below 4.3 Not supported WAS
10012operate time outConnection Timeout
10013invalid_dataConnect 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

attributetypeDefault valuesRequiredIntroductions
successfunctionnoInterface calls the successful callback function
failfunctionnoInterface calls failed callback functions
completefunctionnoInterface calls the end of the callback function (call success or failure will be executed)

error

Error codeError messageIntroductions
0oknormal
-1already connetConnected
10000not initUninitialized Bluetooth adapter
10001not availableThe current Bluetooth adapter is not available
10002no deviceSpecified device not found
10003connection failConnection failure
10004no serviceSpecified service not found
10005no characteristicDid not find the specified signature.
10006no connectionCurrent connection disconnected
10007property not supportCurrent feature does not support this operation
10008system errorAll other system reported anomalies
10009system not supportAndroid System specific, system version below 4.3 Not supported WAS
10012operate time outConnection Timeout
10013invalid_dataConnect 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

attributetypeDefault valuesRequiredIntroductions
deviceIdstringyesBluetooth Device id
serviceIdstringyesBluetooth Feature Corresponding Service UUID
characteristicIdstringyesBluetooth characteristic UUID
valueArrayBufferyesBinary Values for Bluetooth Device Features
writeTypestringyesBluetooth feature value write mode setting, there are two modes, iOS priority write, Android priority writeNoResponse
successfunctionnoInterface calls the successful callback function
failfunctionnoInterface calls failed callback functions
completefunctionnoInterface calls the end of the callback function (call success or failure will be executed)

writeType

Legal valuetype
writeForced reply writing, error reporting not supported
writeNoResponseForced no-reply writing, no error reporting support

error

Error codeError messageIntroductions
0oknormal
-1already connetConnected
10000not initUninitialized Bluetooth adapter
10001not availableThe current Bluetooth adapter is not available
10002no deviceSpecified device not found
10003connection failConnection failure
10004no serviceSpecified service not found
10005no characteristicDid not find the specified signature.
10006no connectionCurrent connection disconnected
10007property not supportCurrent feature does not support this operation
10008system errorAll other system reported anomalies
10009system not supportAndroid System specific, system version below 4.3 Not supported WAS
10012operate time outConnection Timeout
10013invalid_dataConnect 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

attributetypeDefault valuesRequiredIntroductions
deviceIdstringyesBluetooth Device id
mtunumberyesMaximum transmission unit. Set the scope to (22,512) Interval, unit bytes
successfunctionnoInterface calls the successful callback function
failfunctionnoInterface calls failed callback functions
completefunctionnoInterface calls the end of the callback function (call success or failure will be executed)

object.success callback

parameter

Object res

attributetypeIntroductions
mtunumberFinal negotiated MAN Value, consistent with the passed parameter. Android Client 8.0.9 Start supporting

object.fail callback

parameter

Object res

attributetypeIntroductions
mtunumberFinal 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

attributetypeDefault valuesRequiredIntroductions
deviceIdstringyesBluetooth Device id
serviceIdstringyesBluetooth Feature Corresponding Service UUID
characteristicIdstringyesBluetooth characteristic UUID
successfunctionnoInterface calls the successful callback function
failfunctionnoInterface calls failed callback functions
completefunctionnoInterface calls the end of the callback function (call success or failure will be executed)

error

Error codeError messageIntroductions
0oknormal
-1already connetConnected
10000not initUninitialized Bluetooth adapter
10001not availableThe current Bluetooth adapter is not available
10002no deviceSpecified device not found
10003connection failConnection failure
10004no serviceSpecified service not found
10005no characteristicDid not find the specified signature.
10006no connectionCurrent connection disconnected
10007property not supportCurrent feature does not support this operation
10008system errorAll other system reported anomalies
10009system not supportAndroid System specific, system version below 4.3 Not supported WAS
10012operate time outConnection Timeout
10013invalid_dataConnect 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

attributetypeIntroductions
deviceIdstringBluetooth Device id
connectedbooleanAre 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

attributetypeIntroductions
deviceIdstringBluetooth Device id
serviceIdstringBluetooth Feature Corresponding Service UUID
characteristicIdstringBluetooth characteristic UUID
valueArrayBufferCharacteristic 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

attributetypeDefault valuesRequiredIntroductions
deviceIdstringyesBluetooth Device id
serviceIdstringyesBluetooth Feature Corresponding Service UUID
characteristicIdstringyesBluetooth characteristic UUID
statebooleanyesEnable notify
typestringindicationnoSets the characteristic subscription type with a valid value of notification and indication
successfunctionnoInterface calls the successful callback function
failfunctionnoInterface calls failed callback functions
completefunctionnoInterface calls the end of the callback function (call success or failure will be executed)

error

Error codeError messageIntroductions
0oknormal
-1already connetConnected
10000not initUninitialized Bluetooth adapter
10001not availableThe current Bluetooth adapter is not available
10002no deviceSpecified device not found
10003connection failConnection failure
10004no serviceSpecified service not found
10005no characteristicDid not find the specified signature.
10006no connectionCurrent connection disconnected
10007property not supportCurrent feature does not support this operation
10008system errorAll other system reported anomalies
10009system not supportAndroid System specific, system version below 4.3 Not supported WAS
10012operate time outConnection Timeout
10013invalid_dataConnect 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

attributetypeDefault valuesRequiredIntroductions
deviceIdstringyesBluetooth Device id。 Need has passed ft.createBLEConnection Establish a connection
successfunctionnoInterface calls the successful callback function
failfunctionnoInterface calls failed callback functions
completefunctionnoInterface calls the end of the callback function (call success or failure will be executed)

object.success callback

parameter

Object res

attributetypeIntroductions
servicesArray.ObjectDevice Service List
结构attributetypeIntroductions
uuidstringBluetooth Device Service UUID
isPrimarybooleanWhether this service is a master service

error

Error codeError messageIntroductions
0oknormal
-1already connetConnected
10000not initUninitialized Bluetooth adapter
10001not availableThe current Bluetooth adapter is not available
10002no deviceSpecified device not found
10003connection failConnection failure
10004no serviceSpecified service not found
10005no characteristicDid not find the specified signature.
10006no connectionCurrent connection disconnected
10007property not supportCurrent feature does not support this operation
10008system errorAll other system reported anomalies
10009system not supportAndroid System specific, system version below 4.3 Not supported WAS
10012operate time outConnection Timeout
10013invalid_dataConnect 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

attributetypeDefault valuesRequiredIntroductions
deviceIdstringyesBluetooth Device id
successfunctionnoInterface calls the successful callback function
failfunctionnoInterface calls failed callback functions
completefunctionnoInterface calls the end of the callback function (call success or failure will be executed)

object.success callback

parameter

Object res

attributetypeIntroductions
RSSINumberSignal 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

attributetypeDefault valuesRequiredIntroductions
deviceIdstringyesBluetooth Device id。 Need has passed ft.createBLEConnection Establish a connection
serviceIdstringyesBluetooth Service UUID。 Need to call first ft.getBLEDeviceServices Obtain
successfunctionnoInterface calls the successful callback function
failfunctionnoInterface calls failed callback functions
completefunctionnoInterface calls the end of the callback function (call success or failure will be executed)

object.success callback

parameter

Object res

attributetypeIntroductions
characteristicsArray.ObjectEquipment Feature List

characteristics

Structure attributetypeIntroductions
uuidstringBluetooth device feature UUID
propertiesObjectType of operation supported by this feature

properties

Structure attributetypeIntroductions
readbooleanDoes this feature support read operation
writebooleanDoes this feature support write operation
notifybooleanDoes this feature support notify operation
indicatebooleanDoes this feature support indicate operation
writeNoResponsebooleanDoes the feature support no-reply write operations
writeDefaultbooleanDoes the feature support no-reply write operations

error

Error codeError messageIntroductions
0oknormal
-1already connetConnected
10000not initUninitialized Bluetooth adapter
10001not availableThe current Bluetooth adapter is not available
10002no deviceSpecified device not found
10003connection failConnection failure
10004no serviceSpecified service not found
10005no characteristicDid not find the specified signature.
10006no connectionCurrent connection disconnected
10007property not supportCurrent feature does not support this operation
10008system errorAll other system reported anomalies
10009system not supportAndroid System specific, system version below 4.3 Not supported WAS
10012operate time outConnection Timeout
10013invalid_dataConnect 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

attributetypeDefault valuesRequiredIntroductions
deviceIdstringyesBluetooth Device id
timeoutnumbernoTimeout, units Ms, no fill means no timeout
successfunctionnoInterface calls the successful callback function
failfunctionnoInterface calls failed callback functions
completefunctionnoInterface calls the end of the callback function (call success or failure will be executed)

error

Error codeError messageIntroductions
0oknormal
-1already connetConnected
10000not initUninitialized Bluetooth adapter
10001not availableThe current Bluetooth adapter is not available
10002no deviceSpecified device not found
10003connection failConnection failure
10004no serviceSpecified service not found
10005no characteristicDid not find the specified signature.
10006no connectionCurrent connection disconnected
10007property not supportCurrent feature does not support this operation
10008system errorAll other system reported anomalies
10009system not supportAndroid System specific, system version below 4.3 Not supported WAS
10012operate time outConnection Timeout
10013invalid_dataConnect 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

attributetypeDefault valuesRequiredIntroductions
deviceIdstringyesBluetooth Device id
successfunctionnoInterface calls the successful callback function
failfunctionnoInterface calls failed callback functions
completefunctionnoInterface calls the end of the callback function (call success or failure will be executed)

error

Error codeError messageIntroductions
0oknormal
-1already connetConnected
10000not initUninitialized Bluetooth adapter
10001not availableThe current Bluetooth adapter is not available
10002no deviceSpecified device not found
10003connection failConnection failure
10004no serviceSpecified service not found
10005no characteristicDid not find the specified signature.
10006no connectionCurrent connection disconnected
10007property not supportCurrent feature does not support this operation
10008system errorAll other system reported anomalies
10009system not supportAndroid System specific, system version below 4.3 Not supported WAS
10012operate time outConnection Timeout
10013invalid_dataConnect 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

attributetypeIntroductions
deviceIdStringDevice with changed state of connection id
serverIdStringserver of UUID
connectedBooleanConnection 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

attributetypeDefault valuesRequiredIntroductions
successfunctionnoInterface calls the successful callback function
failfunctionnoInterface calls failed callback functions
completefunctionnoInterface calls the end of the callback function (call success or failure will be executed)

object.success callback

parameter

Object res

attributetypeIntroductions
serverBLEPeripheralServerThe 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

attributetypeDefault valuesRequiredIntroductions
serviceObjectyesObject describing service
successfunctionnoInterface calls the successful callback function
failfunctionnoInterface calls failed callback functions
completefunctionnoInterface calls the end of the callback function (call success or failure will be executed)

object.service Structure

attributetypeDefault valuesRequiredIntroductions
uuidStringyesBluetooth Service UUID
characteristicsArray.ObjectyesCharateristics list

characteristics Structure

attributetypeDefault valuesRequiredIntroductions
uuidStringyescharacteristic of UUID
propertiesObjectnoFeature supported operation
permissionObjectnoFeature permission
valueArrayBuffernoBinary value corresponding to feature
descriptorsArray.ObjectnoDescriptor data

properties Structure

attributetypeDefault valuesRequiredIntroductions
writeBooleanfalsenowrite
writeNoResponseBooleanfalsenoNo Reply Write
readBooleanfalsenoread
notifyBooleanfalsenoSubscribe
indicateBooleanfalsenoPack

permission Structure

attributetypeDefault valuesRequiredIntroductions
readableBooleanfalsenoReadable
writeableBooleanfalsenoWritable
readEncryptionRequiredBooleanfalsenoEncrypted read request
writeEncryptionRequiredBooleanfalsenoEncrypted write request

descriptors Structure

attributetypeDefault valuesRequiredIntroductions
uuidStringyesDescriptor of UUID
permissionObjectnoDescriptor permissions
valueArrayBuffernoDescriptor data

permission Structure

attributetypeDefault valuesRequiredIntroductions
writeBooleanfalsenowrite
readBooleanfalsenoread

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

attributetypeDefault valuesRequiredIntroductions
successfunctionnoInterface calls the successful callback function
failfunctionnoInterface calls failed callback functions
completefunctionnoInterface 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

attributetypeIntroductions
serviceIdStringBluetooth Feature Corresponding Service UUID
characteristicIdStringBluetooth characteristic UUID
callbackIdNumberUnique 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

attributetypeIntroductions
serviceIdStringBluetooth Feature Corresponding Service UUID
characteristicIdStringBluetooth 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

attributetypeIntroductions
serviceIdStringBluetooth Feature Corresponding Service UUID
characteristicIdStringBluetooth 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

attributetypeIntroductions
serviceIdStringBluetooth Feature Corresponding Service UUID
characteristicIdStringBluetooth 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

attributetypeDefault valuesRequiredIntroductions
serviceIdStringyesservice of UUID
successfunctionnoInterface calls the successful callback function
failfunctionnoInterface calls failed callback functions
completefunctionnoInterface 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

attributetypeDefault valuesRequiredIntroductions
advertiseRequestObjectyesBroadcast custom parameters
powerLevelStringmediumnoBroadcast power
successfunctionnoInterface calls the successful callback function
failfunctionnoInterface calls failed callback functions
completefunctionnoInterface calls the end of the callback function (call success or failure will be executed)

Object.advertiseRequest Structure

attributetypeDefault valuesRequiredIntroductions
connectableBooleantruenoWhether the current device can be connected
deviceNameStringnoOn the radio. deviceName Field, default empty
serviceUuidsArray.StringnoService to be broadcast UUID List. use 16/32 position UUID Please refer to the points for attention
manufacturerDataArray.ObjectnoManufacturer information for the broadcast. Android only support, iOS Unable to customize due to system limitations.

manufacturerData Structure

attributetypeDefault valuesRequiredIntroductions
manufacturerIdStringyesManufacturer ID, 0x Beginning hexadecimal
manufacturerSpecificDataArrayBuffernoManufacturer Information

Object.powerLevel Legal value

valueIntroductionsMinimum version
lowLow power
mediumModerate power
highHigh 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

attributetypeDefault valuesRequiredIntroductions
successfunctionnoInterface calls the successful callback function
failfunctionnoInterface calls failed callback functions
completefunctionnoInterface 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

attributetypeDefault valuesRequiredIntroductions
serviceIdStringyesBluetooth Feature Corresponding Service UUID
characteristicIdStringyesBluetooth characteristic UUID
valueArrayBufferyescharacteristic Corresponding binary value
needNotifyBooleanyesDo you need to notify the host value Updated
callbackIdNumbernoOptionally, use the
successfunctionnoInterface calls the successful callback function
failfunctionnoInterface calls failed callback functions
completefunctionnoInterface 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

attributetypeDefault valuesRequiredIntroductions
successfunctionnoInterface calls the successful callback function
failfunctionnoInterface calls failed callback functions
completefunctionnoInterface calls the end of the callback function (call success or failure will be executed)

error

Error codeError messageIntroductions
0oknormal
11000unsupportSystem or device does not support
11001bluetooth service unavailableBluetooth service not available
11002location service unavailableLocation service unavailable
11003already startThe search has begun.
11004not startBeaconDiscoverySearch hasn't started yet.
11005system errorSystem error
11006invalid dataIncorrect 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

attributetypeDefault valuesRequiredIntroductions
uuidsArray.<string>yesBeacon Device broadcast UUID list
ignoreBluetoothAvailablebooleanfalsenoVerify 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.
successfunctionnoInterface calls the successful callback function
failfunctionnoInterface calls failed callback functions
completefunctionnoInterface calls the end of the callback function (call success or failure will be executed)

error

Error codeError messageIntroductions
0oknormal
11000unsupportSystem or device does not support
11001bluetooth service unavailableBluetooth service not available
11002location service unavailableLocation service unavailable
11003already startThe search has begun.
11004not startBeaconDiscoverySearch hasn't started yet.
11005system errorSystem error
11006invalid dataIncorrect parameters

Note

  • Interface authorization failure (iOS):
  1. 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

attributetypeIntroductions
beaconsArray.BeaconInfoAll 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

attributetypeIntroductions
availablebooleanService is currently available
discoveringbooleanIs 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

attributetypeDefault valuesRequiredIntroductions
successfunctionnoInterface calls the successful callback function
failfunctionnoInterface calls failed callback functions
completefunctionnoInterface calls the end of the callback function (call success or failure will be executed)

object.success callback

parameter

Object res

attributetypeIntroductions
beaconsArray.BeaconInfoBeacon list

error

Error codeError messageIntroductions
0oknormal
11000unsupportSystem or device does not support
11001bluetooth service unavailableBluetooth service not available
11002location service unavailableLocation service unavailable
11003already startThe search has begun.
11004not startBeaconDiscoverySearch hasn't started yet.
11005system errorSystem error
11006invalid dataIncorrect 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

valueIntroductionsMinimum version
0Signal too weak to calculate distance, or not iOS equipment
1Very close
2Relatively recent
3far

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

attributetypeDefault valuesRequiredIntroductions
firstNamestringyesname
photoFilePathstringnoAvatar local file path
nickNamestringnonickname
lastNamestringnoSurname
middleNamestringnomiddle name
remarkstringnoRemarks
mobilePhoneNumberstringnoPhone number.
weChatNumberstringnoWeChat account
addressCountrystringnoContact address country
addressStatestringnoContact Address Province
addressCitystringnoContact Address City
addressStreetstringnoContact Address Street
addressPostalCodestringnoContact address postal code
organizationstringnocompany
titlestringnoposition
workFaxNumberstringnoWork fax
workPhoneNumberstringnoWork phone
hostNumberstringnoCompany telephone
emailstringnoemail
urlstringnowebsite
workAddressCountrystringnoCountry of work address
workAddressStatestringnoWork Address Province
workAddressCitystringnoWork Address City
workAddressStreetstringnoWork Address Street
workAddressPostalCodestringnoAddress of work post code
homeFaxNumberstringnoResidential facsimile
homePhoneNumberstringnoResidential telephone
homeAddressCountrystringnoResidential address country
homeAddressStatestringnoResidential address provinces
homeAddressCitystringnoResidential address city
homeAddressStreetstringnoResidential address street
homeAddressPostalCodestringnoResidential address postcode
successfunctionnoInterface calls the successful callback function
failfunctionnoInterface calls failed callback functions
completefunctionnoCallback 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

attributetypeDefault valuesRequiredIntroductions
successfunctionnoInterface calls the successful callback function
failfunctionnoInterface calls failed callback functions
completefunctionnoInterface calls the end of the callback function (call success or failure will be executed)

object.success callback

parameter

Object res

attributetypeIntroductions
phoneNumberstringPhone number.
displayNamestringContact Name
phoneNumberListstringAll 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

attributetypeDefault valuesRequiredIntroductions
successfunctionnoInterface calls the successful callback function
failfunctionnoInterface calls failed callback functions
completefunctionnoInterface calls the end of the callback function (call success or failure will be executed)

object.success callback

parameter

Object res

attributetypeIntroductions
openBooleaniOS Turn on the auxiliary function voice-over on Android talkback Return when true