@@ -2310,8 +2310,6 @@ func (ns *NetworkServer) processDownlinkTask(ctx context.Context, consumerID str
23102310 return err
23112311}
23122312
2313- const maxConfirmedDownlinkRetries = 8
2314-
23152313func (ns * NetworkServer ) createProcessPendingDownlinkTask (consumerID string ) func (context.Context ) error {
23162314 return func (ctx context.Context ) error {
23172315 return ns .processPendingDownlinkTask (ctx , consumerID )
@@ -2356,28 +2354,21 @@ func (ns *NetworkServer) processPendingDownlinkTask(ctx context.Context, consume
23562354
23572355 pendingAppDown := dev .MacState .GetPendingApplicationDownlink ()
23582356 if pendingAppDown != nil {
2359- pendingAppDown .FCnt = dev .Session .LastNFCntDown + 1
2360- pendingAppDown .ConfirmedRetry .Attempt ++
2361-
2362- if pendingAppDown .ConfirmedRetry .Attempt > maxConfirmedDownlinkRetries {
2363- dev .MacState .PendingApplicationDownlink = nil
2364- logger .Warn ("Max confirmed downlink retries reached, drop pending application downlink" )
2365- return dev , []string {
2366- "mac_state.pending_application_downlink" ,
2367- }, nil
2357+ queuedApplicationUplinks := []* ttnpb.ApplicationUp {
2358+ {
2359+ EndDeviceIds : dev .Ids ,
2360+ Up : & ttnpb.ApplicationUp_DownlinkNack {
2361+ DownlinkNack : pendingAppDown ,
2362+ },
2363+ CorrelationIds : pendingAppDown .CorrelationIds ,
2364+ },
23682365 }
23692366
2370- // Enqueue the pending application downlink at the front of the queue.
2371- // This preserves the order of other queued application downlinks.
2372- // The pending application downlink will be processed first in the next downlink task.
2373- // This is important for confirmed downlinks, as we need to ensure that the ACK is received
2374- // before processing other downlinks.
2375- dev .Session .QueuedApplicationDownlinks = append (
2376- []* ttnpb.ApplicationDownlink {pendingAppDown },
2377- dev .Session .QueuedApplicationDownlinks ... ,
2378- )
23792367 dev .MacState .PendingApplicationDownlink = nil
2368+ logger .Debug ("Pending application downlink not confirmed in time, send NACK to application" )
2369+ ns .submitApplicationUplinks (ctx , queuedApplicationUplinks ... )
23802370 }
2371+
23812372 return dev , []string {
23822373 "mac_state" ,
23832374 "session" ,
0 commit comments