blob: 01e738a0aee486d1ee212eafb1f2cdc40cfdd979 [file] [log] [blame]
rjw1f884582022-01-06 17:20:42 +08001//ATCI Service atcmd
2#ifndef _ATCI_COMMON_H_
3#define _ATCI_COMMON_H_
4
5#include <stdio.h>
6#include <string.h>
7#include <unistd.h>
8#include <netinet/in.h>
9#include <sys/un.h>
10#include <sys/stat.h>
11#include <sys/wait.h>
12#include <sys/types.h>
13#include <sys/socket.h>
14#include <pthread.h>
15#include <fcntl.h>
16#include <termios.h>
17#include <stdlib.h>
18#include <errno.h>
19#include <signal.h>
20#ifndef ATCI_UT
21#include "log/log.h"
22//#include <sncfg/sncfg.h>
23#include <cutils/properties.h>
24#endif
25#define SYS_SUCC 0
26#define SYS_FAIL -1
27#define INVALIDE_FD -1
28#define MAX_CMD_BUF_LENGTH 4096
29#define MAX_RESP_BUF_LENGTH 4096
30#define MUX_APP_NUM 5
31#define MAX_CMD_HANDLER_MODULE_NUM 20
32#define MAX_CMD_PREFIX_LENGTH 64
33#undef LOG_TAG
34#define LOG_TAG "ATCI"
35
36typedef enum {
37 ATCI_SPACE = ' ',
38 ATCI_EQUAL = '=',
39 ATCI_COMMA = ',',
40 ATCI_SEMICOLON = ';',
41 ATCI_COLON = ':',
42 ATCI_AT = '@',
43 ATCI_HAT = '^',
44 ATCI_MONEY = '$',
45 ATCI_DOUBLE_QUOTE = '"',
46 ATCI_QUESTION_MARK = '?',
47 ATCI_EXCLAMATION_MARK = '!',
48 ATCI_FORWARD_SLASH = '/',
49 ATCI_L_ANGLE_BRACKET = '<',
50 ATCI_R_ANGLE_BRACKET = '>',
51 ATCI_R_BRACKET = ')',
52 ATCI_L_BRACKET = '(',
53 ATCI_L_SQ_BRACKET = '[',
54 ATCI_R_SQ_BRACKET = ']',
55 ATCI_L_CURLY_BRACKET = '{',
56 ATCI_R_CURLY_BRACKET = '}',
57 ATCI_CHAR_STAR = '*',
58 ATCI_CHAR_POUND = '#',
59 ATCI_CHAR_AMPSAND = '&',
60 ATCI_CHAR_PERCENT = '%',
61 ATCI_CHAR_PLUS = '+',
62 ATCI_CHAR_MINUS = '-',
63 ATCI_CHAR_DOT = '.',
64 ATCI_CHAR_ULINE = '_',
65 ATCI_CHAR_TILDE = '~',
66 ATCI_CHAR_REVERSE_SOLIDUS = '\\',
67 ATCI_CHAR_VERTICAL_LINE = '|',
68 ATCI_END_CHAR = '\0',
69 ATCI_CR = '\r',
70 ATCI_LF = '\n',
71 ATCI_CHAR_0 = '0',
72 ATCI_CHAR_1 = '1',
73 ATCI_CHAR_2 = '2',
74 ATCI_CHAR_3 = '3',
75 ATCI_CHAR_4 = '4',
76 ATCI_CHAR_5 = '5',
77 ATCI_CHAR_6 = '6',
78 ATCI_CHAR_7 = '7',
79 ATCI_CHAR_8 = '8',
80 ATCI_CHAR_9 = '9',
81 ATCI_CHAR_A = 'A',
82 ATCI_CHAR_B = 'B',
83 ATCI_CHAR_C = 'C',
84 ATCI_CHAR_D = 'D',
85 ATCI_CHAR_E = 'E',
86 ATCI_CHAR_F = 'F',
87 ATCI_CHAR_G = 'G',
88 ATCI_CHAR_H = 'H',
89 ATCI_CHAR_I = 'I',
90 ATCI_CHAR_J = 'J',
91 ATCI_CHAR_K = 'K',
92 ATCI_CHAR_L = 'L',
93 ATCI_CHAR_M = 'M',
94 ATCI_CHAR_N = 'N',
95 ATCI_CHAR_O = 'O',
96 ATCI_CHAR_P = 'P',
97 ATCI_CHAR_Q = 'Q',
98 ATCI_CHAR_R = 'R',
99 ATCI_CHAR_S = 'S',
100 ATCI_CHAR_T = 'T',
101 ATCI_CHAR_U = 'U',
102 ATCI_CHAR_V = 'V',
103 ATCI_CHAR_W = 'W',
104 ATCI_CHAR_X = 'X',
105 ATCI_CHAR_Y = 'Y',
106 ATCI_CHAR_Z = 'Z',
107 ATCI_CHAR_a = 'a',
108 ATCI_CHAR_b = 'b',
109 ATCI_CHAR_c = 'c',
110 ATCI_CHAR_d = 'd',
111 ATCI_CHAR_e = 'e',
112 ATCI_CHAR_f = 'f',
113 ATCI_CHAR_g = 'g',
114 ATCI_CHAR_h = 'h',
115 ATCI_CHAR_i = 'i',
116 ATCI_CHAR_j = 'j',
117 ATCI_CHAR_k = 'k',
118 ATCI_CHAR_l = 'l',
119 ATCI_CHAR_m = 'm',
120 ATCI_CHAR_n = 'n',
121 ATCI_CHAR_o = 'o',
122 ATCI_CHAR_p = 'p',
123 ATCI_CHAR_q = 'q',
124 ATCI_CHAR_r = 'r',
125 ATCI_CHAR_s = 's',
126 ATCI_CHAR_t = 't',
127 ATCI_CHAR_u = 'u',
128 ATCI_CHAR_v = 'v',
129 ATCI_CHAR_w = 'w',
130 ATCI_CHAR_x = 'x',
131 ATCI_CHAR_y = 'y',
132 ATCI_CHAR_z = 'z',
133} atci_char_enum;
134
135typedef enum {
136 AT_WRONG_MODE, AT_SET_MODE, //Ex: at+eample=xxx
137 AT_READ_MODE, //Ex: at+eample?
138 AT_TEST_MODE, //Ex: at+eample=?
139 AT_ACTIVE_MODE //Ex: at+eample
140} atci_cmd_mode_e;
141
142typedef enum {
143 TARGET_TELEPHONY = 0,
144 /*if need send to new app, add target_type */
145 TARGET_UNKNOWN = MUX_APP_NUM,
146 TARGET_RIL,
147 TARGET_GENERIC,
148 TARGET_PLATFORM,
149 TARGET_BATTERY,
150 TARGET_AUDIO,
151 TARGET_EXTERNAL
152} atci_target_e;
153
154#define ATCI_LOWER_TO_UPPER(alpha_char) (((alpha_char >= ATCI_CHAR_a)&&(alpha_char <= ATCI_CHAR_z)) ? (alpha_char-32): (alpha_char))
155#define ATCI_UPPER_TO_LOWER(alpha_char) (((alpha_char >= ATCI_CHAR_A)&&(alpha_char <= ATCI_CHAR_Z)) ? (alpha_char+32): (alpha_char))
156#define ATCI_IS_CAHR(input ,alpha_char) ((alpha_char == input)? 1 : 0)
157
158#define SysMsg(f,a...) RLOGI("( %s, %d: )" f "\n",__FUNCTION__, __LINE__,## a)
159#define DbgMsg(f,a...) RLOGD("( %s, %d: )" f "\n",__FUNCTION__, __LINE__,## a)
160#define ErrMsg(f,a...) RLOGE("( %s, %d: )" f "\n",__FUNCTION__, __LINE__,## a)
161
162#endif