BLE connection counter

Posted on
  • Hi,

    I tried to find a way to count the number of connections made via BLE. Is there an easy way to accomplish that?

    Thanks
    Jens

  • From which side - central or peripheral?
    If you're the central you are the one who initiates the connection, so you should be able to increment a counter when this happens.

    EDIT:
    From peripheral side there are events for connect and disconnect:
    https://www.espruino.com/Reference#l_NRF­_connect
    https://www.espruino.com/Reference#l_NRF­_disconnect

    This example will flash the green LED on connect and the red on disconnect:

    NRF.on('connect',()=>{
      digitalPulse(LED2,1,200);
    });
    NRF.on('disconnect',()=>{
      digitalPulse(LED1,1,200);
    });
    

    It's easy to try with just the WebIDE as connecting central.

  • Thanks a lot. Will try that.

  • Thanks, that works perfect.

  • Post a reply
    • Bold
    • Italics
    • Link
    • Image
    • List
    • Quote
    • code
    • Preview
About

BLE connection counter

Posted by Avatar for user71506 @user71506

Actions