Golioth Zephyr SDK
SDK for development of Zephyr OS powered devices with Golioth
fw.h File Reference
#include <net/golioth.h>

Go to the source code of this file.

Classes

struct  golioth_fw_download_ctx
 Represents incoming firmware from Golioth. More...
 

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, struct coap_reply *reply, coap_reply_t desired_cb)
 Observe desired firmware. More...
 
int golioth_fw_download (struct golioth_client *client, struct golioth_fw_download_ctx *ctx, const char *uri, size_t uri_len, struct coap_reply *reply, golioth_blockwise_download_received_t received_cb)
 Request firmware download from Golioth. 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 

◆ 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 

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,
struct golioth_fw_download_ctx ctx,
const char *  uri,
size_t  uri_len,
struct coap_reply *  reply,
golioth_blockwise_download_received_t  received_cb 
)

Request firmware download from Golioth.

Parameters
clientClient instance
ctxFirmware download context
uriPointer to URI string
uri_lenLength of URI string
replyCoAP reply handler object used for notifying about received firmware blocks
received_cbCallback that will be executed with each incoming block of firmware
Return values
0On success
<0On failure

◆ golioth_fw_observe_desired()

int golioth_fw_observe_desired ( struct golioth_client client,
struct coap_reply *  reply,
coap_reply_t  desired_cb 
)

Observe desired firmware.

Parameters
clientClient instance
replyCoAP reply handler object used for notifying about received desired firmware description
desired_cbCallback that will be executed when desired firmware description is received
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