Bluetooth Provisioning & Data Acquisition
Bluetooth network configuration and data acquisition integrated solution for terminal developers. The SDK covers native Android, native iOS, Flutter, and UniApp platforms, providing 0x18/0x19 instruction-based secure BLE communication and standard register mechanism for device parameter management.
- Overview
- Core Features
- Integration Guide
- Provisioning Flow
- Protocol Data Definition
- Status Codes
- Best Practices
- FAQ
- Technical Support
- ✓ AECC Smart Data Loggers (industrial / commercial data acquisition & remote monitoring)
- ✓ All Energy Control Cloud products using AECC Bluetooth modules (CT meters, infrared meter readers, P1 meters, smart plugs, Linky meter readers, etc.)
1.1 Background & Goals
AECC Smart Data Logger is a hardware device used for data acquisition and remote monitoring in industrial/commercial scenarios. To help end users quickly integrate the data logger into their own App, we provide SDK solutions covering native Android, native iOS, Flutter, and UniApp platforms.
- Establish secure BLE communication with AECC data loggers
- Complete WiFi provisioning (connect router + connect cloud Server)
- Remotely set and read data logger register parameters
- Monitor real-time communication status between data loggers, routers, and Server
1.2 Solution Architecture
This solution adopts a layered architecture with the following data flow:
- Bluetooth Module: receives App commands, returns execution results
- WiFi Module: connects to LAN routers
- Data Acquisition Module: reads sensor or device data
- Cloud Communication Module: uploads data via WiFi/4G
- Device discovery & pairing
- Command delivery and data reception
- Provisioning parameter transmission
- Protocol packaging & parsing (0x18/0x19 commands)
- Data encryption & decryption
- Bluetooth communication management
- Native Android: integrate via AAR/JAR package
- Native iOS: integrate via Setnet_SDK.framework
- Flutter: bridge via native plugin (Platform Channel)
- UniApp: integrated via native plugin (configure manifest.json)
2.1 Bluetooth Communication
Complete BLE capabilities including auto device discovery, encrypted transmission, and 0x18/0x19 protocol packaging/parsing.
2.2 WiFi Provisioning
Configure data loggers' WiFi via Bluetooth: scan nearby routers, pass SSID and password, get real-time provisioning progress.
2.3 Parameter Set & Read
Standardized register mechanism for remote parameter configuration: 0x18 command to write registers, 0x19 command to read registers.
2.4 Status Monitoring
Two key status registers for monitoring network connection: Register 55 (Router status), Register 60 (Server status).
3.1 Prerequisites
- Get SDK package & authorization: contact NKY for the latest SDK package, keys, and authorization code
- Get example projects: contact NKY for the corresponding platform's Demo example project
- Development environment: ensure your dev environment meets the platform version requirements
3.2 Native Android Integration
Step 1: Import SDK
Step 2: Packaging — Send 0x18 Set Command
// 调用 ProtocolTool 类的 setDatalogerByP0x18() 方法
JSONObject params = new JSONObject();
// 构造参数(具体格式参见数据定义章节)
params.put("commandId", "18");
// ... 构造 param18Obj 数组
byte[] result = ProtocolTool.setDatalogerByP0x18(params, new byte[]{});
// 将 result 强转为 Object 后通过蓝牙发送{"code": 0, "data": "XXXXX"}Step 3: Unpacking — Parse 0x18 Response
// 调用 ProtocolTool 类的 parserPro0x18() 方法
boolean success = ProtocolTool.parserPro0x18(bluetoothData, new boolean());
// 返回 true 表示设置成功Step 4: Packaging — Send 0x19 Read Command
// 调用 ProtocolTool 类的 getDatalogerByP0x19() 方法
byte[] result = ProtocolTool.getDatalogerByP0x19(params, new Object());
// 通过蓝牙发送读取请求Step 5: Unpacking — Parse 0x19 Response
// 调用 ProtocolTool 类的 parserPro0x19() 方法
List<Param> paramList = ProtocolTool.parserPro0x19(bluetoothData, new Object());
// 遍历结果
for (Param param : paramList) {
String value = param.readParamValueText(); // 读取到的值
}{
"code": 0,
"data": [{
"paramNo": 75,
"value": "[{\"signalStrength\":217,\"ssid\":\"TPshuoxd\"},{\"signalStrength\":217,\"ssid\":\"shuoxd\"},...]"
}]
}// 采集器与路由器状态
{"code": 0, "data": [{"paramNo": 55, "value": "4"}]}
// 采集器与 Server 状态
{"code": 0, "data": [{"paramNo": 60, "value": "4"}]}3.3 Native iOS Integration
Step 1: Import SDK
Step 2: Import Header File
#import <Setnet_SDK/SetnetManager.h>Step 3: Packaging — 0x18 Set Command
NSDictionary *params = @{
@"commandId": @"18",
@"param18Obj": @[
@{@"paramId": @"寄存器地址", @"param": @"传输的数据"},
// ... 更多参数
]
};
[[SetnetManager sharedInstance] enCodeWithParams:params block:^(NSDictionary * _Nonnull encryptionDataDic) {
// encryptionDataDic[@"result"] => @"0" 成功, @"1" 失败
// encryptionDataDic[@"data"] => 打包好的 NSData
}];Step 4: Packaging — 0x19 Read Command
NSDictionary *params = @{
@"commandId": @"19",
@"param19Obj": @[@"寄存器地址 1", @"寄存器地址 2"]
};
[[SetnetManager sharedInstance] enCodeWithParams:params block:^(NSDictionary * _Nonnull encryptionDataDic) {
// 同上处理
}];Step 5: Unpacking — Parse Bluetooth Response
[[SetnetManager sharedInstance] DeCodeWithInputData:bluetoothData block:^(NSDictionary * _Nonnull decryptDataDic) {
// decryptDataDic[@"result"] => @"0" 成功
// decryptDataDic[@"msg"] => @"Set successfully" / @"Read successful"
// decryptDataDic[@"data"] => @{@"57": xxxxx, @"58": xxxxx}
// decryptDataDic[@"commandId"] => @"18" 或 @"19"
}];3.4 Flutter Integration
Step 1: Get Plugin
Step 2: Integrate Plugin
Step 3: Call SDK
3.5 UniApp Integration
Step 1: Project Configuration
{
"app-plus": {
"distribute": {
"sdkConfigs": {
// SDK 插件配置
}
}
}
}Step 2: Build Custom Base
Step 3: Android Usage
// 1. 引入 SDK 模块
const aeccSdk = uni.requireNativePlugin('AECC-SDK-PluginName');
// 2. 组包 — 0x18 设置
let setResult = aeccSdk.setDatalogerByP0x18(params);
// 返回: {"code": 0, "data": "0018000600100119dea56a1b17c8bb99..."}
// 3. 组包 — 0x19 读取
let readResult = aeccSdk.getDatalogerByP0x19(params);
// 返回: {"code": 0, "data": "00280006001501187168c19339b8afd61d..."}
// 4. 解析 — 0x18 响应
let parseSetResult = aeccSdk.parserPro0x18(bluetoothResponse);
// 返回: {"code": 0, "data": true}
// 5. 解析 — 0x19 响应
let parseReadResult = aeccSdk.parserPro0x19(bluetoothResponse);
// 返回: {"code": 0, "data": [{"paramNo": 60, "value": "4"}]}Step 4: iOS Usage
4.1 Overall Flow
The provisioning process consists of 6 steps, executed sequentially:
- 1 Bluetooth Connect
- 2 Scan WiFi
- 3 Send WiFi Config
- 4 Verify Router
- 5 Verify Server
- 6 Complete
4.2 Detailed Steps
Step 1: Bluetooth Connect
App scans and connects to AECC data logger via BLE. Requires user authorization for Bluetooth and location (Android).
Step 2: Scan Surrounding WiFi
Read Register 75 via 0x19 command, request the data logger to scan available WiFi routers. Result includes SSID and signal strength.
{
"commandId": "19",
"param19Obj": [75]
}{
"code": 0,
"data": [{
"paramNo": 75,
"value": "[{\"signalStrength\":217,\"ssid\":\"MyRouter\"},{\"signalStrength\":200,\"ssid\":\"OfficeWiFi\"}]"
}]
}Step 3: Send WiFi Configuration
Write the selected WiFi SSID and password to the data logger via 0x18 command. The data logger will automatically attempt to connect to the router.
Step 4: Verify Router Connection Status
Read Register 55 via 0x19 to query the data logger's router connection status. Return value 0 means success; other values refer to the status code table for troubleshooting.
Step 5: Verify Server Connection Status
Read Register 60 via 0x19 to query the data logger's cloud Server connection status. Return value 3, 4 or 16 indicates success.
Step 6: Provisioning Complete
After both statuses are successfully verified, the data logger has connected to the LAN and the cloud Server via WiFi, the data upload channel is established, and the provisioning flow ends.
5.1 Command Overview
| Command | Function | Direction |
|---|---|---|
| 0x18 | Set Parameters - write to device registers | App → Device |
| 0x19 | Read Parameters - read from device registers | App → Device |
5.2 0x18 Command Data Format (Set)
Used to write parameters to the data logger, supports setting multiple registers simultaneously.
{
"commandId": "18",
"param18Obj": [
{
"paramId": "寄存器地址",
"param": "传输的数据"
}
]
}To set multiple parameters, append more objects in the param18Obj array.
{"code": 0, "data": "XXXXX"}{"code": 0, "data": true}5.3 0x19 Command Data Format (Read)
Used to read parameters from the data logger, supports reading multiple registers simultaneously.
{
"commandId": "19",
"param19Obj": ["寄存器地址 1", "寄存器地址 2"]
}{"code": 0, "data": "XXXXX"}{"code": 0, "data": [{"paramNo": 55, "value": "4"}]}{
"code": 0,
"data": [{
"paramNo": 75,
"value": "[{\"signalStrength\":217,\"ssid\":\"TPshuoxd\"},...]"
}]
}5.4 Key Register Address Table
| Register Address | Function | R/W | Description |
|---|---|---|---|
| 55 | Router Connection Status | Read | 0 = connected successfully, other values refer to status code table |
| 60 | Server Connection Status | Read | 3, 4, 16 indicate connected successfully |
| 75 | Surrounding WiFi Router List | Read | Returns WiFi list with SSID and signalStrength |
6.1 Register 55 — Data Logger & Router Status
| Code | Meaning | Suggestion |
|---|---|---|
| 0 | Connected Successfully | Proceed to next step |
| 199 | Acquiring IP | Normal mid-state, wait 3-5 seconds and re-query |
| Other | Connection Failed | Check WiFi password, signal strength, distance to router (<10m recommended) |
6.2 Register 60 — Data Logger & Server Status
| Code | Meaning | Suggestion |
|---|---|---|
| 3 | Connected Successfully | Provisioning complete |
| 4 | Connected Successfully | Provisioning complete |
| 16 | Connected Successfully | Provisioning complete |
| Other | Connection Failed / Pending | Check: (1) Router internet connection; (2) Cloud Server status; (3) Data logger firmware version |
7.1 Permission Configuration
Android
BLUETOOTH/BLUETOOTH_ADMINACCESS_FINE_LOCATION(Bluetooth scan needs location, Android 6.0+)ACCESS_WIFI_STATE/CHANGE_WIFI_STATE
iOS
NSBluetoothAlwaysUsageDescription- Background Bluetooth:
NSBluetoothPeripheralUsageDescription
7.2 User Experience Tips
- Provisioning Guidance:Provide a step-by-step guidance UI that automatically moves to the next step after each is complete
- Status Feedback:Show real-time current step and waiting status (e.g., "Connecting to router...")
- Error Handling:Provide clear user prompts and fix suggestions for each error status code
- Timeout:Set reasonable polling interval (2-3 sec recommended) and timeout (30 sec recommended) when querying status
- Retry:Provide a one-tap retry function when provisioning fails
7.3 Security Tips
- Authorization:Keep keys and authorization codes safe, do not hardcode them in front-end code
- Bluetooth Security:Ensure Bluetooth communication uses the built-in SDK encryption
- WiFi Security:Use WPA2 or higher security WiFi networks
- Transport Security:Use TLS encryption between data logger and Server
This solution is consolidated from the official AECC SDK technical documentation (Android SDK, iOS SDK, Flutter integration guide, UniApp calling guide, SDK parameter provisioning guide). It provides a one-stop integration reference for terminal developers. For the latest SDK version and authorization info, please contact NKY.
| Resource | How to Obtain |
|---|---|
| SDK Package | Contact NKY for the latest SDK package |
| Keys & Authorization Code | Contact NKY for keys and authorization code |
| Demo Examples | Contact NKY for platform-specific Demo projects (Android / iOS / Flutter / UniApp) |
| Technical Support | Contact NKY for integration assistance and troubleshooting |
This solution is consolidated from the official AECC SDK technical documentation (Android SDK, iOS SDK, Flutter integration guide, UniApp calling guide, SDK parameter provisioning guide). It provides a one-stop integration reference for terminal developers. For the latest SDK version and authorization info, please contact NKY.