You are reading a single comment by @dave and its replies. Click here to read the full conversation.
  • Ahh - yes, that's a bit unfortunate... The extra services are advertised in the scan response, which gets overwritten when you use that last bit of code.

    The answer is yes, it is possible - but it's not very nice at the moment.

    Basically you can supply an array to setAdvertising, which will cause it to cycle through different advertisements: https://www.espruino.com/Reference#l_NRF­_setAdvertising

    The problem is that you need to specify all the data as arrays - so what you're currently doing (giving it the object) won't work. You'd have to manually make up the advertising packet yourself (you could use something like nRF Connect to read the packet, then just enter the bytes manually?).

    I hit this just a few days ago (I added the example code for iBeacon & setScanResponse literally just this week), but there wasn't a nice easy fix. I'll file an issue and will see if I can think of a nice way of getting around it... Maybe allowing something like this:

    NRF.setAdvertising([
    require("ble_ibeacon").get({
        uuid : beaconUUID,    // iBeacon uuid
        major : beaconMajor,  // optional
        minor : beaconMinor,  // optional
        rssi : -59            // optional RSSI at 1 meter distance in dBm
      }),
    {
        0x1815 : [button.single, button.long],
        0x180F : [metrics.battery],
        0x1809 : [metrics.temperature],
        0x181A : [metrics.light]
    }],{ interval : 375 });
    
  • Thanks Gordon, I didn't realise the services advertisement was part of the scan response rather than the 'advertisement' as such, but that makes sense now.

    I poked around in the source code to see if I could figure out how setAdvertising converts the object to an array, but my C fu is weak :)

    nRF Connect on my iPhone doesn't seem to display the raw scan response data, are you referring to the desktop version? If so, I'll have to buy a nordic dongle or wait to see if you come up with something in an update. In the meantime I'll live without the extra services advertisement.

    Thanks for your help!

    Incidentally if anyone reading this is struggling to understand how advertisements and scan responses fit together I found this article useful: http://www.argenox.com/a-ble-advertising­-primer/

About

Avatar for dave @dave started