mirror of
https://github.com/espressif/esp-matter.git
synced 2026-04-27 19:13:13 +00:00
Merge branch 'commissioning_events' into 'main'
Expose AppDelegate callbacks APIs as events to application See merge request app-frameworks/esp-matter!183
This commit is contained in:
@@ -32,6 +32,7 @@ application.
|
||||
|
||||
#include <app-common/zap-generated/att-storage.h>
|
||||
#include <app/server/Dnssd.h>
|
||||
#include <platform/CHIPDeviceEvent.h>
|
||||
#include <platform/CHIPDeviceLayer.h>
|
||||
|
||||
namespace esp_matter {
|
||||
@@ -103,3 +104,26 @@ typedef enum command_flags {
|
||||
} command_flags_t;
|
||||
|
||||
} /* esp_matter */
|
||||
|
||||
namespace chip {
|
||||
namespace DeviceLayer {
|
||||
namespace DeviceEventType {
|
||||
|
||||
/**
|
||||
* Enumerates platform-specific event types that are visible to the application.
|
||||
*/
|
||||
enum
|
||||
{
|
||||
/** Signals that Commissioning session has started */
|
||||
kCommissioningSessionStarted = kRange_PublicPlatformSpecific + 0x1000,
|
||||
/** Signals that Commissioning session has stopped */
|
||||
kCommissioningSessionStopped,
|
||||
/** Signals that Commissioning window is now opend */
|
||||
kCommissioningWindowOpened,
|
||||
/** Signals that Commissioning window is now closed */
|
||||
kCommissioningWindowClosed,
|
||||
};
|
||||
|
||||
} // DeviceEventType
|
||||
} // DeviceLayer
|
||||
} // chip
|
||||
|
||||
@@ -62,6 +62,45 @@ namespace {
|
||||
#if CONFIG_ENABLE_ESP32_FACTORY_DATA_PROVIDER
|
||||
chip::DeviceLayer::ESP32FactoryDataProvider factory_data_provider;
|
||||
#endif // CONFIG_ENABLE_ESP32_FACTORY_DATA_PROVIDER
|
||||
|
||||
class AppDelegateImpl : public AppDelegate
|
||||
{
|
||||
public:
|
||||
void OnCommissioningSessionStarted()
|
||||
{
|
||||
PostEvent(chip::DeviceLayer::DeviceEventType::kCommissioningSessionStarted);
|
||||
}
|
||||
|
||||
void OnCommissioningSessionStopped()
|
||||
{
|
||||
PostEvent(chip::DeviceLayer::DeviceEventType::kCommissioningSessionStopped);
|
||||
}
|
||||
|
||||
void OnCommissioningWindowOpened()
|
||||
{
|
||||
PostEvent(chip::DeviceLayer::DeviceEventType::kCommissioningWindowOpened);
|
||||
}
|
||||
|
||||
void OnCommissioningWindowClosed()
|
||||
{
|
||||
PostEvent(chip::DeviceLayer::DeviceEventType::kCommissioningWindowClosed);
|
||||
}
|
||||
|
||||
private:
|
||||
void PostEvent(uint16_t eventType)
|
||||
{
|
||||
chip::DeviceLayer::ChipDeviceEvent event;
|
||||
event.Type = eventType;
|
||||
CHIP_ERROR error = chip::DeviceLayer::PlatformMgr().PostEvent(&event);
|
||||
if (error != CHIP_NO_ERROR)
|
||||
{
|
||||
ESP_LOGE(TAG, "Failed to post event from AppDelegate, err:%" CHIP_ERROR_FORMAT, error.Format());
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
AppDelegateImpl s_app_delegate;
|
||||
|
||||
} // namespace
|
||||
|
||||
typedef struct _attribute {
|
||||
@@ -648,8 +687,7 @@ static void esp_matter_chip_init_task(intptr_t context)
|
||||
|
||||
static chip::CommonCaseDeviceServerInitParams initParams;
|
||||
initParams.InitializeStaticResourcesBeforeServerInit();
|
||||
/** TODO: Add these callbacks and pass them on to the application */
|
||||
// initParams.appDelegate = &sCallbacks;
|
||||
initParams.appDelegate = &s_app_delegate;
|
||||
chip::Server::GetInstance().Init(initParams);
|
||||
|
||||
#if CHIP_DEVICE_CONFIG_ENABLE_THREAD
|
||||
|
||||
@@ -29,17 +29,37 @@ using namespace esp_matter::attribute;
|
||||
static void app_event_cb(const ChipDeviceEvent *event, intptr_t arg)
|
||||
{
|
||||
switch (event->Type) {
|
||||
case chip::DeviceLayer::DeviceEventType::PublicEventTypes::kInterfaceIpAddressChanged:
|
||||
case chip::DeviceLayer::DeviceEventType::kInterfaceIpAddressChanged:
|
||||
#if !CHIP_DEVICE_CONFIG_ENABLE_THREAD
|
||||
chip::app::DnssdServer::Instance().StartServer();
|
||||
esp_route_hook_init(esp_netif_get_handle_from_ifkey("WIFI_STA_DEF"));
|
||||
#endif
|
||||
break;
|
||||
|
||||
case chip::DeviceLayer::DeviceEventType::PublicEventTypes::kCommissioningComplete:
|
||||
case chip::DeviceLayer::DeviceEventType::kCommissioningComplete:
|
||||
ESP_LOGI(TAG, "Commissioning complete");
|
||||
break;
|
||||
|
||||
case chip::DeviceLayer::DeviceEventType::kFailSafeTimerExpired:
|
||||
ESP_LOGI(TAG, "Commissioning failed, fail safe timer expired");
|
||||
break;
|
||||
|
||||
case chip::DeviceLayer::DeviceEventType::kCommissioningSessionStarted:
|
||||
ESP_LOGI(TAG, "Commissioning session started");
|
||||
break;
|
||||
|
||||
case chip::DeviceLayer::DeviceEventType::kCommissioningSessionStopped:
|
||||
ESP_LOGI(TAG, "Commissioning session stopped");
|
||||
break;
|
||||
|
||||
case chip::DeviceLayer::DeviceEventType::kCommissioningWindowOpened:
|
||||
ESP_LOGI(TAG, "Commissioning window opened");
|
||||
break;
|
||||
|
||||
case chip::DeviceLayer::DeviceEventType::kCommissioningWindowClosed:
|
||||
ESP_LOGI(TAG, "Commissioning window closed");
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -30,17 +30,37 @@ using namespace chip::app::Clusters;
|
||||
static void app_event_cb(const ChipDeviceEvent *event, intptr_t arg)
|
||||
{
|
||||
switch (event->Type) {
|
||||
case chip::DeviceLayer::DeviceEventType::PublicEventTypes::kInterfaceIpAddressChanged:
|
||||
case chip::DeviceLayer::DeviceEventType::kInterfaceIpAddressChanged:
|
||||
#if !CHIP_DEVICE_CONFIG_ENABLE_THREAD
|
||||
chip::app::DnssdServer::Instance().StartServer();
|
||||
esp_route_hook_init(esp_netif_get_handle_from_ifkey("WIFI_STA_DEF"));
|
||||
#endif
|
||||
break;
|
||||
|
||||
case chip::DeviceLayer::DeviceEventType::PublicEventTypes::kCommissioningComplete:
|
||||
case chip::DeviceLayer::DeviceEventType::kCommissioningComplete:
|
||||
ESP_LOGI(TAG, "Commissioning complete");
|
||||
break;
|
||||
|
||||
case chip::DeviceLayer::DeviceEventType::kFailSafeTimerExpired:
|
||||
ESP_LOGI(TAG, "Commissioning failed, fail safe timer expired");
|
||||
break;
|
||||
|
||||
case chip::DeviceLayer::DeviceEventType::kCommissioningSessionStarted:
|
||||
ESP_LOGI(TAG, "Commissioning session started");
|
||||
break;
|
||||
|
||||
case chip::DeviceLayer::DeviceEventType::kCommissioningSessionStopped:
|
||||
ESP_LOGI(TAG, "Commissioning session stopped");
|
||||
break;
|
||||
|
||||
case chip::DeviceLayer::DeviceEventType::kCommissioningWindowOpened:
|
||||
ESP_LOGI(TAG, "Commissioning window opened");
|
||||
break;
|
||||
|
||||
case chip::DeviceLayer::DeviceEventType::kCommissioningWindowClosed:
|
||||
ESP_LOGI(TAG, "Commissioning window closed");
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -29,17 +29,37 @@ 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:
|
||||
case chip::DeviceLayer::DeviceEventType::kInterfaceIpAddressChanged:
|
||||
#if !CHIP_DEVICE_CONFIG_ENABLE_THREAD
|
||||
chip::app::DnssdServer::Instance().StartServer();
|
||||
esp_route_hook_init(esp_netif_get_handle_from_ifkey("WIFI_STA_DEF"));
|
||||
#endif
|
||||
break;
|
||||
|
||||
case chip::DeviceLayer::DeviceEventType::PublicEventTypes::kCommissioningComplete:
|
||||
case chip::DeviceLayer::DeviceEventType::kCommissioningComplete:
|
||||
ESP_LOGI(TAG, "Commissioning complete");
|
||||
break;
|
||||
|
||||
case chip::DeviceLayer::DeviceEventType::kFailSafeTimerExpired:
|
||||
ESP_LOGI(TAG, "Commissioning failed, fail safe timer expired");
|
||||
break;
|
||||
|
||||
case chip::DeviceLayer::DeviceEventType::kCommissioningSessionStarted:
|
||||
ESP_LOGI(TAG, "Commissioning session started");
|
||||
break;
|
||||
|
||||
case chip::DeviceLayer::DeviceEventType::kCommissioningSessionStopped:
|
||||
ESP_LOGI(TAG, "Commissioning session stopped");
|
||||
break;
|
||||
|
||||
case chip::DeviceLayer::DeviceEventType::kCommissioningWindowOpened:
|
||||
ESP_LOGI(TAG, "Commissioning window opened");
|
||||
break;
|
||||
|
||||
case chip::DeviceLayer::DeviceEventType::kCommissioningWindowClosed:
|
||||
ESP_LOGI(TAG, "Commissioning window closed");
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -28,17 +28,37 @@ app_driver_handle_t light_handle = NULL;
|
||||
static void app_event_cb(const ChipDeviceEvent *event, intptr_t arg)
|
||||
{
|
||||
switch (event->Type) {
|
||||
case chip::DeviceLayer::DeviceEventType::PublicEventTypes::kInterfaceIpAddressChanged:
|
||||
case chip::DeviceLayer::DeviceEventType::kInterfaceIpAddressChanged:
|
||||
#if !CHIP_DEVICE_CONFIG_ENABLE_THREAD
|
||||
chip::app::DnssdServer::Instance().StartServer();
|
||||
esp_route_hook_init(esp_netif_get_handle_from_ifkey("WIFI_STA_DEF"));
|
||||
#endif
|
||||
break;
|
||||
|
||||
case chip::DeviceLayer::DeviceEventType::PublicEventTypes::kCommissioningComplete:
|
||||
case chip::DeviceLayer::DeviceEventType::kCommissioningComplete:
|
||||
ESP_LOGI(TAG, "Commissioning complete");
|
||||
break;
|
||||
|
||||
case chip::DeviceLayer::DeviceEventType::kFailSafeTimerExpired:
|
||||
ESP_LOGI(TAG, "Commissioning failed, fail safe timer expired");
|
||||
break;
|
||||
|
||||
case chip::DeviceLayer::DeviceEventType::kCommissioningSessionStarted:
|
||||
ESP_LOGI(TAG, "Commissioning session started");
|
||||
break;
|
||||
|
||||
case chip::DeviceLayer::DeviceEventType::kCommissioningSessionStopped:
|
||||
ESP_LOGI(TAG, "Commissioning session stopped");
|
||||
break;
|
||||
|
||||
case chip::DeviceLayer::DeviceEventType::kCommissioningWindowOpened:
|
||||
ESP_LOGI(TAG, "Commissioning window opened");
|
||||
break;
|
||||
|
||||
case chip::DeviceLayer::DeviceEventType::kCommissioningWindowClosed:
|
||||
ESP_LOGI(TAG, "Commissioning window closed");
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -28,17 +28,37 @@ using namespace esp_matter::attribute;
|
||||
static void app_event_cb(const ChipDeviceEvent *event, intptr_t arg)
|
||||
{
|
||||
switch (event->Type) {
|
||||
case chip::DeviceLayer::DeviceEventType::PublicEventTypes::kInterfaceIpAddressChanged:
|
||||
case chip::DeviceLayer::DeviceEventType::kInterfaceIpAddressChanged:
|
||||
#if !CHIP_DEVICE_CONFIG_ENABLE_THREAD
|
||||
chip::app::DnssdServer::Instance().StartServer();
|
||||
esp_route_hook_init(esp_netif_get_handle_from_ifkey("WIFI_STA_DEF"));
|
||||
#endif
|
||||
break;
|
||||
|
||||
case chip::DeviceLayer::DeviceEventType::PublicEventTypes::kCommissioningComplete:
|
||||
case chip::DeviceLayer::DeviceEventType::kCommissioningComplete:
|
||||
ESP_LOGI(TAG, "Commissioning complete");
|
||||
break;
|
||||
|
||||
case chip::DeviceLayer::DeviceEventType::kFailSafeTimerExpired:
|
||||
ESP_LOGI(TAG, "Commissioning failed, fail safe timer expired");
|
||||
break;
|
||||
|
||||
case chip::DeviceLayer::DeviceEventType::kCommissioningSessionStarted:
|
||||
ESP_LOGI(TAG, "Commissioning session started");
|
||||
break;
|
||||
|
||||
case chip::DeviceLayer::DeviceEventType::kCommissioningSessionStopped:
|
||||
ESP_LOGI(TAG, "Commissioning session stopped");
|
||||
break;
|
||||
|
||||
case chip::DeviceLayer::DeviceEventType::kCommissioningWindowOpened:
|
||||
ESP_LOGI(TAG, "Commissioning window opened");
|
||||
break;
|
||||
|
||||
case chip::DeviceLayer::DeviceEventType::kCommissioningWindowClosed:
|
||||
ESP_LOGI(TAG, "Commissioning window closed");
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user