mirror of
https://github.com/espressif/esp-matter.git
synced 2026-04-27 19:13:13 +00:00
Controller: Make the commissioner feature optional
This commit is contained in:
@@ -14,7 +14,11 @@
|
||||
|
||||
#include <controller/CommissioneeDeviceProxy.h>
|
||||
#include <esp_log.h>
|
||||
#if CONFIG_ESP_MATTER_COMMISSIONER_ENABLE
|
||||
#include <esp_matter_commissioner.h>
|
||||
#else
|
||||
#include <app/server/Server.h>
|
||||
#endif
|
||||
#include <esp_matter_controller_subscribe_command.h>
|
||||
|
||||
#include "DataModelLogger.h"
|
||||
@@ -78,11 +82,18 @@ void subscribe_command::on_device_connection_failure_fcn(void *context, const Sc
|
||||
|
||||
esp_err_t subscribe_command::send_command()
|
||||
{
|
||||
#if CONFIG_ESP_MATTER_COMMISSIONER_ENABLE
|
||||
if (CHIP_NO_ERROR ==
|
||||
commissioner::get_device_commissioner()->GetConnectedDevice(m_node_id, &on_device_connected_cb,
|
||||
&on_device_connection_failure_cb)) {
|
||||
return ESP_OK;
|
||||
}
|
||||
#else
|
||||
chip::Server *server = &(chip::Server::GetInstance());
|
||||
server->GetCASESessionManager()->FindOrEstablishSession(ScopedNodeId(m_node_id, /* fabric index */ 1),
|
||||
&on_device_connected_cb, &on_device_connection_failure_cb);
|
||||
return ESP_OK;
|
||||
#endif
|
||||
chip::Platform::Delete(this);
|
||||
return ESP_FAIL;
|
||||
}
|
||||
@@ -183,7 +194,11 @@ esp_err_t send_shutdown_subscription(uint64_t node_id, uint32_t subscription_id)
|
||||
{
|
||||
if (CHIP_NO_ERROR !=
|
||||
InteractionModelEngine::GetInstance()->ShutdownSubscription(
|
||||
#if CONFIG_ESP_MATTER_COMMISSIONER_ENABLE
|
||||
ScopedNodeId(node_id, commissioner::get_device_commissioner()->GetFabricIndex()), subscription_id)) {
|
||||
#else
|
||||
ScopedNodeId(node_id, /* fabric index */ 1), subscription_id)) {
|
||||
#endif
|
||||
ESP_LOGE(TAG, "Shutdown Subscription Failed");
|
||||
return ESP_FAIL;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user