mirror of
https://github.com/espressif/esp-idf.git
synced 2024-10-05 20:47:46 -04:00
feat(openthread): enable time sync feature
This commit is contained in:
parent
8a565641c2
commit
3f02e5e901
@ -329,4 +329,13 @@ menu "OpenThread"
|
||||
default n
|
||||
help
|
||||
Only used for Thread1.2 certification
|
||||
|
||||
config OPENTHREAD_TIME_SYNC
|
||||
bool "Enable the time synchronization service feature"
|
||||
depends on OPENTHREAD_ENABLED
|
||||
default n
|
||||
help
|
||||
Select this option to enable time synchronization feature, the devices in the same Thread network could
|
||||
sync to the same network time.
|
||||
|
||||
endmenu
|
||||
|
@ -551,7 +551,6 @@
|
||||
#define OPENTHREAD_CONFIG_OPERATIONAL_DATASET_AUTO_INIT 1
|
||||
#endif
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* Define as 1 to enable support for allocating message pool buffer in PSRAM
|
||||
@ -570,4 +569,14 @@
|
||||
#define OPENTHREAD_CONFIG_PLATFORM_MESSAGE_MANAGEMENT 1
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @def OPENTHREAD_CONFIG_TIME_SYNC_ENABLE
|
||||
*
|
||||
* Define as 1 to enable the time synchronization service feature.
|
||||
*
|
||||
*/
|
||||
#if CONFIG_OPENTHREAD_TIME_SYNC
|
||||
#define OPENTHREAD_CONFIG_TIME_SYNC_ENABLE 1
|
||||
#endif
|
||||
|
||||
#define OPENTHREAD_FTD 1
|
||||
|
@ -253,4 +253,14 @@
|
||||
*/
|
||||
#define OPENTHREAD_CONFIG_DNS_CLIENT_ENABLE CONFIG_OPENTHREAD_DNS_CLIENT
|
||||
|
||||
/**
|
||||
* @def OPENTHREAD_CONFIG_TIME_SYNC_ENABLE
|
||||
*
|
||||
* Define as 1 to enable the time synchronization service feature.
|
||||
*
|
||||
*/
|
||||
#if CONFIG_OPENTHREAD_TIME_SYNC
|
||||
#define OPENTHREAD_CONFIG_TIME_SYNC_ENABLE 1
|
||||
#endif
|
||||
|
||||
#define OPENTHREAD_MTD 1
|
||||
|
@ -713,15 +713,33 @@ void IRAM_ATTR esp_ieee802154_receive_sfd_done(void)
|
||||
void IRAM_ATTR esp_ieee802154_transmit_sfd_done(uint8_t *frame)
|
||||
{
|
||||
assert(frame == (uint8_t *)&s_transmit_psdu || frame == s_enhack);
|
||||
#if OPENTHREAD_CONFIG_MAC_CSL_RECEIVER_ENABLE
|
||||
otRadioFrame ot_frame;
|
||||
ot_frame.mPsdu = frame + 1;
|
||||
ot_frame.mLength = frame[0];
|
||||
|
||||
#if OPENTHREAD_CONFIG_MAC_CSL_RECEIVER_ENABLE
|
||||
if (s_csl_period > 0) {
|
||||
otRadioFrame ot_frame;
|
||||
ot_frame.mPsdu = frame + 1;
|
||||
ot_frame.mLength = frame[0];
|
||||
|
||||
otMacFrameSetCslIe(&ot_frame, s_csl_period, get_csl_phase());
|
||||
}
|
||||
#endif
|
||||
|
||||
#if OPENTHREAD_CONFIG_TIME_SYNC_ENABLE
|
||||
if (frame == (uint8_t *)&s_transmit_psdu && s_transmit_frame.mInfo.mTxInfo.mIeInfo->mTimeIeOffset != 0)
|
||||
{
|
||||
uint8_t *p_time_ie = s_transmit_frame.mPsdu + s_transmit_frame.mInfo.mTxInfo.mIeInfo->mTimeIeOffset;
|
||||
uint64_t time = (uint64_t)((int64_t)otPlatTimeGet() + s_transmit_frame.mInfo.mTxInfo.mIeInfo->mNetworkTimeOffset);
|
||||
|
||||
*p_time_ie = s_transmit_frame.mInfo.mTxInfo.mIeInfo->mTimeSyncSeq;
|
||||
|
||||
*(++p_time_ie) = (uint8_t)(time & 0xff);
|
||||
for (uint8_t i = 1; i < sizeof(uint64_t); i++)
|
||||
{
|
||||
time = time >> 8;
|
||||
*(++p_time_ie) = (uint8_t)(time & 0xff);
|
||||
}
|
||||
}
|
||||
#endif // OPENTHREAD_CONFIG_TIME_SYNC_ENABLE
|
||||
}
|
||||
|
||||
void IRAM_ATTR esp_ieee802154_energy_detect_done(int8_t power)
|
||||
|
Loading…
Reference in New Issue
Block a user