Bluetooth® Low Energy AT Command Set
This chapter introduces the Bluetooth Low Energy AT command set. Adaptations may vary across different modules. For details, see Firmware Versions and Feature Differences.
AT+BLEMAC: Query or set Bluetooth MAC address
AT+BLEMODE: Query or set Bluetooth operating mode
AT+BLERFPWR: Query or set Bluetooth TX power
AT+BLESTATE: Query connection status
AT+BLEDISCON: Disconnect Bluetooth connection
AT+BLEMTU: Query or set Bluetooth MTU
AT+BLESEND: Send data over Bluetooth transparent transmission channel
AT+BLESERUUID: Query or set UUID of Bluetooth transparent transmission service
AT+BLETXUUID: Query or set UUID of TX characteristic for Bluetooth transparent transmission service
AT+BLERXUUID: Query or set UUID of RX characteristic for Bluetooth transparent transmission service
AT+TRANSENTER: Enter Bluetooth transparent transmission mode
+DATA: Receive Bluetooth transparent transmission data in central mode
AT+BLENAME: Query or set Bluetooth device name
AT+BLECONINTV: Query or set Bluetooth connection interval
AT+BLEAUTH: Query or set Bluetooth pairing PIN
AT+BLEADVINTV: Query or set Bluetooth advertising interval
AT+BLEADVDATA: Query or set Bluetooth advertising data
AT+BLEADVEN: Query or set Bluetooth advertising enable
AT+BLESCAN: Start scanning in Bluetooth central mode
AT+BLECONNECT: Initiate a connection from central
AT+BLEAUTOCON: Set central auto-connect peripheral parameters
AT+BLEDISAUTOCON: Cancel auto scan and connect
AT+BLEIBCNUUID: Query or set Bluetooth iBeacon UUID
AT+BLEIBCNDATA: Set Bluetooth iBeacon data
-
AT+PROVISION: Enable Bluetooth provisioning
AT+MESHSEND: SIG-MESH send data
AT+MESHADDR: Query node address
AT+MESHSTATE: Query provisioning status
-
aliGenie_data: Data pushed from Tmall Genie
AT+AliGenie: Set Tmall Genie triplet
AT+SEND2ALI: Report data to Tmall Genie platform
Basic Commands
AT+BLEMAC: Query or set Bluetooth MAC address
Description
Query or set Bluetooth MAC address
Execute Command
Query Command:
AT+BLEMAC?
Response:
+BLEMAC:<MAC>
OK
Set Command: Set Bluetooth MAC address (takes effect after reboot)
AT+BLEMAC=<MAC>
Response:
OK
Parameters
MAC: Bluetooth MAC address to set, lowercase without separators, e.g.: ab5f8d9ebb01
Example
AT+BLEMAC=ab5f8d9ebb01
OK
AT+BLEMODE: Query or set Bluetooth operating mode
Description
Query or set Bluetooth operating mode
Note
For Realtek series (BW16/BW15), when enabling multiple wireless types, they must be enabled in the specified order
Bluetooth mode takes effect immediately after being set. To enable Bluetooth, configure all Bluetooth parameters before starting Bluetooth
When enabling AP+STA+Bluetooth tri-mode or AP+STA hybrid mode, enable AP first, then connect STA or Bluetooth (order between Bluetooth and STA does not matter, but AP must be enabled first)
Execute Command
Query Command: Query Bluetooth operating mode
AT+BLEMODE?
Response:
+BLEMODE :<mode>
OK
Set Command: Set Bluetooth operating mode
AT+BLEMODE=<mode>
Response:
OK
Parameters
- Mode:
0: Peripheral mode
1: Central mode
2: iBeacon mode
9: Bluetooth disabled
Example
AT+BLEMODE=0
OK
AT+BLERFPWR: Query or set Bluetooth TX power
Description
Query or set Bluetooth TX power
Notes
PB series default TX power is maximum TX power 10
TB series default TX power is maximum TX power 10
Execute Command
Query Command: Query Bluetooth TX power
AT+BLERFPWR?
Response:
+BLERFPWR:MAX:<max_power> MIN:<min_power> CURRENT:<cur_power>
OK
- max_power:当前模组支持的蓝牙最大发射功率
- min_power:当前模组支持的蓝牙最小发射功率
- cur_power:当前模组设置的蓝牙发射功率
Set Command: Set Bluetooth TX power (must be set while Bluetooth is disabled)
AT+BLERFPWR=<power>
Response:
OK
Parameters
power: Bluetooth TX power; integer, MAX (maximum TX power), or MIN (minimum TX power)
Example
AT+BLERFPWR=10
OK
AT+BLESTATE: Query Bluetooth connection status
Description
Query Bluetooth connection status
Execute Command
Command:
AT+BLESTATE?
Response:
+ BLESTATE:<status>
OK
Parameters
- status:
0: Not connected
1: Connected
Example
AT+BLESTATE?
+ BLESTATE:0
OK
AT+BLEDISCON: Disconnect Bluetooth connection
Description
Disconnect Bluetooth connection
Execute Command
Command:
AT+BLEDISCON
Response:
OK
Example
AT+BLEDISCON
OK
AT+BLEMTU: Query or set Bluetooth MTU
Description
Query or set Bluetooth MTU
Notes
PB series default MTU is 23
TB series default MTU is 247
Execute Command
Query Command: Query Bluetooth MTU
AT+BLEMTU?
Response:
+BLEMTU:<MTU>
OK
Set Command: Set Bluetooth MTU
AT+BLEMTU=<mtu>
Response:
OK
Parameters
mtu: Bluetooth MTU to set, range 23~250
Example
AT+BLEMTU=247
OK
AT+BLESEND: Send data over Bluetooth transparent transmission channel
Description
Send data over Bluetooth transparent transmission channel
Execute Command
Command:
AT+BLESEND=<len>,<data>
Response:
OK
Parameters
len: Length of data to send, in bytes
data: Data content to send; length must match len
Example
AT+BLESEND=5,12345
OK
AT+BLESERUUID: Query or set Bluetooth transparent transmission service UUID
Description
Query or set Bluetooth transparent transmission service UUID
Notes
Default primary service UUID: 55535343fe7d4ae58fa99fafd205e455
Execute Command
Query Command: Query UUID of Bluetooth transparent transmission service
AT+BLESERUUID?
Response:
+BLESERUUID:<UUID>
OK
Set Command: Set Bluetooth transparent transmission service UUID (only allowed while Bluetooth is disabled)
AT+BLESERUUID=<UUID>
Response:
OK
Parameters
UUID: 16-byte service ID, 32-character string, e.g.: 00112233445566778899aabbccddeeff
Example
AT+BLESERUUID=55535343fe7d4ae58fa99fafd205e455
OK
AT+BLETXUUID: Query or set TX characteristic UUID of Bluetooth transparent transmission service
Description
Query or set TX characteristic UUID of Bluetooth transparent transmission service
Notes
Default TX UUID: 49535343884143f4a8d4ecbe34729bb3
TX characteristic Bluetooth service property is NOTIFY
Execute Command
Query Command: Query UUID of TX characteristic for Bluetooth transparent transmission service
AT+BLETXUUID?
Response:
+BLETXUUID:<UUID>
OK
Set Command: Set TX characteristic UUID of Bluetooth transparent transmission service (only allowed while Bluetooth is disabled)
AT+BLETXUUID=<UUID>
Response:
OK
Parameters
UUID: 16-byte service ID, 32-character string, e.g.: 00112233445566778899aabbccddeeff
Example
AT+BLETXUUID=49535343884143f4a8d4ecbe34729bb3
OK
AT+BLERXUUID: Query or set RX characteristic UUID of Bluetooth transparent transmission service
Description
Query or set RX characteristic UUID of Bluetooth transparent transmission service
Notes
Default RX UUID: 495353431e4d4bd9ba6123c647249616
RX characteristic Bluetooth service property is NOTIFY
Execute Command
Query Command: Query UUID of RX characteristic for Bluetooth transparent transmission service
AT+BLERXUUID?
Response:
+BLERXUUID:<UUID>
OK
Set Command: Set RX characteristic UUID of Bluetooth transparent transmission service (only allowed while Bluetooth is disabled)
AT+BLERXUUID=<UUID>
Response:
OK
Parameters
UUID: 16-byte service ID, 32-character string, e.g.: 00112233445566778899aabbccddeeff
Example
AT+BLETXUUID=495353431e4d4bd9ba6123c647249616
OK
AT+TRANSENTER: Enter Bluetooth transparent transmission mode
Description
Enter Bluetooth transparent transmission mode
Remark
Enter +++ to exit transparent transmission mode and enter AT command mode
Note: Transparent transmission mode is entered automatically after connection by default
Execute Command
Command:
AT+TRANSENTER
Response:
OK
Example
AT+TRANSENTER
OK
Peripheral Commands
+DATA: Data received over Bluetooth transparent transmission UUID channel in central mode
Description
Data received over Bluetooth transparent transmission UUID channel in central mode
Parameters
len: Length of received data, in bytes
data: Received data content; length must match len
AT+BLENAME: Query or set Bluetooth device name
Description
Query or set Bluetooth device name
Notes
Default Bluetooth name: ai-thinker
Execute Command
Query Command: Query Bluetooth name
AT+BLENAME?
Response:
+BLENAME :<ble name>
OK
Set Command: Set Bluetooth device name (only allowed while Bluetooth is disabled)
AT+BLENAME=<ble name>
Response:
OK
Parameters
ble name: Bluetooth name (UTF-8 format, Chinese supported)
Example
AT+BLENAME=ai-thinker
OK
AT+BLECONINTV: Query or set Bluetooth connection interval
Description
Query or set Bluetooth connection interval
Notes
PB series default parameters: +BLECONINTV:6,12,0,200
TB series default parameters: +BLECONINTV:8,8,99,400
Execute Command
Query Command: Query Bluetooth connection interval
AT+BLECONINTV?
Response:
+BLECONINTV:<min_interval>,< max_interval>,<latency>,< timeout>
OK
Set Command: Set Bluetooth connection interval (only allowed while Bluetooth is disabled)
AT+BLECONINTV=<min_interval>,< max_interval>,<latency>,< timeout>
Response:
OK
Parameters
min_interval: Minimum connection interval, range 6~3200; actual time is minInterval*1.25 ms, required range 7.5 ms ~ 4 s
max_interval: Maximum connection interval, range 6~3200; actual time is maxInterval*1.25 ms, required range 7.5 ms ~ 4 s
Latency: Latency (number of connection events that may be skipped), range 0~499
Timeout: Supervision timeout, range 10~3200; actual time is Timeout*10 ms (100 ms~32*1000 ms), and Timeout*10>(1+Latency)*max_interval*1.25
Example
AT+BLECONINTV=6,12,0,200
OK
AT+BLEAUTH: Query or set Bluetooth pairing PIN
Description
Query or set Bluetooth pairing PIN
Execute Command
Query Command: Query Bluetooth pairing PIN
AT+BLEAUTH?
Response:
+BLEAUTH:<pind>
OK
Set Command: Set Bluetooth pairing PIN (only allowed while Bluetooth is disabled)
AT+BLEAUTH=<pind>
Response:
OK
Parameters
pind: Enable pairing PIN; set 6-digit number, e.g.: 123456
Disable pairing PIN: DISENABLE
Example
AT+BLEAUTH=123456
OK
AT+BLEADVINTV: Query or set Bluetooth advertising interval
Description
Query or set Bluetooth advertising interval
Notes
PB default parameter: 320
TB default parameter: 800
Execute Command
Query Command: Query Bluetooth advertising interval
AT+BLEADVINTV?
Response:
+BLEADVINTV:<intv>
OK
Set Command: Set Bluetooth advertising interval (only allowed while Bluetooth is disabled)
AT+BLEADVINTV=<intv>
Response:
OK
Parameters
<intv>: Advertising interval, range 160~16384; interval = intv*0.625 ms
Example
AT+BLEADVINTV=160
OK
AT+BLEADVDATA: Query or set Bluetooth advertising data
Description
Query or set Bluetooth advertising data
Notes
Default parameter: MAC+55e4 (first four bytes of primary service UUID), e.g.: 40154641871855e4
Execute Command
Query Command: Query Bluetooth advertising data
AT+BLEADVDATA?
Response:
+BLEADVDATA:<data>
OK
Set Command: Set Bluetooth advertising data (only allowed while Bluetooth is disabled)
AT+BLEADVDATA=<data>
Response:
OK
Parameters
data: Bluetooth data to set (hex string, max 32 bytes, e.g.: 00112233445566778899aabbccddeeff)
Example
AT+BLEADVDATA=40154641871855e4
OK
AT+BLEADVEN: Query or set Bluetooth advertising enable
Description
Query or set Bluetooth advertising enable
Notes
Enabled by default
Execute Command
Query Command: Query Bluetooth advertising enable
AT+BLEADVEN?
Response:
+BLEADVEN:<status>
OK
Set Command: Set Bluetooth advertising enable (only allowed in Bluetooth peripheral mode)
AT+BLEADVEN=<status>
Response:
OK
Parameters
- status:
0: Disabled
1: Enabled
Example
AT+BLEADVEN=1
OK
Central Commands
AT+BLESCAN: Start scanning in Bluetooth central mode
Description
Start scanning in Bluetooth central mode
Notes
PB series default scan duration 5 s, scan interval 230*0.625 ms, scan window 160*0.625 ms
TB series default scan duration 2 s, scan interval 160*0.625 ms, scan window 160*0.625 ms
Execute Command
Command:
AT+BLESCAN
Response:
OK //注意这里这个 OK 只是表示指令发送成功了,扫描实际并没有结束
Devices Found:id/total //index/total 表示当前扫描到的蓝牙设备的序号和总共扫描到的数量
name:<name> //蓝牙名称,如果没有则显示 N/A
MAC:<MAC> //小写不加冒号
rssi:<rssi>
Devices Found:<id/total>
name:<name>N/A
MAC:<MAC>
rssi:<rssi>
........
Example
AT+BLEMODE=1
OK
AT+BLESCAN
OK
AT+BLECONNECT: Initiate a connection from Bluetooth central
Description
Initiate a connection from Bluetooth central
Execute Command
Command:
AT+BLECONNECT=<MAC>
Response:
Connecting... ...
OK
Parameters
MAC: Target MAC address to connect (e.g.: A4C13812505C)
Example
AT+BLEMODE=1
OK
AT+BLECONNECT=A4C13812505C
OK
AT+BLEAUTOCON: Set central auto-connect peripheral parameters
Description
Connect to specified Bluetooth device (only allowed in Bluetooth central mode)
Execute Command
Command:
AT+BLEAUTOCON=<MAC>,<UUID>,<save_flash>
Response:
+EVENT:BLE_CONNECTED //如果连接成功则显示这条信息
+BLEAUTOCON:Wait connect //如果当前没有扫描到指定蓝牙,则显示该消息(后台还会自动扫描,当扫描到指定连接的时候就会自动连接)
OK
Parameters
MAC: Target MAC address to connect (e.g.: A4C13812505C)
UUID: If connecting to a specific UUID, set to the last two bytes of the target UUID (e.g.: E455)
Note: Either MAC or UUID is sufficient to connect (both may be set). Set to FALSE if unrestricted. If both MAC and UUID are FALSE, auto-connect is disabled
save_flash: Whether to save to flash and enable auto-connect on power-up; 0 = do not save (connect this time only), 1 = save to flash and auto-connect on next boot
Example
AT+BLEAUTOCON=A4C13812505C,55535343fe7d4ae58fa99fafd205e455,1
OK
AT+BLEDISAUTOCON: Cancel auto scan and connect
Description
Cancel auto scan and connect
Execute Command
Command:
AT+BLEDISAUTOCON
Response:
OK
Example
AT+BLEDISAUTOCON
OK
iBeacon Commands
AT+BLEIBCNUUID: Query or set Bluetooth iBeacon UUID
Description
Query or set Bluetooth iBeacon UUID
Execute Command
Query Command: Query Bluetooth iBeacon UUID
AT+BLEIBCNUUID?
Response:
+BLEIBCNIIUD:<iBeacon>
OK
Set Command: Set Bluetooth iBeacon UUID (only allowed while Bluetooth is disabled)
AT+BLEIBCNUUID=<iBeacon>
Response:
OK
Parameters
iBeacon: UUID to set; 16-byte service ID, 32-character string, e.g.: 00112233445566778899aabbccddeeff
Example
AT+BLETXUUID=495353431e4d4bd9ba6123c647249616
OK
AT+BLEIBCNDATA: Query or set Bluetooth iBeacon data
Description
Query or set Bluetooth iBeacon data
Execute Command
Query Command: Query Bluetooth iBeacon data
AT+BLEIBCNDATA?
Response:
+BLEIBCNDATA:<companyID>,<major>,<minor>,<power>
OK
Set Command: Set Bluetooth iBeacon data (only allowed while Bluetooth is disabled)
AT+BLEIBCNDATA=<company ID>,<MAJOR>,<MINOR>,<POWER>
Response:
OK
Parameters
companyID (2-byte hex data, e.g.: 11aa)
MAJOR (2-byte hex data, e.g.: 11aa)
MINOR (2-byte hex data, e.g.: 11aa)
POWER (1-byte hex data, e.g.: aa)
Example
AT+BLEIBCNDATA=4c00,2774,6b74,c5
OK
BLE MESH Commands
SIG-MESH Commands
AT+PROVISION: Enable Bluetooth provisioning
Description
Enable Bluetooth provisioning
Execute Command
Command:
AT+PROVISION
Response:
OK
Remark
When a node is in unProvisioning state (never provisioned), it does not advertise and the gateway cannot scan or connect to it. Use AT+PROVISION to enable the node so it can be scanned and connected. When a node is in Provisioning state (already provisioned with the gateway), no enable step is needed; the node automatically joins the provisioned mesh network
Example
AT+PROVISION
OK
AT+MESHSEND: SIG-MESH send data
Description
SIG-MESH send data
Execute Command
Command:
AT+MESHSEND=<addr>,<opcode>,<data>
Response:
OK
Parameters
addr: Destination address
opcode: Operation code
The following opcodes are supported for gateways sold by Ai-Thinker:
1: set command, opcode D18888
2: get command, opcode D08888
3: ACK command, opcode D38888
4: delete node command, opcode 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
Execute Command
Command:
AT+MESHADDR
Response:
+MESHADDR:<addr>
OK
Example
AT+MESHADDR
+MESHADDR:<FFFF>
OK
AT+MESHSTATE: Query provisioning status
Description
Query provisioning status
Execute Command
Command:
AT+MESHSTATE
Response:
+MESHSTATE:<status>
OK
Parameters
- status:
0: Failed
1: Success
Example
AT+MESHSTATE
+MESHSTATE:0
OK
ALI-MESH Commands
aliGenie_data: Data pushed from Tmall Genie
Description
Data pushed from Tmall Genie
Format
{ “aliGenie_data” : { “daddr” : %x , “saddr” : %x , “opcode” : %x , “data_len” : %d , “data” : %s }}//Data format is JSON string
daddr: Destination address
saddr: Source address
opcode: Operation code
data_len: Data length
data: Data content
AT+AliGenie: Set Tmall Genie triplet
Description
Set Tmall Genie triplet
Execute Command
Command:
AT+AliGenie=<pid>,<mac>,<secret>
Response:
OK
Parameters
pid: Triplet product ID (8 digits)
mac: Triplet physical address (12 digits)
secret: Triplet secret key (32 digits)
Note: All values are hexadecimal strings
AT+SEND2ALI: Report data to Tmall Genie platform
Description
Report data to Tmall Genie platform
Execute Command
Command:
AT+SEND2ALI=<opcode>,<param>
Response:
OK
Parameters
opcode: Operation code, length 6 or 4 digits
param: Report parameter, max length 20 digits
Example
上报状态为开
AT+SEND2ALI=8204,01
OK