In IoT application development, LoRaWAN technology has attracted much attention due to its low power consumption and long-distance transmission. Chirpstack, as one of the most popular LoRaWAN servers, integrates with Node-RED to provide us with powerful IoT application development capabilities. This article will introduce in detail how to use the Chirpstack node in Node-RED, especially the application of the two important nodes Device Event and Device Downlink.
Ⅰ. Overview of Chirpstack nodes
1. Node type
Node-RED provides ChirpStack related nodes. This article introduces the @chirpstack/node-red-contrib-chirpstack node package, which mainly includes the following two categories:
(1) device event node: used to decode and filter MQTT events
(2) device downlink node: used to add device downlink load to the downlink queue of the specified devEUI device through the ChirpStack API
2. Configuration requirements
Before using the Chirpstack node, you need to ensure that:
(1) Node-RED has been correctly installed
(2) The Chirpstack server has been configured

Ⅱ. Detailed explanation of Device Event node
1. Functional description
The device event node is an event trigger node, mainly used to decode and filter MQTT events, and is usually used in conjunction with the mqtt in node. The following event types are supported:
Uplink: triggered when the device sends data to the network
Join: triggered when the device first joins the LoRaWAN network
Status: device status update event, such as connection status change
Ack (of confirmed downlink): triggered when the device confirms receiving a downlink message
Tx Ack (of downlink transmission): triggered when the device confirms receiving a downlink packet from the gateway
Error: triggered when an error occurs in the device, such as communication failure
2. Configuration steps
(1) Add the mqtt in node to the process
(2) Configure the MQTT subscription topic, standard format: application/+/device/+/event/+
(3) Add the device event node and connect it to the mqtt in node
(4) Configure the event filter, here we choose uplink for deivce event
(5) Add a debug to facilitate debugging and viewing
The process is as follows:

The mqtt in node configuration is as follows:

3. Output message format
When the LoRaWAN node device sends a message:

Ⅲ. Detailed explanation of Device Downlink node
1. Functional description
The device downlink node is used to send data to the node device through the Chirpstack API. The message will be added to the queue of ChirpStack and wait for the node device to receive it. This function can be used to send response data, send control commands, update device configuration, and trigger device actions.
2. Configuration steps
(1) Add the device downlink node to the process
(2) Configure the ChirpStack server connection:
Server: Connect to the ChirpStack server, the default port is 8080
API Token: Find API Keys in the Tenant option of the ChirpStack management page, click Add API Key to generate and copy
(3) Connect the device downlink node to the function node to process the device response
The process is as follows:

The downlink node configuration is as follows:

3. Input message format
The content of the uploaded information is parsed through the function and input into the downlink node. The function content is as follows:

return {

    devEui: msg.payload.deviceInfo.devEui,

    fPort: msg.payload.fPort,

    confirmed: false,

    payload: Buffer.from(msg.payload.data, 'base64').toString('hex')

}

IV. Summary
Through the above configuration, a data echo case can be completed, and the uploaded data can be returned in the original path. The test was carried out through our product E78-868LN22S. The results are as follows. The returned information is the same as the sent information.

The overall workflow is:
1. The device event node receives the device uplink data
2. The function node processes the data and constructs the downlink message
3. The device downlink node sends the message back to the device
4. The device receives the original data echo