ESP Diagnostics Variables¶
Variables¶
Functions¶
-
esp_err_t
esp_diag_variable_init(esp_diag_variable_config_t *config)¶ Initialize the diagnostics variable.
- Return
ESP_OK if successful, appropriate error code otherwise.
- Parameters
[in] config: Pointer to a config structure of type esp_diag_variable_config_t
-
esp_err_t
esp_diag_variables_deinit(void)¶ Deinitialize the diagnostics variables.
- Return
ESP_OK if successful, appropriate error code otherwise.
-
esp_err_t
esp_diag_variable_register(const char *tag, const char *key, const char *label, const char *path, esp_diag_data_type_t type)¶ Register a diagnostics variable.
- Return
ESP_OK if successful, appropriate error code otherwise.
- Parameters
[in] tag: Tag of variable[in] key: Unique key for the variable[in] label: Label for the variable[in] path: Hierarchical path for key, must be separated by ‘.’ for more than one level[in] type: Data type of variable
-
esp_err_t
esp_diag_variable_unregister_all(void)¶ Unregister all previously registered variables.
- Return
ESP_OK if successful, qppropriate error code otherwise.
-
const esp_diag_variable_meta_t *
esp_diag_variable_meta_get_all(uint32_t *len)¶ Get metadata for all variables.
- Return
array Array of variables meta data
- Parameters
[out] len: Length of the variables meta data array
-
void
esp_diag_variable_meta_print_all(void)¶ Print metadata for all variables.
-
esp_err_t
esp_diag_variable_unregister(const char *tag, const char *key)¶ Unregister a diagnostics variable.
- Return
ESP_OK if successful, appropriate error code otherwise.
- Parameters
[in] tag: Tag of variable[in] key: Key for the variable
-
esp_err_t
esp_diag_variable_add_unit(const char *tag, const char *key, const char *unit)¶ Specify unit of the data for the particular key.
- Return
ESP_OK if successful, appropriate error code othewise.
- Note
this API if used, should be called after esp_diag_variable_register API with the same
keyto take effect- Parameters
[in] tag: Tag of variable[in] key: Key for which the unit to be specified[in] unit: Unit string of the data
-
esp_err_t
esp_diag_variable_report(esp_diag_data_type_t data_type, const char *tag, const char *key, const void *val, size_t val_sz, uint64_t ts)¶ Add variable to storage.
- Return
ESP_OK if successful, appropriate error code otherwise.
- Note
esp_diag_timestamp_get() API can be used to get timestamp in mircoseconds.
- Parameters
[in] data_type: Data type of variable esp_diag_data_type_t[in] key: Key of variable[in] val: Value of variable[in] val_sz: Size of val[in] ts: Timestamp in microseconds, this should be the value at the time of data gathering
-
esp_err_t
esp_diag_variable_report_bool(const char *tag, const char *key, bool b)¶ Add the variable of data type boolean.
- Return
ESP_OK if successful, appropriate error code otherwise.
- Parameters
[in] key: Key of the variable[in] b: Value of the variable
-
esp_err_t
esp_diag_variable_report_int(const char *tag, const char *key, int32_t i)¶ Add the variable of data type integer.
- Return
ESP_OK if successful, appropriate error code otherwise.
- Parameters
[in] key: Key of the variable[in] i: Value of the variable
-
esp_err_t
esp_diag_variable_report_uint(const char *tag, const char *key, uint32_t u)¶ Add the variable of data type unsigned integer.
- Return
ESP_OK if successful, appropriate error code otherwise.
- Parameters
[in] key: Key of the variable[in] u: Value of the variable
-
esp_err_t
esp_diag_variable_report_float(const char *tag, const char *key, float f)¶ Add the variable of data type float.
- Return
ESP_OK if successful, appropriate error code otherwise.
- Parameters
[in] key: Key of the variable[in] f: Value of the variable
-
esp_err_t
esp_diag_variable_report_ipv4(const char *tag, const char *key, uint32_t ip)¶ Add the IPv4 address variable.
- Return
ESP_OK if successful, appropriate error code otherwise.
- Parameters
[in] key: Key of the variable[in] ip: IPv4 address
-
esp_err_t
esp_diag_variable_report_mac(const char *tag, const char *key, uint8_t *mac)¶ Add the MAC address variable.
- Return
ESP_OK if successful, appropriate error code otherwise.
- Parameters
[in] key: Key of the variable[in] mac: Array of length 6 i.e 6 octets of mac address
-
esp_err_t
esp_diag_variable_report_str(const char *tag, const char *key, const char *str)¶ Add the variable of data type string.
- Return
ESP_OK if successful, appropriate error code otherwise.
- Parameters
[in] key: Key of the variable[in] str: Value of the variable
Structures¶
-
struct
esp_diag_variable_config_t¶ Diagnostics variable config structure.
Public Members
-
esp_diag_variable_write_cb_t
write_cb¶ Callback function to write diagnostics data
-
void *
cb_arg¶ User data to pass in callback function
-
esp_diag_variable_write_cb_t
-
struct
esp_diag_variable_meta_t¶ Structure for diagnostics variable metadata.
Public Members
-
const char *
tag¶ Tag of variable
-
const char *
key¶ Unique key for the variable
-
const char *
label¶ Label for the variable
-
const char *
path¶ Hierarchical path for the key, must be separated by ‘.’ for more than one level, eg: “wifi”, “heap.internal”, “heap.external”
-
const char *
unit¶ Data unit, can be NULL
-
esp_diag_data_type_t
type¶ Data type of variables
-
const char *
Type Definitions¶
-
typedef esp_err_t (*
esp_diag_variable_write_cb_t)(const char *tag, void *data, size_t len, void *cb_arg)¶ Callback to write variable’s data.
- Parameters
[in] tag: Tag for variable[in] data: Data for variable[in] len: Length of variable[in] cb_arg: User data to pass in write callback
Network Variables¶
Functions¶
-
esp_err_t
esp_diag_network_variables_init(void)¶ Initialize the network variables.
Below listed Wi-Fi and IP parameters are collected and reported to cloud on change. Wi-Fi connection status, BSSID, SSID, channel, authentication mode, Wi-Fi disconnection reason, IP address, netmask, and gateway.
- Return
ESP_OK if successful, appropriate error code otherwise.
-
esp_err_t
esp_diag_network_variables_deinit(void)¶ Deinitialize the network variables.