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 a8b4e87
Showing 1 changed file with 4 additions and 27 deletions.
31 changes: 4 additions & 27 deletions src/src/radio.c
Original file line number Diff line number Diff line change
Expand Up @@ -102,9 +102,8 @@ static otRadioFrame sTransmitFrame;
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;
static otExtAddress sExtAddress;
static otInstance *sInstance = NULL;
#endif

static otRadioFrame sAckFrame;
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 a8b4e87

Please sign in to comment.