Skip to content

Commit 427084d

Browse files
committed
fix(openthread): handle SetTimeSyncState when ifconfig up or down
1 parent 9969b9c commit 427084d

File tree

3 files changed

+18
-1
lines changed

3 files changed

+18
-1
lines changed

components/openthread/private_include/esp_openthread_radio.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,14 @@ void esp_openthread_radio_deinit(void);
4444
*/
4545
void esp_openthread_radio_update(esp_openthread_mainloop_context_t *mainloop);
4646

47+
/**
48+
* @brief This function handles netif change for radio spinel.
49+
*
50+
* @param[in] state The updated netif state.
51+
*
52+
*/
53+
void esp_openthread_handle_netif_state_change(bool state);
54+
4755
/**
4856
* @brief This function performs the OpenThread radio process.
4957
*

components/openthread/src/port/esp_openthread_radio_spinel.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -202,6 +202,11 @@ void esp_openthread_radio_update(esp_openthread_mainloop_context_t *mainloop)
202202
s_spinel_interface.GetSpinelInterface().UpdateFdSet((void *)mainloop);
203203
}
204204

205+
void esp_openthread_handle_netif_state_change(bool state)
206+
{
207+
s_radio.SetTimeSyncState(state);
208+
}
209+
205210
void otPlatRadioGetIeeeEui64(otInstance *instance, uint8_t *ieee_eui64)
206211
{
207212
SuccessOrDie(s_radio.GetIeeeEui64(ieee_eui64));

components/openthread/src/port/esp_openthread_state.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121

2222
static void handle_ot_netif_state_change(otInstance* instance)
2323
{
24-
if (otLinkIsEnabled(instance)) {
24+
if (otIp6IsEnabled(instance)) {
2525
ESP_LOGI(TAG, "netif up");
2626
if (esp_event_post(OPENTHREAD_EVENT, OPENTHREAD_EVENT_IF_UP, NULL, 0, 0) != ESP_OK) {
2727
ESP_LOGE(TAG, "Failed to post OpenThread if up event");
@@ -32,6 +32,10 @@ static void handle_ot_netif_state_change(otInstance* instance)
3232
ESP_LOGE(TAG, "Failed to post OpenThread if down event");
3333
}
3434
}
35+
36+
#if (CONFIG_OPENTHREAD_RADIO_SPINEL_UART || CONFIG_OPENTHREAD_RADIO_SPINEL_SPI)
37+
esp_openthread_handle_netif_state_change(otIp6IsEnabled(instance));
38+
#endif
3539
}
3640

3741
static void handle_ot_netdata_change(void)

0 commit comments

Comments
 (0)