Skip to content

Commit

Permalink
[radio] use new implementation of time sync
Browse files Browse the repository at this point in the history
  • Loading branch information
bukepo committed Aug 27, 2024
1 parent 943b91b commit 519c80d
Showing 1 changed file with 2 additions and 25 deletions.
27 changes: 2 additions & 25 deletions src/src/radio.c
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,6 @@ static uint8_t sTransmitPsdu[OT_RADIO_FRAME_MAX_SIZE + 1];

#if OPENTHREAD_CONFIG_MAC_HEADER_IE_SUPPORT
static otExtAddress sExtAddress;
static otRadioIeInfo sTransmitIeInfo;
static otInstance *sInstance = NULL;
#endif

Expand Down Expand Up @@ -172,9 +171,6 @@ static void dataInit(void)

sDefaultTxPower = OT_RADIO_POWER_INVALID;
sTransmitFrame.mPsdu = sTransmitPsdu + 1;
#if OPENTHREAD_CONFIG_MAC_HEADER_IE_SUPPORT
sTransmitFrame.mInfo.mTxInfo.mIeInfo = &sTransmitIeInfo;
#endif

sReceiveError = OT_ERROR_NONE;

Expand Down Expand Up @@ -1220,8 +1216,6 @@ int8_t otPlatRadioGetReceiveSensitivity(otInstance *aInstance)
#if OPENTHREAD_CONFIG_MAC_HEADER_IE_SUPPORT
void nrf_802154_tx_started(const uint8_t *aFrame)
{
bool processSecurity = false;

assert(aFrame == sTransmitPsdu);
OT_UNUSED_VARIABLE(aFrame);

Expand All @@ -1234,34 +1228,17 @@ void nrf_802154_tx_started(const uint8_t *aFrame)

// Update IE and secure transmit frame
#if OPENTHREAD_CONFIG_TIME_SYNC_ENABLE
if (sTransmitFrame.mInfo.mTxInfo.mIeInfo->mTimeIeOffset != 0)
{
uint8_t *timeIe = sTransmitFrame.mPsdu + sTransmitFrame.mInfo.mTxInfo.mIeInfo->mTimeIeOffset;
uint64_t time = otPlatTimeGet() + sTransmitFrame.mInfo.mTxInfo.mIeInfo->mNetworkTimeOffset;

*timeIe = sTransmitFrame.mInfo.mTxInfo.mIeInfo->mTimeSyncSeq;

*(++timeIe) = (uint8_t)(time & 0xff);
for (uint8_t i = 1; i < sizeof(uint64_t); i++)
{
time = time >> 8;
*(++timeIe) = (uint8_t)(time & 0xff);
}

processSecurity = true;
}
otMacFrameUpdateTimeIe(&sTransmitFrame, otPlatTimeGet());
#endif // OPENTHREAD_CONFIG_TIME_SYNC_ENABLE

#if OPENTHREAD_CONFIG_THREAD_VERSION >= OT_THREAD_VERSION_1_2
otEXPECT(otMacFrameIsSecurityEnabled(&sTransmitFrame) && otMacFrameIsKeyIdMode1(&sTransmitFrame) &&
!sTransmitFrame.mInfo.mTxInfo.mIsSecurityProcessed);

sTransmitFrame.mInfo.mTxInfo.mAesKey = &sCurrKey;

processSecurity = true;
#endif // OPENTHREAD_CONFIG_THREAD_VERSION >= OT_THREAD_VERSION_1_2

otEXPECT(processSecurity);
otEXPECT(!sTransmitFrame.mInfo.mTxInfo.mIsSecurityProcessed);
otMacFrameProcessTransmitAesCcm(&sTransmitFrame, &sExtAddress);

exit:
Expand Down

0 comments on commit 519c80d

Please sign in to comment.