Skip to content

Commit

Permalink
ns: Emit packet error rate in the uplink message
Browse files Browse the repository at this point in the history
  • Loading branch information
adriansmares committed Apr 25, 2024
1 parent ae690b2 commit e27dcfc
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
1 change: 1 addition & 0 deletions pkg/networkserver/grpc_gsns.go
Original file line number Diff line number Diff line change
Expand Up @@ -1150,6 +1150,7 @@ func (ns *NetworkServer) handleDataUplink(ctx context.Context, up *ttnpb.UplinkM
Settings: up.Settings,
ReceivedAt: up.ReceivedAt,
ConsumedAirtime: up.ConsumedAirtime,
PacketErrorRate: mac.LossRate(stored.MacState, matched.phy),
NetworkIds: ns.networkIdentifiers(ctx),
},
},
Expand Down
5 changes: 5 additions & 0 deletions pkg/networkserver/mac/adr.go
Original file line number Diff line number Diff line change
Expand Up @@ -712,3 +712,8 @@ func AdaptDataRate(ctx context.Context, dev *ttnpb.EndDevice, phy *band.Band, de
}
return adaptDataRate(ctx, dev, phy, defaults)
}

// LossRate calculates the loss rate of the recent uplinks in the provided MAC state.
func LossRate(macState *ttnpb.MACState, phy *band.Band) float32 {
return adrLossRate(adrUplinks(macState, phy)...)
}

0 comments on commit e27dcfc

Please sign in to comment.