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 :doc:`../instruction/other/firmware_differences`. :ref:`Basic command `: - :ref:`AT+BLEMAC `: query or set Bluetooth MAC address - :ref:`AT+BLEMODE `: query or set Bluetooth working mode - :ref:`AT+BLERFPWR `: query or set Bluetooth transmit power - :ref:`AT+BLESTATE `: query connection status - :ref:`AT+BLEDISCON `: disconnect Bluetooth - :ref:`AT+BLEMTU `: query or set Bluetooth MTU - :ref:`AT+BLESEND `: Send data to the Bluetooth transparent transmission channel - :ref:`AT+BLESERUUID `: query or set the UUID of the Bluetooth transparent transmission service - :ref:`AT+BLETXUUID `: query or set the UUID of the TX feature of the Bluetooth transparent transmission service - :ref:`AT+BLERXUUID `: Query or set the UUID of the RX feature of the Bluetooth transparent transmission service - :ref:`AT+TRANSENTER `: Enter Bluetooth transparent transmission mode :ref:`slave command `: - :ref:`+DATA `: Bluetooth transparent transmission data received in host mode - :ref:`AT+BLENAME `: query or set the Bluetooth device name - :ref:`AT+BLECONINTV `: query or set the Bluetooth connection interval - :ref:`AT+BLEAUTH `: query or set Bluetooth pairing code - :ref:`AT+BLEADVINTV `: Query or set the Bluetooth broadcast interval - :ref:`AT+BLEADVDATA `: query or set Bluetooth broadcast data - :ref:`AT+BLEADVEN `: query or set Bluetooth broadcast enable :ref:`host command `: - :ref:`AT+BLESCAN `: Initiate scanning in Bluetooth host mode - :ref:`AT+BLECONNECT `: host initiates a connection - :ref:`AT+BLEAUTOCON `: Set the master to automatically connect to the slave parameters - :ref:`AT+BLEDISAUTOCON `: cancel automatic scan connection :ref:`iBeacon command `: - :ref:`AT+BLEIBCNUUID `: query or set Bluetooth iBeacon UUID - :ref:`AT+BLEIBCNDATA `: set Bluetooth iBeacon data :ref:`BLE MESH command `: - :ref:`SIG-MESH command `: - :ref:`AT+PROVISION `: Bluetooth settings enable network provisioning function - :ref:`AT+MESHSEND `: SIG-MESH send data - :ref:`AT+MESHADDR `: query node address - :ref:`AT+MESHSTATE `: query whether the network configuration is successful - :ref:`ALI-MESH command `: - :ref:`aliGenie_data `: Tmall Genie sends data - :ref:`AT+AliGenie `: set Tmall Genie triplet - :ref:`AT+SEND2ALI `: Report data to Tmall Genie platform .. _cmd-basic command: basic command ------------------------------------------------- .. _cmd-BLEMAC: AT+BLEMAC:Query or set Bluetooth MAC address ------------------------------------------------- description ^^^^ - Query or set Bluetooth MAC address excuting an order ^^^^^^^^ **query order:** :: AT+BLEMAC? **respond:** :: +BLEMAC: OK **set command:** Set Bluetooth MAC address (valid after reboot) :: AT+BLEMAC= **respond:** :: OK parameter ^^^^ - The Bluetooth MAC address to be set, the format is lowercase without separation eg:ab5f8d9ebb01 example ^^^^ :: AT+BLEMAC=ab5f8d9ebb01 OK .. _cmd-BLEMODE: 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 : OK **set command:** Set Bluetooth working mode :: AT+BLEMODE= **respond:** :: OK parameter ^^^^ - Mode: - 0:slave mode - 1:host mode - 2:iBeacon mode - 9:Bluetooth off example ^^^^ :: AT+BLEMODE=0 OK .. _cmd-BLERFPWR: 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: MIN: CURRENT: 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= **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 .. _cmd-BLESTATE: AT+BLESTATE:Query the Bluetooth connection status ------------------------------------------------- description ^^^^ - Query the Bluetooth connection status excuting an order ^^^^^^^^ **order:** :: AT+BLESTATE? **respond:** :: + BLESTATE: OK parameter ^^^^ - status: - 0:not connected - 1:connected example ^^^^ :: AT+BLESTATE? + BLESTATE:0 OK .. _cmd-BLEDISCON: AT+BLEDISCON:disconnect Bluetooth ------------------------------------------------- description ^^^^ - disconnect Bluetooth excuting an order ^^^^^^^^ **order:** :: AT+BLEDISCON **respond:** :: OK example ^^^^ :: AT+BLEDISCON OK .. _cmd-BLEMTU: 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: OK **set command:** Set Bluetooth MTU :: AT+BLEMTU= **respond:** :: OK parameter ^^^^ - mtu:Set the MTU of Bluetooth, the value is 23~250 example ^^^^ :: AT+BLEMTU=247 OK .. _cmd-BLESEND: 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=, **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 .. _cmd-BLESERUUID: 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: OK **set command:** Set the Bluetooth transparent transmission service UUID (only allow to set the Bluetooth name when Bluetooth is off) :: AT+BLESERUUID= **respond:** :: OK parameter ^^^^ - UUID:16-byte service ID, string length 32 bits eg:00112233445566778899aabbccddeeff example ^^^^ :: AT+BLESERUUID=55535343fe7d4ae58fa99fafd205e455 OK .. _cmd-BLETXUUID: 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: 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= **respond:** :: OK parameter ^^^^ - UUID:16-byte service ID, string length 32 bits eg:00112233445566778899aabbccddeeff example ^^^^ :: AT+BLETXUUID=49535343884143f4a8d4ecbe34729bb3 OK .. _cmd-BLERXUUID: 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: 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= **respond:** :: OK parameter ^^^^ - UUID:16-byte service ID, string length 32 bits eg:00112233445566778899aabbccddeeff example ^^^^ :: AT+BLETXUUID=495353431e4d4bd9ba6123c647249616 OK .. _cmd-TRANSENTER: 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 .. _cmd-slave command: slave command ------------------------------------------------------- .. _cmd-DATA: +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 .. _cmd-BLENAME: 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 : OK **set command:** Set the bluetooth device name (only allow to set the bluetooth name when bluetooth is off) :: AT+BLENAME= **respond:** :: OK parameter ^^^^ - ble name:Bluetooth name (UTF-8 format, support Chinese) example ^^^^ :: AT+BLENAME=ai-thinker OK .. _cmd-BLECONINTV: 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:,< max_interval>,,< timeout> OK **set command:** Set the Bluetooth connection interval (only allowed to be set when Bluetooth is off) :: AT+BLECONINTV=,< max_interval>,,< 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 .. _cmd-BLEAUTH: 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: OK **set command:** Set the Bluetooth pairing code (only allowed to perform settings when Bluetooth is turned off)) :: AT+BLEAUTH= **respond:** :: OK parameter ^^^^ - pind: Enable pairing code, set 6 digits eg:123456 - Disable pairing code DISENABLE example ^^^^ :: AT+BLEAUTH=123456 OK .. _cmd-BLEADVINTV: 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: OK **set command:** Set the Bluetooth broadcast interval (only allowed to perform settings when Bluetooth is off) :: AT+BLEADVINTV= **respond:** :: OK parameter ^^^^ - : broadcast interval, the unit value is 160~16384, the broadcast interval is iNtv*0.625ms example ^^^^ :: AT+BLEADVINTV=160 OK .. _cmd-BLEADVDATA: 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: OK **set command:** Set Bluetooth broadcast data (only allowed to perform settings when Bluetooth is off) :: AT+BLEADVDATA= **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 .. _cmd-BLEADVEN: 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: OK **set command:** Set the Bluetooth broadcast enable (only allowed to perform settings in the Bluetooth slave state) :: AT+BLEADVEN= **respond:** :: OK parameter ^^^^ - status: - 0:turn off - 1:turn on example ^^^^ :: AT+BLEADVEN=1 OK .. _cmd-host command: host command ------------------------------------------------------- .. _cmd-BLESCAN: 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: //Bluetooth name, if not, display N/A MAC: //lower case without : rssi: Devices Found: name:N/A MAC: rssi: ........ example ^^^^ :: AT+BLEMODE=1 OK AT+BLESCAN OK .. _cmd-BLECONNECT: AT+BLECONNECT:Bluetooth host initiates a connection ------------------------------------------------- description ^^^^ - Bluetooth host initiates a connection excuting an order ^^^^^^^^ **order:** :: AT+BLECONNECT= **respond:** :: Connecting... ... OK parameter ^^^^ - MAC:Connect target mac address(eg:A4C13812505C) example ^^^^ :: AT+BLEMODE=1 OK AT+BLECONNECT=A4C13812505C OK .. _cmd-BLEAUTOCON: 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=,, **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 .. _cmd-BLEDISAUTOCON: AT+BLEDISAUTOCON:cancel automatic scan connection ------------------------------------------------- description ^^^^ - cancel automatic scan connection excuting an order ^^^^^^^^ **order:** :: AT+BLEDISAUTOCON **respond:** :: OK example ^^^^ :: AT+BLEDISAUTOCON OK .. _cmd-iBeacon command: iBeacon command ------------------------------------------------------------ .. _cmd-BLEIBCNUUID: 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: OK **set command:** Set the Bluetooth iBeacon UUID (only allow to set the Bluetooth iBeacon UUID in the Bluetooth turn off state) :: AT+BLEIBCNUUID= **respond:** :: OK parameter ^^^^ - iBeacon: UUID to be set: 16-byte service ID, string length 32 bits eg: 00112233445566778899aabbccddeeff example ^^^^ :: AT+BLETXUUID=495353431e4d4bd9ba6123c647249616 OK .. _cmd-BLEIBCNDATA: 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:,,, OK **set command:** Set Bluetooth iBeacon data (only allowed to set Bluetooth iBeacon UUID in Bluetooth turn off state) :: AT+BLEIBCNDATA=,,, **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 .. _cmd-MESH command: BLE MESH command ------------------------------------------------- .. _cmd-SIG command: SIG-MESH command ------------------------------------------------- .. _cmd-PROVISION: 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 .. _cmd-MESHSEND: AT+MESHSEND:SIG-MESH send data ------------------------------------------------- description ^^^^ - SIG-MESH send data excuting an order ^^^^^^^^ **order:** :: AT+MESHSEND=,, **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 .. _cmd-MESHADDR: AT+MESHADDR:Query node address ------------------------------------------------- description ^^^^ - Query node address excuting an order ^^^^^^^^ **order:** :: AT+MESHADDR **respond:** :: +MESHADDR: OK example ^^^^ :: AT+MESHADDR +MESHADDR: OK .. _cmd-MESHSTATE: 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: OK parameter ^^^^ - status: - 0:fail - 1:success example ^^^^ :: AT+MESHSTATE +MESHSTATE:0 OK .. _cmd-ALI command: ALI-MESH command ------------------------------------------------- .. _cmd-aliGenie_data: 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 .. _cmd-AliGenie: AT+AliGenie:Set the Tmall Genie triplet ------------------------------------------------- description ^^^^ - Set the Tmall Genie triplet excuting an order ^^^^^^^^ **order:** :: AT+AliGenie=,, **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 .. _cmd-SEND2ALI: AT+SEND2ALI:Report data to Tmall Genie platform ------------------------------------------------- description ^^^^ - Report data to Tmall Genie platform excuting an order ^^^^^^^^ **order:** :: AT+SEND2ALI=, **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