• Sorry for the delay...

    so far I have found that I can only send numbers 0-255 (is that 2 bytes?)

    0-255 is 1 byte. Something like 0x2a03 : [String(power)], will convert the value to a string of characters which will easily allow more data, but which will use far more space.

    How do I overcome the limitation?

    The easiest way is to use shifting to explicitly create 2 bytes. For example instead of 0x2a03 : [String(power)], do 0x2a03 : [power>>8, power], - you can now send up to 65535.

    0x2a03 : [power>>16,power>>8, power], will allow up to 16 million.

    Is there a tool to see how many bytes in total are getting sent, so that I know when I am approaching the limit?

    Yep - just use NRF.getAdvertisingData: http://www.espruino.com/Reference#l_NRF_getAdvertisingData

    Use it the same as setAdvertising but it gives you an array of the final data, and you can check the length of that array.

    Also read about using short UUID and not using the name to save on the data.

    Short UUID is what you're currently doing. You could just pack everything into one UUID though? That would save space:

    0xabcd : [power>>8, power,pulseHour>>8,pulseHour, etc], 
    

    I guess one option is to rotate the information sending, instead of sending all at once. I saw an example before, but cannot find it

    http://www.espruino.com/Reference#l_NRF_setAdvertising - about halfway down

    NRF.setAdvertising([
      {0x180F : [Puck.getBatteryPercentage()]}, // normal advertising, with battery %
      require("ble_ibeacon").get(...), // iBeacon
      require("ble_eddystone").get(...), // eddystone
    ], {interval:300});
    

    In your case:

    NRF.setAdvertising([
     { 0x2a03 : [String(power)],  0x2a04 : [String(pulseHour)] },
     { 0x2a05 : [String(pulseDay)], 0x180f : [Puck.getBatteryPercentage()]}] }
    ], {interval: 600,
        name: "PM \xE2\x9A\xA1"} 
    );
    
About

Avatar for Gordon @Gordon started