• I can't find a way to write to a custom service/characteristic exposed on the Puck from Node-RED through EspruinoHub.

    However:

    • Writing from Node-RED to /ble/write/puck/nus/nus_tx through EspruinoHub works
    • Writing to the custom service/characteristic using nRF Connect app on an Android phone works

    The problem only appears when writing to the custom characteristic through EspruinoHub.
    It seems it's not related to Node-RED since the same problem appears also when the MQTT message is published using mosquitto_pub.

    Following the guidance in https://www.espruino.com/Puck.js+Node-RED ...:

    The format is /ble/write/de:vi:ce:ad:dr/service/characteristic, so you don't have to write to the Nordic UART on Puck.js. You can define your own services and write directly to those.

    ...and the guidance in http://www.espruino.com/Reference#l_NRF_setServices, this is the code I have on the Puck (first part unrelated (?), but adding for completeness):

    setInterval(() =>
        NRF.setAdvertising({
            0xFFFF: String(Math.round(Puck.light() * 1000) / 1000).split(""),
            0xFFFE: String(E.getTemperature()).split(""),
            0xFFFD: String(Puck.getBatteryPercentage()).split("")
        }, { interval: 5000 }), 60000
    );
    
    NRF.setServices({
        0xAAAA: {
            0xAAA0: {
                writable: true,
                onWrite: function (evt) {
                    LED1.set();
                }
            }
        }
    });
    

    And publishing to /ble/write/puck/0000aaaa00001000800000805f9b34fb/0000aaa000001000800000805f9b34fb yields:

    <Connect> de:vi:ce:ad:dr: Getting Service...
    <Connect> de:vi:ce:ad:dr: Disconnecting due to lack of use (after 30 secs)
    <Connect> de:vi:ce:ad:dr: Disconnecting.
    <Connect> de:vi:ce:ad:dr: Disconnected
    

    Even extending the CONNECTION_TIMEOUT to 30s and the "getting services" timeout to 15s didn't help.

    Any ideas?

    Is there some interplay between setAdvertising and setServices?
    Am I using the wrong format for specifying service/characteristic ID? (Tried short aaaa, long 0000aaaa00001000800000805f9b34fb, hex 0xaaaa, capitalized, non-capitalized, etc.).

    Environment:

    • Puck.js 1v90
    • EspruinoHub up to date
    • Node-RED 0.15.2
    • MQTT Broker is hbmqtt built into Home Assistant
    • All running on the same Raspberry Pi 3
About

Avatar for Ron @Ron started