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:
@@ -13,10 +13,14 @@
|
||||
// limitations under the License.
|
||||
|
||||
#include <esp_check.h>
|
||||
#include <esp_matter_commissioner.h>
|
||||
#include <esp_matter_controller_utils.h>
|
||||
#include <esp_matter_controller_write_command.h>
|
||||
#include <json_parser.h>
|
||||
#if CONFIG_ESP_MATTER_COMMISSIONER_ENABLE
|
||||
#include <esp_matter_commissioner.h>
|
||||
#else
|
||||
#include <app/server/Server.h>
|
||||
#endif
|
||||
|
||||
using namespace chip::app::Clusters;
|
||||
using chip::ByteSpan;
|
||||
@@ -69,11 +73,18 @@ void write_command<T>::on_device_connection_failure_fcn(void *context, const Sco
|
||||
template <class T>
|
||||
esp_err_t write_command<T>::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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user