blob: 66aa1b9be14277275ea5d31b80772c4cafc7356b [file] [log] [blame]
yuezonghe824eb0c2024-06-27 02:32:26 -07001#ifndef _FOTA_PROTOCOL_UTIL_H_
2#define _FOTA_PROTOCOL_UTIL_H_
3
4#ifdef __cplusplus
5extern "C" {
6#endif
7
8
9#define LINE_BUF_SIZE 128
10
11typedef 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
21typedef 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
32typedef struct {
33 char *string;
34} VString;
35
36/*ЭÒéijÏîÖµÀàÐÍ*/
37typedef enum {
38 ITEMTYPE_DEC,
39 ITEMTYPE_HEX,
40 ITEMTYPE_STRING
41} ItemType;
42
43
44/*º¯ÊýÉùÃ÷*/
45char* protocol_package(char *description, ...);
46
47void format_arguments(VString *message, va_list ap);
48
49int get_action_code(char *content);
50
51int get_result_code(char *content);
52
53int get_version_info(char *content, version_info_t *versionInfo);
54
55int get_version_down_info(char *content, download_info_t *downloadInfo);
56
57void str_append(VString *message, char *str);
58
59void free_version_info(version_info_t *version_info);
60void print_version_info(version_info_t *version_info);
61
62
63
64
65/* notifier list */
66notifier_block_t* notifier_list_add(notifier_block_t* notifier_list, notifier_block_t* notifier_msg);
67
68int notifier_list_free(notifier_block_t* notifier_list);
69
70void notify_callback_process(dmgr_t dm_id, unsigned short event_id, unsigned short msgid, void* data);
71/* notifier list end */
72
73int version_md5_check(const char *filename, char *md5_expect);
74
75
76#ifdef __cplusplus
77}
78#endif
79
80#endif
81
82