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

Added datarate revert mechanism after time synchronization request #761

Merged
merged 1 commit into from
Jul 8, 2019
Merged
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
11 changes: 11 additions & 0 deletions src/apps/LoRaMac/common/LmHandler/packages/LmhpClockSync.c
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ typedef struct LmhpClockSyncState_s
bool AppTimeReqPending;
bool AdrEnabledPrev;
uint8_t NbTransPrev;
uint8_t DataratePrev;
}LmhpClockSyncState_t;

typedef enum LmhpClockSyncMoteCmd_e
Expand Down Expand Up @@ -201,6 +202,11 @@ static void LmhpClockSyncOnMcpsConfirm( McpsConfirm_t *mcpsConfirm )
mibReq.Param.ChannelsNbTrans = LmhpClockSyncState.NbTransPrev;
LoRaMacMibSetRequestConfirm( &mibReq );

// Revert data rate setting
mibReq.Type = MIB_CHANNELS_DATARATE;
mibReq.Param.ChannelsDatarate = LmhpClockSyncState.DataratePrev;
LoRaMacMibSetRequestConfirm( &mibReq );

LmhpClockSyncState.AppTimeReqPending = false;
}
}
Expand Down Expand Up @@ -315,6 +321,11 @@ LmHandlerErrorStatus_t LmhpClockSyncAppTimeReq( void )
mibReq.Param.ChannelsNbTrans = 1;
LoRaMacMibSetRequestConfirm( &mibReq );

// Store data rate
mibReq.Type = MIB_CHANNELS_DATARATE;
LoRaMacMibGetRequestConfirm( &mibReq );
LmhpClockSyncState.DataratePrev = mibReq.Param.ChannelsDatarate;

// Add DeviceTimeReq MAC command.
// In case the network server supports this more precise command
// this package will use DeviceTimeAns answer as clock synchronization
Expand Down