Files
esp-matter/examples/controller/main/app_main.cpp
T
WanqQixiang 27976aeb94 Add controller example and esp_matter_controller component
-Add cluster command feature (on_off, level_control, color_control)

  -Add reading attributes/events features

  -Add writing attributes feature (on_off, level_control, color_control)

  -Add subscribing attributes/events and shutdowning subscription features
2022-11-18 19:27:06 +08:00

63 lines
1.6 KiB
C++

/*
This example code is in the Public Domain (or CC0 licensed, at your option.)
Unless required by applicable law or agreed to in writing, this
software is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
CONDITIONS OF ANY KIND, either express or implied.
*/
#include <esp_err.h>
#include <esp_log.h>
#include <nvs_flash.h>
#include <esp_matter.h>
#include <esp_matter_commissioner.h>
#include <esp_matter_console.h>
#include <esp_matter_controller_console.h>
#include <esp_matter_ota.h>
#include <esp_route_hook.h>
#include <app_reset.h>
static const char *TAG = "app_main";
uint16_t switch_endpoint_id = 0;
using namespace esp_matter;
using namespace esp_matter::attribute;
using namespace esp_matter::endpoint;
static void app_event_cb(const ChipDeviceEvent *event, intptr_t arg)
{
switch (event->Type) {
case chip::DeviceLayer::DeviceEventType::PublicEventTypes::kInterfaceIpAddressChanged:
ESP_LOGI(TAG, "Interface gets IP Address");
break;
default:
break;
}
}
extern "C" void app_main()
{
esp_err_t err = ESP_OK;
/* Initialize the ESP NVS layer */
nvs_flash_init();
/* Matter start */
err = esp_matter::start(app_event_cb);
if (err != ESP_OK) {
ESP_LOGE(TAG, "Matter start failed: %d", err);
}
#if CONFIG_ENABLE_CHIP_SHELL
esp_matter::console::diagnostics_register_commands();
esp_matter::console::init();
esp_matter::lock::chip_stack_lock(portMAX_DELAY);
esp_matter::commissioner::init(5580);
esp_matter::lock::chip_stack_unlock();
esp_matter::console::controller_register_commands();
#endif
}