mirror of
https://github.com/espressif/esp-matter.git
synced 2026-04-27 19:13:13 +00:00
Enable insights support in light app
This commit is contained in:
@@ -0,0 +1,16 @@
|
||||
# App Insights
|
||||
|
||||
if(CONFIG_ESP_MATTER_ENABLE_INSIGHTS)
|
||||
set(srcs app_insights.c)
|
||||
endif()
|
||||
|
||||
idf_component_register(SRCS ${srcs}
|
||||
INCLUDE_DIRS .
|
||||
PRIV_REQUIRES )
|
||||
|
||||
if(CONFIG_ESP_MATTER_ENABLE_INSIGHTS)
|
||||
idf_component_get_property(esp_insights_lib esp_insights COMPONENT_LIB)
|
||||
idf_component_get_property(esp_diag_lib esp_diagnostics COMPONENT_LIB)
|
||||
target_link_libraries(${COMPONENT_LIB} PRIVATE ${esp_insights_lib})
|
||||
target_link_libraries(${COMPONENT_LIB} PRIVATE ${esp_diag_lib})
|
||||
endif()
|
||||
@@ -0,0 +1,12 @@
|
||||
menu "ESP Matter Insights"
|
||||
|
||||
config ESP_MATTER_ENABLE_INSIGHTS
|
||||
bool "ESP Matter Enable Insights"
|
||||
default n
|
||||
select ESP_INSIGHTS_ENABLED
|
||||
help
|
||||
Enable the ESP Matter Insights service.
|
||||
ESP Insights is a remote diagnostics solution that allows users to
|
||||
remotely monitor the devices in the field.
|
||||
|
||||
endmenu
|
||||
@@ -0,0 +1,22 @@
|
||||
/*
|
||||
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_insights.h>
|
||||
#include <esp_rmaker_utils.h>
|
||||
|
||||
esp_err_t app_insights_enable(const char *auth_key)
|
||||
{
|
||||
// Sync the time with the NTP server
|
||||
esp_rmaker_time_sync_init(NULL);
|
||||
|
||||
esp_insights_config_t config = {
|
||||
.log_type = ESP_DIAG_LOG_TYPE_ERROR | ESP_DIAG_LOG_TYPE_WARNING,
|
||||
.auth_key = auth_key,
|
||||
};
|
||||
return esp_insights_init(&config);
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
/*
|
||||
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.
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#if __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#if CONFIG_ESP_MATTER_ENABLE_INSIGHTS
|
||||
|
||||
/**
|
||||
* @brief Initialize the app insights in matter example
|
||||
*
|
||||
* @param[in] auth_key The app insights auth key
|
||||
*
|
||||
* @return ESP_OK on success, appropriate error code otherwise
|
||||
*/
|
||||
esp_err_t app_insights_enable(const char *auth_key);
|
||||
|
||||
#endif // CONFIG_ESP_MATTER_ENABLE_INSIGHTS
|
||||
|
||||
#if __cplusplus
|
||||
}
|
||||
#endif
|
||||
@@ -0,0 +1,20 @@
|
||||
## IDF Component Manager Manifest File
|
||||
dependencies:
|
||||
idf:
|
||||
version: ">=4.4.0"
|
||||
|
||||
rtc_store:
|
||||
path: components/rtc_store
|
||||
git: https://github.com/espressif/esp-insights.git
|
||||
|
||||
esp_diagnostics:
|
||||
path: components/esp_diagnostics
|
||||
git: https://github.com/espressif/esp-insights.git
|
||||
|
||||
rmaker_common:
|
||||
path: ./
|
||||
git: https://github.com/espressif/esp-rainmaker-common.git
|
||||
|
||||
esp_insights:
|
||||
path: components/esp_insights
|
||||
git: https://github.com/espressif/esp-insights.git
|
||||
@@ -1,4 +1,4 @@
|
||||
set(PRIV_REQUIRES_LIST device esp_matter esp_matter_console route_hook app_qrcode app_reset esp_matter_ota)
|
||||
set(PRIV_REQUIRES_LIST device esp_matter esp_matter_console route_hook app_qrcode app_reset esp_matter_ota app_insights)
|
||||
|
||||
idf_component_register(SRC_DIRS "."
|
||||
PRIV_INCLUDE_DIRS "."
|
||||
|
||||
@@ -17,6 +17,15 @@
|
||||
|
||||
#include <app_priv.h>
|
||||
#include <app_qrcode.h>
|
||||
#include <app_insights.h>
|
||||
|
||||
#if CONFIG_ESP_MATTER_ENABLE_INSIGHTS
|
||||
/*
|
||||
* Please check the below link to obtain the ESP Insights Auth Key
|
||||
* https://github.com/espressif/esp-insights/tree/4bc3b0685223a75df0ce71c73af70014f4dd1633/examples#set-up-esp-insights-account
|
||||
*/
|
||||
const char * INSIGHTS_AUTH_KEY = "<paste_insights_auth_key_here>";
|
||||
#endif
|
||||
|
||||
static const char *TAG = "app_main";
|
||||
int light_endpoint_id = 0;
|
||||
@@ -94,4 +103,8 @@ extern "C" void app_main()
|
||||
#if CONFIG_ENABLE_OTA_REQUESTOR
|
||||
esp_matter_ota_requestor_init();
|
||||
#endif
|
||||
|
||||
#if CONFIG_ESP_MATTER_ENABLE_INSIGHTS
|
||||
app_insights_enable(INSIGHTS_AUTH_KEY);
|
||||
#endif
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user