QNBleApi

Entrance class

Method

initSdk

Initialize the SDK according to appid and verify the appid and configuration file. This method will also load the relevant configuration in the configuration file.

This method only needs to be called once, not multiple times. It is recommended that Android be called in Application.onCreate, and iOS should be called under AppDelegate didFinishLaunchingWithOptions. This method only performs lightweight operations, and the time-consuming operations are all performed asynchronously, and will not affect the startup speed of the APP.

Normally, this method sends a request to our server to update the configuration in the configuration file, such as updating the algorithm, updating the index, and adding new models. This can achieve the effect of online upgrade configuration. If you clearly do not want to have this feature, you can close this function with our business communication (that is, change the SDK to offline mode). In addition, if there is no network, after the request fails, there will be no impact, the SDK will continue to use the last configuration.

Note: The 123456789 appid in the demo is the test id, which has instability and random variability. After reaching an agreement with Yolanda, the access provider can obtain an independent and stable appid. Remember to test Id can not be used in the online application market

Parameters

name Types of Explanation
appId String The app_id provided by the company to the customer is verified by the local initialization data packet, and Android iOS shares the same appid
firstDataFile String The file path of the configuration file can be transmitted in the form of uri or the full path of the file. The file contains
callback QNResultCallback Android is the interface, IOS uses the block or closure) callback method, and returns the initialization result. Refer to the attached table for error codes.

getCurSystemBleState

Get the current system Bluetooth status

return value

Type: int

Current System Bluetooth Status

setSysBleStateListener

Set system Bluetooth status callback

Parameters

name Types of Explanation
listener QNBleStateListener The listener contains a method to monitor the Bluetooth status of the system.

setBleDeviceDiscoveryListener

Set the scan callback object. When there is a scan result, it will be returned in the set monitoring method. The SDK only supports one callback object. Repeated settings will overwrite the previous results. When it is not needed, it needs to be reset to null, otherwise a memory leak may occur.

Parameters

name Types of Explanation
listener QNBleDeviceDiscoveryListener The listener contains a method that will callback in this object when the device is scanned.

setDataListener

Set up data transmission listener

Parameters

name Types of Explanation
listener QNScaleDataListener or QNUserScaleDataListener Measurement data monitoring interface, all data will be called back in it

setBleKitchenListener

Set up a Bluetooth kitchen scale listener

Parameters

name Types of Explanation
listener QNBleKitchenListener Bluetooth kitchen scale listener

setLogListener

Set the monitoring of log information

Parameters

name Types of Explanation
listener QNLogListener Log information monitoring

startBleDeviceDiscovery

Start scanning for Bluetooth devices and only return to Yolanda's device. It automatically stops when it encounters an error or Bluetooth is turned off.

The scan result is called back in QNBleDeviceDiscoveryListener

For some configuration behavior of scanning, please refer to getConfig-and-qnconfig

Parameters

name Types of Explanation
callback QNResultCallback Callback object, returns whether the call to start scanning is successful

stopBleDeviceDiscovery

To stop scanning Bluetooth devices, this method calls the system's stop scanning method. If scanning is not started, you also need to call stop scanning to ensure that there will be no more callbacks for scanning objects after calling this method.

Parameters

name Types of Explanation
callback QNResultCallback Callback object, return whether the call to stop scanning is successful

connectDevice

Connect the Yolanda Bluetooth device. The connection process will be called back in QNBleConnectionChangeListener, and the measurement data will be called back in QNScaleDataListener

Parameters

name Types of Explanation
device QNBleDevice Bluetooth device to be connected.
user QNUser When connecting the device, the user model used includes userId and user information. Created by buildUser
callback QNResultCallback Returns whether the connection operation is successfully called (not the connection is successful)

connectUserScaleDevice

Connect the Yolanda User Scale device. The connection process will be called back in QNBleConnectionChangeListener, and the measurement data will be called back in QNScaleDataListener

Parameters

name Types of Explanation
device QNBleDevice Bluetooth device to be connected.
config QNUserScaleConfig Configuration items when connecting to the user scale device
callback QNResultCallback Returns whether the connection operation is successfully called (not the connection is successful)

connectBleKitchenDevice

To link the Bluetooth kitchen scale, the device object must be the Bluetooth kitchen scale device object returned by the search, the link method is only valid for the Bluetooth kitchen scale

Parameters

name Types of Explanation
device QNBleKitchenDevice Bluetooth kitchen scale equipment
callback QNResultCallback Returns whether the link operation was successful

setBleKitchenDeviceConfig

To set the information of the Bluetooth kitchen scale, the setting is valid when the SDK and the Bluetooth kitchen scale remain linked.

Parameters

name Types of Explanation
config QNBleKitchenConfig Bluetooth kitchen scale setting information

disconnectDevice

Disconnect the connected Yolanda Bluetooth device. The process of disconnecting will be called back in QNBleConnectionChangeListener

Parameters

name Types of Explanation
device/mac QNBleDevice/String Need to disconnect the Bluetooth device or mac address, these two parameters only need to wear one
callback QNResultCallback Returns whether the connection operation is successfully called (not the connection is successful)

getConfig

Get the current settings of SDK

return value

Types of: QNConfig

SDK setting object, the setting method is also done through QNConfig

convertWeightWithTargetUnit

Convert the weight into the specified unit according to the weight provided in kg

St is not supported, if st is passed, the value of lb will be returned directly, that is, if lb or st is returned, the APP needs to directly convert the unit of British stone, 1st = 14lb, for example, 145.2lb will be displayed as 10 st 5.2 lb.

Parameters

name Types of Explanation
kgWeight double Weight in kilograms
unit int 0 is kg, the default value
1 is lb, pound, all scales can support this unit
2 is kg. If the scale does not support it, kg will be displayed

return value

Type: String

Returns the value in the specified unit

buildDevice

Factory method for creating SDK Bluetooth objects to help support customers

Parameters

android

name Types of Explanation
device BluetoothDevice Call the system scan and return the Bluetooth object
rssi int Call the system scan and return the signal strength
scanRecord byte[] Call the system scan and return the Bluetooth broadcast data
callback QNResultCallback Returns whether the operation of creating a device object is successful, and if it is not successful, an error code and an error reason are returned.

ios

name Types of Explanation
peripheral CBPeripheral Peripheral objects
advertisementData [String: Any] Bluetooth broadcast data
callback QNResultCallback Returns whether the operation of creating a device object is successful, and if it is not successful, an error code and an error reason are returned.

return value

Type QNBleDevice

Directly return the Yolanda device object created according to the parameters, or NULL if the creation is not successful

buildProtocolHandler

Create a Bluetooth protocol processor to help customers manage their Bluetooth connections

To manage the Bluetooth connection yourself, you need to have a certain understanding of the Bluetooth connection related APIs, and use it with caution

Parameters

name Types of Explanation
device QNBleDevice The scale device to be connected can be created with buildDevice
user QNUser The user model used can be created with buildUser
delegate QNBleProtocolDelegate Auxiliary class of protocol processing class to assist in the operation of Bluetooth
callback QNResultCallback Returns whether the operation was successful

return value

Type QNBleProtocolHandler

If the creation fails, null/nil will be returned. And return an error code in callback.

generateScaleData

Generate measurement data, if the parameter is abnormal, the method will return NUL

This method only supports wsp devices

Parameters

name Types of Explanation
user QNUser The user to which the data belongs
modeId String Model identification
weight Double Weight in kg
resistance int 50 impedance value
secResistance int 500 impedance value
heartRate int Heart rate value, or 0 if none
measureTime Date measure time
hmac String Related data signature

return value

Type: QNScaleData

On error, return NULL

physiqueCalculation

Calculate the user's physical fitness data. If the Physical fitness calculation function option is not enabled in the SDK configuration information, the method will return NUL

Parameters

name Types of Explanation
user QNUser The user to which the data belongs
weight Double Weight in kg
area Int User's region 0: Other ; 1: Asia
measureTime Date measure time

return value

Type: QNScaleData

On error, return NULL

switchUserScaleUser

After the user scale device is successfully connected, the linked user information will be updated, which will be called back in QNUserScaleDataListener, and the measurement data will be called back in QNScaleDataListener

Parameters

name Types of Explanation
user QNUser User Info
callback QNResultCallback Returns whether the call to update the user information of the scale is successful (not that the user information of the scale has been updated)

updateUserScaleIdentifyWeight

Used to update the user scale to identify the user's weight

Parameters

name Types of Explanation
weight double weight
callback QNResultCallback Returns whether the update user scale operation is called successfully

deleteScaleUsers

Used to delete the user information of the user scale

Parameters

name Types of Explanation
indexList [int] user index array
callback QNResultCallback Returns whether the call to delete the user information on the scale is successful or not

Bluetooth ruler api

setBleRulerListener

Set up a bluetooth ruler listener

Parameters

name Types of Explanation
listener QNBleRulerListener Bluetooth ruler listener

connectRulerDevice

connect bluetooth ruler

Parameters

name Types of Explanation
device QNBleRulerDevice Bluetooth ruler
callback QNResultCallback Returns whether the call to the connect method was successful

readAuthDeviceInfoList

Read the list of authorized device information

return value

Device info set

calculateScaleDataByHmac

Recalculate measurement data. If the parameters are abnormal, this method will return NULL.

Parameters

Name Type Description
qnUser QNUser The target user for recalculating the data
hmac String The HMAC of the data
lastEightHmac String The HMAC of the last measurement data, specifically for eight-electrode data. When recalculating using four-electrode data HMAC, this should be passed as null.
  • If the HMAC is for four-electrode data, then lastEightHmac must be passed as null.
  • If the HMAC is for eight-electrode data, lastEightHmac must not pass the four-electrode data HMAC, and can be passed as null.
  • lastEightHmac must come from QNScaleData, and cannot use the hmac from QNScaleStoreData

Return Value

Type: QNScaleData

Returns NULL in case of an error.

results matching ""

    No results matching ""