fix(openthread): handle SetTimeSyncState when ifconfig up or down

This commit is contained in:
Tan Yan Quan
2025-04-24 16:17:27 +08:00
parent f59e0b6dc7
commit a53f89e66c
3 changed files with 18 additions and 1 deletions

View File

@ -44,6 +44,14 @@ void esp_openthread_radio_deinit(void);
*/
void esp_openthread_radio_update(esp_openthread_mainloop_context_t *mainloop);
/**
* @brief This function handles netif change for radio spinel.
*
* @param[in] state The updated netif state.
*
*/
void esp_openthread_handle_netif_state_change(bool state);
/**
* @brief This function performs the OpenThread radio process.
*

View File

@ -209,6 +209,11 @@ void esp_openthread_radio_update(esp_openthread_mainloop_context_t *mainloop)
s_spinel_interface.GetSpinelInterface().UpdateFdSet((void *)mainloop);
}
void esp_openthread_handle_netif_state_change(bool state)
{
s_radio.SetTimeSyncState(state);
}
void otPlatRadioGetIeeeEui64(otInstance *instance, uint8_t *ieee_eui64)
{
SuccessOrDie(s_radio.GetIeeeEui64(ieee_eui64));

View File

@ -21,7 +21,7 @@
static void handle_ot_netif_state_change(otInstance* instance)
{
if (otLinkIsEnabled(instance)) {
if (otIp6IsEnabled(instance)) {
ESP_LOGI(TAG, "netif up");
if (esp_event_post(OPENTHREAD_EVENT, OPENTHREAD_EVENT_IF_UP, NULL, 0, 0) != ESP_OK) {
ESP_LOGE(TAG, "Failed to post OpenThread if up event");
@ -32,6 +32,10 @@ static void handle_ot_netif_state_change(otInstance* instance)
ESP_LOGE(TAG, "Failed to post OpenThread if down event");
}
}
#if (CONFIG_OPENTHREAD_RADIO_SPINEL_UART || CONFIG_OPENTHREAD_RADIO_SPINEL_SPI)
esp_openthread_handle_netif_state_change(otIp6IsEnabled(instance));
#endif
}
static void handle_ot_netdata_change(void)