zephyr/include/mgmt/hawkbit.h
Yong Cong Sin eaa29d9d71 subsys/mgmt/hawkbit: Prevent multiple instances of hawkbit_probe
Use a semaphore to prevent the hawkbit_probe from running more than once
at the same time since it reset the hawkbit context on entry and will
affect other running instance.

Signed-off-by: Yong Cong Sin <yongcong.sin@gmail.com>
2021-08-18 20:10:21 -04:00

70 lines
1.6 KiB
C

/*
* Copyright (c) 2020 Linumiz
*
* SPDX-License-Identifier: Apache-2.0
*/
/**
* @brief Hawkbit Firmware Over-the-Air for Zephyr Project.
* @defgroup hawkbit Hawkbit Firmware Over-the-Air
* @ingroup lib
* @{
*/
#ifndef ZEPHYR_INCLUDE_MGMT_HAWKBIT_H_
#define ZEPHYR_INCLUDE_MGMT_HAWKBIT_H_
#define HAWKBIT_JSON_URL "/default/controller/v1"
/**
* @brief Response message from Hawkbit.
*
* @details These messages are used to inform the server and the
* user about the process status of the Hawkbit and also
* used to standardize the errors that may occur.
*
*/
enum hawkbit_response {
HAWKBIT_NETWORKING_ERROR,
HAWKBIT_UNCONFIRMED_IMAGE,
HAWKBIT_METADATA_ERROR,
HAWKBIT_DOWNLOAD_ERROR,
HAWKBIT_OK,
HAWKBIT_UPDATE_INSTALLED,
HAWKBIT_NO_UPDATE,
HAWKBIT_CANCEL_UPDATE,
HAWKBIT_PROBE_IN_PROGRESS,
};
/**
* @brief Init the flash partition
*
* @return 0 on success, negative on error.
*/
int hawkbit_init(void);
/**
* @brief Runs Hawkbit probe and Hawkbit update automatically
*
* @details The hawkbit_autohandler handles the whole process
* in pre-determined time intervals.
*/
void hawkbit_autohandler(void);
/**
* @brief The Hawkbit probe verify if there is some update to be performed.
*
* @return HAWKBIT_UPDATE_INSTALLED has an update available.
* @return HAWKBIT_NO_UPDATE no update available.
* @return HAWKBIT_NETWORKING_ERROR fail to connect to the Hawkbit server.
* @return HAWKBIT_METADATA_ERROR fail to parse or to encode the metadata.
* @return HAWKBIT_OK if success.
* @return HAWKBIT_DOWNLOAD_ERROR faile while downloading the update package.
*/
enum hawkbit_response hawkbit_probe(void);
/**
* @}
*/
#endif /* _HAWKBIT_H_ */