This commit is contained in:
2026-05-22 21:52:50 +03:00
commit be7c60e4dd
1854 changed files with 583428 additions and 0 deletions
@@ -0,0 +1,96 @@
#include "Insights.h"
#include "WiFi.h"
#include "inttypes.h"
#include "esp_err.h"
#include "esp_random.h"
const char insights_auth_key[] = "<ENTER YOUR AUTH KEY>";
#define WIFI_SSID "<ENTER YOUR SSID>"
#define WIFI_PASSPHRASE "<ENTER YOUR PASSWORD>"
#define MAX_CRASHES 5
#define MAX_PTRS 30
#define TAG "sketch"
RTC_NOINIT_ATTR static uint32_t s_reset_count;
static void *s_ptrs[MAX_PTRS];
static void smoke_test() {
int dice;
int count = 0;
bool allocating = false;
while (1) {
dice = esp_random() % 500;
log_i("dice=%d", dice);
if (dice > 0 && dice < 150) {
log_e("[count][%d]", count);
} else if (dice > 150 && dice < 300) {
log_w("[count][%d]", count);
} else if (dice > 300 && dice < 470) {
Insights.event(TAG, "[count][%d]", count);
} else {
/* 30 in 500 probability to crash */
if (s_reset_count > MAX_CRASHES) {
Insights.event(TAG, "[count][%d]", count);
} else {
log_e("[count][%d] [crash_count][%" PRIu32 "] [excvaddr][0x0f] Crashing...", count, s_reset_count);
//ToDo: find better way to crash
abort();
}
}
Insights.metrics.dumpHeap();
if (count % MAX_PTRS == 0) {
allocating = !allocating;
log_i("Allocating:%s\n", allocating ? "true" : "false");
}
if (allocating) {
uint32_t size = 1024 * (esp_random() % 8);
void *p = malloc(size);
if (p) {
memset(p, size, 'A' + (esp_random() % 26));
log_i("Allocated %" PRIu32 " bytes", size);
}
s_ptrs[count % MAX_PTRS] = p;
} else {
free(s_ptrs[count % MAX_PTRS]);
s_ptrs[count % MAX_PTRS] = NULL;
log_i("Freeing some memory...");
}
count++;
delay(1000);
}
}
void setup() {
Serial.begin(115200);
WiFi.mode(WIFI_STA);
WiFi.begin(WIFI_SSID, WIFI_PASSPHRASE);
while (WiFi.status() != WL_CONNECTED) {
delay(500);
Serial.print(".");
}
Serial.println("");
Serial.println("WiFi connected");
if (!Insights.begin(insights_auth_key)) {
return;
}
Serial.println("=========================================");
Serial.printf("ESP Insights enabled Node ID %s\n", Insights.nodeID());
Serial.println("=========================================");
if (esp_reset_reason() == ESP_RST_POWERON) {
s_reset_count = 1;
} else {
s_reset_count++;
}
}
void loop() {
smoke_test();
delay(100);
}
@@ -0,0 +1,45 @@
# Smoke Test App
## What to expect in this example?
- This example is expected to exercise the various features of the ESP Insights framework
- As a smoke test, this allows you to validate, by a quick perusal of the ESP Insights dashboard, the functioning of all the high-level features
## End-to-End Tests
### Lifecycle of the test (Hard reset resets the cycle)
* Device boots up and logs errors/warnings/events in random order every 10 seconds
* Every error/warning/event log with "diag_smoke" tag is associated with an incremental counter
* There's a 30/500 probability that device will crash, this is done for verification of crash
* Device will crash only five times and hard reset will reset the counter to 1
* On sixth boot onwards device will not crash and logs errors/warnings/events and adds heap metrics
### Facilitate the Auth Key
In this example we will be using the auth key that we downloaded while [setting up ESP Insights account](https://github.com/espressif/esp-insights/tree/main/examples#set-up-esp-insights-account).
Copy Auth Key to the example
```
const char insights_auth_key[] = "<ENTER YOUR AUTH KEY>";
```
### Enter Wi-Fi Credentials
Inside the example sketch, enter your Wi-Fi credentials in `WIFI_SSID` and `WIFI_PASSPHRASE` macros.
### Setup
* Build and flash the sketch and monitor the console
* Device will eventually crash after some time
* Before every crash you will see below log print
```
E (75826) diag_smoke: [count][7] [crash_count][1] [excvaddr][0x0f] Crashing...
// [count][7]: count associated with the log
// [crash_count][1]: This is the first crash since device boot up, this number will increment as the crash count increases
// [excvaddr][0x0f]: Exception vaddr, will see this in crash verification part below
```
* You'll see five crashes([crash_count][5]) and after that device will not crash and will keep on logging and adding metrics
* Onwards this point keep device running for more than 30 minutes
* Now we are all set to visit the [dashboard](https://dashboard.insights.espressif.com)
* Select the node-id printed on the console, look for the below log. It is printed early when device boots up
```
ESP Insights enabled for Node ID ----- wx3vEoGgJPk7Rn5JvRUFs9
```
@@ -0,0 +1,6 @@
requires:
- CONFIG_ESP_INSIGHTS_ENABLED=y
requires_any:
- CONFIG_SOC_WIFI_SUPPORTED=y
- CONFIG_ESP_WIFI_REMOTE_ENABLED=y
@@ -0,0 +1,29 @@
#include "Insights.h"
#include "WiFi.h"
const char insights_auth_key[] = "<ENTER YOUR AUTH KEY>";
#define WIFI_SSID "<ENTER YOUR SSID>"
#define WIFI_PASSPHRASE "<ENTER YOUR PASSWORD>"
void setup() {
Serial.begin(115200);
WiFi.mode(WIFI_STA);
WiFi.begin(WIFI_SSID, WIFI_PASSPHRASE);
while (WiFi.status() != WL_CONNECTED) {
delay(500);
Serial.print(".");
}
Serial.println("");
Serial.println("WiFi connected");
if (!Insights.begin(insights_auth_key)) {
return;
}
Serial.println("=========================================");
Serial.printf("ESP Insights enabled Node ID %s\n", Insights.nodeID());
Serial.println("=========================================");
}
void loop() {
delay(1000);
}
@@ -0,0 +1,43 @@
# Minimal Diagnostics example
- [What to expect in this example](#what-to-expect-in-this-example)
- [Try out the example](#try-out-the-example)
- [Insights Dashboard](#insights-dashboard)
## What to expect in this example?
- This example demonstrates the use of ESP Insights framework in minimal way
- Device will try to connect with the configured Wi-Fi network
- ESP Insights is enabled in this example, so any error/warning logs, crashes will be reported to cloud
- This example collects heap and Wi-Fi metrics every 10 minutes and network variables are collected when they change
## Try out the example
### Facilitate the Auth Key
In this example we will be using the auth key that we downloaded while [setting up ESP Insights account](https://github.com/espressif/esp-insights/tree/main/examples#set-up-esp-insights-account).
Copy Auth Key to the example
```
const char insights_auth_key[] = "<ENTER YOUR AUTH KEY>";
```
### Enter Wi-Fi Credentials
Inside the example sketch, enter your Wi-Fi credentials in `WIFI_SSID` and `WIFI_PASSPHRASE` macros.
### Get the Node ID
- Start the Serial monitor
- Once the device boots, it will connect to the Wi-Fi network, look for logs similar to below and make a note of Node ID.
```
I (4161) esp_insights: =========================================
I (4171) esp_insights: Insights enabled for Node ID 246F2880371C
I (4181) esp_insights: =========================================
```
## Insights Dashboard
Once everything is set up, any diagnostics information reported will show up on the [Insights Dashboard](https://dashboard.insights.espressif.com). Sign in using the your credentials.
### Monitor the device diagnostics
Visit [Nodes](https://dashboard.insights.espressif.com/home/nodes) section on the dashboard and click on the Node ID to monitor device diagnostics information.
> Note: Diagnostics data is reported dynamically or when the buffers are filled to configured threshold. So, it can take some time for the logs to reflect on the dashboard. Moreover, if a large number of logs are generated then data will be sent to cloud but, if it fails(eg reasons: Wi-Fi failure, No internet) then any newer logs will be dropped.
@@ -0,0 +1,6 @@
requires:
- CONFIG_ESP_INSIGHTS_ENABLED=y
requires_any:
- CONFIG_SOC_WIFI_SUPPORTED=y
- CONFIG_ESP_WIFI_REMOTE_ENABLED=y