Skip to content

Commit 65d27a0

Browse files
committed
Remove legacy code.
1 parent 0ab802a commit 65d27a0

File tree

19 files changed

+3
-4236
lines changed

19 files changed

+3
-4236
lines changed

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,6 @@ config_topic_template="{{ .Backend.MQTT.ConfigTopicTemplate }}"
9090
# Payload marshaler.
9191
#
9292
# This defines how the MQTT payloads are encoded. Valid options are:
93-
# * v2_json: The default LoRa Gateway Bridge v2 encoding (will be deprecated and removed in LoRa Gateway Bridge v3)
9493
# * protobuf: Protobuf encoding (this will become the LoRa Gateway Bridge v3 default)
9594
# * json: JSON encoding (easier for debugging, but less compact than 'protobuf')
9695
marshaler="{{ .Backend.MQTT.Marshaler }}"

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ func init() {
8181
viper.SetDefault("backend.mqtt.ack_topic_template", "gateway/{{ .MAC }}/ack")
8282
viper.SetDefault("backend.mqtt.config_topic_template", "gateway/{{ .MAC }}/config")
8383

84-
viper.SetDefault("backend.mqtt.marshaler", "v2_json")
84+
viper.SetDefault("backend.mqtt.marshaler", "json")
8585
viper.SetDefault("backend.mqtt.auth.type", "generic")
8686

8787
viper.SetDefault("backend.mqtt.auth.generic.server", "tcp://127.0.0.1:1883")

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

Lines changed: 0 additions & 88 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,10 @@
11
package cmd
22

33
import (
4-
"fmt"
54
"net/http"
65
"os"
76
"os/signal"
87
"syscall"
9-
"time"
108

119
"github.com/pkg/errors"
1210
"github.com/prometheus/client_golang/prometheus/promhttp"
@@ -16,8 +14,6 @@ import (
1614
"github.com/brocaar/lora-gateway-bridge/internal/backend/mqtt"
1715
"github.com/brocaar/lora-gateway-bridge/internal/config"
1816
"github.com/brocaar/lora-gateway-bridge/internal/gateway/semtech"
19-
"github.com/brocaar/lora-gateway-bridge/internal/legacy/backend/mqttpubsub"
20-
"github.com/brocaar/lora-gateway-bridge/internal/legacy/gateway"
2117
"github.com/brocaar/loraserver/api/gw"
2218
"github.com/brocaar/lorawan"
2319
)
@@ -57,93 +53,9 @@ func run(cmd *cobra.Command, args []string) error {
5753
}()
5854
}()
5955

60-
if config.C.Backend.MQTT.Marshaler == "v2_json" {
61-
if config.C.Backend.MQTT.Auth.Type != "generic" {
62-
return fmt.Errorf("auth type '%s' can not be used with 'v2_json' marshaler", config.C.Backend.MQTT.Auth.Type)
63-
}
64-
65-
return runV2(cmd, args)
66-
}
6756
return runV3(cmd, args)
6857
}
6958

70-
func runV2(cmd *cobra.Command, args []string) error {
71-
var pubsub *mqttpubsub.Backend
72-
for {
73-
var err error
74-
pubsub, err = mqttpubsub.NewBackend(config.C.Backend.MQTT)
75-
if err == nil {
76-
break
77-
}
78-
79-
log.Errorf("could not setup mqtt backend, retry in 2 seconds: %s", err)
80-
time.Sleep(2 * time.Second)
81-
}
82-
defer pubsub.Close()
83-
84-
onNew := func(mac lorawan.EUI64) error {
85-
return pubsub.SubscribeGatewayTopics(mac)
86-
}
87-
88-
onDelete := func(mac lorawan.EUI64) error {
89-
return pubsub.UnSubscribeGatewayTopics(mac)
90-
}
91-
92-
gateway, err := gateway.NewBackend(config.C.PacketForwarder.UDPBind, onNew, onDelete, config.C.PacketForwarder.SkipCRCCheck, config.C.PacketForwarder.Configuration)
93-
if err != nil {
94-
log.Fatalf("could not setup gateway backend: %s", err)
95-
}
96-
defer gateway.Close()
97-
98-
go func() {
99-
for rxPacket := range gateway.RXPacketChan() {
100-
go func(rxPacket gw.RXPacketBytes) {
101-
if err := pubsub.PublishGatewayRX(rxPacket.RXInfo.MAC, rxPacket); err != nil {
102-
log.WithError(err).Error("publish uplink message error")
103-
}
104-
}(rxPacket)
105-
}
106-
}()
107-
108-
go func() {
109-
for stats := range gateway.StatsChan() {
110-
if err := pubsub.PublishGatewayStats(stats.MAC, stats); err != nil {
111-
log.WithError(err).Error("publish gateway stats message error")
112-
}
113-
}
114-
}()
115-
116-
go func() {
117-
for txPacket := range pubsub.TXPacketChan() {
118-
if err := gateway.Send(txPacket); err != nil {
119-
log.WithError(err).Error("send downlink packet error")
120-
}
121-
}
122-
}()
123-
124-
go func() {
125-
for txAck := range gateway.TXAckChan() {
126-
if err := pubsub.PublishGatewayTXAck(txAck.MAC, txAck); err != nil {
127-
log.WithError(err).Error("publish downlink ack error")
128-
}
129-
}
130-
}()
131-
132-
go func() {
133-
for configPacket := range pubsub.ConfigPacketChan() {
134-
if err := gateway.ApplyConfiguration(configPacket); err != nil {
135-
log.WithError(err).Error("apply configuration error")
136-
}
137-
}
138-
}()
139-
140-
sigChan := make(chan os.Signal)
141-
signal.Notify(sigChan, os.Interrupt, syscall.SIGTERM)
142-
log.WithField("signal", <-sigChan).Info("signal received")
143-
log.Warning("shutting down server")
144-
return nil
145-
}
146-
14759
func runV3(cmd *cobra.Command, args []string) error {
14860
backend, err := mqtt.NewBackend(config.C.Backend.MQTT)
14961
if err != nil {

docs/content/install/config.md

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ skip_crc_check = false
141141
# The default values match the default expected configuration of the
142142
# LoRa Server MQTT backend. Therefore only change these values when
143143
# absolutely needed.
144-
# Use "{{ .MAC }}" as an substitution for the LoRa gateway MAC.
144+
# Use "{{ .MAC }}" as an substitution for the LoRa gateway MAC.
145145
#
146146
# Note that some authentication types might overwrite these templates (e.g.
147147
# in case of GCP Cloud IoT Core)!
@@ -154,10 +154,9 @@ config_topic_template="gateway/{{ .MAC }}/config"
154154
# Payload marshaler.
155155
#
156156
# This defines how the MQTT payloads are encoded. Valid options are:
157-
# * v2_json: The default LoRa Gateway Bridge v2 encoding (will be deprecated and removed in LoRa Gateway Bridge v3)
158157
# * protobuf: Protobuf encoding (this will become the LoRa Gateway Bridge v3 default)
159158
# * json: JSON encoding (easier for debugging, but less compact than 'protobuf')
160-
marshaler="v2_json"
159+
marshaler="json"
161160

162161
# MQTT authentication.
163162
[backend.mqtt.auth]
@@ -270,18 +269,6 @@ marshaler="v2_json"
270269
# The ip:port to bind the Prometheus metrics server to for serving the
271270
# metrics endpoint.
272271
bind=""
273-
{{< /highlight >}}
274-
275-
#### Environment variables
276-
277-
Although using the configuration file is recommended, it is also possible
278-
to use environment variables to set configuration variables.
279-
280-
Example:
281-
282-
{{<highlight toml>}}
283-
[packet_forwarder]
284-
udp_bind="0.0.0.0:1700"
285272
{{</highlight>}}
286273

287274
Can be set using the environment variable:

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ serialization format to use for the messages sent and received over MQTT.
1414
This can be configured by the `marshaler` option in the [configuration]({{<ref "/install/config.md">}})
1515
file. The following marshalers are available:
1616

17-
* [V2 JSON]({{<relref "v2-json.md">}}) (will be removed in the next major release)
1817
* [JSON]({{<relref "json.md">}})
1918
* [Protocol Buffers]({{<relref "protobuf.md">}})
2019

docs/content/integrate/payload-types/v2-json.md

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

0 commit comments

Comments
 (0)