Skip to content

Commit

Permalink
client: allow applications to trigger works
Browse files Browse the repository at this point in the history
  • Loading branch information
joelguittet committed Sep 28, 2023
1 parent c4089e4 commit b349e3e
Show file tree
Hide file tree
Showing 8 changed files with 79 additions and 13 deletions.
14 changes: 14 additions & 0 deletions add-ons/src/mender-configure.c
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,20 @@ mender_configure_set(mender_keystore_t *configuration) {
return ret;
}

mender_err_t
mender_configure_execute(void) {

mender_err_t ret;

/* Trigger execution of the work */
if (MENDER_OK != (ret = mender_rtos_work_execute(mender_configure_work_handle))) {
mender_log_error("Unable to trigger configure work");
return ret;
}

return MENDER_OK;
}

mender_err_t
mender_configure_exit(void) {

Expand Down
14 changes: 14 additions & 0 deletions add-ons/src/mender-inventory.c
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,20 @@ mender_inventory_set(mender_keystore_t *inventory) {
return ret;
}

mender_err_t
mender_inventory_execute(void) {

mender_err_t ret;

/* Trigger execution of the work */
if (MENDER_OK != (ret = mender_rtos_work_execute(mender_inventory_work_handle))) {
mender_log_error("Unable to trigger inventory work");
return ret;
}

return MENDER_OK;
}

mender_err_t
mender_inventory_exit(void) {

Expand Down
14 changes: 14 additions & 0 deletions core/src/mender-client.c
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,20 @@ mender_client_init(mender_client_config_t *config, mender_client_callbacks_t *ca
return ret;
}

mender_err_t
mender_client_execute(void) {

mender_err_t ret;

/* Trigger execution of the work */
if (MENDER_OK != (ret = mender_rtos_work_execute(mender_client_work_handle))) {
mender_log_error("Unable to trigger update work");
return ret;
}

return MENDER_OK;
}

mender_err_t
mender_client_exit(void) {

Expand Down
24 changes: 16 additions & 8 deletions include/mender-client.h
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -38,14 +38,14 @@ extern "C" {
* @brief Mender client configuration
*/
typedef struct {
char * mac_address; /**< MAC address of the device */
char * artifact_name; /**< Artifact name */
char * device_type; /**< Device type */
char * host; /**< URL of the mender server */
char * tenant_token; /**< Tenant token used to authenticate on the mender server (optional) */
uint32_t authentication_poll_interval; /**< Authentication poll interval, default is 60 seconds */
uint32_t update_poll_interval; /**< Update poll interval, default is 1800 seconds */
bool recommissioning; /**< Used to force creation of new authentication keys */
char * mac_address; /**< MAC address of the device */
char * artifact_name; /**< Artifact name */
char * device_type; /**< Device type */
char * host; /**< URL of the mender server */
char * tenant_token; /**< Tenant token used to authenticate on the mender server (optional) */
int32_t authentication_poll_interval; /**< Authentication poll interval, default is 60 seconds, -1 permits to disable periodic execution */
int32_t update_poll_interval; /**< Update poll interval, default is 1800 seconds, -1 permits to disable periodic execution */
bool recommissioning; /**< Used to force creation of new authentication keys */
} mender_client_config_t;

/**
Expand All @@ -71,6 +71,14 @@ typedef struct {
*/
mender_err_t mender_client_init(mender_client_config_t *config, mender_client_callbacks_t *callbacks);

/**
* @brief Function used to trigger execution of the authentication and update work
* @note Calling this function is optional when the periodic execution of the work is configured
* @note It only permits to execute the work as soon as possible to synchronize updates
* @return MENDER_OK if the function succeeds, error code otherwise
*/
mender_err_t mender_client_execute(void);

/**
* @brief Release mender client
* @return MENDER_OK if the function succeeds, error code otherwise
Expand Down
10 changes: 9 additions & 1 deletion include/mender-configure.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ extern "C" {
* @brief Mender configure configuration
*/
typedef struct {
uint32_t refresh_interval; /**< Configure refresh interval, default is 28800 seconds */
int32_t refresh_interval; /**< Configure refresh interval, default is 28800 seconds, -1 permits to disable periodic execution */
} mender_configure_config_t;

/**
Expand Down Expand Up @@ -80,6 +80,14 @@ mender_err_t mender_configure_get(mender_keystore_t **configuration);
*/
mender_err_t mender_configure_set(mender_keystore_t *configuration);

/**
* @brief Function used to trigger execution of the configure work
* @note Calling this function is optional when the periodic execution of the work is configured
* @note It only permits to execute the work as soon as possible to synchronize configuration
* @return MENDER_OK if the function succeeds, error code otherwise
*/
mender_err_t mender_configure_execute(void);

/**
* @brief Release mender configure add-on
* @return MENDER_OK if the function succeeds, error code otherwise
Expand Down
10 changes: 9 additions & 1 deletion include/mender-inventory.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ extern "C" {
* @brief Mender inventory configuration
*/
typedef struct {
uint32_t refresh_interval; /**< Inventory refresh interval, default is 28800 seconds */
int32_t refresh_interval; /**< Inventory refresh interval, default is 28800 seconds, -1 permits to disable periodic execution */
} mender_inventory_config_t;

/**
Expand All @@ -63,6 +63,14 @@ mender_err_t mender_inventory_activate(void);
*/
mender_err_t mender_inventory_set(mender_keystore_t *inventory);

/**
* @brief Function used to trigger execution of the inventory work
* @note Calling this function is optional when the periodic execution of the work is configured
* @note It only permits to execute the work as soon as possible to synchronize inventory
* @return MENDER_OK if the function succeeds, error code otherwise
*/
mender_err_t mender_inventory_execute(void);

/**
* @brief Release mender inventory add-on
* @return MENDER_OK if the function succeeds, error code otherwise
Expand Down
4 changes: 2 additions & 2 deletions include/mender-rtos.h
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ extern "C" {
*/
typedef struct {
mender_err_t (*function)(void); /**< Work function */
uint32_t period; /**< Work period (seconds), null value permits to disable periodic execution */
char * name; /**< Work name */
int32_t period; /**< Work period (seconds), negative or null value permits to disable periodic execution */
char * name; /**< Work name */
} mender_rtos_work_params_t;

/**
Expand Down
2 changes: 1 addition & 1 deletion include/mender-troubleshoot.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ extern "C" {
* @brief Mender troubleshoot configuration
*/
typedef struct {
uint32_t healthcheck_interval; /**< Troubleshoot healthcheck interval, default is 30 seconds */
int32_t healthcheck_interval; /**< Troubleshoot healthcheck interval, default is 30 seconds, -1 permits to disable periodic execution */
} mender_troubleshoot_config_t;

/**
Expand Down

0 comments on commit b349e3e

Please sign in to comment.