forked from espressif/arduino-esp32
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathInsights.h
119 lines (93 loc) · 3.52 KB
/
Insights.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
/*
* SPDX-FileCopyrightText: 2022 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
#pragma once
#include "sdkconfig.h"
#ifdef CONFIG_ESP_INSIGHTS_ENABLED
#include "Arduino.h"
#ifdef __cplusplus
class ESPInsightsMetricsClass {
private:
bool initialized;
public:
ESPInsightsMetricsClass() : initialized(false) {}
bool addBool(const char *tag, const char *key, const char *label, const char *path);
bool addInt(const char *tag, const char *key, const char *label, const char *path);
bool addUint(const char *tag, const char *key, const char *label, const char *path);
bool addFloat(const char *tag, const char *key, const char *label, const char *path);
bool addString(const char *tag, const char *key, const char *label, const char *path);
bool addIPv4(const char *tag, const char *key, const char *label, const char *path);
bool addMAC(const char *tag, const char *key, const char *label, const char *path);
bool setBool(const char *key, bool b);
bool setInt(const char *key, int32_t i);
bool setUint(const char *key, uint32_t u);
bool setFloat(const char *key, float f);
bool setString(const char *key, const char *str);
bool setIPv4(const char *key, uint32_t ip);
bool setMAC(const char *key, uint8_t *mac);
bool remove(const char *key);
bool removeAll();
void setHeapPeriod(uint32_t seconds);
void setWiFiPeriod(uint32_t seconds);
bool dumpHeap();
bool dumpWiFi();
//internal use
void setInitialized(bool init) {
initialized = init;
}
};
class ESPInsightsVariablesClass {
private:
bool initialized;
public:
ESPInsightsVariablesClass() : initialized(false) {}
bool addBool(const char *tag, const char *key, const char *label, const char *path);
bool addInt(const char *tag, const char *key, const char *label, const char *path);
bool addUint(const char *tag, const char *key, const char *label, const char *path);
bool addFloat(const char *tag, const char *key, const char *label, const char *path);
bool addString(const char *tag, const char *key, const char *label, const char *path);
bool addIPv4(const char *tag, const char *key, const char *label, const char *path);
bool addMAC(const char *tag, const char *key, const char *label, const char *path);
bool setBool(const char *key, bool b);
bool setInt(const char *key, int32_t i);
bool setUint(const char *key, uint32_t u);
bool setFloat(const char *key, float f);
bool setString(const char *key, const char *str);
bool setIPv4(const char *key, uint32_t ip);
bool setMAC(const char *key, uint8_t *mac);
bool remove(const char *key);
bool removeAll();
//internal use
void setInitialized(bool init) {
initialized = init;
}
};
class ESPInsightsClass {
private:
bool initialized;
public:
ESPInsightsMetricsClass metrics;
ESPInsightsVariablesClass variables;
ESPInsightsClass();
~ESPInsightsClass();
bool begin(const char *auth_key, const char *node_id = NULL, uint32_t log_type = 0xFFFFFFFF, bool alloc_ext_ram = false, bool use_default_transport = true);
void end();
bool send();
const char *nodeID();
void dumpTasksStatus();
bool event(const char *tag, const char *format, ...);
};
extern ESPInsightsClass Insights;
extern "C" {
#endif
#include "esp_err.h"
#include "esp_log.h"
esp_err_t esp_diag_log_event(const char *tag, const char *format, ...) __attribute__((format(printf, 2, 3)));
#define insightsEvent(tag, format, ...) \
{ esp_diag_log_event(tag, "EV (%" PRIu32 ") %s: " format, esp_log_timestamp(), tag, ##__VA_ARGS__); }
#ifdef __cplusplus
}
#endif
#endif