- Contact Sensor Broadcast Message
- BLE communication packet basic format
- 0x00 General Command
- 0x02 Get device basic information command
- The following table is the Service Data of SCAN_RSP.
RESP Packet status: 1 | ||
---|---|---|
Byte: 0 | Enctype Device type | Bit[7]:NC 0: No encryption 1: With encryption, encryption method 1 |
Bit[6:0]-Device Type 'D' : Pair Mode 'd' : Const Adv Mode | ||
Byte: 1 | Status | Bit[7]: Has it been scope tested 1: Tested 0: Not tested |
Bit[6]: PIR State 0: No one moves 1: Someone is moving | ||
Bit[5:0] NC | ||
Byte: 2 | update utc Battery | Bit[7]:NC |
Bit[6:0]: battery capacity | ||
Byte: 3 | Sensor Data | Bit[7]: Since the last trigger PIR time(s)Highest bit (*65536) |
Bit[6]: Since the last trigger HAL time(s)Highest bit(*65536) | ||
Bit[3:5]:reserve | ||
Bit[1:2]:Hal State 0:door close 1:door open 2:timeout not close | ||
Bit[0]:Light Level 0:dark 1:light | ||
Byte: 4~Byte: 5 | PIR UTC | Time from the last PIR trigger(s)low 16 Bit Byte4 High 8 Bit Byte5 Low 8 Bit |
Byte: 6~Byte: 7 | HAL UTC | Time from the last HAL trigger(s)low 16 Bit Byte6 High 8 Bit Byte7 Low 8 Bit |
Byte: 8 | Act Counter | Bit[6:7]: Number of entrances The number of door entry actions, the Counter value is increased by 1 (1~3)cycle, 3 Value changes after overflow 1 |
Bit[4:5]: Number of Go out Counter The number of times to go out, the Counter value is increased by 1 (1~3)cycle, 3 Value changes after overflow 1 | ||
Bit[0:3]:Button push counter Each time the button is pressed, the Counter value increases by 1 (1~15)cycle,16 Value changes after overflow 1 |
Example:
- The controlling terminal (short as the Terminal below) and the configured device (short as the Device below) use BLE to communicate with each other wirelessly. During the communication, the Terminal acts as a central device, while the Device acts as peripheral device. The Terminal gets basic device info by reading the broadcast message of the Device. They exchange data by using read and write characteristic of communication service.
- All bilateral communication is after the BLE connection established. The Terminal send a REQ message to the Device, and then the Device returns a RESP message.
- All communication message data length is 1-20 bytes, i.e. MTU=20.
-
- UUID: ''cba20002-224d-11e6-9fb8-0002a5d5c51b''
- UUID TYPE: Vendor UUID types start at this index (128-bit)
- Char Attribute: RW
- Char Properties: notify
-
- ''cba20003-224d-11e6-9fb8-0002a5d5c51b''
- UUID TYPE: Vendor UUID types start at this index (128-bit)
- Char Attribute: RW
- The control terminal sends the REQ packet format, and the specific content format of PayLoad varies from Command:
REQ Packet No encryption | ||
---|---|---|
Byte: 0 | Magic Number | 0x57 – (fixed value) |
Byte: 1 | Header | Bit [7:6] – Version 0 – (fixed value) |
Bit [7:6] – Version 0 – (fixed value) | ||
Bit [7:6] – Version 0 – (fixed value) | ||
Byte: 2-19 | Payload | Depends on Command |
- Contact Sensor Returns the RESP packet format of the control terminal as follows:
REQ Packet No encryption | ||
---|---|---|
Byte: 0 | Response status | 0x01 - OK Action executed 0x02 - ERROR Error while executing an Action 0x03 - BUSY Device is busy now, please try later 0x04 - Communication protocol version incompatible 0x05 - Device does not support this Command 0x06 - Device low battery 0x07 - Device is encrypted 0x08 - Device is unencrypted 0x09 - Password error 0x0A - Device does not support this encription method 0x0B - Failed to locate a nearby mesh Device 0x0C - Failed to connect to the network 0x0D - This command is not supported in the current mode 0x0E - Disconnected from the device that needs to stay connected |
Byte: 1-19 | Payload | Depends on the Command to reply |
Note:
-
Status returns the processing status of the previous command, which is the first BYTE of each RESP packet, which is also necessary.
-
PayLoad's specific content format depends on Command and its processing results, the data length ranges from 0-19 bytes, that is, no.
- Obtain the status information of the Contact Sensor device;
- The format of the command sent by the terminal to the device is as follows:
REQ Packet CMD Format | ||
---|---|---|
Index | Section | Value |
Byte: 0 | Magic num | 0x57 |
Byte: 1 | General cmd | 0x00 |
Byte: 2 | Subcmd | 0x11 |
- After successful execution, the Status byte of the RESP packet is 1, the Payload is 8 (index), and the format of the RESP Packet payload is as follows:
RESP Packet | ||
---|---|---|
Byte: 0 | Status | Command execution status |
Byte: 1 | Payload | rule code When the parsing rule is 0x01 |
Byte: 2~Byte: 5 | The number of seconds from the current HAL last trigger, door close trigger or door open trigger (normal mode) Device local UTC (test mode) | |
Byte: 6 | Pir Status 0:unmanned 1:someone | |
Byte: 7 | Light Level 0: dark 1: bright | |
Byte: 8 | Door Status 0:Close 1:Open 2:Timeout not close |
Example:
Use NRF Connect to issue command 0x570011 to the Device, Get device basic information.
The replied RESP message is 0x010100000DBB010100;
Status Byte is 0x01 OK Action executed.
RESP message payload Byte 0: 0x01, Command execution status.
RESP message payload Byte 1: 0x01, rule code.
RESP message payload Byte 2~Byte5: 0x00000DBB, utc timestamp (big endian).
RESP message payload Byte 6: 0x01, Pir Status.
RESP message payload Byte 7: 0x01, Light Level.
RESP message payload Byte 8: 0x00, Door Status.
- This command is used to obtain the basic information of the device:
- The Status byte of the RESP packet after successful execution is 1, and the Payload is the basic information of the device:
- This command is used to obtain the basic information of the Contact Sensor device (battery power, firmware version, Hall enable status, PIR detection distance, cloud service switch, door sensor installation position, PIR working mode, light effect switch, door access mode, timeout Unclosed time, whether it is in the adding process, environmental threshold state);
- The payload is 0 (index), and the format of the REQ Packet payload is as follows:
REQ Packet payload: 0 |
- After successful execution, the Status byte of the RESP packet is 1, the Payload is 6 (index), and the format of the RESP Packet payload is as follows:
RESP Packet payload | ||
---|---|---|
Byte: 0 | Bat Per | The battery percentage |
Byte: 1 | FW Ver | Firmware Version |
Byte: 2 | Para Info | bit[7-6]:Active Hal 0-reserve 1-Active left 2-Active right 3-Active both bit[5]:detect range 0-short 1-long bit[4]: 0-disable iot 1-enable iot bit[2:3] Installation location 0-door 1-wall 2-window Bit[1]:PIR Work Mode 0-Normal Mode 1-Test Mode Bit[0]: 0-Disable LED 1-Enable LED |
Byte: 3 | Total Act Num | Total Act Num |
Byte: 4 | Go-Out Mode | bit[7]: 0-Press Mode 1-Auto Detec Mode bit[6~0]: Detection Time |
Byte: 5 | Timeout Close Time | Door and window open time overtime (min) |
Byte: 6 | Add process Environment dark threshold setting | Bit[2:7] reserve Bit[1]: Work flow identification 0-Normal work flow 1-Add process (use for adding process) Bit[0] Ambient dark threshold state 0-Can't set current status 1-Can set current status |
Example:
Use NRF Connect to issue command 0x5702 to the Device, Get device basic information.
The replied RESP message is 0x01640B2101030501;
Status Byte is 0x01 OK Action executed.
RESP message payload Byte 0: 0x00, The battery percentage.
RESP message payload Byte 1: 0x10, Firmware Version.
RESP message payload Byte 2: 0x00, Para Info.
RESP message payload Byte 3: 0x10, Total Act Num.
RESP message payload Byte 4: 0x00, Go-Out Mode.
RESP message payload Byte 5: 0x10, Timeout Close Time.
RESP message payload Byte 6: 0x00, Add process and Environment dark threshold setting.
CopyRight@2022 Wonderlabs, Inc.