Controller: Make the commissioner feature optional

This commit is contained in:
WanqQixiang
2022-11-24 16:20:40 +08:00
parent 1baf476692
commit 00412aa3cb
11 changed files with 87 additions and 12 deletions
@@ -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;
}