Bluetooth® Low Energy AT order set¶
This chapter introduces the Bluetooth low energy instruction set. This instruction set will be adapted differently for different modules. For specific differences, please move to Firmware iterations and differences.
AT+BLEMAC: query or set Bluetooth MAC address
AT+BLEMODE: query or set Bluetooth working mode
AT+BLERFPWR: query or set Bluetooth transmit power
AT+BLESTATE: query connection status
AT+BLEDISCON: disconnect Bluetooth
AT+BLEMTU: query or set Bluetooth MTU
AT+BLESEND: Send data to the Bluetooth transparent transmission channel
AT+BLESERUUID: query or set the UUID of the Bluetooth transparent transmission service
AT+BLETXUUID: query or set the UUID of the TX feature of the Bluetooth transparent transmission service
AT+BLERXUUID: Query or set the UUID of the RX feature of the Bluetooth transparent transmission service
AT+TRANSENTER: Enter Bluetooth transparent transmission mode
+DATA: Bluetooth transparent transmission data received in host mode
AT+BLENAME: query or set the Bluetooth device name
AT+BLECONINTV: query or set the Bluetooth connection interval
AT+BLEAUTH: query or set Bluetooth pairing code
AT+BLEADVINTV: Query or set the Bluetooth broadcast interval
AT+BLEADVDATA: query or set Bluetooth broadcast data
AT+BLEADVEN: query or set Bluetooth broadcast enable
AT+BLESCAN: Initiate scanning in Bluetooth host mode
AT+BLECONNECT: host initiates a connection
AT+BLEAUTOCON: Set the master to automatically connect to the slave parameters
AT+BLEDISAUTOCON: cancel automatic scan connection
AT+BLEIBCNUUID: query or set Bluetooth iBeacon UUID
AT+BLEIBCNDATA: set Bluetooth iBeacon data
-
AT+PROVISION: Bluetooth settings enable network provisioning function
AT+MESHSEND: SIG-MESH send data
AT+MESHADDR: query node address
AT+MESHSTATE: query whether the network configuration is successful
-
aliGenie_data: Tmall Genie sends data
AT+AliGenie: set Tmall Genie triplet
AT+SEND2ALI: Report data to Tmall Genie platform
basic command¶
AT+BLEMAC:Query or set Bluetooth MAC address¶
description¶
Query or set Bluetooth MAC address
excuting an order¶
query order:
AT+BLEMAC?
respond:
+BLEMAC:<MAC>
OK
set command: Set Bluetooth MAC address (valid after reboot)
AT+BLEMAC=<MAC>
respond:
OK
parameter¶
The Bluetooth MAC address to be set, the format is lowercase without separation eg:ab5f8d9ebb01
example¶
AT+BLEMAC=ab5f8d9ebb01
OK
AT+BLEMODE:Query or set the Bluetooth working mode¶
description¶
Query or set the Bluetooth working mode
Notice¶
For Realtek series (BW16/BW15), if multiple wireless types are turned on, they need to be turned on in the specified order
It will be executed immediately after setting the bluetooth mode. If you start bluetooth, you need to set the bluetooth parameter first and then start bluetooth
If you enable AP+STA+Bluetooth three-mode, or AP+STA hybrid mode, you need to turn on the AP first, and then connect to STA or Bluetooth (there is no requirement for the order of Bluetooth and STA, but you must turn on the AP first)
excuting an order¶
query order: Set Bluetooth working mode
AT+BLEMODE?
respond:
+BLEMODE :<mode>
OK
set command: Set Bluetooth working mode
AT+BLEMODE=<mode>
respond:
OK
parameter¶
- Mode:
0:slave mode
1:host mode
2:iBeacon mode
9:Bluetooth off
example¶
AT+BLEMODE=0
OK
AT+BLERFPWR:Query or set the Bluetooth transmission power¶
description¶
Query or set the Bluetooth transmission power
remark¶
The default current transmit power of PB series is the maximum transmit power 10 - The default current transmit power of TB series is the maximum transmit power 10
excuting an order¶
query order: Query Bluetooth transmit power
AT+BLERFPWR?
respond:
+BLERFPWR:MAX:<max_power> MIN:<min_power> CURRENT:<cur_power>
OK
- max_power: The maximum Bluetooth transmission power supported by the current module
- min_power: The minimum Bluetooth transmission power supported by the current module
- cur_power: Bluetooth transmission power set by the current module
set command: Set the Bluetooth transmission power (need to be set when Bluetooth is off)
AT+BLERFPWR=<power>
respond:
OK
parameter¶
power:Bluetooth transmit power, the value is an integer, MAX (maximum transmit power), MIN (minimum transmit power)
example¶
AT+BLERFPWR=10
OK
AT+BLESTATE:Query the Bluetooth connection status¶
description¶
Query the Bluetooth connection status
excuting an order¶
order:
AT+BLESTATE?
respond:
+ BLESTATE:<status>
OK
parameter¶
- status:
0:not connected
1:connected
example¶
AT+BLESTATE?
+ BLESTATE:0
OK
AT+BLEDISCON:disconnect Bluetooth¶
description¶
disconnect Bluetooth
excuting an order¶
order:
AT+BLEDISCON
respond:
OK
example¶
AT+BLEDISCON
OK
AT+BLEMTU:Query or set Bluetooth MTU¶
description¶
Query or set Bluetooth MTU
remark¶
The default MTU of PB series is 23
The default MTU of TB series is 247
excuting an order¶
query order: Query Bluetooth MTU
AT+BLEMTU?
respond:
+BLEMTU:<MTU>
OK
set command: Set Bluetooth MTU
AT+BLEMTU=<mtu>
respond:
OK
parameter¶
mtu:Set the MTU of Bluetooth, the value is 23~250
example¶
AT+BLEMTU=247
OK
AT+BLESEND:Send data to the Bluetooth transparent transmission channel¶
description¶
Send data to the Bluetooth transparent transmission channel
excuting an order¶
order:
AT+BLESEND=<len>,<data>
respond:
OK
parameter¶
len: the length of the data to be sent, in bytes
data: the content of the data to be sent, the length should be consistent with len
example¶
AT+BLESEND=5,12345
OK
AT+BLESERUUID:Query or set the Bluetooth transparent transmission service UUID¶
description¶
Query or set the Bluetooth transparent transmission service UUID
remark¶
default master service UUID: 55535343fe7d4ae58fa99fafd205e455
excuting an order¶
query order: Query the UUID of the Bluetooth transparent transmission service
AT+BLESERUUID?
respond:
+BLESERUUID:<UUID>
OK
set command: Set the Bluetooth transparent transmission service UUID (only allow to set the Bluetooth name when Bluetooth is off)
AT+BLESERUUID=<UUID>
respond:
OK
parameter¶
UUID:16-byte service ID, string length 32 bits eg:00112233445566778899aabbccddeeff
example¶
AT+BLESERUUID=55535343fe7d4ae58fa99fafd205e455
OK
AT+BLETXUUID:Query or set the TX characteristic UUID of the Bluetooth transparent transmission service¶
description¶
Query or set the TX characteristic UUID of the Bluetooth transparent transmission service
remark¶
Default TX UUID: 49535343884143f4a8d4ecbe34729bb3
The Bluetooth service attribute corresponding to TX is NOTIFY
excuting an order¶
query order: Query the UUID of the TX characteristic of the Bluetooth transparent transmission service
AT+BLETXUUID?
respond:
+BLETXUUID:<UUID>
OK
set command: Set the TX characteristic UUID of the Bluetooth transparent transmission service (only allow to set the Bluetooth name when the Bluetooth is turned off)
AT+BLETXUUID=<UUID>
respond:
OK
parameter¶
UUID:16-byte service ID, string length 32 bits eg:00112233445566778899aabbccddeeff
example¶
AT+BLETXUUID=49535343884143f4a8d4ecbe34729bb3
OK
AT+BLERXUUID:Query or set the RX characteristic UUID of the Bluetooth transparent transmission service¶
description¶
Query or set the RX characteristic UUID of the Bluetooth transparent transmission service
remark¶
Default RX UUID: 495353431e4d4bd9ba6123c647249616
The Bluetooth service attribute corresponding to RX is NOTIFY
excuting an order¶
query order: Query the UUID of the RX characteristic of the Bluetooth transparent transmission service
AT+BLERXUUID?
respond:
+BLERXUUID:<UUID>
OK
set command: Set the RX characteristic UUID of the Bluetooth transparent transmission service (only allow to set the Bluetooth name when the Bluetooth is turned off)
AT+BLERXUUID=<UUID>
respond:
OK
parameter¶
UUID:16-byte service ID, string length 32 bits eg:00112233445566778899aabbccddeeff
example¶
AT+BLETXUUID=495353431e4d4bd9ba6123c647249616
OK
AT+TRANSENTER:Enter Bluetooth transparent transmission mode¶
description¶
Enter Bluetooth transparent transmission mode
remark¶
After entering +++, you can exit the transparent transmission mode and enter the AT command mode
remark: Automatically enter transparent transmission mode after default connection
excuting an order¶
order:
AT+TRANSENTER
respond:
OK
example¶
AT+TRANSENTER
OK
slave command¶
+DATA:In host mode, the data sent by the Bluetooth transparent UUID channel is received¶
description¶
In host mode, the data sent by the Bluetooth transparent UUID channel is received
parameter¶
len: length of received data in bytes
data: the received data content, the length should be consistent with len
AT+BLENAME:Query or set the Bluetooth device name¶
description¶
Query or set the Bluetooth device name
remark¶
default Bluetooth name: ai-thinker
excuting an order¶
query order: Query Bluetooth name
AT+BLENAME?
respond:
+BLENAME :<ble name>
OK
set command: Set the bluetooth device name (only allow to set the bluetooth name when bluetooth is off)
AT+BLENAME=<ble name>
respond:
OK
parameter¶
ble name:Bluetooth name (UTF-8 format, support Chinese)
example¶
AT+BLENAME=ai-thinker
OK
AT+BLECONINTV:Query or set the Bluetooth connection interval¶
description¶
Query or set the Bluetooth connection interval
remark¶
PB series default parameter: +BLECONINTV:6,12,0,200
TB series default parameter: +BLECONINTV:8,8,99,400
excuting an order¶
query order: Query the Bluetooth connection interval
AT+BLECONINTV?
respond:
+BLECONINTV:<min_interval>,< max_interval>,<latency>,< timeout>
OK
set command: Set the Bluetooth connection interval (only allowed to be set when Bluetooth is off)
AT+BLECONINTV=<min_interval>,< max_interval>,<latency>,< timeout>
respond:
OK
parameter¶
min_interval: the minimum connection interval, the value is 6~3200, the actual time is minInterval*1.25ms, the requirement is 7.5ms ~ 4s - max_interval: the maximum connection interval, the value is 6~3200, the actual time is minInterval*1.25ms, the requirement is 7.5ms ~ 4s - Latency: Delay (can skip several connections), required between 0~499 - Timeout: timeout time, the value is 10~3200, the actual time is Timeout*10ms or 100ms~32*1000ms and Timeout*10>(1+Latency)*max_interval*1.25
example¶
AT+BLECONINTV=6,12,0,200
OK
AT+BLEAUTH:Query or set the Bluetooth pairing code¶
description¶
Query or set the Bluetooth pairing code
excuting an order¶
query order: Query Bluetooth pairing code
AT+BLEAUTH?
respond:
+BLEAUTH:<pind>
OK
set command: Set the Bluetooth pairing code (only allowed to perform settings when Bluetooth is turned off))
AT+BLEAUTH=<pind>
respond:
OK
parameter¶
pind: Enable pairing code, set 6 digits eg:123456
Disable pairing code DISENABLE
example¶
AT+BLEAUTH=123456
OK
AT+BLEADVINTV:Query or set the Bluetooth broadcast interval¶
description¶
Query or set the Bluetooth broadcast interval
remark¶
PB default parameter 320
TB default parameter 800
excuting an order¶
query order: Query the Bluetooth broadcast interval
AT+BLEADVINTV?
respond:
+BLEADVINTV:<intv>
OK
set command: Set the Bluetooth broadcast interval (only allowed to perform settings when Bluetooth is off)
AT+BLEADVINTV=<intv>
respond:
OK
parameter¶
<intv>: broadcast interval, the unit value is 160~16384, the broadcast interval is iNtv*0.625ms
example¶
AT+BLEADVINTV=160
OK
AT+BLEADVDATA:Query or set Bluetooth broadcast data¶
description¶
Query or set Bluetooth broadcast data
remark¶
Default parameter: MAC+55e4 (the first four uuids of the main service), for example: 40154641871855e4
excuting an order¶
query order: Query Bluetooth broadcast data
AT+BLEADVDATA?
respond:
+BLEADVDATA:<data>
OK
set command: Set Bluetooth broadcast data (only allowed to perform settings when Bluetooth is off)
AT+BLEADVDATA=<data>
respond:
OK
parameter¶
data:The set Bluetooth data (this is hex data in the form of a string, the maximum length is 32 bytes eg:00112233445566778899aabbccddeeff)
example¶
AT+BLEADVDATA=40154641871855e4
OK
AT+BLEADVEN:Query or set Bluetooth broadcast enable¶
description¶
Query or set Bluetooth broadcast enable
remark¶
enabled by default
excuting an order¶
query order: Query Bluetooth broadcast enable
AT+BLEADVEN?
respond:
+BLEADVEN:<status>
OK
set command: Set the Bluetooth broadcast enable (only allowed to perform settings in the Bluetooth slave state)
AT+BLEADVEN=<status>
respond:
OK
parameter¶
- status:
0:turn off
1:turn on
example¶
AT+BLEADVEN=1
OK
host command¶
AT+BLESCAN:Initiate scanning in Bluetooth host mode¶
description¶
Initiate scanning in Bluetooth host mode
remark¶
The default scan time of PB series is 5 seconds, the scan interval is 230*0.625 mSec, and the scan window is 160*0.625 mSec
The default scan time of TB series is 2 seconds, the scan interval is 160*0.625 mSec, and the scan window is 160*0.625 mSec
excuting an order¶
order:
AT+BLESCAN
respond:
OK //Notice here this OK just means that the command is sent successfully, the scan is not actually over
Devices Found:id/total //index/total Indicates the serial number of the currently scanned Bluetooth device and the total number of scanned devices
name:<name> //Bluetooth name, if not, display N/A
MAC:<MAC> //lower case without :
rssi:<rssi>
Devices Found:<id/total>
name:<name>N/A
MAC:<MAC>
rssi:<rssi>
........
example¶
AT+BLEMODE=1
OK
AT+BLESCAN
OK
AT+BLECONNECT:Bluetooth host initiates a connection¶
description¶
Bluetooth host initiates a connection
excuting an order¶
order:
AT+BLECONNECT=<MAC>
respond:
Connecting... ...
OK
parameter¶
MAC:Connect target mac address(eg:A4C13812505C)
example¶
AT+BLEMODE=1
OK
AT+BLECONNECT=A4C13812505C
OK
AT+BLEAUTOCON:Set the master to automatically connect to the slave parameter¶
description¶
Connect to the specified Bluetooth (only allowed to connect in the Bluetooth host state)
excuting an order¶
order:
AT+BLEAUTOCON=<MAC>,<UUID>,<save_flash>
respond:
+EVENT:BLE_CONNECTED //This message is displayed if the connection is successful
+BLEAUTOCON:Wait connect
//If the specified Bluetooth is not currently scanned, the message will be displayed (the background will also scan automatically, and it will automatically connect when the specified connection is scanned)
OK
parameter¶
MAC: The mac address of the connection target (eg: A4C13812505C)
UUID: If you need to connect to the specified UUID, set it to the last two digits of the target UUID (eg: E455)
Notice: Either input MAC, UUID can realize the connection (both can be set), if there is no limit, set it to FALSE, if both MAC and UUID are set to FALSE, then turn off to automatically connect
save_flash: Whether to save to flash, and set to automatically connect when booting, 0 means not to save, only this connection, 1 means save to flash, and automatically connect next time
example¶
AT+BLEAUTOCON=A4C13812505C,55535343fe7d4ae58fa99fafd205e455,1
OK
AT+BLEDISAUTOCON:cancel automatic scan connection¶
description¶
cancel automatic scan connection
excuting an order¶
order:
AT+BLEDISAUTOCON
respond:
OK
example¶
AT+BLEDISAUTOCON
OK
iBeacon command¶
AT+BLEIBCNUUID:Query or set Bluetooth iBeacon UUID¶
description¶
Query or set Bluetooth iBeacon UUID
excuting an order¶
query order: Query Bluetooth iBeacon UUID
AT+BLEIBCNUUID?
respond:
+BLEIBCNIIUD:<iBeacon>
OK
set command: Set the Bluetooth iBeacon UUID (only allow to set the Bluetooth iBeacon UUID in the Bluetooth turn off state)
AT+BLEIBCNUUID=<iBeacon>
respond:
OK
parameter¶
iBeacon: UUID to be set: 16-byte service ID, string length 32 bits eg: 00112233445566778899aabbccddeeff
example¶
AT+BLETXUUID=495353431e4d4bd9ba6123c647249616
OK
AT+BLEIBCNDATA:Query or set Bluetooth iBeacon data¶
description¶
Query or set Bluetooth iBeacon data
excuting an order¶
query order: Query Bluetooth iBeacon data
AT+BLEIBCNDATA?
respond:
+BLEIBCNDATA:<companyID>,<major>,<minor>,<power>
OK
set command: Set Bluetooth iBeacon data (only allowed to set Bluetooth iBeacon UUID in Bluetooth turn off state)
AT+BLEIBCNDATA=<company ID>,<MAJOR>,<MINOR>,<POWER>
respond:
OK
parameter¶
companyID (2 bytes of hexadecimal data, eg: 11aa)
MAJOR (2 bytes of hexadecimal data, eg: 11aa)
MINOR (2 bytes of hexadecimal data, eg: 11aa)
POWER (1 byte hexadecimal data, eg: aa)
example¶
AT+BLEIBCNDATA=4c00,2774,6b74,c5
OK
BLE MESH command¶
SIG-MESH command¶
AT+PROVISION:Bluetooth settings start distribution network function¶
description¶
Set Bluetooth to enable network distribution function
excuting an order¶
order:
AT+PROVISION
respond:
OK
remark¶
When the node is in the unProvisioning state, that is, it has not been provisioned, no broadcast is sent at this time, and the gateway cannot scan the device and connect it. If you need to connect, you need to use the AT+PROVISION command to enable the node so that the device can be scanned and connected. When the device is in the Provisioning state, that is, it has already been configured with the gateway, no need to enable the node, and the node will automatically connect to the mesh network that has been configured
example¶
AT+PROVISION
OK
AT+MESHSEND:SIG-MESH send data¶
description¶
SIG-MESH send data
excuting an order¶
order:
AT+MESHSEND=<addr>,<opcode>,<data>
respond:
OK
parameter¶
addr: the address of the target
opcode: opcode
At present, the operation codes for the gateways sold by our company are as follows:
1:set command, opcode is D18888
2: get command, the opcode is D08888
3: ACK command, the opcode is D38888
4: delete node command opcode opcode is D28888
data: data example:
{“mesh_data vendor” : { “daddr” : 3 , “saddr” : 2 , “opcode” : d38888 , “data_len” :2 , “data” : 0101 (hex string) ret : 1 }}
example¶
AT+MESHSEND=FFFF,D38888,0102030405
OK
AT+MESHADDR:Query node address¶
description¶
Query node address
excuting an order¶
order:
AT+MESHADDR
respond:
+MESHADDR:<addr>
OK
example¶
AT+MESHADDR
+MESHADDR:<FFFF>
OK
AT+MESHSTATE:Query whether the distribution network is successful¶
description¶
Query whether the distribution network is successful
excuting an order¶
order:
AT+MESHSTATE
respond:
+MESHSTATE:<status>
OK
parameter¶
- status:
0:fail
1:success
example¶
AT+MESHSTATE
+MESHSTATE:0
OK
ALI-MESH command¶
aliGenie_data:Tmall Genie sends data¶
description¶
Tmall Genie sends data
mode¶
{ “aliGenie_data” : { “daddr” : %x , “saddr” : %x , “opcode” : %x , “data_len” : %d , “data” : %s }}//data mode is json character string
daddr: destination address
saddr: source address
opcode: opcode
data_len: data length
data: data content
AT+AliGenie:Set the Tmall Genie triplet¶
description¶
Set the Tmall Genie triplet
excuting an order¶
order:
AT+AliGenie=<pid>,<mac>,<secret>
respond:
OK
parameter¶
pid: triple product ID (8 digits)
mac: triplet physical address (12 bits)
secret: Triple key (32 bits)
Notice: All are hexadecimal strings
AT+SEND2ALI:Report data to Tmall Genie platform¶
description¶
Report data to Tmall Genie platform
excuting an order¶
order:
AT+SEND2ALI=<opcode>,<param>
respond:
OK
parameter¶
opcode: operation code, length 6 bits/4 bits
param: report parameter, the maximum length is 20 characters
example¶
report status is open
AT+SEND2ALI=8204,01
OK