Skip to content

Commit e7d8a94

Browse files
committed
Add filters to concentratord backend.
This ports #218 to the master branch.
1 parent 38655ae commit e7d8a94

File tree

1 file changed

+13
-5
lines changed

1 file changed

+13
-5
lines changed

internal/backend/concentratord/concentratord.go

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package concentratord
22

33
import (
44
"context"
5+
"encoding/base64"
56
"sync"
67
"time"
78

@@ -12,6 +13,7 @@ import (
1213

1314
"github.com/brocaar/chirpstack-gateway-bridge/internal/backend/events"
1415
"github.com/brocaar/chirpstack-gateway-bridge/internal/config"
16+
"github.com/brocaar/chirpstack-gateway-bridge/internal/filters"
1517
"github.com/brocaar/lorawan"
1618
"github.com/chirpstack/chirpstack/api/go/v4/gw"
1719
)
@@ -323,12 +325,18 @@ func (b *Backend) handleUplinkFrame(bb []byte) error {
323325
return errors.Wrap(err, "protobuf unmarshal error")
324326
}
325327

326-
log.WithFields(log.Fields{
327-
"uplink_id": pl.GetRxInfo().GetUplinkId(),
328-
}).Info("backend/concentratord: uplink event received")
328+
if filters.MatchFilters(pl.PhyPayload) {
329+
log.WithFields(log.Fields{
330+
"uplink_id": pl.GetRxInfo().GetUplinkId(),
331+
}).Info("backend/concentratord: uplink event received")
329332

330-
if b.uplinkFrameFunc != nil {
331-
b.uplinkFrameFunc(&pl)
333+
if b.uplinkFrameFunc != nil {
334+
b.uplinkFrameFunc(&pl)
335+
}
336+
} else {
337+
log.WithFields(log.Fields{
338+
"data_base64": base64.StdEncoding.EncodeToString(pl.PhyPayload),
339+
}).Debug("backend/concentratord: uplink event dropped because of configured filters")
332340
}
333341

334342
return nil

0 commit comments

Comments
 (0)