# Function Command
#Command List
Num | Command | Function |
1 | Query/Set Bluetooth LE device name. | |
2 | Query the BLE public static address of the device, which is also the built-in MAC address of the device. | |
3 | Query/Set BLE scan parameter. | |
4 | Enable/disable BLE scanning and provide advanced filtering parameters for scanning. | |
5 | Query/Set Bluetooth LE Broadcast Parameters. | |
6 | Query/Set Bluetooth LE Broadcast Data. | |
7 | Automatically generate BLE broadcast packets based on configuration. | |
8 | Start BLE Broadcast. | |
9 | Stop BE Broadcast. | |
10 | Query/Set Bluetooth Transmission Power. | |
11 | Proactively disconnect from the current Central device. | |
12 | Send data to Central devices through the BLE Transparent service. | |
13 | Set the IO interface capability of the BLE device. | |
14 | To enable the BLE binding pairing process. | |
15 | Cancel the currently in progress pairing process. | |
16 | Obtain the list of devices saved by the module that have completed pairing and binding. | |
17 | Set/Query a fixed PASSKEY. | |
18 | Confirm and reply to the received PASSKEY. | |
19 | Enter PASSKEY during the authentication process. |
#1. AT+BLENAME
Function:Query/Set Bluetooth LE device name.
Query Command: | AT+BLENAME? |
Response: | +BLENAME:<"device_name"> OK |
Parameter: | Please refer to set command parameter. |
Set Command: | AT+BLENAME=<“device_name”> |
Response: | OK |
Parameter: | <device_ Name>: Bluetooth LE device name, maximum length: 32, default name is "XAT". |
Description:
- If AT+SYSSTORE=1, the configuration changes will be saved in the KV area.
- The device name will be included in the GAP attribute.
- The device name will also be included in the device's broadcast package, which defaults to scan response. And it can be set through the AT+BLEADVPARM command.
- The device name format of the broadcast package is "device_name_XXXX", where XXXX is the lowest four bytes of the device MAC address.
Example:
AT+BLENAME="Hello"
OK
#2. AT+BLEADDR
Function:Query the BLE public static address of the device, which is also the built-in MAC address of the device.
Query Command: | AT+BLEADDR? |
Response: | +BLEADDR:<"public_addr"> OK |
Parameter | <public_addr>:BLE public static address is also the device's built-in MAC address. String format, separating each byte with:. |
Demo:
AT+BLEADDR?
+BLEADDR:"D0:BA:E4:8F:07:E2"
OK
#3. AT+BLESCANPARAM
Function:Query/Set BLE scan parameter.
Query Command: | AT+BLESCANPARAM? |
Response: | +BLESCANPARAM:<scan_type>, <filter>, <scan_interval>, <scan_window>,<timeout> |
Parameter | Please refer to set command parameter. |
Set Command: | AT+BLESCANPARAM=<scan_type>,[<filter>,<scan_interval>,<scan_window>,<timeout>] |
Reponse: | OK |
Parameter |
|
Description:
- The number of address filtering tables is 80. If more than 80 broadcast packets with different addresses have been found, more broadcast packets will not be filtered. Therefore, scanning should be stopped and restarted.
Demo:
//Passive scanning, same as MAC address filtering, 3 second timeout
AT+BLESCANPARAM=0,1,,,300
OK
AT+BLESCAN=1
OK
+BLESCAN:"E8:3F:EA:95:05:CC","random",-92,"ADV_NONCONN_IND","07FF4C0012020002"
+BLESCAN:"72:7B:61:DF:53:20","random",-92,"ADV_NONCONN_IND","1EFF060001092002E7187730AD7CA2896FF30E52B7FC2ED776902011EDEBC7"
+BLESCAN:"54:13:79:88:21:CA","public",-93,"ADV_SCAN_IND","1AFF4C00021550765CB7D9EA4E2199A4FA879613A492E35EE473CE"
+BLESCAN:"15:9E:E7:95:9F:3D","random",-56,"ADV_NONCONN_IND","02011A0BFF4C00090603DDC0A81FD9"
+BLESCAN:"1B:DC:54:87:E4:08","random",-91,"ADV_NONCONN_IND","02011A14FF4C0009060395C0A81FDF1307024A9A47CBDF98"
+BLESCAN:"17:CB:95:66:FF:E5","random",-63,"ADV_NONCONN_IND","02011A0BFF4C0009060318C0A81FC8"
+BLESCAN:"58:BA:28:C8:98:C8","random",-101,"ADV_IND","02011A020A0C0AFF4C001005101C3AE6B3"
#4. AT+BLESCAN
Enable/disable Bluetooth LE scanning and provide advanced filtering parameters for scanning.
Set Command: | AT+BLESCAN=<enable>[,<filter_type>,<"filter_param">] |
Response: | OK |
Parameter |
|
Event Response: | +BLESCAN:<"addr">,<"addr_type">,<rssi>,<"adv_type">,<"adv_data"> |
|
Description:
- The number of advanced filtering tables is 20. If more than 20 matching broadcast packets have been found, more broadcast packets will not be filtered. Therefore, scanning should be stopped and restarted.
Demo:
// Start scanning and filter based on MAC address
AT+BLESCAN=1,1,"6C:4A:85"
OK
+BLESCAN:"6C:4A:85:0D:4C:BA","public",-65,"ADV_IND","02011A020A0C0AFF4C00100501146FB165"
// Set scanning parameters and use active scanning Because the device name is usually located in the Scan Response broadcast package
AT+BLESCANPARAM=1,1,,,300
OK
// Start scanning and filter based on device name
AT+BLESCAN=1,2,"SGUAI-S1X"
OK
+BLESCAN:"C3:0A:50:00:06:40","random",-106,"SCAN_RSP","0A0953475541492D533158"
+BLESCAN:"C3:0A:50:00:06:40","random",-106,"ADV_IND","02010609FFFFFF400600500AC31107B4A5C1D179EDC79CB17E5FF9D2830A50"
#5. AT+BLEADVPARM
Query/Set Bluetooth LE Broadcast Parameters.
Query Command: | AT+BLEADVPARM? |
Response: | +BLESCANPARAM:<options>,<adv_int_min>,<adv_int_max>,<"peer_addr">,<"peer_addr_type"> OK |
Parameter: | Please refer to set command parameter. |
Set Command: | AT+BLEADVPARM=<options>[,<adv_int_min>,<adv_int_max>,<"peer_addr">,<"peer_addr_type">] |
Response: | OK |
Parameter: |
|
Description:
- If AT+SYSSTORE=1, the configuration changes will be saved in the KV area.
#6. AT+BLEADVDATA
Function:Query/Set Bluetooth LE Broadcast Data.
Query Command: | AT+BLEADVDATA? |
Response: | +BLEADVDATA:<"adv_data">,<"scan_rsp_data"> OK |
Parameter: | Please refer to set command parameter. |
Set Command: | AT+BLEADVDATA=<"adv_data">[,<"scan_rsp_data">] |
Response: | OK |
Parameter: |
|
Description:
- If AT+SYSSTORE=1, configuration changes will be saved in the KV area.
- The response to the query command does not include broadcast data automatically added by the system, such as device name, transmission power, etc.
Demo:
AT+BLEADVDATA?
+BLEADVDATA:"020106030300FE06FF22090007E2"
#7. AT+BLEADVDATAEX
Function:Automatically generate BLE broadcast packets based on configuration.
Set Command: | AT+BLEADVDATAEX=[<"manufacture_data">,<include_power>,<"UUID16s/UUID128">,<"UUID16_DATA">]" |
Response: | OK |
Parameter: |
|
Description:
- If AT+SYSSTORE=1, new broadcast data will be generated and changes will be saved in the KV area.
- It will overwrite the custom broadcast data set using the AT+BLEADVDATA command.
Demo:
AT+BLEADVDATAEX="010203",0,"FFF0FFF1","1234"
OK
AT+BLEADVDATA?
+BLEADVDATA:"04FF0102030503F0FFF1FF03161234"
OK
#8. AT+BLEADVSTART
Funciton: Start BLE Broadcast.
Excecute Command: | AT+BLEADVSTART |
Response: | OK |
Description:
- Broadcast based on saved broadcast data and broadcast parameter settings.
- If the broadcast parameters or data have been modified, the broadcast should be restarted to take effect.
- The default broadcast parameter, please refer to the work mode switching content on this page.
#9. AT+BLEADVSTOP
Function: Stop BE Broadcast.
Excecute Command: | AT+BLEADVSTART |
Response: | OK |
#10. AT+POWER
Function: Query/Set Bluetooth Transmission Power.
Query Command: | AT+POWER? |
Response: | +POWER:<power> OK |
Parameter: | Please refer to set command parameter. |
Set Command: | AT+POWER=<power> |
Response: | OK |
Parameter: | <power>: Emission power, signed integer, in dBm. Value range: -127~127. The specific settable power varies depending on different hardware platforms. |
#11. AT+BLEDISCONN
Proactively disconnect from the current Central device.
Execute Command: | AT+BLEDISCONN |
Response: | OK |
Demo:
+BLECONN//Connection success message
AT+BLEDISCONN//Device actively disconnects
OK
+BLEDISCONN//Connection disconnect message
#12. AT+BLEGATTSNTFY
Send data to Central devices through the BLE Transparent service.
Execute Command: | AT+BLEGATTSNTFY |
Response: | OK > |
Description: | Receive data from the serial interface, and send the received data to the Central device through the Data Out feature of the Transparent service. The method of receiving data adopts the packaging method in the transparent transmission working mode, which includes two methods: "maximum data length packaging" and "no data received within a certain period of time packaging". This working mode will continue until:
A series of event messages will be generated, which can be closed or opened using AT+SYSMSG: When exiting the current mode, a+QUITT message will be sent. Normal exit: will send+SEND_ OK message
|
Set Command: | AT+BLEGATTSNTFY=<length> |
Response: | OK > |
Parameter: | <length>: Receives data of a specified length from the serial port and sends the data to the Bluetooth protocol stack, which is then sent to the Central device through the Data Out feature of the Transparent service. |
Description: | Start receiving data of specified length from the serial port. And the received data will be sent to the Central device through the Data Out feature of the Transparent service, where only the "maximum data length packaging" in the transparent working mode is used, and the "no data received within a certain period of time packaging" is not used. This working mode will continue until:
A series of event messages will be generated, which can be closed or opened using AT+SYSMSG:
|
Tips:
When sending, it is necessary to ensure that the connection has been established and that the main device has opened the Notification flag of the device Data Out feature through CCCD. Otherwise, it will directly return ERROR
Demo:
Receive data of variable length from the serial port and send it to the Central device. Exit when receiving+++.
+BLECONN //BLE Connection success message
+NOTIFY_ ENABLED //Notification flag on message
AT+BLEGATTSNTFY
OK
> //Waiting for data to be received from the serial port
+QUITT //Received+++, exit current mode
+SEND_ OK //Sending successful message
Receive data of variable length from the serial port and send it to the Central device. But there was a disconnection event.
+BLECONN //BLE Connection success message
+NOTIFY_ENABLED //Notification flag on message
AT+BLEGATTSNTFY
OK
> //Waiting for data to be received from the serial port
+NOTIFY_DISABLED //Notification flag clear event (triggered before the disconnection event occurs)
+SEND_CANCELED //Cancle sending event
+BLEDISCONN //Disconnection event
Receive 4 bytes of data from the serial port and send it to the Central device.
+BLECONN
+NOTIFY_ENABLED
AT+BLEGATTSNTFY=4
OK
+QUITT
+SEND_OK
#13. AT+BLEIOCAP
Function: Set the IO interface capability of the BLE device, and the protocol stack determines which authentication method to use during the pairing and binding process based on this capability.
Set Command: | AT+BLEIOCAP=<io> |
Response: | OK |
Parameter: | IO: The IO interface capability of BLE devices, supporting the following parameters:
|
Demo:
Set the device's ability to display the current paired password through the display device.
AT+BLEIOCAP=2 //Set IO capability
OK
+BLECONN //Waiting BLE connection
AT+BLEPAIR=4 //Starting pairing according to security level 4
OK
+PASSKEY_DISPLAY:"F4:D4:88:7C:AC:7D (public)","575000" //The password generated by the module needs to be entered or confirmed by the user on another device (based on the capabilities of the other device)
+PAIR_COMPLETE:"F4:D4:88:7C:AC:7D (public)",1 //Pairing success event
#14. AT+BLEPAIR
To enable the BLE binding pairing process, it is necessary to ensure that the BLE connection has been established before calling, i.e. a +BLECONN
event is generated.
Set Command: | AT+BLEPAIR=<sec_level: (1 - 4)>[,<force: (0: no, 1: force)>] |
Response: | OK |
Parameter: |
|
#15. AT+BLEPAIR_CANCEL
Cancel the currently in progress pairing process.
Execute Command: | AT+BLEPAIR_CANCEL |
Response: | OK |
#16. AT+BLEBONDS
Obtain the list of devices saved by the module that have completed pairing and binding.
Query Command: | AT+BLEBONDS? |
Response: | +BLEBONDS:<"address"> OK |
Parameter: |
|
Clear the device information saved in the flash of the module that has completed pairing and binding.
Execute Command: | AT+BLEBONDS_CLEAR |
Response: | OK |
Parameter: |
Demo:
AT+BLEBONDS?
+BLEBONDS:"F4:D4:88:7C:AC:7D (public)"
OK
#17. AT+BLEFIXEDPASSKEY
Set/Query a fixed PASSKEY for the following situations:
- When generating a PASSKEY, the module no longer generates it randomly, but instead uses the fixed PASSKEY.
- When a PASSKEY needs to be input, the module automatically enters the set fixed PASSKEY.
Set Command: | AT+BLEFIXEDPASSKEY=[<passkey: (0 - 999999)>] |
Response: | OK |
Parameter: | Passkey: Fixed PASSKEY, ranging from 0 to 999999. If an empty parameter is provided, the saved fixed PASSKEY in Flash is clear. |
Query Command: | AT+BLEFIXEDPASSKEY? |
Response: | +BLEFIXEDPASSKEY:<"NONE"|passkey> |
Parameter: | Passkey: Fixed PASSKEY, ranging from 0 to 999999. If an empty parameter is provided, the saved fixed PASSKEY in Flash is clear. |
#18. AT+BLEPASSKEY_CONFIRM
Confirm and reply to the received PASSKEY.
Execute Command: | AT+BLEPASSKEY_CONFIRM |
Response: | OK |
#19. AT+BLEPASSKEY_INPUT
Enter PASSKEY during the authentication process, and the protocol stack will verify whether the entered PASSKEY is correct to determine whether the authentication is successful.
Set Command: | AT+BLEPASSKEY_INPUT=<passkey: (0 - 999999)> |
Response: | OK |
_____________________________________________________________________________________________________________
End.