Skip to content

Commit

Permalink
Merge pull request #7103 from TheThingsNetwork/fix/device-dowlink-cou…
Browse files Browse the repository at this point in the history
…nters

Fix device downlink frame counter shown as `n/a`
  • Loading branch information
ryaplots authored May 27, 2024
2 parents fef609f + 691801b commit 4c5a554
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 7 deletions.
3 changes: 2 additions & 1 deletion pkg/webui/console/containers/device-title-section/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ const DeviceTitleSection = props => {
const showUplinkCount = typeof uplinkFrameCount === 'number'
const showAppDownlinkCount = typeof downlinkAppFrameCount === 'number'
const showNwkDownlinkCount = typeof downlinkNwkFrameCount === 'number'

const notAvailableElem = <Message content={sharedMessages.notAvailable} />
const downlinkValue =
showAppDownlinkCount && showNwkDownlinkCount ? (
Expand All @@ -83,7 +84,7 @@ const DeviceTitleSection = props => {
</>
) : showNwkDownlinkCount ? (
<>
<FormattedNumber value={downlinkNwkFrameCount} /> {'(Nwk)'},
<FormattedNumber value={downlinkNwkFrameCount} /> {'(Nwk)'}
</>
) : (
notAvailableElem
Expand Down
21 changes: 15 additions & 6 deletions pkg/webui/console/store/reducers/devices.js
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ const devices = (state = defaultState, { type, payload, event }) => {
if (session) {
derived.uplinkFrameCount = session.last_f_cnt_up
if (parseLorawanMacVersion(lorawanVersion) < 110) {
derived.downlinkFrameCount = session.last_n_f_cnt_down
derived.downlinkNwkFrameCount = session.last_n_f_cnt_down
} else {
// For 1.1+ end devices there are two frame counters.
derived.downlinkAppFrameCount = session.last_a_f_cnt_down
Expand Down Expand Up @@ -166,11 +166,20 @@ const devices = (state = defaultState, { type, payload, event }) => {
const lorawanVersion = getByPath(state.entities, `${combinedDeviceId}.lorawan_version`)

if (parseLorawanMacVersion(lorawanVersion) < 110) {
const downlinkFrameCount = getByPath(event, 'data.payload.mac_payload.full_f_cnt')
if (typeof downlinkFrameCount === 'number') {
return mergeDerived(state, combinedDeviceId, {
downlinkFrameCount,
})
if (getByPath(event, 'data.payload.mac_payload.f_port') === undefined) {
const downlinkNwkFrameCount = getByPath(event, 'data.payload.mac_payload.full_f_cnt')
if (typeof downlinkNwkFrameCount === 'number') {
return mergeDerived(state, combinedDeviceId, {
downlinkNwkFrameCount,
})
}
} else if (getByPath(event, 'data.payload.mac_payload.f_port') > 0) {
const downlinkAppFrameCount = getByPath(event, 'data.payload.mac_payload.full_f_cnt')
if (typeof downlinkAppFrameCount === 'number') {
return mergeDerived(state, combinedDeviceId, {
downlinkAppFrameCount,
})
}
}
}

Expand Down

0 comments on commit 4c5a554

Please sign in to comment.