BLE/NRF error

Posted on
Page
of 2
Prev
/ 2
  • no no no no no... writing does work!
    just the callback function onWrite() is not implemented
    I can both read and write / edit the value of certain characteristic, but could not call the onWrite() callback function
    In 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.

  • Using now GATTBrowser to check the service and the custom characteristics, look fine to me.


    5 Attachments

    • 2_services_ESP32.jpg
    • 3._characteristic.jpg
    • 4_characteristic_read_ESP32.jpg
    • 5_characteristics_write_read_ESP32.jpg
    • 1_device_ESP32.jpg
  • 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.

  • 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);
    
  • 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.

  • I can read it after writing, so I can read the value I wrote. Just write => read.

  • read Hello
    write world
    read world

    so write changes the value from Hello to world in my test, but the leds on D19 did not switch on and off.

  • Yes, yes, it is indeed this issue.

  • 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 too

    I 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

  • 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.

  • 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

  • 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

  • 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
     }
    >
    
  • Post a reply
    • Bold
    • Italics
    • Link
    • Image
    • List
    • Quote
    • code
    • Preview
About

BLE/NRF error

Posted by Avatar for SI_Cheng-Yun @SI_Cheng-Yun

Actions