node-red-contrib-mongoose-os-rpc
v0.1.0
Published
A node for calling functions via RPC on Mongoose OS enabled devices (ESP8266 etc.)
Downloads
12
Maintainers
Readme
node-red-contrib-mongoose-os-rpc
A node for calling functions via RPC on Mongoose OS enabled devices (ESP8266 etc.) in NodeRED
Overview
This node connects to a Mongoose OS enabled device, executes given function by its name (optionally passing arguments) then returns function's result (asynchronously).
The address property has the following format depending of the transport being used:
- http://deviceIpOrDnsName/rpc - when using HTTP transport
- ws://deviceIpOrDnsName/rpc - when using WebSocket transport
- mqtt://deviceIpOrDnsName/device_id - when using MQTT transport
The function can be specified dynamically via input message where topic is function's name and payload contains the arguments (JSON string or JSON object).
Error handling
To handle RPC related errors (timeouts, unsupported commands etc.) you need to put a Catch node in your flow. The payload of the Catch node will contain error's object:
{code: xyz, message: "specific error message"}
The code property maps to standard http error codes.
All transport errors are reported via node.error and will be recorded in NodeRED's log (i.e. they will not reach any Catch node).