setAdvertising: Multiple packets Issue

Posted on
  • Hi,

    I'm trying to use a collection of pucks as both iBeacons and to report sensor information. I use them to automate lights, heating and track our position in the house. My implementation is rather hacky at the moment. I'm trying to refactor the code but I'm struggling to utilise setAdvertising as shown in the examples across the documentation.

    In the two examples shown below I'm led to believe I can send both iBeacon and sensor readouts in sequential packets.

    NRF.setAdvertising([
      {0x180F : [Puck.getBatteryPercentage()]}, // normal advertising, with battery %
      require("ble_ibeacon").get(...), // iBeacon
      require("ble_eddystone").get(...), // eddystone
    ],{interval:500});
    
    NRF.setAdvertising([
      require("ble_ibeacon").get(...),
      require("ble_eddystone").get(...),
      {} // this will add a 'normal' advertising packet showing name/etc  
      ], {interval:100});
    

    I'm using Noble on a RPi to pick up the broadcasts and the reason I post both examples is because the first does not work for me at all. If any packet exists before the iBeacon package then I don't seem to pick anything up.

    I have more success with the second example code but Noble only seems to pick up the iBeacon broadcast and not the temperature. If I drop the iBeacon require then the temperature broadcast is picked up as expected.

    The actual code I want to run is a little more involved, and didn't work, which led me to use the basic examples exactly as shown above just to make sure I was on the right track, but I can't get them to work. To be clear I've limited the code to exactly the code above and am having no success.

    Am I missing something? Really I'm looking for reassurance that something isn't broken at a deeper level than I can fix/understand. If it's my setup then I can investigate further but fear at this stage I might be wasting my time.

    Deeply greatful to anyone who replies or has any ideas of something I can try.

    Thanks,

    Nic

  • Hi! Please can you try flashing one of the 'cutting edge' builds of Espruino from http://www.espruino.com/binaries/travis/master/ and see if you have any more success?

    I noticed something similar a week or two ago and what it seems was happening was that Espruino was skipping over one advertising message each time. It worked if you had 3 like the example (or an odd number), but if you had 2 (or an even number) then it'd continually skip over the even-numbered messages.

    It's now fixed and it'll be in 2v02 when that's released, so if you had 2v01 or before it'd have the problem.

  • Hi Gordon,

    Typically my tests probably always included an even number of messages. I flashed to .69 and it works now as expected.

    Thank you for your help!

    Nic

  • Hi Gordon,

    I was sure this was working... I've just done some code tweaks and found it to be unreliable again. I flashed to the newest edge build in case further issues had been rectified but alas I can't get it to work.

    Here's my code:

    function AdvertiseData(Interval) {
    	NRF.setAdvertising([require("ble_ibeacon").get({
              uuid : UUID, // iBeacon UUID
              major : 0x0001, // optional
              minor : 0x0001, // optional
              rssi : -79 // optional RSSI at 1 meter distance in dBm
            })],{manufacturer: 0x0590, manufacturerData:[SensorID, Light, Temperature, Battery, ActionID, Active_Press_Action, Stuck], interval:Interval});
    

    Noble detects the iBeacon as the manufacturer data and the array of data is never picked up. If I pad it with another value preceeding the iBeacon like so:

    function AdvertiseData(Interval) {
    	NRF.setAdvertising([{0x180F : [0]},
            require("ble_ibeacon").get({
              uuid : UUID, // iBeacon UUID
              major : 0x0001, // optional
              minor : 0x0001, // optional
              rssi : -79 // optional RSSI at 1 meter distance in dBm
            })],{manufacturer: 0x0590, manufacturerData:[SensorID, Light, Temperature, Battery, ActionID, Active_Press_Action, Stuck], interval:Interval});
    
    }
    

    Noble picks up the array of values but the iBeacon isn't working.

    Any ideas?

    Thanks

    Nic

  • Fri 2019.04.19

    Hello Nic, would you please post for Gordon, the results of process.env as there have been several changes with 'cutting edge' builds of Espruino, and a month has elapsed since post #4.

    This will save time not having intermediate back-n-forth 'what version' confirmations.

  • Nic did say he'd tried the absolute latest build as of his post...

    You don't have the version of your code that worked before when you posted everything was fine do you?

    You'd expect that:

    NRF.setAdvertising([require("ble_ibeacon").get(...)],
       {manufacturer: 0x0590, manufacturerData:[...]});
    

    Would only do iBeacon, because require("ble_ibeacon").get is supplying binary data which can't be modified to include the manufacturer data. The second option should work though - I don't have a device here to test with so I'm not sure what to suggest, but maybe see if adding more advertising packet types changes things - and try something else to debug it, like nRF connect on a phone

  • Hi Gordon. Thank for the reply.

    I had already tried adding more packets and varying the order of things but didn't have any success. It was a bit of a frantic day but I am pretty certain my changes were minor and unrelated to the advertising/iBeacon code.

    Nonetheless, I do have that version. With a clear mind I'll have another go and see if I can get to the bottom of it.

    I was sure this code was and had been runnning correctly up until I re-uploaded the code. Very strange.

    I'll let you know how I get on.

    Thanks,

    Nic

  • Hi Gordon,

    It turns out I'd make a mistake. No issue to see here!

    Thanks!

    Nic

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

setAdvertising: Multiple packets Issue

Posted by Avatar for Nic @Nic

Actions