yuezonghe | 824eb0c | 2024-06-27 02:32:26 -0700 | [diff] [blame] | 1 | #ifndef _FOTA_PROTOCOL_UTIL_H_ |
| 2 | #define _FOTA_PROTOCOL_UTIL_H_ |
| 3 | |
| 4 | #ifdef __cplusplus |
| 5 | extern "C" { |
| 6 | #endif |
| 7 | |
| 8 | |
| 9 | #define LINE_BUF_SIZE 128 |
| 10 | |
| 11 | typedef enum { |
| 12 | INT_ARGUMENT = 1, |
| 13 | DOUBLE_ARGUMENT, |
| 14 | STRING_ARGUMENT, |
| 15 | HEX_ARGUMENT, |
| 16 | CHARACTER_ARGUMENT, |
| 17 | POINTER_ARGUMENT, |
| 18 | MESSAGE_END |
| 19 | } ArgumentType; |
| 20 | |
| 21 | typedef struct { |
| 22 | ArgumentType type; |
| 23 | union { |
| 24 | int int_val; |
| 25 | double double_val; |
| 26 | char *string_val; |
| 27 | void *pointer_val; |
| 28 | int character_val; |
| 29 | } u; |
| 30 | } ArgumentInfo; |
| 31 | |
| 32 | typedef struct { |
| 33 | char *string; |
| 34 | } VString; |
| 35 | |
| 36 | /*ÐÒéijÏîÖµÀàÐÍ*/ |
| 37 | typedef enum { |
| 38 | ITEMTYPE_DEC, |
| 39 | ITEMTYPE_HEX, |
| 40 | ITEMTYPE_STRING |
| 41 | } ItemType; |
| 42 | |
| 43 | |
| 44 | /*º¯ÊýÉùÃ÷*/ |
| 45 | char* protocol_package(char *description, ...); |
| 46 | |
| 47 | void format_arguments(VString *message, va_list ap); |
| 48 | |
| 49 | int get_action_code(char *content); |
| 50 | |
| 51 | int get_result_code(char *content); |
| 52 | |
| 53 | int get_version_info(char *content, version_info_t *versionInfo); |
| 54 | |
| 55 | int get_version_down_info(char *content, download_info_t *downloadInfo); |
| 56 | |
| 57 | void str_append(VString *message, char *str); |
| 58 | |
| 59 | void free_version_info(version_info_t *version_info); |
| 60 | void print_version_info(version_info_t *version_info); |
| 61 | |
| 62 | |
| 63 | |
| 64 | |
| 65 | /* notifier list */ |
| 66 | notifier_block_t* notifier_list_add(notifier_block_t* notifier_list, notifier_block_t* notifier_msg); |
| 67 | |
| 68 | int notifier_list_free(notifier_block_t* notifier_list); |
| 69 | |
| 70 | void notify_callback_process(dmgr_t dm_id, unsigned short event_id, unsigned short msgid, void* data); |
| 71 | /* notifier list end */ |
| 72 | |
| 73 | int version_md5_check(const char *filename, char *md5_expect); |
| 74 | |
| 75 | |
| 76 | #ifdef __cplusplus |
| 77 | } |
| 78 | #endif |
| 79 | |
| 80 | #endif |
| 81 | |
| 82 | |