mirror of
https://github.com/espressif/esp-idf.git
synced 2025-08-04 21:24:32 +02:00
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
This commit is contained in:
@@ -76,6 +76,14 @@ esp_netif_t *esp_openthread_get_backbone_netif(void);
|
||||
*/
|
||||
esp_err_t esp_openthread_set_meshcop_instance_name(const char *instance_name);
|
||||
|
||||
/**
|
||||
* @brief Gets the meshcop(e) instance name.
|
||||
*
|
||||
* @return The instance name.
|
||||
*
|
||||
*/
|
||||
const char* esp_openthread_get_meshcop_instance_name(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
41
components/openthread/include/esp_openthread_meshcop_mdns.h
Normal file
41
components/openthread/include/esp_openthread_meshcop_mdns.h
Normal file
@@ -0,0 +1,41 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2025 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "esp_openthread.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Publishes the OpenThread meshcop service in mDNS
|
||||
*
|
||||
* @param[in] instance_name Instance name of meshcop mDNS service
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK success
|
||||
* - ESP_ERR_NO_MEM memory error
|
||||
* - ESP_FAIL failed to add service
|
||||
*
|
||||
*/
|
||||
esp_err_t esp_openthread_publish_meshcop_mdns(const char *instance_name);
|
||||
|
||||
/**
|
||||
* @brief Removes the OpenThread meshcop service in mDNS
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK success
|
||||
* - ESP_ERR_NO_MEM memory error
|
||||
* - ESP_FAIL failed to remove service
|
||||
*
|
||||
*/
|
||||
esp_err_t esp_openthread_remove_meshcop_mdns(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
Submodule components/openthread/lib updated: 459448381b...fff1e900a1
Submodule components/openthread/openthread updated: ec2b0d4873...b945928d72
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2023 Espressif Systems (Shanghai) CO LTD
|
||||
* SPDX-FileCopyrightText: 2023-2025 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
@@ -10,6 +10,11 @@
|
||||
#include <esp_openthread.h>
|
||||
#include <esp_openthread_types.h>
|
||||
|
||||
#define ESP_OPENTHREAD_BORDER_ROUTER_FLAG_OF_INTEREST \
|
||||
(OT_CHANGED_THREAD_ROLE | OT_CHANGED_THREAD_EXT_PANID | OT_CHANGED_THREAD_NETWORK_NAME | \
|
||||
OT_CHANGED_ACTIVE_DATASET | OT_CHANGED_THREAD_PARTITION_ID | OT_CHANGED_THREAD_BACKBONE_ROUTER_STATE | \
|
||||
OT_CHANGED_PSKC)
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
@@ -5,4 +5,4 @@ supplier: 'Organization: Espressif Systems (Shanghai) CO LTD'
|
||||
originator: 'Organization: Google LLC'
|
||||
description: OpenThread released by Google is an open-source implementation of the Thread networking
|
||||
url: https://github.com/espressif/openthread
|
||||
hash: ec2b0d487356d2955346457a6515201039140037
|
||||
hash: b945928d722177cd9caeab2e1025499628c101ef
|
||||
|
@@ -10,7 +10,9 @@
|
||||
#include <esp_check.h>
|
||||
#include <esp_event.h>
|
||||
#include <esp_log.h>
|
||||
#include <esp_openthread_border_router.h>
|
||||
#include <esp_openthread_dns64.h>
|
||||
#include <esp_openthread_meshcop_mdns.h>
|
||||
#include <esp_openthread_netif_glue_priv.h>
|
||||
#include <esp_openthread_radio.h>
|
||||
#include <esp_openthread_state.h>
|
||||
@@ -19,6 +21,19 @@
|
||||
|
||||
#define TAG "OT_STATE"
|
||||
|
||||
#if CONFIG_OPENTHREAD_BORDER_ROUTER
|
||||
static void handle_ot_border_router_state_changed(otInstance* instance)
|
||||
{
|
||||
otDeviceRole role = otThreadGetDeviceRole(esp_openthread_get_instance());
|
||||
|
||||
if (role == OT_DEVICE_ROLE_CHILD || role == OT_DEVICE_ROLE_ROUTER || role == OT_DEVICE_ROLE_LEADER) {
|
||||
esp_openthread_publish_meshcop_mdns(esp_openthread_get_meshcop_instance_name());
|
||||
} else {
|
||||
esp_openthread_remove_meshcop_mdns();
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
static void handle_ot_netif_state_change(otInstance* instance)
|
||||
{
|
||||
if (otIp6IsEnabled(instance)) {
|
||||
@@ -123,6 +138,12 @@ static void ot_state_change_callback(otChangedFlags changed_flags, void* ctx)
|
||||
return;
|
||||
}
|
||||
|
||||
#if CONFIG_OPENTHREAD_BORDER_ROUTER
|
||||
if (changed_flags & ESP_OPENTHREAD_BORDER_ROUTER_FLAG_OF_INTEREST) {
|
||||
handle_ot_border_router_state_changed(instance);
|
||||
}
|
||||
#endif
|
||||
|
||||
if (changed_flags & OT_CHANGED_THREAD_ROLE) {
|
||||
handle_ot_role_change(instance);
|
||||
}
|
||||
|
Reference in New Issue
Block a user