Skip to content

Commit c976203

Browse files
committed
Merge branch 'feat/call_meshcop_mdns_publish_in_idf' into 'master'
Handle MeshCoP mDNS service in state change callback, update OpenThread upstream See merge request espressif/esp-idf!39517
2 parents 7ee40d6 + 96fb64d commit c976203

File tree

7 files changed

+79
-4
lines changed

7 files changed

+79
-4
lines changed

components/openthread/include/esp_openthread_border_router.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,14 @@ esp_netif_t *esp_openthread_get_backbone_netif(void);
7676
*/
7777
esp_err_t esp_openthread_set_meshcop_instance_name(const char *instance_name);
7878

79+
/**
80+
* @brief Gets the meshcop(e) instance name.
81+
*
82+
* @return The instance name.
83+
*
84+
*/
85+
const char* esp_openthread_get_meshcop_instance_name(void);
86+
7987
#ifdef __cplusplus
8088
}
8189
#endif
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
/*
2+
* SPDX-FileCopyrightText: 2025 Espressif Systems (Shanghai) CO LTD
3+
*
4+
* SPDX-License-Identifier: Apache-2.0
5+
*/
6+
7+
#pragma once
8+
9+
#include "esp_openthread.h"
10+
11+
#ifdef __cplusplus
12+
extern "C" {
13+
#endif
14+
15+
/**
16+
* @brief Publishes the OpenThread meshcop service in mDNS
17+
*
18+
* @param[in] instance_name Instance name of meshcop mDNS service
19+
*
20+
* @return
21+
* - ESP_OK success
22+
* - ESP_ERR_NO_MEM memory error
23+
* - ESP_FAIL failed to add service
24+
*
25+
*/
26+
esp_err_t esp_openthread_publish_meshcop_mdns(const char *instance_name);
27+
28+
/**
29+
* @brief Removes the OpenThread meshcop service in mDNS
30+
*
31+
* @return
32+
* - ESP_OK success
33+
* - ESP_ERR_NO_MEM memory error
34+
* - ESP_FAIL failed to remove service
35+
*
36+
*/
37+
esp_err_t esp_openthread_remove_meshcop_mdns(void);
38+
39+
#ifdef __cplusplus
40+
}
41+
#endif

components/openthread/openthread

Submodule openthread updated 253 files

components/openthread/private_include/esp_openthread_state.h

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* SPDX-FileCopyrightText: 2023 Espressif Systems (Shanghai) CO LTD
2+
* SPDX-FileCopyrightText: 2023-2025 Espressif Systems (Shanghai) CO LTD
33
*
44
* SPDX-License-Identifier: Apache-2.0
55
*/
@@ -10,6 +10,11 @@
1010
#include <esp_openthread.h>
1111
#include <esp_openthread_types.h>
1212

13+
#define ESP_OPENTHREAD_BORDER_ROUTER_FLAG_OF_INTEREST \
14+
(OT_CHANGED_THREAD_ROLE | OT_CHANGED_THREAD_EXT_PANID | OT_CHANGED_THREAD_NETWORK_NAME | \
15+
OT_CHANGED_ACTIVE_DATASET | OT_CHANGED_THREAD_PARTITION_ID | OT_CHANGED_THREAD_BACKBONE_ROUTER_STATE | \
16+
OT_CHANGED_PSKC)
17+
1318
#ifdef __cplusplus
1419
extern "C" {
1520
#endif

components/openthread/sbom_openthread.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,4 @@ supplier: 'Organization: Espressif Systems (Shanghai) CO LTD'
55
originator: 'Organization: Google LLC'
66
description: OpenThread released by Google is an open-source implementation of the Thread networking
77
url: https://github.com/espressif/openthread
8-
hash: ec2b0d487356d2955346457a6515201039140037
8+
hash: b945928d722177cd9caeab2e1025499628c101ef

components/openthread/src/port/esp_openthread_state.c

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,9 @@
1010
#include <esp_check.h>
1111
#include <esp_event.h>
1212
#include <esp_log.h>
13+
#include <esp_openthread_border_router.h>
1314
#include <esp_openthread_dns64.h>
15+
#include <esp_openthread_meshcop_mdns.h>
1416
#include <esp_openthread_netif_glue_priv.h>
1517
#include <esp_openthread_radio.h>
1618
#include <esp_openthread_state.h>
@@ -19,6 +21,19 @@
1921

2022
#define TAG "OT_STATE"
2123

24+
#if CONFIG_OPENTHREAD_BORDER_ROUTER
25+
static void handle_ot_border_router_state_changed(otInstance* instance)
26+
{
27+
otDeviceRole role = otThreadGetDeviceRole(esp_openthread_get_instance());
28+
29+
if (role == OT_DEVICE_ROLE_CHILD || role == OT_DEVICE_ROLE_ROUTER || role == OT_DEVICE_ROLE_LEADER) {
30+
esp_openthread_publish_meshcop_mdns(esp_openthread_get_meshcop_instance_name());
31+
} else {
32+
esp_openthread_remove_meshcop_mdns();
33+
}
34+
}
35+
#endif
36+
2237
static void handle_ot_netif_state_change(otInstance* instance)
2338
{
2439
if (otIp6IsEnabled(instance)) {
@@ -123,6 +138,12 @@ static void ot_state_change_callback(otChangedFlags changed_flags, void* ctx)
123138
return;
124139
}
125140

141+
#if CONFIG_OPENTHREAD_BORDER_ROUTER
142+
if (changed_flags & ESP_OPENTHREAD_BORDER_ROUTER_FLAG_OF_INTEREST) {
143+
handle_ot_border_router_state_changed(instance);
144+
}
145+
#endif
146+
126147
if (changed_flags & OT_CHANGED_THREAD_ROLE) {
127148
handle_ot_role_change(instance);
128149
}

0 commit comments

Comments
 (0)