Supported Devices
  • 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 Solution Overview

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.

By using this solution, developers can:
  • 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:

Cloud Server Layer: Receives, stores, and processes data uploaded by data loggers for business system calls.
Data Logger Device Layer: AECC smart data loggers internally contain:
  • 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
Bluetooth Communication Layer: SDK core layer connects with AECC data loggers via BLE (Bluetooth Low Energy):
  • Device discovery & pairing
  • Command delivery and data reception
  • Provisioning parameter transmission
SDK Core Layer: All platforms are built upon the Setnet-SDK core layer, responsible for:
  • Protocol packaging & parsing (0x18/0x19 commands)
  • Data encryption & decryption
  • Bluetooth communication management
Terminal App Layer: Developers choose the SDK integration method based on their tech stack:
  • 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 Core Features

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 Integration Guide

3.1 Prerequisites

Before integration, please ensure:
  1. Get SDK package & authorization: contact NKY for the latest SDK package, keys, and authorization code
  2. Get example projects: contact NKY for the corresponding platform's Demo example project
  3. Development environment: ensure your dev environment meets the platform version requirements

3.2 Native Android Integration

Step 1: Import SDK

Place the AAR/JAR package provided by SDK into the project's libs directory and add dependencies in build.gradle.

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 后通过蓝牙发送
Return format:
{"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();  // 读取到的值
}
Read surrounding WiFi routers - example:
{
  "code": 0,
  "data": [{
    "paramNo": 75,
    "value": "[{\"signalStrength\":217,\"ssid\":\"TPshuoxd\"},{\"signalStrength\":217,\"ssid\":\"shuoxd\"},...]"
  }]
}
Read device status - examples:
// 采集器与路由器状态
{"code": 0, "data": [{"paramNo": 55, "value": "4"}]}
// 采集器与 Server 状态
{"code": 0, "data": [{"paramNo": 60, "value": "4"}]}

3.3 Native iOS Integration

Step 1: Import SDK

Add Setnet_SDK.framework to your Xcode project and link it in Build Phases.

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

Contact NKY for the Flutter platform plugin package.

Step 2: Integrate Plugin

Add the plugin to dependencies in pubspec.yaml.

Step 3: Call SDK

Refer to the Demo example project (contact NKY). The Flutter plugin wraps Android/iOS native SDK logic via Platform Channel.

3.5 UniApp Integration

Step 1: Project Configuration

1. Unzip the SDK compressed file and place it in the corresponding directory of the project.
2. Configure SDK plugin info in manifest.json (note: id must match the file name):
{
  "app-plus": {
    "distribute": {
      "sdkConfigs": {
        // SDK 插件配置
      }
    }
  }
}

Step 2: Build Custom Base

After configuration, you must build a custom base before you can call Bluetooth SDK functions.

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

iOS usage is similar to Android. Packaging/parsing logic can refer to the Android example. The iOS SDK is also based on Setnet_SDK.framework.
4 Provisioning Flow

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.

Request params:
{
  "commandId": "19",
  "param19Obj": [75]
}
Response example:
{
  "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 Protocol Data Definition

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.

Request params structure:
{
  "commandId": "18",
  "param18Obj": [
    {
      "paramId": "寄存器地址",
      "param": "传输的数据"
    }
  ]
}

To set multiple parameters, append more objects in the param18Obj array.

Success packaging return:
{"code": 0, "data": "XXXXX"}
Parsed return:
{"code": 0, "data": true}

5.3 0x19 Command Data Format (Read)

Used to read parameters from the data logger, supports reading multiple registers simultaneously.

Request params structure:
{
  "commandId": "19",
  "param19Obj": ["寄存器地址 1", "寄存器地址 2"]
}
Success packaging return:
{"code": 0, "data": "XXXXX"}
Parsed return - read status:
{"code": 0, "data": [{"paramNo": 55, "value": "4"}]}
Parsed return - read WiFi list:
{
  "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 Status Code Reference

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 Integration Best Practices

7.1 Permission Configuration

Android

  • BLUETOOTH / BLUETOOTH_ADMIN
  • ACCESS_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

  1. Provisioning Guidance:Provide a step-by-step guidance UI that automatically moves to the next step after each is complete
  2. Status Feedback:Show real-time current step and waiting status (e.g., "Connecting to router...")
  3. Error Handling:Provide clear user prompts and fix suggestions for each error status code
  4. Timeout:Set reasonable polling interval (2-3 sec recommended) and timeout (30 sec recommended) when querying status
  5. Retry:Provide a one-tap retry function when provisioning fails

7.3 Security Tips

  1. Authorization:Keep keys and authorization codes safe, do not hardcode them in front-end code
  2. Bluetooth Security:Ensure Bluetooth communication uses the built-in SDK encryption
  3. WiFi Security:Use WPA2 or higher security WiFi networks
  4. Transport Security:Use TLS encryption between data logger and Server
8 Frequently Asked Questions
Q1: Which Bluetooth protocols does the SDK support?
A: SDK communicates with the data logger based on the Modbus protocol.
Q2: Is there any distance requirement between the data logger and router during provisioning?
A: It is recommended that the data logger be no more than 10 meters from the router to ensure sufficient signal strength.
Q3: Can the 0x18 command set multiple registers at once?
A: Yes. Add multiple {paramId, param} objects to the param18Obj array.
Q4: Do UniApp / Flutter require custom base building?
A: Yes. Both cross-platform solutions require custom base building before Bluetooth SDK functions can be used.
Q5: How to obtain SDK and authorization code?
A: Please contact NKY for the latest SDK package, keys, authorization codes, and platform-specific Demo projects.
Q6: Register 55 returns 199, how to handle?
A: 199 means the data logger is acquiring an IP address, which is a normal mid-state. Recommend waiting 3-5 seconds and re-querying.
Q7: Register 60 doesn't return a success value for a long time, what to do?
A: Please check in order: (1) Whether the router is connected to internet; (2) Whether the cloud Server is running normally; (3) Whether the data logger firmware version matches.
👉 Contact NKY for the latest SDK package, keys, authorization codes, and Demo projects. 👈
Contact Us