Golioth Zephyr SDK
fw.h File Reference
#include <stddef.h>
#include <stdint.h>
#include <net/golioth/req.h>

Go to the source code of this file.

Enumerations

enum  golioth_fw_state { GOLIOTH_FW_STATE_IDLE = 0 , GOLIOTH_FW_STATE_DOWNLOADING = 1 , GOLIOTH_FW_STATE_DOWNLOADED = 2 , GOLIOTH_FW_STATE_UPDATING = 3 }
 State of downloading or updating the firmware. More...
 
enum  golioth_dfu_result {
  GOLIOTH_DFU_RESULT_INITIAL = 0 , GOLIOTH_DFU_RESULT_FIRMWARE_UPDATED_SUCCESSFULLY , GOLIOTH_DFU_RESULT_NOT_ENOUGH_FLASH_MEMORY , GOLIOTH_DFU_RESULT_OUT_OF_RAM ,
  GOLIOTH_DFU_RESULT_CONNECTION_LOST , GOLIOTH_DFU_RESULT_INTEGRITY_CHECK_FAILURE , GOLIOTH_DFU_RESULT_UNSUPPORTED_PACKAGE_TYPE , GOLIOTH_DFU_RESULT_INVALID_URI ,
  GOLIOTH_DFU_RESULT_FIRMWARE_UPDATE_FAILED , GOLIOTH_DFU_RESULT_UNSUPPORTED_PROTOCOL
}
 Result of downloading or updating the firmware. More...
 

Functions

int golioth_fw_desired_parse (const uint8_t *payload, uint16_t payload_len, uint8_t *version, size_t *version_len, uint8_t *uri, size_t *uri_len)
 Parse desired firmware description. More...
 
int golioth_fw_observe_desired (struct golioth_client *client, golioth_req_cb_t cb, void *user_data)
 Observe desired firmware. More...
 
int golioth_fw_download (struct golioth_client *client, const uint8_t *uri, size_t uri_len, golioth_req_cb_t cb, void *user_data)
 Request firmware download from Golioth. More...
 
int golioth_fw_report_state_cb (struct golioth_client *client, const char *package_name, const char *current_version, const char *target_version, enum golioth_fw_state state, enum golioth_dfu_result result, golioth_req_cb_t cb, void *user_data)
 Report state of firmware (callback based) More...
 
int golioth_fw_report_state (struct golioth_client *client, const char *package_name, const char *current_version, const char *target_version, enum golioth_fw_state state, enum golioth_dfu_result result)
 Report state of firmware. More...
 

Enumeration Type Documentation

◆ golioth_dfu_result

Result of downloading or updating the firmware.

Enumerator
GOLIOTH_DFU_RESULT_INITIAL 
GOLIOTH_DFU_RESULT_FIRMWARE_UPDATED_SUCCESSFULLY 
GOLIOTH_DFU_RESULT_NOT_ENOUGH_FLASH_MEMORY 
GOLIOTH_DFU_RESULT_OUT_OF_RAM 
GOLIOTH_DFU_RESULT_CONNECTION_LOST 
GOLIOTH_DFU_RESULT_INTEGRITY_CHECK_FAILURE 
GOLIOTH_DFU_RESULT_UNSUPPORTED_PACKAGE_TYPE 
GOLIOTH_DFU_RESULT_INVALID_URI 
GOLIOTH_DFU_RESULT_FIRMWARE_UPDATE_FAILED 
GOLIOTH_DFU_RESULT_UNSUPPORTED_PROTOCOL 

Definition at line 29 of file fw.h.

◆ golioth_fw_state

State of downloading or updating the firmware.

Enumerator
GOLIOTH_FW_STATE_IDLE 
GOLIOTH_FW_STATE_DOWNLOADING 
GOLIOTH_FW_STATE_DOWNLOADED 
GOLIOTH_FW_STATE_UPDATING 

Definition at line 19 of file fw.h.

Function Documentation

◆ golioth_fw_desired_parse()

int golioth_fw_desired_parse ( const uint8_t *  payload,
uint16_t  payload_len,
uint8_t *  version,
size_t *  version_len,
uint8_t *  uri,
size_t *  uri_len 
)

Parse desired firmware description.

Parameters
payloadPointer to CBOR encoded 'desired' description
payload_lenLength of CBOR encoded 'desired' description
versionPointer to version string, which will be updated by this function
version_lenOn input pointer to available space in version string, on output actual length of version string
uriURI of the image, which will be updated by this function
uri_lenOn input pointer to available space in URI string, on output actual length of URI string
Return values
0On success
<0On failure

◆ golioth_fw_download()

int golioth_fw_download ( struct golioth_client client,
const uint8_t *  uri,
size_t  uri_len,
golioth_req_cb_t  cb,
void *  user_data 
)

Request firmware download from Golioth.

Parameters
clientClient instance
uriPointer to URI string
uri_lenLength of URI string
cbCallback executed on response received, timeout or error
user_dataUser data passed to cb with each invocation
Return values
0On success
<0On failure

◆ golioth_fw_observe_desired()

int golioth_fw_observe_desired ( struct golioth_client client,
golioth_req_cb_t  cb,
void *  user_data 
)

Observe desired firmware.

Parameters
clientClient instance
cbCallback executed on response received, timeout or error
user_dataUser data passed to cb
Return values
0On success
<0On failure

◆ golioth_fw_report_state()

int golioth_fw_report_state ( struct golioth_client client,
const char *  package_name,
const char *  current_version,
const char *  target_version,
enum golioth_fw_state  state,
enum golioth_dfu_result  result 
)

Report state of firmware.

Parameters
clientClient instance
package_namePackage name of firmware
current_versionCurrent firmware version
target_versionTarget firmware version
stateState of firmware
resultResult of downloading or updating firmware
Return values
0On success
<0On failure

◆ golioth_fw_report_state_cb()

int golioth_fw_report_state_cb ( struct golioth_client client,
const char *  package_name,
const char *  current_version,
const char *  target_version,
enum golioth_fw_state  state,
enum golioth_dfu_result  result,
golioth_req_cb_t  cb,
void *  user_data 
)

Report state of firmware (callback based)

Asynchronously push firmware state information to Golioth

Warning
Experimental API
Parameters
clientClient instance
package_namePackage name of firmware
current_versionCurrent firmware version
target_versionTarget firmware version
stateState of firmware
resultResult of downloading or updating firmware
cbCallback executed on response received, timeout or error
user_dataUser data passed to cb
Return values
0On success
<0On failure