Skip to main content

Device Health

Overview

This component lets you know the various parameters of your device and running firmware such as Number of errors since last reboot, Device revision, Number of reboots, Last reboot reason. Apart from giving these parameters, user can also set their own user data in numeric and string format.
Following table explains the parameters logged by this API in detail.

ParameterDescription
Last reboot reasonThis parameter gives the reason ny which the device was reset. These reasons will be one of the predefined reasons in the ESP-IDF SDK
Device revisionThis parameter gives the details about chip model and revision
Number of errors since last rebootThis parameter returns number of errors since last reboot
Number of rebootsThis parameter counts number of reboots since last reset counter. To reset this parameter use restart_counter api
User numeric dataUser can use this parameter to put their own data in numeric form
User String dataUser can use this parameter to put their own data in string form

Usage

This component is used to check the health of device and firmware running on it. For example:

  • To get to know number of errors for a specific amount of time.
  • To diagnose what is happening in your firmware remotely.

Available Macros

None

Functions

bool encode_message(uint8_t *buffer, size_t buffer_size, size_t *message_length)

Reads various parameters of device like Number of errors since last reboot, Device revision, Number of reboots, Last reboot reason, encodes it in a uint8_t array as a protofile, which is the first parameter of this api.

  • buffer: A string (char*). Used to stored serialized device health data.
  • buffer_size: size_t. Size of the specified buffer.
  • message_length: ptr to size_t. It tells user the actual size of proto encoded data.
    Returns
  • True of encoding was successful, false otherwise

bool decode_message(uint8_t *buffer, size_t message_length)

Decodes the device health parameters which are already encoded using encode_message api. This api prints all the decoded parameters to the serial monitor.

  • buffer: A string (char*). Used to stored serialized device health data.
  • buffer_size: size_t. Size of the specified buffer.
    Returns
  • True if buffer successfully decoded, False otherwise.

esp_err_t deviceHealthStore(uint8_t *deviceHealthproto)

Stores the encoded device health protobuf file which is encoded using encode_message

  • deviceHealthproto: A uint8_t array. This is the protobuf file which is encoded using encoded_message.
    Returns
  • esp_err_t. ESP_OK if successfully stored.

int restart_counter()

This function restores the number of reset occurences, which is stored in NVS.
Returns

  • True if counter was resetted successfully, False otherwise