# BLE AT Usgage
#1. Slave
Send command in BLE Slave mode.
1. AT+BROLE=0 Set Slave mode
2. AT+BNAME=xxx Set broadcasting device name for BLE
3. AT+BLE=ON Enable BLE
By following the above three steps, you can open a Slave BLE mode. Please note that BLE=ON needs to be placed later.
#1.1. Service UUID
By default, Sevice UUID is enabled with 0xA00A.
Users can set a new Service UUID by issuing the command AT+BSERVUUID=xxxx. The service UUID can be either 16 bit or 128 bit.
For example, to set the service UUID bit 16 with a value of 0xA00C, you can call the AT command: AT+BSERVUUID=A00C to complete.
#1.2. RX UUID and TX UUID
Slave defines 0xB002 as RX UUID and 0xB003 as TX UUID by default.
Users can set RX UUID by using the command AT+BRXUUID; AT+BTXUUID to set TX UUID, also supports two types of UUID: 16bit and 128bit. Among them, TX UUID is a Write attribute that can be sent and processed through the Master. RX UUID is a Notify attribute. Slave sends data to Master, and before Slave sends data, Master needs to first enable write permission.
#1.3. Send Data
Slave sends data by using the command AT+BSEND or entering BLE transparent mode: AT+BSENDRAW. At this point, Slave sends the data to the Master through Notify.
#1.4. Receive Data
Master sends data to Slave through TX UUID, and Slave notifies data through+BEVENT event.
#2. Master
- AT+BROLE=1 set to Master mode
- AT+BLE=ON Enable BLE
- AT+BINQ=1, scan BLE Slave devices with device name 'slave'. You can also use Service UUID as a parameter for scan: for example, if the command is AT+BINQ=0, A00A indicates that the scan service UUID is a slave of A00A.
If a device is found, the following event will be generated:+BEVENT: SCAN, 0849DC28C6654, -42, slave; After EVENT SCAN, 0 represents the 0th slave. If there are multiple slaves, multiple will be listed; Then there are the MAC address, signal strength, and Device name of Slave.
- AT+BCONN=0 Connect to the Slave number scanned by Scan above. Successfully connecting will generate Event:+BEVENT: Connection, CLIENT, 0, ON
Once connected, data can be sent and received through BLE.
#3. Example of Slave and Master Communication
Decompress the compressed package above, which contains two SSCOM configuration files for Slave and Master. Connect two modules separately and control them to achieve interaction through BLE.
_____________________________________________________________________________________________________________
END.
若有收获,就点个赞吧