找回密码
 立即注册
搜索
查看: 930|回复: 0

将 chirpstack-gateway-bridge 部署到网关

[复制链接]

266

主题

0

回帖

1119

积分

管理员

积分
1119
发表于 2023-12-26 00:18:29 | 显示全部楼层 |阅读模式

下载

根据网关选择,这里下载 ARMv7 指令集的二进制程序

https://artifacts.chirpstack.io/downloads/chirpstack-gateway-bridge/chirpstack-gateway-bridge_3.14.3_linux_armv7.tar.gz

配置

从 Ubuntu 服务器中找到 apt 安装时自动创建的配置文件。

基本配置

# Gateway backend configuration.
[backend]
# Backend type.
type="semtech_udp"

  # Semtech UDP packet-forwarder backend.
  [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.
  udp_bind = "0.0.0.0:1700"

# Integration configuration.
[integration]
# Payload marshaler.
#
# This defines how the MQTT payloads are encoded. Valid options are:
# * protobuf:  Protobuf encoding
# * json:      JSON encoding (easier for debugging, but less compact than 'protobuf')
marshaler="protobuf"

  # MQTT integration configuration.
  [integration.mqtt]
  # Event topic template.
  event_topic_template="gateway/{{ .GatewayID }}/event/{{ .EventType }}"

  # Command topic template.
  command_topic_template="gateway/{{ .GatewayID }}/command/#"

  # MQTT authentication.
  [integration.mqtt.auth]
  # Type defines the MQTT authentication type to use.
  #
  # Set this to the name of one of the sections below.
  type="generic"

    # Generic MQTT authentication.
    [integration.mqtt.auth.generic]
    # MQTT server (e.g. scheme://host:port where scheme is tcp, ssl or ws)
    server="tcp://183.171.15.181:1883"

    # Connect with the given username (optional)
    username=""

    # Connect with the given password (optional)
    password=""

日志配置

[general]
# debug=5, info=4, warning=3, error=2, fatal=1, panic=0
log_level=4

# Log to syslog.
#
# When set to true, log messages are being written to syslog.
log_to_syslog=true

查看日志方法:

logread -f -e chirpstack

安装

安装脚本

#!/bin/sh

if [ -f /etc/init.d/lora-bridge ] 
then 
  /etc/init.d/lora-bridge stop
  /etc/init.d/lora-bridge disable
fi

cp chirpstack-gateway-bridge /usr/sbin/
chmod +rx /usr/sbin/chirpstack-gateway-bridge
cp lora-bridge /etc/init.d/
chmod +rx /etc/init.d/lora-bridge
mkdir -p /etc/chirpstack-gateway-bridge
cp chirpstack-gateway-bridge.toml /etc/chirpstack-gateway-bridge/
chmod +r /etc/chirpstack-gateway-bridge/chirpstack-gateway-bridge.toml

/etc/init.d/lora-bridge enable
/etc/init.d/lora-bridge start

服务脚本

注意,以下代码无效(仅做记录):

#!/bin/sh /etc/rc.common

START=98
STOP=1

start()
{
    echo service chirpstack-gateway-bridge start
    /usr/sbin/chirpstack-gateway-bridge &
}

stop()
{
    echo service chirpstack-gateway-bridge stop
    bridge_pid=$( ps -w | grep chirpstack-gateway-bridge | grep -v grep | awk '{print $1}' 2>/dev/null )
    if [ -n "$bridge_pid" ];then
        kill $bridge_pid > /dev/null 2>&1
    fi
}

使用前边的 start()、stop() 的形式创建的服务只能手动启动运行,不能启动时自动运行,查了很久没弄明白。而网关中的其他一些服务比如 lora 就可以正常自启动,不知是否与目标程序有关。

以下代码可用:

#!/bin/sh /etc/rc.common

START=98
STOP=1
USE_PROCD=1
PROG=/usr/sbin/chirpstack-gateway-bridge

start_service () {
    echo service chirpstack-gateway-bridge start
    procd_open_instance
    procd_set_param command "$PROG"
    procd_close_instance
}

stop_service() {
    echo service chirpstack-gateway-bridge stop
}

配置网关

通常在网关的 WebUI 上将 lora 的 server address 改为 localhost 即可。


您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

Archiver|手机版|小黑屋|棱讯科技 ( 粤ICP备2024228160号-2|粤公网安备44030002003510号 )

GMT+8, 2024-7-27 18:29 , Processed in 0.014218 second(s), 3 queries , Redis On.

Powered by Discuz! X3.5

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表