Edgehog Device SDK ESP32
ESP32 device SDK for the Edgehog platform
edgehog_device.h File Reference

Edgehog device SDK API. More...

#include "edgehog.h"
#include <astarte_device.h>
#include <esp_err.h>
#include <nvs.h>
Include dependency graph for edgehog_device.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  edgehog_device_telemetry_config_t
 Edgehog device configuration struct. More...
 
struct  edgehog_device_config_t
 Edgehog device configuration struct. More...
 

Typedefs

typedef struct edgehog_device_t * edgehog_device_handle_t
 

Enumerations

enum  telemetry_type_t {
  EDGEHOG_TELEMETRY_INVALID = 0 , EDGEHOG_TELEMETRY_HW_INFO = 1 , EDGEHOG_TELEMETRY_WIFI_SCAN = 2 , EDGEHOG_TELEMETRY_SYSTEM_STATUS = 3 ,
  EDGEHOG_TELEMETRY_STORAGE_USAGE = 4 , EDGEHOG_TELEMETRY_BATTERY_STATUS = 5 , EDGEHOG_TELEMETRY_GEOLOCATION_INFO = 6
}
 Edgehog telemetry types. More...
 

Functions

edgehog_device_handle_t edgehog_device_new (edgehog_device_config_t *config)
 create Edgehog device handle. More...
 
void edgehog_device_destroy (edgehog_device_handle_t edgehog_device)
 destroy Edgehog device. More...
 
esp_err_t edgehog_device_set_system_serial_number (edgehog_device_handle_t edgehog_device, const char *serial_num)
 set the system serial number More...
 
esp_err_t edgehog_device_set_system_part_number (edgehog_device_handle_t edgehog_device, const char *part_num)
 set the system part number More...
 
void edgehog_device_astarte_event_handler (edgehog_device_handle_t edgehog_device, astarte_device_data_event_t *event)
 receive data from Astarte Server. More...
 
edgehog_err_t edgehog_device_start (edgehog_device_handle_t edgehog_device)
 start Edgehog device. More...
 

Detailed Description

Edgehog device SDK API.

Enumeration Type Documentation

◆ telemetry_type_t

Edgehog telemetry types.

This enum is used for configuring the telemetry type in edgehog_device_telemetry_config_t struct.

Enumerator
EDGEHOG_TELEMETRY_INVALID 

The telemetry type is invalid.

EDGEHOG_TELEMETRY_HW_INFO 

The hardware info telemetry type.

EDGEHOG_TELEMETRY_WIFI_SCAN 

The wifi scan telemetry type.

EDGEHOG_TELEMETRY_SYSTEM_STATUS 

The system status telemetry type.

EDGEHOG_TELEMETRY_STORAGE_USAGE 

The storage usage telemetry type.

EDGEHOG_TELEMETRY_BATTERY_STATUS 

The battery status telemetry type.

EDGEHOG_TELEMETRY_GEOLOCATION_INFO 

The geolocation info telemetry type.

Function Documentation

◆ edgehog_device_astarte_event_handler()

void edgehog_device_astarte_event_handler ( edgehog_device_handle_t  edgehog_device,
astarte_device_data_event_t *  event 
)

receive data from Astarte Server.

This function must be called when an Astarte Data event coming from server.

Parameters
edgehog_deviceA valid Edgehog device handle.
eventA valid Astarte device data event.

◆ edgehog_device_destroy()

void edgehog_device_destroy ( edgehog_device_handle_t  edgehog_device)

destroy Edgehog device.

This function destroys the device, freeing all its resources.

Parameters
edgehog_deviceA valid Edgehog device handle.

◆ edgehog_device_new()

edgehog_device_handle_t edgehog_device_new ( edgehog_device_config_t config)

create Edgehog device handle.

This function creates an Edgehog device handle. It must be called before anything else.

Example: astarte_device_handle_t astarte_device = astarte_device_init();

edgehog_device_config_t edgehog_conf = { .astarte_device = astarte_device, };

edgehog_device_handle_t edgehog_device = edgehog_device_new(&edgehog_conf);

Parameters
configAn edgehog_device_config_t struct.
Returns
The handle to the device, NULL if an error occurred.

◆ edgehog_device_set_system_part_number()

esp_err_t edgehog_device_set_system_part_number ( edgehog_device_handle_t  edgehog_device,
const char *  part_num 
)

set the system part number

This function sends the system part number on Astarte and stores it on the nvs.

Parameters
edgehog_deviceA valid Edgehog device handle.
part_numThe part number to be stored
Returns
ESP_OK if the data was successfully stored and sent, an esp_err_t otherwise.

◆ edgehog_device_set_system_serial_number()

esp_err_t edgehog_device_set_system_serial_number ( edgehog_device_handle_t  edgehog_device,
const char *  serial_num 
)

set the system serial number

This function sends the system serial number on Astarte and stores it on the nvs.

Parameters
edgehog_deviceA valid Edgehog device handle.
serial_numThe serial number to be stored
Returns
ESP_OK if the data was successfully stored and sent, an esp_err_t otherwise.

◆ edgehog_device_start()

edgehog_err_t edgehog_device_start ( edgehog_device_handle_t  edgehog_device)

start Edgehog device.

This function starts the device, enabling the telemetry update if configured.

Parameters
deviceA valid Edgehog device handle.
Returns
EDGEHOG_OK if the device was successfully started, another edgehog_err_t otherwise.