ChirpStack MQTT Forwarder应用
LoRa UDP Forwarder服务,默认是UDP数据,可以使用MQTT Forwarder转发服务,转换为MQTT数据。
默认的配置文件路径/etc/chirpstack-mqtt-forwarder.toml
修改chirpstack-mqtt-forwarder.toml配置文件内容,修改项目
server配置MQTT的服务端IP地址和端口
backend.semtech_udp中的bind选项是UDP Forwarder程序的转发地址
topic_prefix这是MQTT的主题前缀,建议修改
# Logging settings.
[logging]
# Log level.
#
# Valid options are:
# * TRACE
# * DEBUG
# * INFO
# * WARN
# * ERROR
# * OFF
level="info"
# Log to syslog.
#
# If set to true, log messages are being written to syslog instead of stdout.
log_to_syslog=false
# MQTT settings.
[mqtt]
# Topic prefix.
#
# ChirpStack MQTT Forwarder publishes to the following topics:
#
# * [Prefix/]gateway/[Gateway ID]/event/[Event]
# * [Prefix/]gateway/[Gateway ID]/state/[State]
#
# And subscribes to the following topic:
#
# * [Prefix/]gateway/[Gateway ID]/command/[Command]
#
# The topic prefix can be used to define the region of the gateway.
# Note, there is no need to add a trailing '/' to the prefix. The trailing
# '/' is automatically added to the prefix if it is configured.
topic_prefix="cn470_10"
# Use JSON encoding instead of Protobuf (binary).
#
# Note, only use this for debugging purposes.
json=true
# MQTT server (e.g. scheme://host:port where scheme is tcp, ssl or ws)
server="tcp://broker.emqx.io:1883"
# Connect with the given username (optional)
username=""
# Connect with the given password (optional)
password=""
# Quality of service level
#
# 0: at most once
# 1: at least once
# 2: exactly once
#
# Note: an increase of this value will decrease the performance.
# For more information: https://www.hivemq.com/blog/mqtt-essentials-part-6-mqtt-quality-of-service-levels
qos=0
# Clean session
#
# Set the "clean session" flag in the connect message when this client
# connects to an MQTT broker. By setting this flag you are indicating
# that no messages saved by the broker for this client should be delivered.
clean_session=false
# Client ID
#
# Set the client id to be used by this client when connecting to the MQTT
# broker. A client id must be no longer than 23 characters. If left blank,
# a random id will be generated by ChirpStack.
client_id=""
# CA certificate file (optional)
#
# Use this when setting up a secure connection (when server uses ssl://...)
# but the certificate used by the server is not trusted by any CA certificate
# on the server (e.g. when self generated).
ca_cert=""
# TLS certificate file (optional)
tls_cert=""
# TLS key file (optional)
tls_key=""
# Backend configuration.
[backend]
# Enabled backend.
#
# Set this to the backend that must be used by the ChirpStack MQTT Forwarder.
# Valid options are:
# * concentratord
# * semtech_udp
enabled="semtech_udp"
# Filters.
[backend.filters]
# Forward CRC ok.
forward_crc_ok=true
# Forward CRC invalid.
forward_crc_invalid=false
# Forward CRC missing.
forward_crc_missing=false
# DevAddr prefix filters.
#
# Example configuration:
# dev_addr_prefixes=["0000ff00/24"]
#
# The above filter means that the 24MSB of 0000ff00 will be used to
# filter DevAddrs. Uplinks with DevAddrs that do not match any of the
# configured filters will not be forwarded. Leaving this option empty
# disables filtering on DevAddr.
dev_addr_prefixes=[
]
# JoinEUI prefix filters.
#
# Example configuration:
# join_eui_prefixes=["0000ff0000000000/24"]
#
# The above filter means that the 24MSB of 0000ff0000000000 will be used
# to filter JoinEUIs. Uplinks with JoinEUIs that do not match any of the
# configured filters will not be forwarded. Leaving this option empty
# disables filtering on JoinEUI.
join_eui_prefixes=[
]
# ChirpStack Concentratord backend configuration.
[backend.concentratord]
# Event API URL.
event_url="ipc:///tmp/concentratord_event"
# Command API URL.
command_url="ipc:///tmp/concentratord_command"
# Semtech UDP backend configuration.
[backend.semtech_udp]
# ip:port to bind the UDP listener to.
#
# Example: 0.0.0.0:1700 to listen on port 1700 for all network interfaces.
# This is the listener to which the packet-forwarder forwards its data
# so make sure the 'serv_port_up' and 'serv_port_down' from your
# packet-forwarder matches this port.
bind="127.0.0.1:1700"
# Time fallback.
#
# In case the UDP packet-forwarder does not set the 'time' field, then the
# server-time will be used as fallback if this option is enabled.
time_fallback_enabled=false
# Gateway metadata configuration.
[metadata]
# Static key / value metadata.
[metadata.static]
# Example:
# serial_number="1234"
# Commands returning metadata.
[metadata.commands]
# Example:
# datetime=["date", "-R"]
# Executable commands.
[commands]
# Example:
# reboot=["/usr/bin/reboot"]
修改后,运行程序
systemctl start chirpstack-mqtt-forwarder
systemctl enable chirpstack-mqtt-forwarder
程序运行后,会自动连接到MQTT服务端,节点发数据后,可以在MQTT服务端看到。
记得要配置UDP Forwarder的global_conf.json配置文件中的server_address为127.0.0.1 。
以下是节点发送的数据,当前已经配置为JSON模式
客户端连接相同的MQTT服务端,订阅Topic为cn470_10/gateway/1172bdd0cd032a42/event/up
Topic: cn470_10/gateway/1172bdd0cd032a42/event/up
{
"phyPayload": "QA3UyQGABAACsP6Tt34h",
"txInfo": {
"frequency": 486300000,
"modulation": {
"lora": {
"bandwidth": 125000,
"spreadingFactor": 12,
"codeRate": "CR_4_5"
}
}
},
"rxInfo": {
"gatewayId": "1172bdd0cd032a42",
"uplinkId": 1656649496,
"rssi": -86,
"snr": 6.2,
"context": "MAXKWw==",
"crcStatus": "CRC_OK"
}
}
作者:SteveChen 创建时间:2024-09-14 17:15
最后编辑:SteveChen 更新时间:2024-09-27 10:24
最后编辑:SteveChen 更新时间:2024-09-27 10:24