Hello everybody,
I encountered the following problem using BLE AT. I got two modules. One as a BLE client (ESP32-WROOM-32) and one as a BLE server (ESP32-C3-WROOM). I am sending AT commands via UART. Everything works fine until i want to enable notification or indication. Therefore I want the client to wirte 0x0001 or 0x0002 to the corresponding discriptor. Like this: AT+BLEGATTCWR=0,4,1,1,2\r\n > '2''0' (note: these are integer not ascii values). However not matter how many bytes or which value I try to write I always receive +WRITE:0,2,1,1,2,'1''0'\r\n on the server side. I fllowed the example on https://docs.espressif.com/projects/esp ... e-services. If I use the nRF Connect App on my phone to enable notification or indication everything works properly. I can also write characteristic values without any problems. Only that one dosent seem to work.
Steps to repropduce
1. Step: init server and client
Server
--> AT+BLEINIT=2
--> AT+BLEADDR? --> +BLEADDR:"7c:df:a1:b2:a2:6e"
--> AT+BLEGATTSSRVCRE
--> AT+BLEGATTSSRVSTART
--> AT+BLEGATTSCHAR? --> +BLEGATTSCHAR:"char",1,1,0x2A2B,0x12
+BLEGATTSCHAR:"desc",1,1,1,0x2902
+BLEGATTSCHAR:"char",2,1,0x2700,0x3a
+BLEGATTSCHAR:"desc",2,1,1,0x2902
+BLEGATTSCHAR:"desc",2,1,2,0x2901
+BLEGATTSCHAR:"char",2,2,0x2700,0x02
+BLEGATTSCHAR:"desc",2,2,1,0x2901
--> AT+BLEADVPARAM=100,200,0,0,7
--> AT+BLEADVSTART
Client
--> AT+BLEINIT=1
--> AT+BLESCAN=1,3 --> +BLESCAN:"7c:df:a1:b2:a2:6e",-32,,,0
2. Step: Connect divices
Client
--> AT+BLECONN=0,"7c:df:a1:b2:a2:6e" --> +BLECONN:0,"7c:df:a1:b2:a2:6e"
3. Step: Write to CCCD
Client
--> AT+BLEGATTCPRIMSRV=0 --> +BLEGATTCPRIMSRV:0,1,0x1801,1
+BLEGATTCPRIMSRV:0,2,0x1800,1
+BLEGATTCPRIMSRV:0,3,0x1805,1
+BLEGATTCPRIMSRV:0,4,0x2D59D6C1C1CE4A1AAAACF59BD3F057DB,1
--> AT+BLEGATTCCHAR=0,4 --> +BLEGATTCCHAR:"char",0,4,1,0x2700,0x3a
+BLEGATTCCHAR:"desc",0,4,1,1,0x2902
+BLEGATTCCHAR:"desc",0,4,1,2,0x2901
+BLEGATTCCHAR:"char",0,4,2,0x2700,0x02
+BLEGATTCCHAR:"desc",0,4,2,1,0x2901
--> AT+BLEGATTCWR=0,4,1,1,2 --> '>'
-->'0''2' --> OK
Server
+WRITE:0,2,1,1,2,'1''0'
ESP AT BLE can not enable notification or indication
ESP AT BLE can not enable notification or indication
- Attachments
-
- Service.csv
- (546 Bytes) Downloaded 443 times
Re: ESP AT BLE can not enable notification or indication
Hi, It seems that you wrote it wrong here. The target feature value written is CCC, and the AT will automatically correct the written value according to the target's prop.If you are interested, you can read chapter 3.4.5 of this document (https://blog.csdn.net/espressif/article ... /105048087).
Re: ESP AT BLE can not enable notification or indication
Thank you for your help. Unfortunately I reveive a timeout tyring to open this link https://blog.csdn.net/espressif/article ... /105048087. Can you please tell me how to enable notifications then. That would be great.ESP_Sun wrote: ↑Thu Mar 03, 2022 6:47 amHi, It seems that you wrote it wrong here. The target feature value written is CCC, and the AT will automatically correct the written value according to the target's prop.If you are interested, you can read chapter 3.4.5 of this document (https://blog.csdn.net/espressif/article ... /105048087).
Re: ESP AT BLE can not enable notification or indication
3.4.5 Client: Register Notification
On top of read and write, BLE characteristics contain notify and indicate, which are used when the server sends data to the client. For successful data transmission, the client needs to register notification in advance, or in other words write the value of CCC.
For notify, please write 0x1; for indicate, please write 0x2 (to description 0x2902).
For example, in default ESP-AT services, the property of 0xC305 is notify, and the property of 0xC306 is indicate. We write to descriptor 0x2902 in the two characteristics respectively:
Writing CCC value is necessary for the server to notify and indicate.
Tips
- ESP-AT will internally convert wrong values written to descriptors to the right ones.
3.4.6 Server: Send Data to the Client
Once CCC value has been written, we can send data using notify and indicate.
For meanings of above parameters, please refer to the command set.(https://docs.espressif.com/projects/esp ... t-commands)
On top of read and write, BLE characteristics contain notify and indicate, which are used when the server sends data to the client. For successful data transmission, the client needs to register notification in advance, or in other words write the value of CCC.
For notify, please write 0x1; for indicate, please write 0x2 (to description 0x2902).
For example, in default ESP-AT services, the property of 0xC305 is notify, and the property of 0xC306 is indicate. We write to descriptor 0x2902 in the two characteristics respectively:
Code: Select all
// client
AT+BLEGATTCWR=0,3,6,1,2
> // write 0x01
OK
// server
+WRITE:0,1,6,1,2,<0x01>,<0x00>
AT+BLEGATTCWR=0,3,7,1,2
> // write 0x02
OK
// server
+WRITE:0,1,6,1,2,<0x02>,<0x00>
Tips
- ESP-AT will internally convert wrong values written to descriptors to the right ones.
3.4.6 Server: Send Data to the Client
Once CCC value has been written, we can send data using notify and indicate.
Code: Select all
// server
AT+BLEGATTSNTFY=0,1,6,8
> //enter 123456789
OK
// client
+NOTIFY:0,3,6,8,12345678
// server
AT+BLEGATTSIND=0,1,7,9
> //enter aaabbbccc
OK
// client
+INDICATE:0,3,7,9,aaabbbccc
Re: ESP AT BLE can not enable notification or indication
Thank you for your help. I really appreciate that. I understood that I have to write the value of the CCC to enable indication or notification. My problem is just that it seems I am write the wrong values. For example:
Since
Code: Select all
//Frist example:
//Client
AT+BLEGATTCWR=0,4,1,1,2
> <0x00><0x02> //write 0x0002
OK
//Server
+WRITE:0,2,1,1,2,<0x01>,<0x00> //wrong value! It schould be <0x02>,<0x00>
//Second example:
//Client
AT+BLEGATTCWR=0,4,1,1,2
> <0x00><0x00> //write 0x0000
OK
//Server
+WRITE:0,2,1,1,2,<0x01>,<0x00> //wrong value! It schould be <0x00>,<0x00>
What I am doing wronge then?The target feature value written is CCC, and the AT will automatically correct the written value according to the target's prop.
Re: ESP AT BLE can not enable notification or indication
Little Update:
I found out that, if the characteristic got the property indication, the value will always be 0x02. If the characteristic got the property notification the value will always be 0x01. If the Characteristic got both of the properties the vaule will be 0x01. So on the one hand I can enable one of them, but on the other hand I can't disable it .
I found out that, if the characteristic got the property indication, the value will always be 0x02. If the characteristic got the property notification the value will always be 0x01. If the Characteristic got both of the properties the vaule will be 0x01. So on the one hand I can enable one of them, but on the other hand I can't disable it .
Re: ESP AT BLE can not enable notification or indication
You can try compiling AT firmware with the following library (
), if the characteristic got the property indication, the value will always be 0x02. If the characteristic got the property notification the value will always be 0x01. If the Characteristic got both of the properties the vaule will be 0x03.Who is online
Users browsing this forum: No registered users and 16 guests