AiLink broadcast scale data decryption and body fat algorithm Flutter library.

Necessary condition

  1. Acquired AILink Bluetooth communication protocol
  2. Have smart devices that support AILink Bluetooth module
  3. Have knowledge of Flutter development and debugging


  1. Add maven { url '' } in android/build.gradle file
    allprojects {
        repositories {
            maven { url '' }
  1. Modify minSdkVersion 21 in the android/app/build.gradle file
    defaultConfig {
        // TODO: Specify your own unique Application ID (
        applicationId "com.example.ailink_example"
        // You can update the following values to match your application needs.
        // For more information, see:
        minSdkVersion 21 //flutter.minSdkVersion
        targetSdkVersion flutter.targetSdkVersion
        versionCode flutterVersionCode.toInteger()
        versionName flutterVersionName
  1. To use the flutter_blue_plus library, you need to add the required permissions to android/app/src/main/AndroidManifest.xml
    <manifest xmlns:android="">
        <uses-permission android:name="android.permission.BLUETOOTH" />
        <uses-permission android:name="android.permission.BLUETOOTH_ADMIN" />
        <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
    <manifest xmlns:android="">


  1. When using the flutter_blue_plus library, you need to add the required permissions to ios/Runner/Info.plist
    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "">
    <plist version="1.0">
            <string>Need BLE permission</string>
            <string>Need BLE permission</string>
            <string>Need Location permission</string>
            <string>Need Location permission</string>
            <string>Need Location permission</string>


graph TD
  A[Scan] -->|Filter by Guid F0A0 and FFE0| B(Scan results)
  B --> C{Process scan results}
  C -->|Broadcast Device| D[Parse broadcast data]
  C -->|Connect Device| E[Start connecting]
  E --> |Connection successful|F[Discover BluetoothService]
  E --> |Connection failed|G[Reconnect] --> E
  F --> H[Get BluetoothCharacteristic]
  H --> I[Set notify]
  I --> J[Write instructions via Guid FFE3 and start handshake processing at the same time]
  J --> K[Process the received instructions and perform two-way handshake processing at the same time]
  1. import AiLink plugin
    import 'package:ailink/ailink.dart';
  1. Plug-in initialization
    final _ailinkPlugin = Ailink();

Broadcast Data Encryption and Decryption, and Retrieval of Body Fat Data

  1. Decrypt data
  1. Get body fat data

Bluetooth Handshake Command Encryption and Decryption

After connecting to the device, two handshakes are required First call final firstHandShakeData = _ailinkPlugin.initHandShake() to obtain handshake instructions And call characteristic.write(firstHandShakeData.toList(), withoutResponse: true) to send to the device

After writing, the set handshake instruction setHandShakeData returned by the device is received. The second call final secondHandShakeData = _ailinkPlugin.getHandShakeEncryptData(Uint8List.fromList(setHandShakeData)) And call characteristic.write(secondHandShakeData.toList(), withoutResponse: true) to send to the device That completes the handshake

  1. The app sends this A6 data to actively start handshake with ble, and the return byte[] needs to be sent to ble actively
  1. This method encrypts the A6 data of the ble test app and sends the app to the device, otherwise the device will disconnect the app and return byte[] and need to actively send it to ble

For specific usage, please see example