Avatar for HeneryH_(Henery_Hawk)

HeneryH_(Henery_Hawk)

Member since Sep 2020 • Last active Nov 2021
  • 8 conversations
  • 25 comments

Most recent activity

  • in General
    Avatar for HeneryH_(Henery_Hawk)

    Re:
    Advertising

    Data that is received via bluetooth advertising will be relayed over
    MQTT in the following format:

    /ble/presence/DEVICE - 1 or 0 depending on whether device has been seen or not
    /ble/advertise/DEVICE - JSON for device's broadcast name, rssi and manufacturer-specific data (if mqtt_advertise=true in config.json -the default)
    /ble/advertise/DEVICE/manufacturer/COMPA­NY - Manufacturer-specific data (without leading company code) encoded in base16. To decode use var data = Buffer.from(msg.payload, 'hex'); (if mqtt_advertise_manufacturer_data=true in config.json - the default)
    /ble/advertise/DEVICE/rssi - Device signal strength
    /ble/advertise/DEVICE/SERVICE - Raw service data (as a JSON Array of bytes) (if mqtt_advertise_service_data=true in config.json)
    /ble/advertise/DEVICE/PRETTY or /ble/PRETTY/DEVICE - Decoded service data based on the decoding in attributes.js
        1809 decodes to temp (Temperature in C)
        180f decodes to battery
        feaa decodes to url (Eddystone)
        2a6d decodes to pressure (Pressure in pa)
        2a6e decodes to temp (Temperature in C)
        2a6f decodes to humidity (Humidity in %)
        ffff decodes to data (This is not a standard - however it's useful for debugging or quick tests)
    /ble/json/DEVICE/UUID - Decoded service data (as above) as JSON, eg /ble/json/DEVICE/1809 => {"temp":16.5} (if mqtt_format_json=true in config.json - the default)
    /ble/advertise/DEVICE/espruino - If manufacturer data is broadcast Espruino's manufacturer ID 0x0590 and it is valid JSON, it is rebroadcast. If an object like {"a":1,"b":2} is sent,
    /ble/advertise/DEVICE/a and /ble/advertise/DEVICE/b will also be sent. (A JSON5 parser is used, so the more compact {a:1,b:2} is also valid).
    

    I have multiple devices and would like to register for messages from any of them. Sometimes I take one to my Mom's house where one is in use for her to have a panic button that sends me an SMS when she presses it. I have a lab setup at home here. I have another one etc etc.

    Rather than having to change the ID for each environment it would be nice to register for any messages coming from manufacturer ID == x.

    Is it correct that that isn't available using the current broadcasting/registration model?

  • in Puck.js, Pixl.js and MDBT42
    Avatar for HeneryH_(Henery_Hawk)

    p.s. I have done both a) most of the logic/programming/timers in the puck.js code and b) the logic/program/timers in Node-Red.

    This code version is where nearly all of the logic is one in Node-Red.

    can make a new thread if it gets meaty. Pros/cons?

  • in Puck.js, Pixl.js and MDBT42
    Avatar for HeneryH_(Henery_Hawk)

    This seems pretty basic.

    If I save a "program" to flash, will it execute again to reload the functions and watches if the battery is changed?

    Thanks

    var presses = 0;
    clearWatch();
    clearTimeout();
    clearInterval();
    
    flashingLedInterval=0;
    
    setWatch(function() {
      presses++;
      console.log("Pressed");
      NRF.setAdvertising({
        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({
        0x1811 : [presses],
        0x180F : [E.getBattery()],
        0x1809 : [Math.round(E.getTemperature())]
      });
    }, 30000);    // 30 sec
    
    function startFlashing(pin, period) {
      var on = false;
      flashingLedInterval = setInterval(function() {
        on = !on;
        digitalWrite(pin, on);
      }, period);
    }
    
    function stopFlashing(pin) {
      clearInterval(flashingLedInterval);
      digitalWrite(pin, off);
    }
    
  • in Interfacing
    Avatar for HeneryH_(Henery_Hawk)

    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.

  • in Interfacing
    Avatar for HeneryH_(Henery_Hawk)

    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

  • in Projects
    Avatar for HeneryH_(Henery_Hawk)

    @Gordon not sure how authoritative this is...

    https://randomnerdtutorials.com/upgrade-­from-node-red-contrib-ui-to-node-red-das­hboard/
    Upgrade from Node-RED-Contrib-UI to Node-RED-Dashboard

    [NEW GUIDE] Learn how to use Node-RED Dashboard with your Raspberry Pi

    If you followed the Build a Home Automation System for $100 course prior to August 27 2016, you know that I’ve used Node-RED-Contrib-UI to build the user interface for the home automation system. But, sadly the guy that developed the Node-RED-Contrib-UI will no longer be able to update that package.

    Luckily, the Node-RED team announced that Node-RED-Contribu-UI will continue to be developed under a new name: Node-RED-Dashboard.

Actions