16 #ifndef __OTA_APP_EXT_H__
17 #define __OTA_APP_EXT_H__
23 #define OTA_LIB_VERSION "1.00"
24 #define OTA_VENDOR_TEMPLATE_STR "Vid00_Pid00_Ver00"
25 #define OTASTAT_FILENAME "/sys/otastat.txt"
27 #define MAX_EAGAIN_RETRIES 10
28 #define MAX_RESOURCES 16
29 #define MAX_CONSECUTIVE_NET_ACCESS_ERRORS 10
31 #define MAX_SERVER_NAME 32
32 #define MAX_PATH_PREFIX 48
33 #define MAX_REST_HDRS_SIZE 96
34 #define MAX_USER_NAME_STR 8
35 #define MAX_USER_PASS_STR 8
36 #define MAX_CERT_STR 32
37 #define MAX_KEY_STR 32
45 _i32 secured_connection;
46 _u8 server_domain[MAX_SERVER_NAME];
47 _u8 rest_update_chk[MAX_PATH_PREFIX];
48 _u8 rest_rsrc_metadata[MAX_PATH_PREFIX];
49 _u8 rest_hdr[MAX_REST_HDRS_SIZE];
50 _u8 rest_hdr_val[MAX_REST_HDRS_SIZE];
51 _u8 user_name[MAX_USER_NAME_STR];
52 _u8 user_pass[MAX_USER_PASS_STR];
53 _u8 ca_cert_filename[MAX_CERT_STR];
54 _u8 client_cert_filename[MAX_CERT_STR];
55 _u8 privatekey_filename[MAX_KEY_STR];
57 _u8 log_server_name[MAX_SERVER_NAME];
58 _u8 rest_files_put[MAX_REST_HDRS_SIZE];
59 _u8 log_mac_address[6];
65 typedef _i32 (*OpenFileCB) (_u8 *file_name, _i32 file_size, _u32 *ulToken, _i32
66 *lFileHandle, _i32 open_flags);
67 typedef _i32 (*WriteFileCB) (_i32 fileHandle, _i32 offset, _u8 *buf, _i32 len);
68 typedef _i32 (*ReadFileCB) (_i32 fileHandle, _i32 offset, _u8 *buf, _i32 len);
69 typedef _i32 (*CloseFileCB) (_i32 fileHandle, _u8 *pCeritificateFileName,
70 _u8 *pSignature ,_u32 SignatureLen);
71 typedef _i32 (*AbortFileCB)(_i32 fileHandle);
72 typedef _i32 (*CheckConvertFileCB)(_u8* file_name);
80 WriteFileCB pWriteFile;
82 CloseFileCB pCloseFile;
83 AbortFileCB pAbortFile;
98 _u8 rsrc_file_name[256];
100 _i32 sflash_file_size;
103 _u8 cert1_filename[64];
104 _u8 cert2_filename[64];
105 _u8 *p_cert_filename;
108 _u8 signature_filename[64];
119 EXTLIB_OTA_SET_OPT_SERVER_INFO = 0,
120 EXTLIB_OTA_SET_OPT_VENDOR_ID,
121 EXTLIB_OTA_SET_OPT_IMAGE_TEST,
122 EXTLIB_OTA_SET_OPT_IMAGE_COMMIT
127 EXTLIB_OTA_GET_OPT_IS_ACTIVE,
128 EXTLIB_OTA_GET_OPT_IS_PENDING_COMMIT,
129 EXTLIB_OTA_GET_OPT_PRINT_STAT
136 #define RUN_MODE_OS (0 << 0)
137 #define RUN_MODE_NONE_OS (1 << 0)
138 #define RUN_MODE_BLOCKING (0 << 1)
139 #define RUN_MODE_NONE_BLOCKING (1 << 1)
142 #define RUN_STAT_DOWNLOAD_DONE 0x0002
143 #define RUN_STAT_NO_UPDATES 0x0001
144 #define RUN_STAT_OK 0
145 #define RUN_STAT_CONTINUE 0
146 #define RUN_STAT_ERROR -1
147 #define RUN_STAT_ERROR_TIMEOUT -2
148 #define RUN_STAT_ERROR_CONNECT_OTA_SERVER -3
149 #define RUN_STAT_ERROR_RESOURCE_LIST -4
150 #define RUN_STAT_ERROR_METADATA -5
151 #define RUN_STAT_ERROR_CONNECT_CDN_SERVER -6
152 #define RUN_STAT_ERROR_DOWNLOAD_SAVE -7
153 #define RUN_STAT_ERROR_CONTINUOUS_ACCESS_FAILURES -1000
156 #define OTA_ACTION_RESET_MCU 0x1
157 #define OTA_ACTION_RESET_NWP 0x2
159 #define OTA_ACTION_IMAGE_COMMITED 1
160 #define OTA_ACTION_IMAGE_NOT_COMMITED 0
273 _i32
sl_extLib_OtaSet(
void *pvOtaApp, _i32 Option, _i32 OptionLen, _u8 *pOptionVal);
306 _i32
sl_extLib_OtaGet(
void *pvOtaApp, _i32 Option, _i32 *OptionLen, _u8 *pOptionVal);
_i32 sl_extLib_OtaSet(void *pvOtaApp, _i32 Option, _i32 OptionLen, _u8 *pOptionVal)
Set OTA command/parameter.
void * sl_extLib_OtaInit(_i32 runMode, FlcCb_t *pFlcHostCb)
Initialize OTA application.
_i32 sl_extLib_OtaGet(void *pvOtaApp, _i32 Option, _i32 *OptionLen, _u8 *pOptionVal)
Get the current OTA status.
_i32 sl_extLib_OtaRun(void *pvOtaApp)
Run the OTA App state machine.