Skip to content

Commit b9124a4

Browse files
committed
Implement Basic Station support.
1 parent fe6bc4e commit b9124a4

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+4426
-326
lines changed

README.md

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,25 @@
22

33
[![Build Status](https://travis-ci.org/brocaar/lora-gateway-bridge.svg?branch=master)](https://travis-ci.org/brocaar/lora-gateway-bridge)
44

5-
LoRa Gateway Bridge is a service which abstracts the
6-
[packet_forwarder UDP protocol](https://github.com/Lora-net/packet_forwarder/blob/master/PROTOCOL.TXT)
7-
running on most LoRa gateways into JSON over MQTT. It enables you to use MQTT for
8-
receiving data from and sending data to your gateways.
5+
LoRa Gateway Bridge is a service which converts LoRa packet-forwarder protocols
6+
into a LoRa Server [common protocol](https://github.com/brocaar/loraserver/blob/master/api/gw/gw.proto) (JSON and Protobuf).
97
This project is part of the [LoRa Server](https://github.com/brocaar/loraserver)
108
project.
119

10+
## Backends
11+
12+
The following packet-forwarder backends are provided:
13+
14+
* [Semtech UDP packet-forwarder](https://github.com/Lora-net/packet_forwarder)
15+
* [Basic Station packet-forwarder](https://github.com/lorabasics/basicstation)
16+
17+
## Integrations
18+
19+
The following integrations are provided:
20+
21+
* Generic MQTT broker
22+
* [GCP Cloud IoT Core MQTT Bridge](https://cloud.google.com/iot-core/)
23+
1224
## Architecture
1325

1426
![architecture](https://docs.loraserver.io/img/architecture.png)

cmd/lora-gateway-bridge/cmd/configfile.go

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,14 @@ log_level = {{ .General.LogLevel }}
1818
# Gateway backend configuration.
1919
[backend]
2020
21+
# Backend type.
22+
#
23+
# Valid options are:
24+
# * semtech_udp
25+
# * basic_station
26+
type="{{ .Backend.Type }}"
27+
28+
2129
# Semtech UDP packet-forwarder backend.
2230
[backend.semtech_udp]
2331
@@ -69,6 +77,61 @@ log_level = {{ .General.LogLevel }}
6977
# # permissions to execute this command.
7078
# restart_command="/etc/init.d/lora-packet-forwarder restart"
7179
80+
# Basic Station backend.
81+
[backend.basic_station]
82+
83+
# ip:port to bind the Websocket listener to.
84+
bind="{{ .Backend.BasicStation.Bind }}"
85+
86+
# TLS certificate and key files.
87+
#
88+
# When set, the websocket listener will use TLS to secure the connections
89+
# between the gateways and LoRa Gateway Bridge (optional).
90+
tls_cert="{{ .Backend.BasicStation.TLSCert }}"
91+
tls_key="{{ .Backend.BasicStation.TLSKey }}"
92+
93+
# TLS CA certificate.
94+
#
95+
# When configured, LoRa Gateway Bridge will validate that the client
96+
# certificate of the gateway has been signed by this CA certificate.
97+
ca_cert="{{ .Backend.BasicStation.CACert }}"
98+
99+
# Ping interval.
100+
ping_interval="{{ .Backend.BasicStation.PingInterval }}"
101+
102+
# Read timeout.
103+
#
104+
# This interval must be greater than the configured ping interval.
105+
read_timeout="{{ .Backend.BasicStation.ReadTimeout }}"
106+
107+
# Write timeout.
108+
write_timeout="{{ .Backend.BasicStation.WriteTimeout }}"
109+
110+
# Region.
111+
#
112+
# Please refer to the LoRaWAN Regional Parameters specification
113+
# for the complete list of common region names.
114+
region="{{ .Backend.BasicStation.Region }}"
115+
116+
# Minimal frequency (Hz).
117+
frequency_min={{ .Backend.BasicStation.FrequencyMin }}
118+
119+
# Maximum frequency (Hz).
120+
frequency_max={{ .Backend.BasicStation.FrequencyMax }}
121+
122+
# Filters.
123+
[backend.basic_station.filters]
124+
125+
# NetIDs to filter on when receiving uplinks.
126+
net_ids=[{{ range $index, $elm := .Backend.BasicStation.Filters.NetIDs }}
127+
"{{ $elm }}",{{ end }}
128+
]
129+
130+
# JoinEUIs to filter on when receiving join-requests.
131+
join_euis=[{{ range $index, $elm := .Backend.BasicStation.Filters.JoinEUIs }}
132+
["{{ index $elm 0 }}", "{{ index $elm 1 }}"],{{ end }}
133+
]
134+
72135
73136
# Integration configuration.
74137
[integration]

cmd/lora-gateway-bridge/cmd/root.go

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,20 @@ func init() {
3434

3535
// default values
3636
viper.SetDefault("general.log_level", 4)
37+
viper.SetDefault("backend.type", "semtech_udp")
3738
viper.SetDefault("backend.semtech_udp.udp_bind", "0.0.0.0:1700")
3839

39-
viper.SetDefault("integration.marshaler", "protobuf")
40+
viper.SetDefault("backend.basic_station.bind", ":3001")
41+
viper.SetDefault("backend.basic_station.ping_interval", time.Minute)
42+
viper.SetDefault("backend.basic_station.read_timeout", time.Minute+(5*time.Second))
43+
viper.SetDefault("backend.basic_station.write_timeout", time.Second)
44+
viper.SetDefault("backend.basic_station.filters.net_ids", []string{"000000"})
45+
viper.SetDefault("backend.basic_station.filters.join_euis", [][2]string{{"0000000000000000", "ffffffffffffffff"}})
46+
viper.SetDefault("backend.basic_station.region", "EU868")
47+
viper.SetDefault("backend.basic_station.frequency_min", 863000000)
48+
viper.SetDefault("backend.basic_station.frequency_max", 870000000)
4049

50+
viper.SetDefault("integration.marshaler", "protobuf")
4151
viper.SetDefault("integration.mqtt.auth.type", "generic")
4252

4353
viper.SetDefault("integration.mqtt.event_topic_template", "gateway/{{ .GatewayID }}/event/{{ .EventType }}")

docs/config.toml

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,19 +25,26 @@ pygmentsUseClasses = true
2525
url = "/gateway/"
2626
weight = 3
2727

28+
[[menu.main]]
29+
pre = "<i class='far fa-file-alt'></i>"
30+
name = "Payloads"
31+
identifier = "payloads"
32+
url = "/payloads/"
33+
weight = "4"
34+
2835
[[menu.main]]
2936
pre = "<i class='fas fa-code'></i>"
3037
name = "Integrate"
3138
identifier = "integrate"
3239
url = "/integrate/"
33-
weight = 4
40+
weight = 5
3441

3542
[[menu.main]]
3643
pre = "<i class='fab fa-github'></i>"
3744
name = "Community & support"
3845
identifier = "community"
3946
url = "/community/"
40-
weight = 5
47+
weight = 6
4148

4249
[params]
4350
version = "2.7.1"

docs/content/install/config.md

Lines changed: 65 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -9,18 +9,6 @@ description: Instructions and examples how to configure the LoRa Gateway Bridge
99

1010
# Configuration
1111

12-
## Gateway
13-
14-
Modify the [packet-forwarder](https://github.com/lora-net/packet_forwarder)
15-
of your gateway so that it will send its data to the LoRa Gateway Bridge.
16-
You will need to change the following configuration keys:
17-
18-
* `server_address` to the IP address / hostname of the LoRa Gateway Bridge
19-
* `serv_port_up` to `1700` (the default port that LoRa Gateway Bridge is using)
20-
* `serv_port_down` to `1700` (same)
21-
22-
## LoRa Gateway Bridge
23-
2412
The `lora-gateway-bridge` has the following command-line flags:
2513

2614
{{<highlight text>}}
@@ -45,7 +33,7 @@ Flags:
4533
Use "lora-gateway-bridge [command] --help" for more information about a command.
4634
{{< /highlight >}}
4735

48-
### Configuration file
36+
## Configuration file
4937

5038
By default `lora-gateway-bridge` will look in the following order for a
5139
configuration at the following paths when `--config` / `-c` is not set:
@@ -82,6 +70,14 @@ log_level = 4
8270
# Gateway backend configuration.
8371
[backend]
8472

73+
# Backend type.
74+
#
75+
# Valid options are:
76+
# * semtech_udp
77+
# * basic_station
78+
type="semtech_udp"
79+
80+
8581
# Semtech UDP packet-forwarder backend.
8682
[backend.semtech_udp]
8783

@@ -133,6 +129,61 @@ log_level = 4
133129
# # permissions to execute this command.
134130
# restart_command="/etc/init.d/lora-packet-forwarder restart"
135131

132+
# Basic Station backend.
133+
[backend.basic_station]
134+
135+
# ip:port to bind the Websocket listener to.
136+
bind=":3001"
137+
138+
# TLS certificate and key files.
139+
#
140+
# When set, the websocket listener will use TLS to secure the connections
141+
# between the gateways and LoRa Gateway Bridge (optional).
142+
tls_cert=""
143+
tls_key=""
144+
145+
# TLS CA certificate.
146+
#
147+
# When configured, LoRa Gateway Bridge will validate that the client
148+
# certificate of the gateway has been signed by this CA certificate.
149+
ca_cert=""
150+
151+
# Ping interval.
152+
ping_interval="1m0s"
153+
154+
# Read timeout.
155+
#
156+
# This interval must be greater than the configured ping interval.
157+
read_timeout="1m5s"
158+
159+
# Write timeout.
160+
write_timeout="1s"
161+
162+
# Region.
163+
#
164+
# Please refer to the LoRaWAN Regional Parameters specification
165+
# for the complete list of common region names.
166+
region="EU868"
167+
168+
# Minimal frequency (Hz).
169+
frequency_min=863000000
170+
171+
# Maximum frequency (Hz).
172+
frequency_max=870000000
173+
174+
# Filters.
175+
[backend.basic_station.filters]
176+
177+
# NetIDs to filter on when receiving uplinks.
178+
net_ids=[
179+
"000000",
180+
]
181+
182+
# JoinEUIs to filter on when receiving join-requests.
183+
join_euis=[
184+
["0000000000000000", "ffffffffffffffff"],
185+
]
186+
136187

137188
# Integration configuration.
138189
[integration]
@@ -263,7 +314,7 @@ marshaler="protobuf"
263314
bind=""
264315
{{</highlight>}}
265316

266-
#### Environment variables
317+
## Environment variables
267318

268319
Although using the configuration file is recommended, it is also possible
269320
to use environment variables to set configuration variables.

docs/content/install/debian.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ commands:
2424
{{<highlight bash>}}
2525
sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 1CE2AFD36DBCCA00
2626

27-
sudo echo "deb https://artifacts.loraserver.io/packages/2.x/deb stable main" | sudo tee /etc/apt/sources.list.d/loraserver.list
27+
sudo echo "deb https://artifacts.loraserver.io/packages/3.x/deb stable main" | sudo tee /etc/apt/sources.list.d/loraserver.list
2828
sudo apt-get update
2929
{{< /highlight >}}
3030

docs/content/install/deployment.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,13 +39,13 @@ the setup, but has the following advantages:
3939

4040
### MQTT (using TCP) over UDP
4141

42-
By using MQTT (which uses TCP) over UDP, the connection becomes more reliable
43-
in case packetloss is common.
42+
By using MQTT (which uses TCP) over UDP when using the Semtech UDP packet-forwarder
43+
backend, the connection becomes more reliable in case packetloss is common.
4444

4545
### Authentication
4646

47-
It is possible to setup credentials for each gateway, meaning you know where
48-
your data is coming from.
47+
It is possible to setup credentials for each gateway, so that only gateways with
48+
valid credentials are able to ingest data.
4949

5050
### SSL/TLS
5151

docs/content/integrate/generic-mqtt.md

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,12 @@ Examples:
2626
# show data from all gateways
2727
mosquitto_sub -t "gateway/#" -v
2828

29-
# show all data for the given gateway
30-
mosquitto_sub -t "gateway/0101010101010101/+" -v
31-
{{< /highlight >}}
29+
# show all events and commands for the given gateway ID
30+
mosquitto_sub -t "gateway/0101010101010101/#" -v
31+
32+
# show all events for the given gateway ID
33+
mosquitto_sub -t "gateway/0101010101010101/event/+" -v
34+
35+
# show all commands for the given gateway ID
36+
mosquitto_sub -t "gateway/0101010101010101/command/+" -v
37+
{{< /highlight >}}

docs/content/integrate/payload-types/_index.md

Lines changed: 0 additions & 70 deletions
This file was deleted.

0 commit comments

Comments
 (0)