Last updated:
0 purchases
ailink food probe
ailink_food_probe #
##中文
AiLink probe and probe box protocol data processing Flutter library.
Necessary condition #
Acquired AILink Bluetooth communication protocol
Have smart devices that support AILink Bluetooth module
Have knowledge of Flutter development and debugging
UUID Description #
FFE1: Write A7 data
FFE2: Monitor A7 data changes
FFE3: Write A6 data and monitor A6 data changes
Android #
Add maven { url 'https://jitpack.io' } in android/build.gradle file
allprojects {
repositories {
google()
mavenCentral()
//add
maven { url 'https://jitpack.io' }
}
}
copied to clipboard
Modify minSdkVersion 21 in the android/app/build.gradle file
defaultConfig {
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
applicationId "com.elinkthings.ailink_food_probe_example"
// You can update the following values to match your application needs.
// For more information, see: https://docs.flutter.dev/deployment/android#reviewing-the-gradle-build-configuration.
minSdkVersion 21 //flutter.minSdkVersion
targetSdkVersion flutter.targetSdkVersion
versionCode flutterVersionCode.toInteger()
versionName flutterVersionName
}
copied to clipboard
To use the flutter_blue_plus library, you need to add the required permissions to android/app/src/main/AndroidManifest.xml
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
<!-- Tell Google Play Store that your app uses Bluetooth LE
Set android:required="true" if bluetooth is necessary -->
<uses-feature android:name="android.hardware.bluetooth_le" android:required="false" />
<!-- New Bluetooth permissions in Android 12
https://developer.android.com/about/versions/12/features/bluetooth-permissions -->
<uses-permission android:name="android.permission.BLUETOOTH_SCAN" android:usesPermissionFlags="neverForLocation" />
<uses-permission android:name="android.permission.BLUETOOTH_CONNECT" />
<!-- legacy for Android 11 or lower -->
<uses-permission android:name="android.permission.BLUETOOTH" android:maxSdkVersion="30" />
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN" android:maxSdkVersion="30" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" android:maxSdkVersion="30"/>
<!-- legacy for Android 9 or lower -->
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" android:maxSdkVersion="28" />
</manifest>
copied to clipboard
iOS #
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" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>NSBluetoothAlwaysUsageDescription</key>
<string>This app always needs Bluetooth to function</string>
<key>NSBluetoothPeripheralUsageDescription</key>
<string>This app needs Bluetooth Peripheral to function</string>
<key>NSLocationAlwaysAndWhenInUseUsageDescription</key>
<string>This app always needs location and when in use to function</string>
<key>NSLocationAlwaysUsageDescription</key>
<string>This app always needs location to function</string>
<key>NSLocationWhenInUseUsageDescription</key>
<string>This app needs location when in use to function</string>
</dict>
</plist>
copied to clipboard
Flutter #
Probe Command Related #
ElinkProbeCmdUtils
import 'package:ailink_food_probe/utils/elink_probe_cmd_utils.dart';
List<int> probeMac;
final elinkProbeCmdUtils = ElinkProbeCmdUtils(probeMac);
copied to clipboard
Get version information:
final cmd = elinkProbeCmdUtils.getVersion();
copied to clipboard
Get battery level:
final cmd = elinkProbeCmdUtils.getBattery();
copied to clipboard
Switch unit:
final cmd = elinkProbeCmdUtils.switchUnit(unit); //0: °C, 1: °F
copied to clipboard
Set data:
import 'package:ailink_food_probe/model/elink_probe_info.dart';
ElinkProbeInfo probeInfo;
final cmd = elinkProbeCmdUtils.setProbeInfo(probeInfo);
copied to clipboard
Get data:
final cmd = elinkProbeCmdUtils.getProbeInfo();
copied to clipboard
Clear data:
final cmd = elinkProbeCmdUtils.clearProbeInfo();
copied to clipboard
Probe Command callback #
ElinkProbeParseCallback
import 'package:ailink_food_probe/utils/elink_probe_data_parse_utils.dart';
import 'package:ailink_food_probe/utils/elink_probe_parse_callback.dart';
List<int> probeMac;
final elinkProbeDataParseUtils = ElinkProbeDataParseUtils(probeMac);
final probeCallback = ElinkProbeParseCallback(
onGetVersion: (version) {},
onGetBattery: (state, battery) {},
onSetResult: (setResult) {},
onSwitchUnit: (setResult) {},
onGetRealTimeData: (realTimeModel) {},
onGetProbeInfo: (probeInfo) {},
onGetProbeInfoFailure: (mac) {}
);
elinkProbeDataParseUtils.setProbeCallback(probeCallback);
///After discovering the service, determine the characteristic value UUID to be ElinkBleCommonUtils.elinkWriteAndNotifyUuid or ElinkBleCommonUtils.elinkNotifyUuid
characteristic.onValueReceived.listen((data) {
elinkProbeDataParseUtils.parseElinkData(data);
}
copied to clipboard
Probe Box Command Related #
ElinkProbeBoxCmdUtils
import 'package:ailink_food_probe/utils/elink_probe_box_cmd_utils.dart';
List<int> probeBoxMac;
final elinkProbeBoxCmdUtils = ElinkProbeBoxCmdUtils(probeBoxMac);
copied to clipboard
Get version information:
final cmd = elinkProbeBoxCmdUtils.getVersion();
copied to clipboard
Sync time:
final cmd = elinkProbeBoxCmdUtils.syncTime(dateTime);
copied to clipboard
Switch unit:
final cmd = elinkProbeBoxCmdUtils.switchUnit(unit); //0: °C, 1: °F
copied to clipboard
Get probe data (based on the probe's MAC address):
List<int> probeMac;
final cmd = elinkProbeBoxCmdUtils.getBoxProbeInfo(probeMac);
copied to clipboard
Set probe data (only the alarm temperature in the probe data is processed by the device, other data is not processed):
import 'package:ailink_food_probe/model/elink_probe_info.dart';
ElinkProbeInfo probeInfo;
final cmd = elinkProbeBoxCmdUtils.setBoxProbeInfo(probeInfo);
copied to clipboard
Clear probe data (based on the probe's MAC address):
List<int> probeMac;
final cmd = elinkProbeBoxCmdUtils.clearBoxProbeInfo(probeMac);
copied to clipboard
Probe box command callback #
ElinkProbeBoxParseCallback
import 'package:ailink_food_probe/utils/elink_probe_data_parse_utils.dart';
import 'package:ailink_food_probe/utils/elink_probe_box_parse_callback.dart';
List<int> probeBoxMac;
final elinkProbeDataParseUtils = ElinkProbeDataParseUtils(probeBoxMac);
final boxCallback = ElinkProbeBoxParseCallback(
onGetVersion: (version) {},
onRequestSyncTime: () {},
onSetResult: (setResult) {},
onSyncTimeResult: (syncResult) {},
onSwitchUnit: (setResult) {},
onGetProbeChargingBoxInfo: (supportNum, currentNum, boxChargingState, boxBattery, boxUnit, probeList) {},
onGetProbeInfo: (probeInfo) {}
);
elinkProbeDataParseUtils.setProbeBoxCallback(boxCallback);
///After discovering the service, determine the characteristic value UUID to be ElinkBleCommonUtils.elinkWriteAndNotifyUuid or ElinkBleCommonUtils.elinkNotifyUuid
characteristic.onValueReceived.listen((data) {
elinkProbeDataParseUtils.parseElinkData(data);
}
copied to clipboard
Probe Box With Screen Command Related #
ElinkProbeBoxWithScreenCmdUtils
import 'package:ailink_food_probe/utils/elink_probe_box_with_screen_cmd_utils.dart';
List<int> probeBoxMac;
final elinkProbeBoxWithScreenCmdUtils = ElinkProbeBoxWithScreenCmdUtils(probeBoxMac);
copied to clipboard
Get version information:
final cmd = elinkProbeBoxWithScreenCmdUtils.getVersion();
copied to clipboard
Sync time:
final cmd = elinkProbeBoxWithScreenCmdUtils.syncTime(dateTime);
copied to clipboard
Switch unit:
final cmd = elinkProbeBoxWithScreenCmdUtils.switchUnit(unit); //0: °C, 1: °F
copied to clipboard
Get probe data:
List<int> probeMac;
final cmd = elinkProbeBoxWithScreenCmdUtils.getProbeInfo();
copied to clipboard
Set probe data (only the alarm temperature in the probe data is processed by the device, other data is not processed):
import 'package:ailink_food_probe/model/elink_probe_info.dart';
ElinkProbeInfo probeInfo;
final cmd = elinkProbeBoxWithScreenCmdUtils.setBoxProbeInfo(probeInfo);
copied to clipboard
Clear probe data (based on the probe's MAC address):
List<int> probeMac;
final cmd = elinkProbeBoxWithScreenCmdUtils.clearBoxProbeInfo(probeMac);
copied to clipboard
Probe box with screen command callback #
ElinkProbeBoxWithScreenParseCallback
import 'package:ailink_food_probe/utils/elink_probe_data_parse_utils.dart';
import 'package:ailink_food_probe/utils/elink_probe_box_with_screen_parse_callback.dart';
List<int> probeBoxMac;
final elinkProbeDataParseUtils = ElinkProbeDataParseUtils(probeBoxMac);
final boxCallback = ElinkProbeBoxWithScreenParseCallback(
onGetVersion: (version) {},
onRequestSyncTime: () {},
onSetResult: (setResult) {},
onSyncTimeResult: (syncResult) {},
onSwitchUnit: (setResult) {},
onGetProbeChargingBoxInfo: (supportNum, connectNum, boxChargingState, boxBattery, boxUnit, probeList) {},
onGetProbeInfo: (probeInfo) {},
onGetProbeInfoFailure: (mac) {},
onCancelAmbientAlarm: (mac, cancel) {},
onEndWorkByBox: (mac) {},
);
elinkProbeDataParseUtils.setProbeBoxCallback(boxCallback);
///发现服务后判断特征值UUID为ElinkBleCommonUtils.elinkWriteAndNotifyUuid或ElinkBleCommonUtils.elinkNotifyUuid
characteristic.onValueReceived.listen((data) {
elinkProbeDataParseUtils.parseElinkData(data);
}
copied to clipboard
For specific usage, please see example
For personal and professional use. You cannot resell or redistribute these repositories in their original state.
There are no reviews.