Files
ESPDocs/public/exemplos/esp-matter.c
T
Lucas Rayan 2a6699bbfb feat: Enhance Header component to improve active link detection
- Updated the `isActive` function in `Header.jsx` to handle root path and include logic for other paths.

chore: Update package-lock.json to remove peer dependencies

- Removed unnecessary peer dependencies from various packages in `package-lock.json`.

feat: Update frameworks.json to include example links

- Changed `exemplo_codigo` to `exemplo` and added `exemplos` links for various frameworks in `frameworks.json`.

feat: Add placa images to series.json

- Included image paths for different ESP32 series in `series.json`.

feat: Create CodeExample component for displaying code snippets

- Added a new `CodeExample.jsx` component to fetch and display code examples dynamically.

feat: Add example Arduino code for Wi-Fi connection

- Created `arduino.ino` example for connecting to Wi-Fi.

feat: Add example code for audio playback using ESP-ADF

- Created `esp-adf.c` example for audio playback using ESP-ADF.

feat: Add example code for DSP operations

- Created `esp-dsp.c` example demonstrating basic DSP operations.

feat: Add example code for ESP-IDF LED blinking

- Created `esp-idf.c` example for blinking an LED using ESP-IDF.

feat: Add example code for Matter integration

- Created `esp-matter.c` example for Matter device initialization and event handling.

feat: Add example code for neural network operations

- Created `esp-nn.c` example demonstrating basic neural network operations.

feat: Add example code for face detection using ESP-WHO

- Created `esp-who.c` example for face detection using ESP-WHO library.

feat: Add MicroPython example for LED blinking

- Created `micropython.py` example for blinking an LED using MicroPython.
2025-10-22 23:10:30 -03:00

45 lines
1.5 KiB
C

#include <stdio.h>
#include "esp_log.h"
#include "esp_matter.h"
#include "esp_matter_controller.h"
#include "nvs_flash.h"
static const char *TAG = "esp-matter-example";
void app_event_cb(const esp_matter_event_t *event)
{
switch (event->event_id) {
case ESP_MATTER_EVENT_ATTRIBUTE_UPDATE: {
const esp_matter_attr_update_t *attr_update = &event->data.attr_update;
if (attr_update->endpoint_id == 1 && attr_update->cluster_id == ESP_MATTER_ON_OFF_CLUSTER_ID) {
bool on = false;
esp_matter_attribute_get(attr_update->endpoint_id, attr_update->cluster_id,
attr_update->attribute_id, &on);
ESP_LOGI(TAG, "Lâmpada %s", on ? "ligada" : "desligada");
}
break;
}
default:
break;
}
}
void app_main(void)
{
// Inicializa NVS
esp_err_t err = nvs_flash_init();
if (err == ESP_ERR_NVS_NO_FREE_PAGES || err == ESP_ERR_NVS_NEW_VERSION_FOUND) {
ESP_ERROR_CHECK(nvs_flash_erase());
ESP_ERROR_CHECK(nvs_flash_init());
}
// Inicializa o Matter node
esp_matter::node_t *node = esp_matter::node::create(NULL, app_event_cb);
esp_matter::endpoint_t *endpoint = esp_matter::endpoint::create(node, ESP_MATTER_ENDPOINT_TYPE_ON_OFF_LIGHT);
// Inicia o stack Matter
ESP_ERROR_CHECK(esp_matter::start(node));
ESP_LOGI(TAG, "Dispositivo Matter iniciado. Aguardando comissionamento...");
}