• I had much of this working a while back but am starting a new project from scratch.

    To start back at step 0, I am just trying to advertise a couple of puck metrics and pick them up in Node-Red.

    Here is the puck code...

    var presses = 0;
    clearWatch();
    clearTimeout();
    clearInterval();
    
    setWatch(function() {
      presses++;
      console.log("Pressed");
      NRF.setAdvertising({
        manufacturer: 0x0590, 
        0x1811 : [presses],
        0x180F : [E.getBattery()],
        0x1809 : [Math.round(E.getTemperature())]
      });
    }, BTN, { edge:"rising", repeat:true, debounce:25 });
    
    
    // Interval to update advertising values
    setInterval(function() {
      NRF.setAdvertising({
        manufacturer: 0x0590, 
        0x1811 : [presses],
        0x180F : [E.getBattery()-1],
        0x1809 : [Math.round(E.getTemperature())]
      });
    }, 30000);    // 30 sec
    

    On the pi node-red flow I have very simple mqtt receivers and debug statements.

    The battery and temp are coming through just fine but I cannot get the presses 0x1811 to work.

    At first I subscribed to /ble/advertise/e9:1d:0b:37:51:d3/1811 which was not working.

    Then I read more closely in the instructions which said

    /ble/advertise/DEVICE/SERVICE - Raw service data (as a JSON Array of
    bytes) (if mqtt_advertise_service_data=true in config.json)

    So maybe my config.json had that turned off, which it did. I also saw in the config the ability to name services so I tried to put a name to 0x1811 but might be doing that wrong.

    I set these two changes from the default config.json.

    .
    .
      "// We can add our own custom advertising UUIDs here with names to help decode them":0,
      "advertised_services" : {
        "1811" : {
          "presses" : "level"
        }
      },
    .
    .
      "// Send /ble/advertise/ad:dr:es:ss/uuid raw service data":0,
      "mqtt_advertise_service_data": true,
    

    I know I am doing something stupid wrong and I used to have this all working fine.

    Can anyone spot my error?

    Thanks

  • Hi, One thing I do notice is:

      NRF.setAdvertising({
        manufacturer: 0x0590,  //<=============================
        0x1811 : [presses],
        0x180F : [E.getBattery()-1],
        0x1809 : [Math.round(E.getTemperature())]
      });
    

    The manufacturer mine is for manufacturerData and if used should be in the second argument. I'd just remove it as it could be causing issues.

    Also, I think you changed the wrong thing on advertised_services... The default example is:

      "advertised_services" : {
        "ffff" : {
          "name" : "level"
        }
      },
    

    and I think you wanted to do:

      "advertised_services" : {
        "1811" : {
          "name" : "presses"
        }
      },
    

    Looks like you changed name to presses rather than level :)

  • Awesome, that worked. Both fixes.

    I can't tell you how much I appreciate this help.

    I think I did the appropriate amount of trying/learning/failing on my own but started running out of things to try.

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

Adding recognized services to Espruino Hub - config.json

Posted by Avatar for HeneryH_(Henery_Hawk) @HeneryH_(Henery_Hawk)

Actions