1 /** @defgroup ota_hal_os_api
2  * @{
3  *
4  * This is an include file of OTA OS adapt interface.
5  *
6  * Copyright (C) 2015-2021 Alibaba Group Holding Limited
7  */
8 
9 #ifndef OTA_HAL_OS_H
10 #define OTA_HAL_OS_H
11 
12 #ifdef __cplusplus
13 extern "C" {
14 #endif
15 
16 #define ota_snprintf snprintf
17 
18 /*memory*/
19 void ota_free(void *ptr);
20 void *ota_malloc(int size);
21 void *ota_calloc(int n, int size);
22 void *ota_realloc(void *ptr, int size);
23 
24 void ota_msleep(int ms);
25 
26 /*Reboot*/
27 void ota_reboot(void);
28 
29 /* String */
30 int ota_to_capital(char *value, int len);
31 int ota_str2hex(const char *src, char *dest, unsigned int dest_len);
32 int ota_hex2str(char *dest_buf, const unsigned char *src_buf, unsigned int dest_len, unsigned int src_len);
33 
34 /*Base64*/
35 int ota_base64_decode(const unsigned char *input, unsigned int input_len, unsigned char *output, unsigned int *output_len);
36 
37 /*CRC16*/
38 typedef struct {
39     unsigned short crc;
40 } ota_crc16_ctx;
41 void ota_crc16_init(ota_crc16_ctx *ctx);
42 void ota_crc16_update(ota_crc16_ctx *ctx, const void *inSrc, unsigned int inLen);
43 void ota_crc16_final(ota_crc16_ctx *ctx, unsigned short *outResult);
44 unsigned short ota_get_data_crc16(const unsigned char *buf, unsigned int len);
45 void ota_thread_destroy(void *ptread);
46 
47 /**
48  * @}
49  */
50 #ifdef __cplusplus
51 }
52 #endif
53 #endif /*OTA_HAL_OS_H*/
54