I've forked this repository in order to make original one working with
latest version of protobufjs.
I am new to JS, so that feel free to review my code and correct if you think
thad shings could be done in better way.
I've make file reorganisation to be able to git clone
it to node_modules
directory easily.
#Original Readme
Encoder and Decoder nodes for Protocol Buffers. These wrap protobuf.js
Typical example flows would be
Input
MQTT input node -> Protocol Buffers Decoder Node -> Debug logging node
The Protocol buffers decoder node requires the following configuration
- file path to a .proto file to use for decode
- message type to decode
The output will be a Javascript object containing the decoded fields
Output
Injector node -> Protocol Buffers Encoder Node -> MQTT output node
The Protocol buffers decoder node requires the following configuration
- file path to a .proto file to use for encode
- message type to encode
The input to the encoder node must contain payload in JSON format suitable for encoding using the .proto message definition
e.g.
.proto file
message ApnConfig { optional string apn = 1; optional string username = 2; optional string password = 3; }
Injector JSON parameter
{ "apn" : "MyAPN", "username" : "MyUserName", "password" : "MyPassword" }
Node configuration would then contain the path to the .proto file and the message type would be ApnConfig.
The output to the MQTT output node will contain a byte array payload for transmission.