-
• #2
I usually use EspruinoHub to bridge from MQTT.
However one of the steps to set up Noble (the lib that contrib-blue-uart probably uses) is to run the command:
sudo setcap cap_net_raw+eip $(eval readlink -f `which node`)
Have you done that? It might help? If
node
doesn't exist you might have to change it towhich nodejs
-
• #4
Either way will work. contrib-blue-uart is a less Espruino-specific way that doesn't require a separate service, but EspruinoHub will be able to pick up advertising data and report it back via MQTT.
Info on using EspruinoHub to send commands to Puck.js here: http://www.espruino.com/Puck.js+Node-RED
-
• #6
Ahh - I'm afraid that functionality isn't built in to EspruinoHub yet.
You might be able to do a write to
/ble/write/_address_/nus/nus_tx
followed by a write (contents don't matter) to/ble/read/_address_/nus/nus_rx
after a delay, and then listen on/ble/data/_address_/nus/nus_rx
but that would only return the last 18 characters or so of response (plus some formatting characters).To make it better you could ensure you send
"\x10print(your_function())"
(that's character code 16 at the start) - which will ensure that the data you receive is only the data your function returned.However in this case, you're probably better off using
contrib-blue-uart
- did you get it working?The advice above (
"\x10print(your_function())"
) will still help you though. -
• #7
Hi @Gordon,
I am using https://www.npmjs.com/package/node-red-contrib-ble-uart
Here on the sample workflow there is a On/Off input to BLE followed by ToString function dumped on the output.I cannot make it scanning even with the advises above. Once done, how can I send the command to the specific Puck with xx:xx:xx:xx:xx:xx address ?
Thanks!
-
• #8
I've just tried node-red-contrib-ble-uart and node-red-contrib-ble, and I can't make either of them work properly (although node-red-contrib-ble actually looks more promising).
Not sure what to suggest really - you could contact the authors of those modules/post on their GitHub pages? Puck.js is a standard Nordic UART device, so they should definitely be able to work.
-
• #10
It shouldn't be too hard to add - are you interested in trying to do it yourself?
I'd:
- Add an
eval
function toconnect
(https://github.com/espruino/EspruinoHub/blob/master/lib/connect.js#L39) that mashes together the read and write functionality (connect, listen for notifications, write, then wait a bit and return anything returned from notifications). - Add a check for
eval
in the path to https://github.com/espruino/EspruinoHub/blob/master/lib/mqttclient.js#L53 and make that call your eval function, and then send the result of that back as something like/ble/address/result
.
- Add an
Hi @Gordon,
How can Puck's UART service be connected from node-red ?
I have installed https://www.npmjs.com/package/node-red-contrib-ble-uart and created a sample workflow as suggested, but Puck does not appear. Any thoughts ?
Thank you!