# Combo Module Bluetooth Distribution Network Protocol
Note:This protocol does not require MCU participation.
#Version
Date | Version | Description |
2022.11.16 | V0.1 | Initial Version |
#1.Bluetooth broadcast packet specification
The Bluetooth broadcast packet format follows the Bluetooth 4.0 specification and consists of several AD Structures (see Bluetooth 4.2 Core Specification, Volume 3, Part C, Chapter 11), each of which consists of Length, AD Type, and ADData.
As shown in the following figure:
#
#1.1 Bluetooth broadcast package content
Broadcast packet standard data segment:
TYPE | LEN | VALUE |
0x01(flags) | 0x02 | 0x06 |
0x03(service uuid) | 0x03 | 0x0922 |
0x09(Local name) | 0x03 | "MX" |
0xFF(manufacture data) | 0x13 | Custom data segments |
Custom data segments
Custom data segments | |
Endian | Content |
byte[0]--byte[1] | Company ID |
byte[2] | MASK |
byte[3]--byte[8] | MAC地址 |
byte[9]--byte[17] | 9 bytes, users can configure: AT+STARTSMART=6, hexstring The longest hexstring is 18 bytes, which is the hexstring data of this broadcast content. |
Remarks:
1. MASK: Function enable mask, specifying functions in bit order
2. Product ID, Product ID, Product ID is a 6-digit string, fixed as ascii "000000"
Bit序 | Function Description |
1~0 | (reserved) Bluetooth version,
|
2 | Distribution network status identifier,
|
3 |
|
4 |
|
7~5 | Keep for future use, fill in all zeros |
#2.Bluetooth connection service
The service declaration is Primary Service, and the Service UUID is 0x0922
#2.1 Characteristics Description
The service includes the following 2 characteristics.
Characteristics Name | Write Characteristics | Notify Characteristics |
Characteristics UUID | 0xAAB1 | 0xAAB2 |
Requirement | Mandatory | Mandatory |
Properties | Write | Notify |
Permission | Write | None |
Notes | APP -> WiFi | WiFi -> APP |
#2.2 Protocol frame
Protocol Detail | Raw Data | Encrypted Data |
JSON | sdfhisdhfs=dhldjkfhslhf |
#2.2.1 SAR Subcontracting method
If a packet length is greater than MTU, it needs to be sent in shards, and the corresponding receiver needs to reassemble these sharded messages.
This agreement is based on the sharding and reassembly mechanism of the Mesh GATT Bear layer, and the packet format is as follows:
SAR | Data | |||
Octet 0 | Octet 1 | Octet 2 | ...... | Octet n |
SAR Explanation:
Value | Description |
0x00 | Complete Data Package |
0x01 | Fragmented packet 1 |
0x10 | Packet 2~n of sharded data |
0x11 | Last packet of sharded data packet |
#2.2.2 Raw Data
The raw data is in JSON format, and the JSON packet must include the key value: Type. After receiving the Bluetooth packet in its entirety, the module first determines the Type and processes the data based on it. The Type value is as follows:
Key | Value | Description |
Type | apinfo | WiFi configuration information packet |
wifi_reply | WiFi connection status feedback |
#2.2.3 apinfo
APP->WiFi
Explanation: The APP sends routing information and other information to the WiFi module.
{
"type": "apinfo",
"data": {
"ssid": "xxx",
"password": "xxx"
}
}
#2.2.4 wifi_reply
WiFi->APP
Explanation: After receiving apinfo and connecting to the router, the WiFi module responds as connected to the APP. If the connection times out for 30 seconds, the WiFi module will return the reason for the APP failure
{
"type": "wifi_reply",
"data": {
"error_code": 0,
"describe": "connected"
}
}
WiFi connection status feedback content description:
JSONKey | error_code | describe |
Object | 0 | connected |
1 | ap not found | |
2 | rssi too low | |
3 | fail connected |
#3.Distribution network flowchart
#4.Distribution network example
The app combines ssid and password to form a JSON package for apinfo
Convert the JSON package of apinfo to hex format data and add a header. Please determine the header based on the size of the MTU. If not subcontracted, hex data:007B2274797065223A20226170696E666F222C2264617461223A207B2273736964223A202274657374222C2270617373776F7264223A20223132333435363738227D7DAfter connecting to the router, the Wi Fi module will reply with a successful status. Hex data:007B2274797065223A22776966695F7265706C79222C2264617461223A7B226572726F725F636F6465223A302C226465736372696265223A22636F6E6E6563746564227D7DConvert the above hex to JSON format:5.nrf connect test-------------------------------------------------------------------------------End.