ESP32-C3 no response issue on BLE Server
Posted: Fri Apr 19, 2024 12:17 pm
Hi,
My board uses a STM32L4 MCU to communicate with a ESP32-C3-MINI-1 module (running v3.2.0.0 firmware) over UART for WiFi and Bluetooth connectivity. Logics have been developed for both BLE server and client with below simple features.
BLE Server:
- broadcast services
- accept connection
- updating its characteristic once every 10 sec in connected state
BLE client:
- scan server & connect to server
- read server's characteristic every second
While setting up two identical boards for testing BLE client and server, initial testing went fine and BLE client can read server characteristic without problem. However, the ESP32-C3 module of the BLE server occasionally reaches to a state that no AT response was returning to the STM side. From debugging on the STM, a BUSY status (not ERROR) was returned from HAL_UART_Receive_DMA() function when the 'unresponsive' moment came. At the moment, I can only workaround this situation by restarting the receive DMA on STM a few times (spanned across a few seconds) to resume a normal operation with the BLE connection kept connected. WiFi is connected by that time but no active communication was undergoing actually.
I also tried on BLE server not updating its characteristic but just query the connection and it still reached to that BUSY state. In fact, the same server program is running the BLE client side (with settings as 'client') and the BLE client has never reached to that state.
Does anybody has a similar situation on setting up a BLE server on ESP32-C3 or other ESP modules that reaches to a similar state? Appreciate for any kind of help! Thanks!
The following AT commands are issued to the ESP32-C3 module on BLE server.
========================================================
AT+BLEINIT=2
OK
AT+BLEADDR?
+BLEADDR:"7c:df:a1:b0:9f:96"
OK
AT+BLEGATTSSRVCRE
OK
AT+BLEGATTSSRVSTART
OK
AT+BLEGATTSCHAR?
+BLEGATTSCHAR:"char",1,1,0xC300,0x02
+BLEGATTSCHAR:"desc",1,1,1,0x2901
+BLEGATTSCHAR:"char",2,1,0xC400,0x02
+BLEGATTSCHAR:"desc",2,1,1,0x2901
+BLEGATTSCHAR:"char",2,2,0xC401,0x02
+BLEGATTSCHAR:"desc",2,2,1,0x2901
OK
AT+BLESECPARAM=13,2,16,3,3
OK
AT+BLEADVDATAEX="ABCD000001","A002","123456789012",1
OK
AT+BLEGATTSSETATTR=2,1,,18
>
ABCD000001-Dev_BLE
AT+BLEGATTSSETATTR=1,1,,10
>
0-0-00.000
AT+BLECONN?
+BLECONN:
OK
AT+BLECONN?
+BLECONN:0,"d4:f9:8d:02:6b:b2"
OK
+BLEAUTHCMPL:0,0
AT+BLEADVSTART
OK
AT+BLEGATTSSETATTR=1,1,,10
>
0-0-00.001
AT+BLECONN?
+BLECONN:0,"d4:f9:8d:02:6b:b2"
OK
AT+BLECONN?
+READ:0,"d4:f9:8d:02:6b:b2"
+BLECONN:0,"d4:f9:8d:02:6b:b2"
OK
AT+BLEGATTSSETATTR=1,1,,10
>
0-0-00.002
AT+BLECONN?
+BLECONN:0,"d4:f9:8d:02:6b:b2"
OK
...
...
========================================================
My board uses a STM32L4 MCU to communicate with a ESP32-C3-MINI-1 module (running v3.2.0.0 firmware) over UART for WiFi and Bluetooth connectivity. Logics have been developed for both BLE server and client with below simple features.
BLE Server:
- broadcast services
- accept connection
- updating its characteristic once every 10 sec in connected state
BLE client:
- scan server & connect to server
- read server's characteristic every second
While setting up two identical boards for testing BLE client and server, initial testing went fine and BLE client can read server characteristic without problem. However, the ESP32-C3 module of the BLE server occasionally reaches to a state that no AT response was returning to the STM side. From debugging on the STM, a BUSY status (not ERROR) was returned from HAL_UART_Receive_DMA() function when the 'unresponsive' moment came. At the moment, I can only workaround this situation by restarting the receive DMA on STM a few times (spanned across a few seconds) to resume a normal operation with the BLE connection kept connected. WiFi is connected by that time but no active communication was undergoing actually.
I also tried on BLE server not updating its characteristic but just query the connection and it still reached to that BUSY state. In fact, the same server program is running the BLE client side (with settings as 'client') and the BLE client has never reached to that state.
Does anybody has a similar situation on setting up a BLE server on ESP32-C3 or other ESP modules that reaches to a similar state? Appreciate for any kind of help! Thanks!
The following AT commands are issued to the ESP32-C3 module on BLE server.
========================================================
AT+BLEINIT=2
OK
AT+BLEADDR?
+BLEADDR:"7c:df:a1:b0:9f:96"
OK
AT+BLEGATTSSRVCRE
OK
AT+BLEGATTSSRVSTART
OK
AT+BLEGATTSCHAR?
+BLEGATTSCHAR:"char",1,1,0xC300,0x02
+BLEGATTSCHAR:"desc",1,1,1,0x2901
+BLEGATTSCHAR:"char",2,1,0xC400,0x02
+BLEGATTSCHAR:"desc",2,1,1,0x2901
+BLEGATTSCHAR:"char",2,2,0xC401,0x02
+BLEGATTSCHAR:"desc",2,2,1,0x2901
OK
AT+BLESECPARAM=13,2,16,3,3
OK
AT+BLEADVDATAEX="ABCD000001","A002","123456789012",1
OK
AT+BLEGATTSSETATTR=2,1,,18
>
ABCD000001-Dev_BLE
AT+BLEGATTSSETATTR=1,1,,10
>
0-0-00.000
AT+BLECONN?
+BLECONN:
OK
AT+BLECONN?
+BLECONN:0,"d4:f9:8d:02:6b:b2"
OK
+BLEAUTHCMPL:0,0
AT+BLEADVSTART
OK
AT+BLEGATTSSETATTR=1,1,,10
>
0-0-00.001
AT+BLECONN?
+BLECONN:0,"d4:f9:8d:02:6b:b2"
OK
AT+BLECONN?
+READ:0,"d4:f9:8d:02:6b:b2"
+BLECONN:0,"d4:f9:8d:02:6b:b2"
OK
AT+BLEGATTSSETATTR=1,1,,10
>
0-0-00.002
AT+BLECONN?
+BLECONN:0,"d4:f9:8d:02:6b:b2"
OK
...
...
========================================================