mirror of
https://github.com/espressif/openthread.git
synced 2026-09-08 10:10:06 +00:00
[ci] test with time sync and header ie (#3514)
This commit adds the missing test with ie present by enabling TIME_SYNC feature, so that IE code are covered.
This commit is contained in:
@@ -131,6 +131,10 @@ ifeq ($(SNTP_CLIENT),1)
|
||||
configure_OPTIONS += --enable-sntp-client
|
||||
endif
|
||||
|
||||
ifeq ($(TIME_SYNC),1)
|
||||
COMMONCFLAGS += -DPENTHREAD_CONFIG_ENABLE_TIME_SYNC=1
|
||||
endif
|
||||
|
||||
ifeq ($(UDP_FORWARD),1)
|
||||
configure_OPTIONS += --enable-udp-forward
|
||||
endif
|
||||
|
||||
@@ -54,7 +54,7 @@ PLATFORM_SOURCES = \
|
||||
$(NULL)
|
||||
|
||||
libopenthread_posix_a_SOURCES = \
|
||||
$(PLATFORM_SOURCES) \
|
||||
$(PLATFORM_SOURCES) \
|
||||
$(NULL)
|
||||
|
||||
noinst_HEADERS = \
|
||||
|
||||
@@ -181,4 +181,16 @@ void platformAlarmProcess(otInstance *aInstance)
|
||||
#endif // OPENTHREAD_CONFIG_ENABLE_PLATFORM_USEC_TIMER
|
||||
}
|
||||
|
||||
#if OPENTHREAD_CONFIG_ENABLE_TIME_SYNC
|
||||
uint64_t otPlatTimeGet(void)
|
||||
{
|
||||
return platformAlarmGetNow();
|
||||
}
|
||||
|
||||
uint16_t otPlatTimeGetXtalAccuracy(void)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
#endif // OPENTHREAD_CONFIG_ENABLE_TIME_SYNC
|
||||
|
||||
#endif // OPENTHREAD_POSIX_VIRTUAL_TIME
|
||||
|
||||
@@ -33,6 +33,7 @@
|
||||
#include <openthread/platform/alarm-milli.h>
|
||||
#include <openthread/platform/diag.h>
|
||||
#include <openthread/platform/radio.h>
|
||||
#include <openthread/platform/time.h>
|
||||
|
||||
#include "utils/code_utils.h"
|
||||
|
||||
@@ -107,6 +108,11 @@ static otRadioFrame sReceiveFrame;
|
||||
static otRadioFrame sTransmitFrame;
|
||||
static otRadioFrame sAckFrame;
|
||||
|
||||
#if OPENTHREAD_CONFIG_HEADER_IE_SUPPORT
|
||||
static otRadioIeInfo sTransmitIeInfo;
|
||||
static otRadioIeInfo sReceivedIeInfo;
|
||||
#endif
|
||||
|
||||
static uint8_t sExtendedAddress[OT_EXT_ADDRESS_SIZE];
|
||||
static uint16_t sShortAddress;
|
||||
static uint16_t sPanid;
|
||||
@@ -376,6 +382,13 @@ void platformRadioInit(void)
|
||||
sReceiveFrame.mPsdu = sReceiveMessage.mPsdu;
|
||||
sTransmitFrame.mPsdu = sTransmitMessage.mPsdu;
|
||||
sAckFrame.mPsdu = sAckMessage.mPsdu;
|
||||
#if OPENTHREAD_CONFIG_HEADER_IE_SUPPORT
|
||||
sTransmitFrame.mIeInfo = &sTransmitIeInfo;
|
||||
sReceiveFrame.mIeInfo = &sReceivedIeInfo;
|
||||
#else
|
||||
sTransmitFrame.mIeInfo = NULL;
|
||||
sReceiveFrame.mIeInfo = NULL;
|
||||
#endif
|
||||
}
|
||||
|
||||
bool otPlatRadioIsEnabled(otInstance *aInstance)
|
||||
@@ -494,6 +507,9 @@ void platformRadioReceive(otInstance *aInstance, uint8_t *aBuf, uint16_t aBufLen
|
||||
sReceiveFrame.mInfo.mRxInfo.mUsec = 0; // Don't support microsecond timer for now.
|
||||
}
|
||||
|
||||
#if OPENTHREAD_CONFIG_ENABLE_TIME_SYNC
|
||||
sReceiveFrame.mIeInfo->mTimestamp = otPlatTimeGet();
|
||||
#endif
|
||||
sReceiveFrame.mLength = (uint8_t)(aBufLength - 1);
|
||||
|
||||
if (sState == OT_RADIO_STATE_TRANSMIT && sAckWait && !isAckRequested(sTransmitFrame.mPsdu) &&
|
||||
@@ -544,6 +560,34 @@ void platformRadioReceive(otInstance *aInstance, uint8_t *aBuf, uint16_t aBufLen
|
||||
|
||||
void radioSendMessage(otInstance *aInstance)
|
||||
{
|
||||
#if OPENTHREAD_CONFIG_HEADER_IE_SUPPORT
|
||||
bool notifyFrameUpdated = false;
|
||||
|
||||
#if OPENTHREAD_CONFIG_ENABLE_TIME_SYNC
|
||||
if (sTransmitFrame.mIeInfo->mTimeIeOffset != 0)
|
||||
{
|
||||
uint8_t *timeIe = sTransmitFrame.mPsdu + sTransmitFrame.mIeInfo->mTimeIeOffset;
|
||||
uint64_t time = (uint64_t)((int64_t)otPlatTimeGet() + sTransmitFrame.mIeInfo->mNetworkTimeOffset);
|
||||
|
||||
*timeIe = sTransmitFrame.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);
|
||||
}
|
||||
|
||||
notifyFrameUpdated = true;
|
||||
}
|
||||
#endif // OPENTHREAD_CONFIG_ENABLE_TIME_SYNC
|
||||
|
||||
if (notifyFrameUpdated)
|
||||
{
|
||||
otPlatRadioFrameUpdated(aInstance, &sTransmitFrame);
|
||||
}
|
||||
#endif // OPENTHREAD_CONFIG_HEADER_IE_SUPPORT
|
||||
|
||||
sTransmitMessage.mChannel = sTransmitFrame.mChannel;
|
||||
|
||||
otPlatRadioTxStarted(aInstance, &sTransmitFrame);
|
||||
|
||||
Reference in New Issue
Block a user