BLE Basic API
BLE API Reference
Document Version: V0.1 Preliminary | Last Updated: 2026-04-21 | Accessible Scope: Public
This document is intended for third-party Apps, gateways, or debugging tools to interface with the device's BLE API. It describes only the externally visible protocols and does not cover internal implementations.
Applied Product Models
1
SPM01-D2EW
SPM01 1PN FLEX/63A Open BLE+Wi-Fi
2
SPM01-D1EW
SPM01 1PN MCBM-BM/63A Open BLE+Wi-Fi
3
SPM01-U1EW
SPM01 1PN MCBM-TM/63A Open BLE+Wi-Fi
4
SPM02-D2EW
SPM02 3PN FLEX/63A Open BLE+Wi-Fi
5
SPM02-D1EW
SPM02 3PN MCBM-BM/63A Open BLE+Wi-Fi
6
SPM02-U1EW
SPM02 3PN MCBM-TM/63A Open BLE+Wi-Fi
7
SDM01-EWM-12
SDM01 SCTA-3×120A/Φ16 Wi-Fi (ESP32) + RS485
8
SDM01-EWM-20
SDM01 SCTA-3×200A/Φ20 Wi-Fi (ESP32) + RS485
9
SDM01-EWM-12-BKW
SDM01 SCTA-3x120A/Φ16 Wi-Fi (ESP32) + RS485 BKW
1. Connection Information
1.1 Device Broadcast Name
Naming Rule:
<Product Model>-<Device Serial Number>Example:
SPM01A-1234567890AB
1.2 GATT Services and Characteristics
Primary Service UUID:
0000A002-0000-1000-8000-00805F9B34FBRead Characteristic UUID:
0000C304-0000-1000-8000-00805F9B34FBWrite Characteristic UUID:
0000C303-0000-1000-8000-00805F9B34FBNotify Characteristic UUID:
0000C305-0000-1000-8000-00805F9B34FB
1.3 Interaction Channel Description
The client sends commands via the Write Characteristic.
The device returns processing results via the Notify Characteristic.
Recommendation: Subscribe to the Notify Characteristic immediately after connection.
The maximum MTU can reach up to 512 (the actual effective value depends on the connection negotiation result).
2. Standard Interaction Flow
2.1 Flow Overview
Scan and connect to the device.
Subscribe to the Notify Characteristic.
Send the unlock command (
cmd=pass).Send business commands after successful unlocking.
Receive the result for each command from the Notify Characteristic.
2.2 Unlock Requirements
In an un-unlocked state, most business commands will be rejected.
The unlock command must include the password field
pas.After a successful unlock, subsequent
cmdrequests within the current BLE connection session do not need to carrypasandauthby default.If unlocking fails, a "Password Error" or "Please unlock" prompt is returned.
2.3 Phone Binding Authentication (Optional)
If the device has phone authentication enabled:
It is recommended to include
authin the unlock command during the first authentication.An authentication error is returned if
authdoes not match.For the initial binding scenario,
authcan be written in the unlock command.
3. Request & Response Specification
3.1 Common Request Fields (Client -> Device)
cmd: Command word (Required).pas: BLE password. Required only for the initial verification (cmd=pass).auth: Authentication identifier. Recommended during initial verification (if authentication is enabled).Session Rule: After successful initial verification, subsequent commands within the same connection session do not need to carry
pasandauth.
3.2 Common Response Fields (Device -> Client)
ok: Boolean, indicates whether the request was processed successfully.msg: String, processing result description.event: String (Optional), usually echoes the command word.d: Object (Optional), appears only when query commands return data.
3.3 Common Failure Semantics
Password Error: Incorrect password.Please unlock: Device is not unlocked.auth error: Incorrect authentication field.not authenticated: Authentication failed.illegal cmd: Command not supported.
4. Command API Details
4.1 Initial Handshake
Purpose: Unlock session, change password, set session persistence, and bind initial authentication identifier.
Fields:
cmd: Fixed aspass.pas: Current BLE password (Required).newpas: New password (Optional, max 16 characters).continue: Keep session alive (Optional, Boolean). If omitted, every communication requires a handshake.auth: Authentication identifier (Optional, max 40 characters).
Request Example:
Response Example (Success):
4.2 Reboot
Purpose: Trigger the device reboot process.
Fields:
cmd: Fixed asrestart.
Request Example:
4.3 Device Location
Purpose: Trigger location processing. The device indicator will flash at 4Hz for 15 seconds.
Fields:
cmd: Fixed aslocation.
Request Example:
4.4 Unbind
Purpose: Clear the bound authentication status.
Fields:
cmd: Fixed asresetauth.
Request Example:
4.5 Set MQTT Topic 1
Purpose: Set the first group of MQTT topic parameters.
Fields:
cmd: Fixed astopic1.topic_post: Uplink topic.topic_set: Downlink control topic.
Request Example:
4.6 Set MQTT Topic 2
Purpose: Set the second group of MQTT topic parameters.
Fields:
cmd: Fixed astopic2.topic_response: Response topic.topic_metadata: Metadata topic.
Request Example:
4.7 Unlock Read Characteristic
Purpose: Enter readable state to prepare for subsequent status data reading.
Fields:
cmd: Fixed asread.continue: Default is read once. Add this field (true) for continuous reading (Optional).
Request Example:
4.8 Clear Energy Data
Purpose: Clear all accumulated energy data (Irreversible).
Fields:
cmd: Fixed aszero.
Request Example:
4.11 Get Function Map
Purpose: Read the
functionMap(16-bit feature bitmap).Fields:
cmd: Fixed asgetFunctionMap.
Request Example:
Response Example:
Bit Definition Table (Bit 15 is the highest bit):
15
Modbus TCP
1=Enable, 0=Disable
14
TLS Enable
1=Enable, 0=Disable
13
UDP
1=Enable, 0=Disable
11
WebSocket
1=Enable, 0=Disable
9
MQTT
1=Enable, 0=Disable
7
HTTP
1=Enable, 0=Disable
5
LoRaWAN
1=Enable, 0=Disable
4.12 TLS Multiplexing Status
Purpose: Read the Modbus TLS multiplexing status value.
Fields:
cmd: Fixed asgetModbusTlsMuxSetupStatus.
Response Example:
Status Value Description:
0:MODBUS_TLS_MUX_SETUP_IDLE- Uninitialized (e.g., Wi-Fi disconnected, feature disabled).1:MODBUS_TLS_MUX_SETUP_PLAIN_OK- Started successfully in plaintext (due to incomplete certificates).2:MODBUS_TLS_MUX_SETUP_TLS_OK- TLS started successfully.3:MODBUS_TLS_MUX_SETUP_TLS_CERT- Certificate/Key file error.4:MODBUS_TLS_MUX_SETUP_TLS_SOCK- TLS socket/bind/listen failed.5:MODBUS_TLS_MUX_SETUP_PLAIN_FAIL- Plaintext startup failed.
4.23 Set Function Map
Purpose: Directly write the
functionMapvalue.Fields:
cmd: Fixed asfunctionMap.value: 16-bit integer.
Request Example:
4.24 Data Format
Purpose: Set the message reporting format.
0represents BT format,1represents common format.Fields:
cmd: Fixed ascommonmode.value: Mode value.
Request Example:
4.25 Factory Reset
Purpose: Clear configuration and trigger a reboot.
Fields:
cmd: Fixed asreset.
Request Example:
4.26 Wi-Fi Configuration
Purpose: Set Wi-Fi connection parameters.
Fields:
cmd: Fixed aswifi.ssid: Wi-Fi Name (<=64 chars).pass: Wi-Fi Password (<=64 chars).
Request Example:
4.27 MQTT Configuration
Purpose: Configure MQTT. Using
mqtrwill additionally trigger a reboot.Fields:
cmd:mqttormqtr.data: Formatted ashost|clientid|ssl|port|interval|username|password.
Request Example:
4.28 Start Certificate Writing
Purpose: Create/clear the certificate file and prepare for fragmented writing.
Fields:
cmd: Fixed ascafilestart.filename: Target certificate file.
Request Example:
4.29 Write Certificate Fragment
Purpose: Write a fragment of the certificate content.
Fields:
cmd: Fixed ascafiledata.cadata: Certificate fragment string. Fixed size of 128 bytes (no padding needed for the last packet).
Request Example:
4.30 Add UDP Target
Purpose: Add a new UDP upload target.
Fields:
cmd: Fixed asudp.IpAddress: Target IP.localUdpPort: Target port.
Request Example:
4.31 OTA Status
Purpose: Query the OTA status.
Fields:
cmd: Fixed ascheckota.
Response Example:
otastatus Value Description:
200: Update package available.404: No update package available (already on the latest version).-2: OTA URL not configured.Other values: HTTP/Network error codes (e.g., connection failed, timeout).
4.32 OTA Progress
Purpose: Read the OTA progress percentage.
Fields:
cmd: Fixed asotaprogress.
Response Example:
4.33 Start OTA
Purpose: Start the OTA task.
Fields:
cmd: Fixed asstartota.
Request Example:
4.34 Delete UDP Target
Purpose: Delete an existing UDP target.
Fields:
cmd: Fixed asdeleteudp.IpAddress: Target IP.localUdpPort: Target port.
Request Example:
4.35 UDP List
Purpose: Read the list of UDP targets.
Fields:
cmd: Fixed asudpdata.
Response Example:
4.36 Enable HTTP
Purpose: Enable the HTTP bit.
Fields:
cmd: Fixed asenablehttp.
Request Example:
4.37 Enable WebSocket
Purpose: Enable/Disable the WebSocket bit.
Fields:
cmd: Fixed asenablewebsocket.enable:trueto enable,falseto disable.
Request Example:
4.38 Enable Modbus TCP
Purpose: Enable/Disable the Modbus TCP bit.
Fields:
cmd: Fixed asenablemodbustcp.enable:trueto enable,falseto disable.
Request Example:
4.39 Enable TLS
Purpose: Enable/Disable the TLS bit.
Fields:
cmd: Fixed asenabletls.enable:trueto enable,falseto disable.
Request Example:
4.40 Modify BLE Password
Purpose: Modify the BLE password.
Fields:
cmd: Fixed asblepassword.old: Old password.new: New password (<=16 chars).
Request Example:
4.41 Modbus Parameters
Purpose: Set serial Modbus communication parameters.
Fields:
cmd: Fixed asmodbus.baud: Baud rate.parityStop: Parity/Stop bits.address: Slave address.
Request Example:
4.42 Device Name
Purpose: Set the device name.
Fields:
cmd: Fixed asdeviceName.name: Device name (<=30 chars).
Request Example:
4.45 Read Configuration
Purpose: Read the comprehensive configuration snapshot of the device.
Fields:
cmd: Fixed asmodel.type: Optional refresh type.
Request Example:
Response Example:
4.46 Read MQTT Data
Purpose: Read MQTT related topics and account information.
Fields:
cmd: Fixed asmqttdata.
Request Example:
Response Example:
5. Integration Notes
It is recommended to uniformly use UTF-8 encoded JSON text for all requests.
Always confirm that the Notify Characteristic is subscribed to before sending commands.
After a successful initial
cmd=pass, subsequent commands within the same connection session do not need to carrypasandauth.If the device returns
Please unlockornot authenticated, you must re-execute the initial verification process.Supported commands may vary by model. It is recommended to perform capability probing using query commands.
6. Version & Compatibility
Backward Compatibility Recommendation: The response structure is fixed as
ok / msg / event / d.During external integration, it is recommended to implement failure retries and error prompts at the command level.
Here is the complete, restructured English documentation optimized for GitBook. I have categorized the APIs into logical modules, used parameter tables, and applied GitBook's native {% tabs %} syntax to make the code blocks compact and easy to read.
You can copy and paste this directly into your GitBook editor.
BLE API Reference
Document Version: V0.1 Preliminary | Last Updated: 2026-04-21 | Accessible Scope: Public
This document is intended for third-party Apps, gateways, or debugging tools to interface with the device's BLE API. It describes only the externally visible protocols and does not cover internal implementations.
Applied Product Models
1
SPM01-D2EW
SPM01 1PN FLEX/63A Open BLE+Wi-Fi
2
SPM01-D1EW
SPM01 1PN MCBM-BM/63A Open BLE+Wi-Fi
3
SPM01-U1EW
SPM01 1PN MCBM-TM/63A Open BLE+Wi-Fi
4
SPM02-D2EW
SPM02 3PN FLEX/63A Open BLE+Wi-Fi
5
SPM02-D1EW
SPM02 3PN MCBM-BM/63A Open BLE+Wi-Fi
6
SPM02-U1EW
SPM02 3PN MCBM-TM/63A Open BLE+Wi-Fi
7
SDM01-EWM-12
SDM01 SCTA-3×120A/Φ16 Wi-Fi (ESP32) + RS485
8
SDM01-EWM-20
SDM01 SCTA-3×200A/Φ20 Wi-Fi (ESP32) + RS485
9
SDM01-EWM-12-BKW
SDM01 SCTA-3x120A/Φ16 Wi-Fi (ESP32) + RS485 BKW
1. Connection & Interaction Overview
1.1 BLE Connection Info
Broadcast Name Rule:
<Product Model>-<Device Serial Number>(e.g.,SRS01A-1234567890AB)Primary Service UUID:
0000A002-0000-1000-8000-00805F9B34FBWrite Characteristic UUID:
0000C303-0000-1000-8000-00805F9B34FB(Client sends commands here)Notify Characteristic UUID:
0000C305-0000-1000-8000-00805F9B34FB(Device returns results here)Read Characteristic UUID:
0000C304-0000-1000-8000-00805F9B34FB
💡 Best Practice: Always subscribe to the Notify Characteristic immediately after connection. The maximum MTU can reach up to 512. We recommend using UTF-8 encoded JSON text for all requests.
1.2 Standard Interaction Flow
Connect & Subscribe: Scan, connect, and subscribe to the Notify Characteristic.
Unlock Session: Send the unlock command (
cmd=pass). Most business commands are rejected if the device is locked.Send Commands: After a successful unlock, subsequent commands in the same session do not need to carry the password (
pas) or auth token (auth).Receive Results: Listen to the Notify Characteristic for the
ok,msg,event, andd(data) fields.
2. Authentication & Session Management
Initial Handshake (pass)
Unlocks the session, changes the password, sets session persistence, and binds the initial authentication identifier.
Parameters:
cmd
String
Yes
Fixed as pass.
pas
String
Yes
Current BLE password.
newpas
String
No
New password (Max 16 chars).
continue
Boolean
No
Keep session alive. If omitted, every communication requires a handshake.
auth
String
No
Authentication identifier (Max 40 chars).
{
"cmd": "pass",
"pas": "123456",
"continue": true
}
</div><div data-gb-custom-block data-tag="tab" data-title='Response (Success)'>json
{
"ok": true,
"msg": "Password Correct",
"event": "pass"
}
</div><div data-gb-custom-block data-tag="tab" data-title='Response (Fail)'>json
{
"ok": false,
"msg": "Password Error",
"event": "pas"
}
```### Modify BLE Password (blepassword)
Changes the BLE connection password.
Parameters:
cmd
String
Yes
Fixed as blepassword.
old
String
Yes
Old password.
new
String
Yes
New password (Max 16 chars).
{
"cmd": "blepassword",
"old": "123456",
"new": "654321"
}
</div><div data-gb-custom-block data-tag="tab" data-title='Response'>json
{
"ok": true,
"msg": "Password yes",
"event": "blepassword"
}
```### Unbind (resetauth)
Clears the bound authentication status.
```json
{
"cmd": "resetauth"
}
</div><div data-gb-custom-block data-tag="tab" data-title='Response'>json
{
"ok": true,
"msg": "resetauth received",
"event": "resetauth"
}
```### Unlock Read Characteristic (read)
Enables the readable state to prepare for subsequent status data reading.
Parameters:
cmd
String
Yes
Fixed as read.
continue
Boolean
No
Default is read once. Set to true for continuous reading.
{
"cmd": "read",
"continue": true
}
</div><div data-gb-custom-block data-tag="tab" data-title='Response'>json
{
"ok": true,
"msg": "ready",
"event": "read"
}
// Response: { "ok": true, "event": "udpdata", "d": { "items": [] } }---
4. Device Control & Status
Device Operations (restart, reset, location, zero)
Basic device control commands requiring only the cmd field.
restart: Triggers device reboot.reset: Clears configuration and triggers a factory reset.location: Device indicator flashes at 4Hz for 15 seconds.zero: Clears all accumulated energy data (Irreversible).### Device Name (
deviceName) Sets a custom name for the device.
Parameters:
cmd
String
Yes
Fixed as deviceName.
name
String
Yes
Device name (Max 30 chars).
{
"cmd": "deviceName",
"name": "RoomMeter01"
}
```### Read Configuration (model & mqttdata)
Reads device configuration snapshots.
```json
{
"cmd": "model",
"type": 1
}
// Response: { "ok": true, "event": "mqttdata", "d": { "TP": "dev/up", "TC": "dev/down" } }---
5. Feature Flags & Protocols
Function Map (getFunctionMap / functionMap)
Reads or writes the 16-bit feature bitmap.
Bit Definition Table (Bit 15 is MSB):
15
Modbus TCP
1=Enable, 0=Disable
14
TLS Enable
1=Enable, 0=Disable
13
UDP
1=Enable, 0=Disable
11
WebSocket
1=Enable, 0=Disable
9
MQTT
1=Enable, 0=Disable
7
HTTP
1=Enable, 0=Disable
5
LoRaWAN
1=Enable, 0=Disable
{
"cmd": "getFunctionMap"
}
// Response: { "ok": true, "event": "checkota", "d": { "otastatus": 200 } }
```json { "cmd": "otaprogress" }
5. Revision History
V1.0
2025-11-01
Initial release. Dedicated complete list for limited customers and users.
HX
LHL
N/A
V1.1 Preliminary
2026-04-14
Document maintained from Feishu/Larksuite to Gitbook
HX
LHL
N/A
Last updated