Golioth Firmware SDK
golioth_fw_update.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2022 Golioth, Inc.
3  *
4  * SPDX-License-Identifier: Apache-2.0
5  */
6 #pragma once
7 
8 #include "golioth.h"
9 #include <stdbool.h>
10 
11 #define GOLIOTH_FW_UPDATE_DEFAULT_PACKAGE_NAME "main"
12 
13 typedef struct {
15  const char* current_version;
18  const char* fw_package_name;
20 
26 
43 void golioth_fw_update_init(golioth_client_t client, const char* current_version);
44 
50  golioth_client_t client,
51  const golioth_fw_update_config_t* config);
52 
59  golioth_ota_state_t state,
60  golioth_ota_reason_t reason,
61  void* user_arg);
62 
72  void* user_arg);
73 
74 //---------------------------------------------------------------------------
75 // Backend API for firmware updates. Required to be implemented by port.
76 // Not intended to be called by user code.
77 //---------------------------------------------------------------------------
78 
82 
84 void fw_update_rollback(void);
85 
90 void fw_update_reboot(void);
91 
96 
108  const uint8_t* block,
109  size_t block_size,
110  size_t offset,
111  size_t total_size);
112 
126  uint8_t* buf,
127  size_t bufsize,
128  size_t offset);
129 
135 
145 
152 
157 void fw_update_end(void);
158 //---------------------------------------------------------------------------
159 
golioth_status_t
void * golioth_client_t
Opaque handle to the Golioth client.
golioth_status_t fw_update_validate(void)
golioth_status_t fw_update_read_current_image_at_offset(uint8_t *buf, size_t bufsize, size_t offset)
void fw_update_rollback(void)
Initiate a firmware rollback.
void fw_update_post_download(void)
golioth_status_t fw_update_change_boot_image(void)
void golioth_fw_update_register_state_change_callback(golioth_fw_update_state_change_callback callback, void *user_arg)
void golioth_fw_update_init(golioth_client_t client, const char *current_version)
void(* golioth_fw_update_state_change_callback)(golioth_ota_state_t state, golioth_ota_reason_t reason, void *user_arg)
void fw_update_end(void)
void fw_update_cancel_rollback(void)
void golioth_fw_update_init_with_config(golioth_client_t client, const golioth_fw_update_config_t *config)
golioth_status_t fw_update_handle_block(const uint8_t *block, size_t block_size, size_t offset, size_t total_size)
bool fw_update_is_pending_verify(void)
void fw_update_reboot(void)
golioth_ota_reason_t
A reason associated with state changes.
Definition: golioth_ota.h:35
golioth_ota_state_t
State of OTA update, reported to Golioth server.
Definition: golioth_ota.h:23
const char * current_version
The current firmware version, NULL-terminated, shallow-copied from user. (e.g. "1....