OpenThread border router: support border router to connect with SSED

This commit is contained in:
Xu Si Yu 2023-04-19 15:00:17 +08:00 committed by BOT
parent 8d84a5315a
commit fc1fdca416
6 changed files with 60 additions and 21 deletions

View File

@ -67,6 +67,7 @@ if(CONFIG_OPENTHREAD_ENABLED)
"openthread/src/core/api/icmp6_api.cpp"
"openthread/src/core/api/ip6_api.cpp"
"openthread/src/core/api/link_api.cpp"
"openthread/src/core/api/link_metrics_api.cpp"
"openthread/src/core/api/message_api.cpp"
"openthread/src/core/api/nat64_api.cpp"
"openthread/src/core/api/netdata_api.cpp"
@ -91,6 +92,7 @@ if(CONFIG_OPENTHREAD_ENABLED)
"openthread/src/core/thread/discover_scanner.cpp"
"openthread/src/core/thread/energy_scan_server.cpp"
"openthread/src/core/thread/key_manager.cpp"
"openthread/src/core/thread/link_metrics.cpp"
"openthread/src/core/thread/lowpan.cpp"
"openthread/src/core/thread/mesh_forwarder.cpp"
"openthread/src/core/thread/mesh_forwarder_ftd.cpp"

View File

@ -41,12 +41,7 @@ static inline uint32_t calculate_duration(uint32_t target, uint32_t now)
uint64_t otPlatTimeGet(void)
{
struct timeval tv_now;
int err = gettimeofday(&tv_now, NULL);
assert(err == 0);
return (uint64_t)tv_now.tv_sec * US_PER_S + tv_now.tv_usec;
return (uint64_t)esp_timer_get_time();
}
void otPlatAlarmMilliStartAt(otInstance *aInstance, uint32_t aT0, uint32_t aDt)
@ -68,7 +63,7 @@ void otPlatAlarmMilliStop(otInstance *aInstance)
uint32_t inline otPlatAlarmMilliGetNow(void)
{
return esp_timer_get_time() / US_PER_MS;
return otPlatTimeGet() / US_PER_MS;
}
void otPlatAlarmMicroStartAt(otInstance *aInstance, uint32_t aT0, uint32_t aDt)
@ -89,7 +84,7 @@ void otPlatAlarmMicroStop(otInstance *aInstance)
uint32_t inline otPlatAlarmMicroGetNow(void)
{
return esp_timer_get_time();
return otPlatTimeGet();
}
esp_err_t esp_openthread_alarm_init(void)

View File

@ -27,6 +27,7 @@
#include "openthread/link.h"
#include "openthread/platform/diag.h"
#include "openthread/platform/radio.h"
#include "openthread/platform/time.h"
#include "utils/link_metrics.h"
#include "utils/mac_frame.h"
@ -493,7 +494,7 @@ void otPlatRadioSetMacFrameCounter(otInstance *aInstance, uint32_t aMacFrameCoun
uint64_t otPlatRadioGetNow(otInstance *aInstance)
{
OT_UNUSED_VARIABLE(aInstance);
return esp_timer_get_time();
return otPlatTimeGet();
}
#if OPENTHREAD_CONFIG_MAC_CSL_RECEIVER_ENABLE
@ -505,7 +506,7 @@ void otPlatRadioUpdateCslSampleTime(otInstance *aInstance, uint32_t aCslSampleTi
static IRAM_ATTR uint16_t get_csl_phase()
{
uint32_t cur_time = esp_timer_get_time();
uint32_t cur_time = otPlatTimeGet();
uint32_t csl_period_us = s_csl_period * OT_US_PER_TEN_SYMBOLS;
uint32_t diff = (csl_period_us - (cur_time % csl_period_us) + (s_csl_sample_time % csl_period_us)) % csl_period_us;
@ -578,7 +579,7 @@ static void IRAM_ATTR convert_to_ot_frame(uint8_t *data, esp_ieee802154_frame_in
radio_frame->mInfo.mRxInfo.mRssi = frame_info->rssi;
radio_frame->mInfo.mRxInfo.mLqi = frame_info->lqi;
radio_frame->mInfo.mRxInfo.mAckedWithFramePending = frame_info->pending;
radio_frame->mInfo.mRxInfo.mTimestamp = esp_timer_get_time();
radio_frame->mInfo.mRxInfo.mTimestamp = otPlatTimeGet();
#if OPENTHREAD_CONFIG_MAC_CSL_RECEIVER_ENABLE
radio_frame->mInfo.mRxInfo.mTimestamp = frame_info->timestamp;
@ -677,6 +678,8 @@ void IRAM_ATTR esp_ieee802154_receive_done(uint8_t *data, esp_ieee802154_frame_i
s_receive_frame[s_recv_queue.tail].mInfo.mRxInfo.mAckedWithSecEnhAck = s_with_security_enh_ack;
s_receive_frame[s_recv_queue.tail].mInfo.mRxInfo.mAckFrameCounter = s_ack_frame_counter;
s_receive_frame[s_recv_queue.tail].mInfo.mRxInfo.mAckKeyId = s_ack_key_id;
} else {
s_receive_frame[s_recv_queue.tail].mInfo.mRxInfo.mAckedWithSecEnhAck = false;
}
s_with_security_enh_ack = false;
#endif // OPENTHREAD_CONFIG_THREAD_VERSION >= OT_THREAD_VERSION_1_2

View File

@ -321,3 +321,32 @@ const char *otPlatRadioGetVersionString(otInstance *aInstance)
}
#endif // OPENTHREAD_CONFIG_DIAG_ENABLE
uint64_t otPlatRadioGetNow(otInstance *aInstance)
{
OT_UNUSED_VARIABLE(aInstance);
return s_radio.GetNow();
}
#if OPENTHREAD_CONFIG_MAC_CSL_TRANSMITTER_ENABLE
uint8_t otPlatRadioGetCslAccuracy(otInstance *aInstance)
{
OT_UNUSED_VARIABLE(aInstance);
return s_radio.GetCslAccuracy();
}
uint8_t otPlatRadioGetCslUncertainty(otInstance *aInstance)
{
OT_UNUSED_VARIABLE(aInstance);
return s_radio.GetCslUncertainty();
}
#endif
#if OPENTHREAD_CONFIG_MLE_LINK_METRICS_SUBJECT_ENABLE
otError otPlatRadioConfigureEnhAckProbing(otInstance *aInstance, otLinkMetrics aLinkMetrics, const otShortAddress aShortAddress, const otExtAddress *aExtAddress)
{
OT_UNUSED_VARIABLE(aInstance);
return s_radio.ConfigureEnhAckProbing(aLinkMetrics, aShortAddress, *aExtAddress);
}
#endif

View File

@ -446,16 +446,6 @@
#define OPENTHREAD_CONFIG_MAC_CSL_RECEIVER_ENABLE 1
#endif
/**
* @def OPENTHREAD_CONFIG_MAC_CSL_RECEIVER_ENABLE
*
* Define as 1 to set the ahead time for CSL transmit timing.
*
*/
#ifndef OPENTHREAD_CONFIG_MAC_CSL_REQUEST_AHEAD_US
#define OPENTHREAD_CONFIG_MAC_CSL_REQUEST_AHEAD_US 20000
#endif
/**
* @def OPENTHREAD_CONFIG_MAC_CSL_DEBUG_ENABLE
*
@ -468,6 +458,16 @@
#endif // CONFIG_OPENTHREAD_CSL_ENABLE
/**
* @def OPENTHREAD_CONFIG_MAC_CSL_REQUEST_AHEAD_US
*
* Define as 1 to set the ahead time for CSL transmit timing.
*
*/
#ifndef OPENTHREAD_CONFIG_MAC_CSL_REQUEST_AHEAD_US
#define OPENTHREAD_CONFIG_MAC_CSL_REQUEST_AHEAD_US 20000
#endif
#if CONFIG_OPENTHREAD_LINK_METRICS
/**

View File

@ -206,3 +206,13 @@
#endif
#define OPENTHREAD_RADIO 1
/**
* @def OPENTHREAD_CONFIG_MLE_LINK_METRICS_SUBJECT_ENABLE
*
* Define as 1 to support Thread 1.2 Link Metrics Subject feature.
*
*/
#ifndef OPENTHREAD_CONFIG_MLE_LINK_METRICS_SUBJECT_ENABLE
#define OPENTHREAD_CONFIG_MLE_LINK_METRICS_SUBJECT_ENABLE 1
#endif