-
• #27
Using now GATTBrowser to check the service and the custom characteristics, look fine to me.
5 Attachments
-
• #28
Check issue #1777 Improve ESP32 implementation for fixed and open issues.
Thanks. Not much BLE related there however, I see only
- NRF.updateServices() needs fixing issue 2292
- BLE/NRF error , check issue 2493, issue 2292
so I guess this patch mentioned above solves/helps with #2292 which is actually quite old and known
So it makes sense there is no info in the list about using BLE characteristics (writing callback + notifications) since nobody could try with NRF.setServices not working.
- NRF.updateServices() needs fixing issue 2292
-
• #29
but the event is not fired, or is something wrong with my test code?
digitalWrite(D19,0); function blink(duration){ digitalWrite(D19,0);setTimeout(()=>{digitalWrite(D19,0);},duration); } NRF.setServices({ 0x1901: { 0x1902: { value : "Hello", broadcast : true, readable : true, writable : true, notify : true, indicate: true, onWrite: (event) => { console.log("Got: ", event); blink(5000); } } } }); // edit Serial1.setConsole(1);
-
• #30
I can both read and write / edit the value of certain characteristic, but could not call the onWrite() callback function
Yes that is good, what I meant is that if you don't get the callback then you don't know what value was written so writing is not very useful.
-
• #31
I can read it after writing, so I can read the value I wrote. Just write => read.
-
• #32
read
Hello
writeworld
readworld
so write changes the value from Hello to world in my test, but the leds on D19 did not switch on and off.
-
• #33
Yes, yes, it is indeed this issue.
-
• #34
Thanks for looking into this!
You can force the console to stay on Serial1 even when connected with BLE with
Serial1.setConsole(1)
which really helps with debugging.Also
ESP32.setBLE_Debug(7)
can help to display extra info tooI looked and there is some code for handling writes there, but on trying the code above and writing I get:
Uncaught Error: Too much recursion - the stack is about to overflow Execution Interrupted
Is this what you see too? I'll have a look and see if I can figure out what's broken
-
• #35
Is this what you see too? I'll have a look and see if I can figure out what's broken
Yes, I see that too.
-
• #36
Well, that was a nightmare. Pretty much everything was broken.
But I have now fixed setServices, onWrite, and notifications/indications, so I think it should be ok if you try a 'cutting edge' build now
-
• #37
Hmm, seems to be a huge thing, still get this when writing
WARNING: Event:ESP_GATTS_WRITE_EVT gatts_if:4 WARNING: Event:ESP_GATTS_RESPONSE_EVT gatts_if:4 Uncaught Error: Too much recursion - the stack is about to overflow Execution Interrupted >
Edit: GIT_COMMIT: "3076d5133" ups this is not the latest commit
-
• #38
Now with the correct version it works - Many thanks, will close issue 2493
> >Event:ESP_GATTS_CONNECT_EVT gatts_if:4 Event:ESP_GATTS_CONNECT_EVT gatts_if:5 Event:ESP_GATTC_CONNECT_EVT gattc_if:3 gattc_event_handler: 40 Event:ESP_GAP_BLE_AUTH_CMPL_EVT Event:ESP_GATTS_MTU_EVT gatts_if:4 Event:ESP_GATTS_MTU_EVT gatts_if:5 Event:ESP_GATTS_READ_EVT gatts_if:5 Event:ESP_GATTS_RESPONSE_EVT gatts_if:5 Event:ESP_GATTS_READ_EVT gatts_if:4 Event:ESP_GATTS_RESPONSE_EVT gatts_if:4 Event:ESP_GATTS_WRITE_EVT gatts_if:4 Event:ESP_GATTS_RESPONSE_EVT gatts_if:4 Got: { "data": new Uint8Array([69, 115, 112, 114, 117, 105, 110, 111, 32]).buffer } >
-
• #39
👍👍👍
no no no no no... writing does work!
just the callback function
onWrite()
is not implementedI can both read and write / edit the value of certain characteristic, but could not call the
onWrite()
callback functionIn my conception, I should write / edit the value of characteristic A, and then my ESP32 call the
onWrite()
callback function to verify this value. If the value is valid, ESP32 will change characteristic B to readable mode.Just like some kind of encryption verification.