• Hi! Actually someone else had exactly this problem recently!

    The issue is that setServices sets the services that are available once you're connected to the device. There's another type of services - advertised services - that are broadcast to everyone even when not connected, and it's those that Web Bluetooth is looking for.

    It's actually in the second half of the setServices docs: https://www.espruino.com/Reference#l_NRF­_setServices

    Something like this should fix it:

    NRF.setServices({
      0x180F : { // Battery Service
        0x2A19: {  // Battery Level
          readable: true,
          notify: true,
          value : [Puck.getBatteryPercentage()]
    }}},{
      advertise: [ '180F' ]
    });
    

    Out of interest, any thoughts about where I could put some info on this so others are less likely to fall into the same trap :)

About

Avatar for Gordon @Gordon started