diff --git a/components/esp_matter/esp_matter_core.cpp b/components/esp_matter/esp_matter_core.cpp index be60fe74b..0a23d233f 100644 --- a/components/esp_matter/esp_matter_core.cpp +++ b/components/esp_matter/esp_matter_core.cpp @@ -18,12 +18,14 @@ #include #include +#include #include #include #include #include #include #include +#include #include #include #if CHIP_DEVICE_CONFIG_ENABLE_THREAD @@ -43,6 +45,8 @@ using chip::DeviceLayer::ConfigurationMgr; using chip::DeviceLayer::ConnectivityManager; using chip::DeviceLayer::ConnectivityMgr; using chip::DeviceLayer::PlatformMgr; +using chip::DeviceLayer::DiagnosticDataProvider; +using chip::DeviceLayer::GetDiagnosticDataProvider; #if CHIP_DEVICE_CONFIG_ENABLE_THREAD using chip::DeviceLayer::ThreadStackMgr; #endif @@ -665,8 +669,15 @@ static void esp_matter_chip_init_task(intptr_t context) if (endpoint::enable_all() != ESP_OK) { ESP_LOGE(TAG, "Enable all endpoints failure"); } - // Add this function to record start up event in basic information cluster. + // The following two events can't be recorded when we start the server because the endpoints are not enabled. + // TODO: Find a better way to record the events which should be recorded in matter server init + // Record start up event in basic information cluster. PlatformMgr().HandleServerStarted(); + // Record boot reason evnet in general diagnostics cluster. + chip::app::Clusters::GeneralDiagnostics::BootReasonType bootReason; + if (GetDiagnosticDataProvider().GetBootReason(bootReason) == CHIP_NO_ERROR) { + chip::app::Clusters::GeneralDiagnosticsServer::Instance().OnDeviceReboot(bootReason); + } #if CHIP_DEVICE_CONFIG_ENABLE_WIFI { static chip::app::Clusters::NetworkCommissioning::Instance sWiFiNetworkCommissioningInstance(0,