3.3.0 • Published 1 year ago

@mschaeffler/node-red-lora v3.3.0

Weekly downloads
-
License
LGPL-2.1
Repository
github
Last release
1 year ago

@mschaeffler/node-red-lora

Five nodes to send and receive LoRaWan messages via a gateway via the Semtech UDP protocol.

image of example flow

Install

$ npm install @mschaeffler/node-red-lora

Usage

By combining this five nodes, you can receive and send LoRaWan messages via a compatible gateway.

lora server

This node is a UDP server to communicate with LoRa gateways via the SEMTECH protocol.

Input

msg.typedescription
payloadobjectencoded txpk object generated py lora encoder.

Outputs

tx
msg.typedescription
payloadobjectreceived message to be processed by lora decoder.
macstringmac of the gateway.
stat
msg.typedescription
payloadobjectstatistical data from gateway.
macstringmac of the gateway.

Parameters

configtypedescription
UDP Portnumberport at which the server receives messages from the gateway.

lora decoder

This node decodes a LoraWan message received by lora server. It also generates messages to be sent to the end node in case of

  • confirmed messages: the corresponding acknowledgment
  • a message for this node from the send queue (s. lora send).

By this the downlink messages can be timed to be sent in the RX1 receive window of the LoRa end node.

Input

msg.typedescription
payloadobjectlora message received by lora server.

Outputs

decoded payload
msg.typedescription
topicstringname of the end node from lora keys.
payloadobjectdecoded message to be further processed by lora check FC.
timeoutnumbertimeout, if present in lora keys for this node.
{
    "rxpk": {                    // data from lora server
        "tmst": 501680883,
        "chan": 0,
        "rfch": 1,
        "freq": 868.1,
        "stat": 1,
        "modu": "LORA",
        "datr": "SF7BW125",
        "codr": "4/5",
        "lsnr": 10.3,
        "rssi": -67,
        "size": 23,
        "data": "...",
        "time": 1643556838991
    },
    "device_address": "123456ab",
    "frame_count": 4592,
    "port": 10,
    "mtype": "Confirmed Data Up",
    "confirmed": true,           // confirmed uplink?
    "type": "FooType",           // type of the lora node from lorawan-keys
    "name": "FooBar",            // name of the lora node from lorawan-keys
    "data": [ 0, 0 ]             // payload of the lora message
}
unknown sender
msg.typedescription
payloadobjectmessages from unkown end nodes.
send message for encoder
msg.typedescription
payloadobjectmessage from send queue to be encoded by lora encoder.

Parameters

configtypedescription
LoRa Keyslorawan-keysconfiguration node to define the end nodes.
TX-delaynumberdelay in µs for a downlink message (RECEIVE_DELAY1 in LoRa); possibly needs some tweaking.

lora encoder

This node encodes a LoraWan message.

A local filesystem context store called storeInFile is needed to store the internal data.

Input

msg.typedescription
payloadobjectlora message to be sent; normally from lora decoder, send message for encoder.
framecounternumberset frame counter default value from versions <2.0.0; this default value wil be active until Node-RED will be restarted.
framecounterobjectset frame counters with value from persistent memory.

Outputs

encoded payload
msg.typedescription
payloadobjectencoded message for lora sender.
frame counters for persistence
msg.typedescription
payloadnumberframe counters for the different lora nodes for persistent storage.

Parameters

configtypedescription
LoRa Keyslorawan-keysconfiguration node to define the end nodes.
TX-Powernumbertransmit power for the gateway.

lora check FC

This node checks the frame counter (FC) of a LoraWan message.

It recognizes this situations:

  • first message received: ok
  • FC 0: ok, startup of end node
  • FC increased by one: ok
  • FC rollover: ok
  • FC increased by more then one: ok + error message missing frame
  • FC the same as last valid one: duplicate message
  • anything else: error merssage, LoRa message is discared

Input

msg.typedescription
topicstringname of the end node from lora keys.
payloadobjectlora message decoded by lora decoder.

Outputs

checked lora message
msg.typedescription
topicstringname of the end node from lora keys.
payloadobjectchecked ok message ready for node specific payload decoder.
duplicate message
msg.typedescription
topicstringname of the end node from lora keys.
payloadobjectmessage in case of a reuse of the last valid farme counter value.
error message
msg.typedescription
topicstringsubject of the error message.
payloadstringerror message for logging.
loraobjectlora msg that caused the error message.
counters
msg.typedescription
payload.oknumberNumber of ok messages.
payload.noknumberNumber of error messages.
payload.dupnumberNumber of duplicate messages.
payload.misnumberNumber of missing messages.

lora send

This node puts a LoraWan message into the send queue. The send queue is stored in the flow context sendqueue.

Input

msg.typedescription
payloadbyte arraylora payload to be sent; as an array of bytes or as a Buffer.
topicstringname of the LoRa end node as in LoRa Keys.

Parameters

configtypedescription
LoRa Keyslorawan-keysconfiguration node to define the end nodes.

lora keys

This configuration node stores data about the LoRa end nodes.

Parameters

configtypedescription
LoRa-Keysobjectconfig data about the end nodes.
{
    <device address in lowercase hex>: {
        "nsw": "<LoRa NwkSKey>",
        "asw": "<LoRa AppSKey>",
        "type": "<Type of the node for further processing>",
        "name": "<Name of the node>",
        "timeout": <Timeout value for further processing, optional>;
    },
    "123456ab": {
        "nsw": "0123456789abcdef0123456789abcdef",
        "asw": "0123456789abcdef0123456789abcdef",
        "type": "FooType",
        "name": "FooBar",
        "timeout": 3600
    },
    ...
}

Example Flow

example flow

Author

Mathias Schäffler

License

LGPL-2.1

3.3.0

1 year ago

3.2.3

1 year ago

3.2.2

1 year ago

3.2.1

1 year ago

3.2.0

2 years ago

3.1.1

2 years ago

3.1.0

2 years ago

3.0.1

2 years ago

2.1.4

2 years ago

2.1.3

2 years ago

2.1.2

2 years ago

2.1.1

3 years ago

2.1.0

3 years ago

2.0.1

3 years ago

1.4.0

3 years ago

2.0.0

3 years ago

1.3.1

3 years ago

1.3.0

3 years ago

1.2.7

3 years ago

1.2.6

3 years ago

1.2.5

3 years ago

1.2.4

3 years ago