Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Release device and gateway locks if nothing to send for class C #604

Closed
wants to merge 2 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions internal/downlink/data/data.go
Original file line number Diff line number Diff line change
Expand Up @@ -1266,6 +1266,20 @@ func stopOnNothingToSend(ctx *dataContext) error {
// in reply to a confirmed-uplink and no requirement to send an empty downlink
// (e.g. in case of ADRACKReq).
if ctx.DeviceQueueItem == nil && len(ctx.MACCommands) == 0 && !ctx.ACK && !ctx.MustSend {
if ctx.DeviceMode == storage.DeviceModeC {
// If we made it this far for a class C device we most certainly own
// the device and gateway locks so make sure to release them before returning.
key := storage.GetRedisKey(deviceDownlinkLockKey, ctx.DeviceSession.DevEUI)
_ = storage.RedisClient().Del(ctx.ctx, key).Err()

if classCGatewayDownlinkLockDuration != 0 {
var id lorawan.EUI64
copy(id[:], ctx.DownlinkFrame.GatewayId)
key := storage.GetRedisKey(gatewayDownlinkLockKey, id)
_ = storage.RedisClient().Del(ctx.ctx, key).Err()
}
}

// ErrAbort will not be handled as a real error
return ErrAbort
}
Expand Down
Loading