Firmware OTA API
Firmware over-the-air update API.
Example Usage
#include <fota.h>
/* Initialize fota and add fota command to console */
fota_init();
/* to programatically start fota */
fota_start("http://url/to/fota/firmware");
/* To register fota using Logicrom Device management console */
/*
* First parameter is application firmware code, a unique code
* registered on server.
*
* Second parameter is current version of application firmware
*/
logicrom_fota_register("FWCODE", "1.0.0");
API Reference
Header File
Source: include/fota.h
#include <fota.h>
Functions
-
int fota_init(void)
Add fota command to CLI
Usage: fota=[url]
- Returns:
returns 0
-
int fota_start(const char *in_url)
Start Firmware Update
- Parameters:
in_url – [in] HTTP URL to download firmware
- Returns:
0 on success, negative value on error
-
int fota_abort(void)
Request to abort firmware update.
- Returns:
return 0 on success, negative value on error
-
int fota_in_progress(void)
Get OTA status
- Returns:
Return 1 if FOTA in progress, 0 otherwise
-
int logicrom_fota_register(const char *code, const char *ver)
Register with Logicrom FOTA server for automatic firmware updates via Device management console. Automatic firmware update is checked once a day on Waybyte server. This function also enable core firmware update checks.
This function also add additional options in “fota” command
To check update on server
fota=check
To force download firmware
fota=download
To manually update firmware
fota=update
- Parameters:
code – Firmware code to identify application
ver – current firmware version
- Returns:
return 0 on success, negative value on failure
-
int fota_set_interval(int hours)
Set fota check interval.
- Parameters:
hours – interval value in hours
- Returns:
return 0 on success, negative value on error
-
int fota_get_interval(void)
Get current fota check interval.
- Returns:
return fota interval in hours
-
int appfota_init(int *handle)
Initialize application firmware update.
- Parameters:
handle – [out] handle to use in subsequent calls
- Returns:
return 0 on success, negative value on error
-
int appfota_write(int handle, const void *buff, size_t len)
Write firmware data to application firmware update.
- Parameters:
handle – [in] handle returned by appfota_init()
buff – [in] buffer containing firmware data
len – [in] length of buffer
- Returns:
return 0 on success, negative value on error
-
int appfota_finish(int handle)
Finish application firmware update, If the firmware binary is valid, system will enter bootloader and update firmware. If the firmware binary is invalid, an error will be returned.
- Parameters:
handle – [in] handle returned by appfota_init()
- Returns:
return negative value on error
