Unverified Commit 55d7847f authored by conny-andersson-netmore's avatar conny-andersson-netmore Committed by GitHub
Browse files

Async passive roaming downlink (#563)

parent 476afac3
......@@ -60,7 +60,12 @@ var tasks = []func(*dataContext) error{
syncUplinkFCnt,
saveDeviceSession,
handleUplinkACK,
handleDownlink,
isRoaming(false,
handleDownlink,
),
isRoaming(true,
handlePassiveRoamingDownlink,
),
}
var (
......@@ -91,6 +96,20 @@ type dataContext struct {
MustSendDownlink bool
}
func isRoaming(r bool, tasks ...func(*dataContext) error) func(*dataContext) error {
return func(ctx *dataContext) error {
if r == (ctx.RXPacket.RoamingMetaData != nil) {
for _, f := range tasks {
if err := f(ctx); err != nil {
return err
}
}
}
return nil
}
}
// Handle handles an uplink data frame
func Handle(ctx context.Context, rxPacket models.RXPacket) error {
dctx := dataContext{
......@@ -694,6 +713,25 @@ func handleDownlink(ctx *dataContext) error {
return nil
}
func handlePassiveRoamingDownlink(dCtx *dataContext) error {
newCtx := context.WithValue(context.Background(), logging.ContextIDKey, dCtx.ctx.Value(logging.ContextIDKey))
dCtx.ctx = newCtx
go func() {
logFields := log.Fields{
"dev_eui": dCtx.DeviceSession.DevEUI,
"ctx_id": dCtx.ctx.Value(logging.ContextIDKey),
}
err := handleDownlink(dCtx)
if err != nil {
log.WithFields(logFields).WithError(errors.Wrap(err, "failed to handle passive roaming downlink"))
}
}()
return nil
}
// handleUplinkMACCommands handles the given uplink mac-commands.
// It returns the mac-commands to respond with + a bool indicating the a downlink MUST be send,
// this to make sure that a response has been received by the NS.
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment