Skip to content

Commit 07cdab4

Browse files
committed
Update components. Add MQTT config wizard to gateway-config.
1 parent b907c02 commit 07cdab4

File tree

6 files changed

+94
-34
lines changed

6 files changed

+94
-34
lines changed

layers/chirpstack/meta-chirpstack/recipes-chirpstack/chirpstack-gateway-bridge/chirpstack-gateway-bridge/chirpstack-gateway-bridge.toml

Lines changed: 35 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -21,17 +21,17 @@ log_to_syslog=true
2121
# Backend type.
2222
type="concentratord"
2323

24-
# ChirpStack Concentratord backend.
25-
[backend.concentratord]
24+
# ChirpStack Concentratord backend.
25+
[backend.concentratord]
2626

27-
# Check for CRC OK.
28-
crc_check=true
27+
# Check for CRC OK.
28+
crc_check=true
2929

30-
# Event API URL.
31-
event_url="ipc:///tmp/concentratord_event"
30+
# Event API URL.
31+
event_url="ipc:///tmp/concentratord_event"
3232

33-
# Command API URL.
34-
command_url="ipc:///tmp/concentratord_command"
33+
# Command API URL.
34+
command_url="ipc:///tmp/concentratord_command"
3535

3636

3737
# Integration configuration.
@@ -43,28 +43,35 @@ type="concentratord"
4343
# * json: JSON encoding (easier for debugging, but less compact than 'protobuf')
4444
marshaler="protobuf"
4545

46-
# MQTT integration configuration.
47-
[integration.mqtt]
48-
# Event topic template.
49-
event_topic_template="gateway/{{ .GatewayID }}/event/{{ .EventType }}"
46+
# MQTT integration configuration.
47+
[integration.mqtt]
48+
# Event topic template.
49+
event_topic_template="gateway/{{ .GatewayID }}/event/{{ .EventType }}"
5050

51-
# Command topic template.
52-
command_topic_template="gateway/{{ .GatewayID }}/command/#"
51+
# Command topic template.
52+
command_topic_template="gateway/{{ .GatewayID }}/command/#"
5353

54-
# MQTT authentication.
55-
[integration.mqtt.auth]
56-
# Type defines the MQTT authentication type to use.
57-
#
58-
# Set this to the name of one of the sections below.
59-
type="generic"
54+
# MQTT authentication.
55+
[integration.mqtt.auth]
56+
# Type defines the MQTT authentication type to use.
57+
type="generic"
6058

61-
# Generic MQTT authentication.
62-
[integration.mqtt.auth.generic]
63-
# MQTT server (e.g. scheme://host:port where scheme is tcp, ssl or ws)
64-
server="tcp://127.0.0.1:1883"
59+
# Generic MQTT authentication.
60+
[integration.mqtt.auth.generic]
61+
# MQTT server (e.g. scheme://host:port where scheme is tcp, ssl or ws)
62+
server="tcp://127.0.0.1:1883"
6563

66-
# Connect with the given username (optional)
67-
username=""
64+
# Connect with the given username (optional)
65+
username=""
6866

69-
# Connect with the given password (optional)
70-
password=""
67+
# Connect with the given password (optional)
68+
password=""
69+
70+
# CA certificate file (optional)
71+
ca_cert=""
72+
73+
# mqtt TLS certificate file (optional)
74+
tls_cert=""
75+
76+
# mqtt TLS key file (optional)
77+
tls_key=""

layers/targets/meta-raspberrypi/recipes-core/gateway-config/files/gateway-config.sh

Lines changed: 59 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -313,7 +313,7 @@ do_set_concentratord() {
313313
}
314314

315315
do_prompt_concentrator_reset_pin() {
316-
# $1 concentratord version
316+
# $1 concentratord version
317317
PIN=$(dialog --inputbox "Please enter the GPIO pin to which the concentrator reset is connected: " 8 60 \
318318
3>&1 1>&2 2>&3)
319319
RET=$?
@@ -325,9 +325,9 @@ do_prompt_concentrator_reset_pin() {
325325
}
326326

327327
do_set_concentrator_reset_pin() {
328-
# $1 concentratord version
329-
# $2 reset pin
330-
sed -i "s/reset_pin=.*/reset_pin=$2/" /etc/chirpstack-concentratord/$1/global.toml
328+
# $1 concentratord version
329+
# $2 reset pin
330+
sed -i "s/reset_pin=.*/reset_pin=$2/" /etc/chirpstack-concentratord/$1/global.toml
331331
}
332332

333333
do_copy_concentratord_config() {
@@ -404,7 +404,7 @@ do_restart_chirpstack_ns() {
404404
}
405405

406406
do_edit_chirpstack_concentratord_config() {
407-
FUN=$(dialog --title "Edit ChirpStack Concentratord config" --menu "Select shield:" 15 60 3 \
407+
FUN=$(dialog --title "Edit ChirpStack Concentratord config" --menu "Edit config file:" 15 60 3 \
408408
1 "General configuration" \
409409
2 "Beacon configuration" \
410410
3 "Channel configuration" \
@@ -422,7 +422,60 @@ do_edit_chirpstack_concentratord_config() {
422422
}
423423

424424
do_edit_chirpstack_gateway_bridge_config() {
425-
nano /etc/chirpstack-gateway-bridge/chirpstack-gateway-bridge.toml
425+
FUN=$(dialog --title "Edit ChirpStack Gateway Bridge config" --menu "Edit config file:" 14 60 2 \
426+
1 "Edit configuration file" \
427+
2 "MQTT connection wizard" \
428+
3>&1 1>&2 2>&3)
429+
RET=$?
430+
if [ $RET -eq 0 ]; then
431+
case "$FUN" in
432+
1) nano /etc/chirpstack-gateway-bridge/chirpstack-gateway-bridge.toml;;
433+
2) do_edit_chirpstack_gateway_bridge_config_mqtt_wizard;;
434+
esac
435+
fi
436+
}
437+
438+
do_edit_chirpstack_gateway_bridge_config_mqtt_wizard() {
439+
# mqtt broker
440+
MQTT_BROKER=$(dialog --inputbox "Please enter the MQTT broker address (e.g. tcp://server:1883, ssl://server:8883): " 8 60 \
441+
3>&1 1>&2 2>&3)
442+
RET=$?
443+
if [ $RET -eq 1 ]; then
444+
return;
445+
fi
446+
sed -i "s/server=.*/server=\"${MQTT_BROKER//\//\\/}\"/" /etc/chirpstack-gateway-bridge/chirpstack-gateway-bridge.toml
447+
448+
# ca cert
449+
dialog --yesno "Would you like to configure a CA certificate?" 6 60
450+
RET=$?
451+
if [ $RET -eq 0 ]; then
452+
touch /etc/chirpstack-gateway-bridge/ca.pem
453+
454+
dialog --title "MQTT connection wizard" --msgbox "Enter the content of the CA certificate in the next screen and close the editor with Ctrl+X." 7 60
455+
sed -i "s/ca_cert=.*/ca_cert=\"\/etc\/chirpstack-gateway-bridge\/ca.pem\"/" /etc/chirpstack-gateway-bridge/chirpstack-gateway-bridge.toml
456+
nano /etc/chirpstack-gateway-bridge/ca.pem
457+
else
458+
sed -i "s/tls_cert=.*/tls_cert=\"\"/" /etc/chirpstack-gateway-bridge/chirpstack-gateway-bridge.toml
459+
fi
460+
461+
# client cert
462+
dialog --yesno "Would you like to configure a client certificate?" 6 60
463+
RET=$?
464+
if [ $RET -eq 0 ]; then
465+
touch /etc/chirpstack-gateway-bridge/cert.pem
466+
touch /etc/chirpstack-gateway-bridge/key.pem
467+
468+
dialog --title "MQTT connection wizard" --msgbox "Enter the content of the client-certificate in the next screen and close the editor with Ctrl+X." 7 60
469+
sed -i "s/tls_cert=.*/tls_cert=\"\/etc\/chirpstack-gateway-bridge\/cert.pem\"/" /etc/chirpstack-gateway-bridge/chirpstack-gateway-bridge.toml
470+
nano /etc/chirpstack-gateway-bridge/cert.pem
471+
472+
dialog --title "MQTT connection wizard" --msgbox "Enter the content of the client-certificate key in the next screen and close the editor with Ctrl+X." 7 60
473+
sed -i "s/tls_key=.*/tls_key=\"\/etc\/chirpstack-gateway-bridge\/key.pem\"/" /etc/chirpstack-gateway-bridge/chirpstack-gateway-bridge.toml
474+
nano /etc/chirpstack-gateway-bridge/key.pem
475+
else
476+
sed -i "s/tls_cert=.*/tls_cert=\"\"/" /etc/chirpstack-gateway-bridge/chirpstack-gateway-bridge.toml
477+
sed -i "s/tls_key=.*/tls_key=\"\"/" /etc/chirpstack-gateway-bridge/chirpstack-gateway-bridge.toml
478+
fi
426479
}
427480

428481
do_restart_chirpstack_concentratord() {

0 commit comments

Comments
 (0)