|
| 1 | +############ |
| 2 | +ESP Insights |
| 3 | +############ |
| 4 | + |
| 5 | +About |
| 6 | +----- |
| 7 | + |
| 8 | +ESP Insights is a remote diagnostics solution that allows users to remotely monitor the health of ESP devices in the field. |
| 9 | + |
| 10 | +Developers normally prefer debugging issues by physically probing them using gdb or observing the logs. This surely helps debug issues, but there are often cases wherein issues are seen only in specific environments under specific conditions. Even things like casings and placement of the product can affect the behaviour. A few examples are |
| 11 | + |
| 12 | +- Wi-Fi disconnections for a smart switch concealed in a wall. |
| 13 | +- Smart speakers crashing during some specific usage pattern. |
| 14 | +- Appliance frequently rebooting due to power supply issues. |
| 15 | + |
| 16 | +Additional information about ESP Insights can be found `here <https://insights.espressif.com/>`__. |
| 17 | + |
| 18 | +ESP Insights Agent API |
| 19 | +---------------------- |
| 20 | + |
| 21 | +Insights.begin |
| 22 | +************** |
| 23 | + |
| 24 | +This initializes the ESP Insights agent. |
| 25 | + |
| 26 | +.. code-block:: arduino |
| 27 | +
|
| 28 | + bool begin(const char *auth_key, const char *node_id = NULL, uint32_t log_type = 0xFFFFFFFF, bool alloc_ext_ram = false); |
| 29 | +
|
| 30 | +* ``auth_key`` Auth key generated using Insights dashboard |
| 31 | +* ``log_type`` Type of logs to be captured (value can be a mask of ESP_DIAG_LOG_TYPE_ERROR, ESP_DIAG_LOG_TYPE_WARNING and ESP_DIAG_LOG_TYPE_EVENT) |
| 32 | + |
| 33 | +This function will return |
| 34 | + |
| 35 | +1. true : On success |
| 36 | +2. false in case of failure |
| 37 | + |
| 38 | +Insights.send |
| 39 | +************* |
| 40 | + |
| 41 | +Read insights data from buffers and send it to the cloud. Call to this function is asynchronous, it may take some time to send the data. |
| 42 | + |
| 43 | +.. code-block:: arduino |
| 44 | +
|
| 45 | + bool sendData() |
| 46 | +
|
| 47 | +This function will return |
| 48 | + |
| 49 | +1. true : On success |
| 50 | +2. false in case of failure |
| 51 | + |
| 52 | +Insights.end |
| 53 | +************ |
| 54 | + |
| 55 | +Deinitialize ESP Insights. |
| 56 | + |
| 57 | +.. code-block:: arduino |
| 58 | +
|
| 59 | + void end(); |
| 60 | +
|
| 61 | +Insights.disable |
| 62 | +**************** |
| 63 | + |
| 64 | +Disable ESP Insights. |
| 65 | + |
| 66 | +.. code-block:: arduino |
| 67 | +
|
| 68 | + void disable(); |
| 69 | +
|
| 70 | +ESP Insights Metrics API |
| 71 | +------------------------ |
| 72 | + |
| 73 | +`metrics` object of `Insights` class expose API's for using metrics. |
| 74 | + |
| 75 | +Insights.metrics.addX |
| 76 | +********************* |
| 77 | + |
| 78 | +Register a metric of type X, where X is one of: Bool, Int, Uint, Float, String, IPv4 or MAC |
| 79 | + |
| 80 | +.. code-block:: arduino |
| 81 | +
|
| 82 | + bool addX(const char *tag, const char *key, const char *label, const char *path); |
| 83 | +
|
| 84 | +* ``tag`` : Tag of metrics |
| 85 | +* ``key`` : Unique key for the metrics |
| 86 | +* ``label`` : Label for the metrics |
| 87 | +* ``path`` : Hierarchical path for key, must be separated by '.' for more than one level |
| 88 | + |
| 89 | +This function will return |
| 90 | + |
| 91 | +1. true : On success |
| 92 | +2. false in case of failure |
| 93 | + |
| 94 | +Insights.metrics.remove |
| 95 | +*********************** |
| 96 | + |
| 97 | +Unregister a diagnostics metrics |
| 98 | + |
| 99 | +.. code-block:: arduino |
| 100 | +
|
| 101 | + bool remove(const char *key); |
| 102 | +
|
| 103 | +* ``key`` : Key for the metrics |
| 104 | + |
| 105 | +This function will return |
| 106 | + |
| 107 | +1. true : On success |
| 108 | +2. false in case of failure |
| 109 | + |
| 110 | +Insights.metrics.removeAll |
| 111 | +************************** |
| 112 | + |
| 113 | +Unregister all previously registered metrics |
| 114 | + |
| 115 | +.. code-block:: arduino |
| 116 | +
|
| 117 | + bool removeAll(); |
| 118 | +
|
| 119 | +This function will return |
| 120 | + |
| 121 | +1. true : On success |
| 122 | +2. false in case of failure |
| 123 | + |
| 124 | +Insights.metrics.setX |
| 125 | +********************* |
| 126 | + |
| 127 | +Add metrics of type X to storage, where X is one of: Bool, Int, Uint, Float, String, IPv4 or MAC |
| 128 | + |
| 129 | +.. code-block:: arduino |
| 130 | +
|
| 131 | + bool setX(const char *key, const void val); |
| 132 | +
|
| 133 | +* ``key`` : Key of metrics |
| 134 | +* ``val`` : Value of metrics |
| 135 | + |
| 136 | +This function will return |
| 137 | + |
| 138 | +1. `ESP_OK` : On success |
| 139 | +2. Error in case of failure |
| 140 | + |
| 141 | +Insights.metrics.dumpHeap |
| 142 | +************************* |
| 143 | + |
| 144 | +Dumps the heap metrics and prints them to the console. |
| 145 | +This API collects and reports metrics value at any give point in time. |
| 146 | + |
| 147 | +.. code-block:: arduino |
| 148 | +
|
| 149 | + bool dumpHeap(); |
| 150 | +
|
| 151 | +This function will return |
| 152 | + |
| 153 | +1. true : On success |
| 154 | +2. false in case of failure |
| 155 | + |
| 156 | +Insights.metrics.dumpWiFi |
| 157 | +************************* |
| 158 | + |
| 159 | +Dumps the wifi metrics and prints them to the console. |
| 160 | +This API can be used to collect wifi metrics at any given point in time. |
| 161 | + |
| 162 | +.. code-block:: arduino |
| 163 | +
|
| 164 | + bool dumpWiFi(); |
| 165 | +
|
| 166 | +This function will return |
| 167 | + |
| 168 | +1. true : On success |
| 169 | +2. false in case of failure |
| 170 | + |
| 171 | +Insights.metrics.setHeapPeriod |
| 172 | +****************************** |
| 173 | + |
| 174 | +Reset the periodic interval |
| 175 | +By default, heap metrics are collected every 30 seconds, this function can be used to change the interval. |
| 176 | +If the interval is set to 0, heap metrics collection disabled. |
| 177 | + |
| 178 | +.. code-block:: arduino |
| 179 | +
|
| 180 | + void setHeapPeriod(uint32_t period); |
| 181 | +
|
| 182 | +* ``period`` : Period interval in seconds |
| 183 | + |
| 184 | +Insights.metrics.setWiFiPeriod |
| 185 | +****************************** |
| 186 | + |
| 187 | +Reset the periodic interval |
| 188 | +By default, wifi metrics are collected every 30 seconds, this function can be used to change the interval. |
| 189 | +If the interval is set to 0, wifi metrics collection disabled. |
| 190 | + |
| 191 | +.. code-block:: arduino |
| 192 | +
|
| 193 | + void setHeapPeriod(uint32_t period); |
| 194 | +
|
| 195 | +* ``period`` : Period interval in seconds |
| 196 | + |
| 197 | +ESP Insights Variables API |
| 198 | +-------------------------- |
| 199 | + |
| 200 | +`variables` object of `Insights` class expose API's for using variables. |
| 201 | + |
| 202 | +Insights.variables.addX |
| 203 | +*********************** |
| 204 | + |
| 205 | +Register a variable of type X, where X is one of: Bool, Int, Uint, Float, String, IPv4 or MAC |
| 206 | + |
| 207 | +.. code-block:: arduino |
| 208 | +
|
| 209 | + bool addX(const char *tag, const char *key, const char *label, const char *path); |
| 210 | +
|
| 211 | +* ``tag`` : Tag of variable |
| 212 | +* ``key`` : Unique key for the variable |
| 213 | +* ``label`` : Label for the variable |
| 214 | +* ``path`` : Hierarchical path for key, must be separated by '.' for more than one level |
| 215 | + |
| 216 | +This function will return |
| 217 | + |
| 218 | +1. true : On success |
| 219 | +2. false in case of failure |
| 220 | + |
| 221 | +Insights.variables.remove |
| 222 | +************************* |
| 223 | + |
| 224 | +Unregister a diagnostics variable |
| 225 | + |
| 226 | +.. code-block:: arduino |
| 227 | +
|
| 228 | + bool remove(const char *key); |
| 229 | +
|
| 230 | +* ``key`` : Key for the variable |
| 231 | + |
| 232 | +This function will return |
| 233 | + |
| 234 | +1. true : On success |
| 235 | +2. false in case of failure |
| 236 | + |
| 237 | +Insights.variables.removeAll |
| 238 | +**************************** |
| 239 | + |
| 240 | +Unregister all previously registered variables |
| 241 | + |
| 242 | +.. code-block:: arduino |
| 243 | +
|
| 244 | + bool unregisterAll(); |
| 245 | +
|
| 246 | +This function will return |
| 247 | + |
| 248 | +1. true : On success |
| 249 | +2. false in case of failure |
| 250 | + |
| 251 | +Insights.variables.setX |
| 252 | +*********************** |
| 253 | + |
| 254 | +Add variable of type X to storage, where X is one of: Bool, Int, Uint, Float, String, IPv4 or MAC |
| 255 | + |
| 256 | +.. code-block:: arduino |
| 257 | +
|
| 258 | + bool setX(const char *key, const void val); |
| 259 | +
|
| 260 | +* ``key`` : Key of metrics |
| 261 | +* ``val`` : Value of metrics |
| 262 | + |
| 263 | +This function will return |
| 264 | + |
| 265 | +1. true : On success |
| 266 | +2. false in case of failure |
| 267 | + |
| 268 | +Example |
| 269 | +------- |
| 270 | + |
| 271 | +To get started with Insights, you can try: |
| 272 | + |
| 273 | +.. literalinclude:: ../../../libraries/Insights/examples/MinimalDiagnostics/MinimalDiagnostics.ino |
| 274 | + :language: arduino |
0 commit comments