lh | 9ed821d | 2023-04-07 01:36:19 -0700 | [diff] [blame] | 1 | #ifndef CONFIG_MIN_8M_VERSION |
| 2 | #include "ext_socket_func.h" |
| 3 | #include "cfg_nv_def.h" |
| 4 | #include "at_context.h" |
| 5 | #include "kwatch_msg.h" |
| 6 | |
| 7 | int netcon_extcid = -1; |
| 8 | char netcon_configname[10] = {0}; |
| 9 | int netcon_value_int = 0; |
| 10 | char netcon_value_char[70] = {0}; |
| 11 | extern char* normal_getzversion(); |
| 12 | int urcsysinfo = 0; |
xf.li | 9d1a0e1 | 2023-09-20 01:43:20 -0700 | [diff] [blame] | 13 | typedef struct |
| 14 | { |
| 15 | int mode; |
| 16 | int creg; |
| 17 | int cgreg; |
| 18 | int cereg; |
lh | 9ed821d | 2023-04-07 01:36:19 -0700 | [diff] [blame] | 19 | } EXT_NETSTATE_INFO; |
| 20 | EXT_NETSTATE_INFO urcinfo = {0}; |
| 21 | //========================================================================================================// |
| 22 | //¹úµçsocket·½°¸º¯ÊýʵÏÖÇø |
| 23 | //========================================================================================================// |
| 24 | static int gsmband = 0; |
| 25 | |
| 26 | static void comm_rspmsg_proc(void *rsp_msg, void**ret, int *retlen) |
| 27 | { |
xf.li | 9d1a0e1 | 2023-09-20 01:43:20 -0700 | [diff] [blame] | 28 | AT_COMM_RSPMSG *msg = (AT_COMM_RSPMSG*)rsp_msg; |
| 29 | char *at_str = NULL; |
| 30 | int offset = 0; |
lh | 9ed821d | 2023-04-07 01:36:19 -0700 | [diff] [blame] | 31 | |
xf.li | 9d1a0e1 | 2023-09-20 01:43:20 -0700 | [diff] [blame] | 32 | if (msg->result < 0) |
| 33 | { |
| 34 | at_str = malloc(32); |
| 35 | assert(at_str); |
| 36 | memset(at_str, 0x00, 32); |
| 37 | if (msg->errcode) |
| 38 | { |
| 39 | sprintf(at_str, "\r\nERROR: %d\r\n", msg->errcode); |
| 40 | } |
| 41 | else |
| 42 | { |
| 43 | sprintf(at_str, "\r\nERROR\r\n"); |
| 44 | } |
| 45 | } |
| 46 | else |
| 47 | { |
| 48 | at_str = malloc(64); |
| 49 | assert(at_str); |
| 50 | memset(at_str, 0x00, 64); |
| 51 | if (msg->msg_cmd == MSG_CMD_NETACT_REQ) |
| 52 | { |
| 53 | offset += sprintf(at_str, "\r\nOK\r\n"); |
| 54 | if (msg->urc_switch) |
| 55 | { |
| 56 | if (g_customer_type == CUSTOMER_GUODIAN) |
| 57 | { |
| 58 | offset += sprintf(at_str + offset, "\r\n$MYURCACT: %d,%d\r\n", msg->extcid, msg->act_type); |
| 59 | } |
| 60 | else if (g_customer_type == CUSTOMER_NANDIAN) |
| 61 | { |
| 62 | offset += sprintf(at_str + offset, "\r\n$MYURCACT: %d,%d,\"%s\"\r\n", msg->extcid, msg->act_type, msg->ip); |
| 63 | } |
| 64 | } |
lh | 9ed821d | 2023-04-07 01:36:19 -0700 | [diff] [blame] | 65 | |
xf.li | 9d1a0e1 | 2023-09-20 01:43:20 -0700 | [diff] [blame] | 66 | *ret = at_str; |
| 67 | *retlen = offset; |
| 68 | return; |
| 69 | } |
| 70 | sprintf(at_str, "\r\nOK\r\n"); |
| 71 | } |
| 72 | *ret = at_str; |
| 73 | *retlen = strlen(at_str); |
lh | 9ed821d | 2023-04-07 01:36:19 -0700 | [diff] [blame] | 74 | |
| 75 | } |
| 76 | |
| 77 | |
| 78 | int ext_netcon_req(int at_fd, char *at_paras, void ** res_msg, int *res_msglen) |
| 79 | { |
xf.li | 9d1a0e1 | 2023-09-20 01:43:20 -0700 | [diff] [blame] | 80 | struct netcon_reqmsg *reqmsg = malloc(sizeof(struct netcon_reqmsg)); |
| 81 | assert(reqmsg); |
| 82 | char configname[10] = {0}; |
| 83 | char *l_quota = NULL;//×óË«ÒýºÅ |
| 84 | char *r_quota = NULL;//ÓÒË«ÒýºÅ |
| 85 | char *at_str = NULL; |
lh | 9ed821d | 2023-04-07 01:36:19 -0700 | [diff] [blame] | 86 | |
xf.li | 9d1a0e1 | 2023-09-20 01:43:20 -0700 | [diff] [blame] | 87 | //if (NULL == reqmsg) softap_assert(""); |
| 88 | //³õʼ»¯ |
| 89 | memset(reqmsg, 0x00, sizeof(struct netcon_reqmsg)); |
| 90 | reqmsg->auth_type = -1; |
| 91 | reqmsg->cfgp = -1; |
| 92 | reqmsg->cfgt = -1; |
lh | 9ed821d | 2023-04-07 01:36:19 -0700 | [diff] [blame] | 93 | |
xf.li | 9d1a0e1 | 2023-09-20 01:43:20 -0700 | [diff] [blame] | 94 | reqmsg->extcid = at_paras[0] - '0'; |
| 95 | if (reqmsg->extcid < 0 || reqmsg->extcid >= 6) |
| 96 | { |
| 97 | goto error; |
| 98 | } |
| 99 | l_quota = strstr(at_paras, "\""); |
| 100 | if (NULL == l_quota) |
| 101 | { |
| 102 | goto error; |
| 103 | } |
| 104 | r_quota = strstr(l_quota + 1, "\""); |
lh | 9ed821d | 2023-04-07 01:36:19 -0700 | [diff] [blame] | 105 | |
xf.li | 9d1a0e1 | 2023-09-20 01:43:20 -0700 | [diff] [blame] | 106 | if (NULL == r_quota) |
| 107 | { |
| 108 | goto error; |
| 109 | } |
| 110 | memcpy(configname, l_quota + 1, r_quota - l_quota - 1); |
| 111 | if (0 == at_strncmp(configname, "APN", strlen("APN"))) |
| 112 | { |
| 113 | l_quota = strstr(r_quota + 1, "\""); |
| 114 | if (l_quota == NULL) |
| 115 | { |
| 116 | goto error; |
lh | 9ed821d | 2023-04-07 01:36:19 -0700 | [diff] [blame] | 117 | } |
xf.li | 9d1a0e1 | 2023-09-20 01:43:20 -0700 | [diff] [blame] | 118 | r_quota = strstr(l_quota + 1, "\""); |
| 119 | if (r_quota == NULL) |
| 120 | { |
| 121 | goto error; |
lh | 9ed821d | 2023-04-07 01:36:19 -0700 | [diff] [blame] | 122 | } |
xf.li | 9d1a0e1 | 2023-09-20 01:43:20 -0700 | [diff] [blame] | 123 | memcpy(reqmsg->apn, l_quota + 1, r_quota - l_quota - 1); |
| 124 | memset(netcon_value_char, 0, sizeof(netcon_value_char)); |
| 125 | memcpy(netcon_value_char, l_quota + 1, r_quota - l_quota - 1); |
| 126 | } |
| 127 | else if (0 == at_strncmp(configname, "USERPWD", strlen("USERPWD"))) |
| 128 | { |
| 129 | l_quota = strstr(r_quota + 1, "\""); |
| 130 | if (l_quota == NULL) |
| 131 | { |
| 132 | goto error; |
lh | 9ed821d | 2023-04-07 01:36:19 -0700 | [diff] [blame] | 133 | } |
xf.li | 9d1a0e1 | 2023-09-20 01:43:20 -0700 | [diff] [blame] | 134 | r_quota = strstr(l_quota + 1, "\""); |
| 135 | if (r_quota == NULL) |
| 136 | { |
| 137 | goto error; |
| 138 | } |
| 139 | char *comma = strstr(l_quota + 1, ","); |
| 140 | if (NULL != comma) //ÓжººÅ£¬Óû§ÃûÃÜÂ벻Ϊ¿Õ |
| 141 | { |
| 142 | if (comma > r_quota) |
| 143 | { |
| 144 | goto error; |
| 145 | } |
| 146 | memcpy(reqmsg->username, l_quota + 1, comma - l_quota - 1); |
| 147 | memcpy(reqmsg->password, comma + 1, r_quota - comma - 1); |
| 148 | } |
| 149 | memset(netcon_value_char, 0, sizeof(netcon_value_char)); |
| 150 | memcpy(netcon_value_char, l_quota + 1, r_quota - l_quota - 1); |
lh | 9ed821d | 2023-04-07 01:36:19 -0700 | [diff] [blame] | 151 | |
xf.li | 9d1a0e1 | 2023-09-20 01:43:20 -0700 | [diff] [blame] | 152 | reqmsg->is_userpwd = 1; |
| 153 | } |
| 154 | else if (0 == at_strncmp(configname, "CFGT", strlen("CFGT"))) |
| 155 | { |
| 156 | int len = strlen(r_quota + 2); |
| 157 | char* str = malloc(len + 1); |
| 158 | assert(str); |
| 159 | strcpy(str, r_quota + 2); |
| 160 | reqmsg->cfgt = atoi(str); |
| 161 | if (reqmsg->cfgt < 1 || reqmsg->cfgt > 65535) |
| 162 | { |
| 163 | free(str); |
| 164 | goto error; |
| 165 | } |
| 166 | netcon_value_int = atoi(str); |
| 167 | free(str); |
| 168 | } |
| 169 | else if (0 == at_strncmp(configname, "CFGP", strlen("CFGP"))) |
| 170 | { |
| 171 | int len = strlen(r_quota + 2); |
| 172 | char* str = malloc(len + 1); |
| 173 | assert(str); |
| 174 | strcpy(str, r_quota + 2); |
| 175 | reqmsg->cfgp = atoi(str); |
| 176 | if (reqmsg->cfgp < 1 || reqmsg->cfgp > 1460) |
| 177 | { |
| 178 | free(str); |
| 179 | goto error; |
| 180 | } |
| 181 | netcon_value_int = atoi(str); |
| 182 | free(str); |
| 183 | } |
| 184 | else if (0 == at_strncmp(configname, "AUTH", strlen("AUTH"))) |
| 185 | { |
| 186 | int len = strlen(r_quota + 2); |
| 187 | char* str = malloc(len + 1); |
| 188 | assert(str); |
| 189 | strcpy(str, r_quota + 2); |
| 190 | reqmsg->auth_type = atoi(str); |
| 191 | if (reqmsg->auth_type < 0 || reqmsg->auth_type > 2) |
| 192 | { |
| 193 | free(str); |
| 194 | goto error; |
| 195 | } |
| 196 | netcon_value_int = atoi(str); |
| 197 | free(str); |
| 198 | } |
| 199 | else |
| 200 | { |
| 201 | goto error; |
| 202 | } |
| 203 | netcon_extcid = reqmsg->extcid; |
| 204 | strncpy(netcon_configname, configname, sizeof(netcon_configname) - 1); |
| 205 | |
| 206 | *res_msg = reqmsg; |
| 207 | *res_msglen = sizeof(struct netcon_reqmsg); |
| 208 | return AT_CONTINUE; |
lh | 9ed821d | 2023-04-07 01:36:19 -0700 | [diff] [blame] | 209 | error: |
| 210 | free(reqmsg); |
xf.li | 9d1a0e1 | 2023-09-20 01:43:20 -0700 | [diff] [blame] | 211 | at_str = malloc(32); |
| 212 | assert(at_str); |
| 213 | memset(at_str, 0x00, 32); |
| 214 | sprintf(at_str, "\r\nERROR: 980\r\n"); |
| 215 | *res_msg = at_str; |
| 216 | *res_msglen = strlen(at_str); |
| 217 | return AT_END; |
lh | 9ed821d | 2023-04-07 01:36:19 -0700 | [diff] [blame] | 218 | } |
| 219 | int ext_netcon_rsp(void *rsp_msg, void**ret, int *retlen) |
| 220 | { |
xf.li | 9d1a0e1 | 2023-09-20 01:43:20 -0700 | [diff] [blame] | 221 | comm_rspmsg_proc(rsp_msg, ret, retlen); |
| 222 | return AT_END; |
lh | 9ed821d | 2023-04-07 01:36:19 -0700 | [diff] [blame] | 223 | } |
| 224 | |
| 225 | int ext_netact_req(int at_fd, char *at_paras, void ** res_msg, int *res_msglen) |
| 226 | { |
xf.li | 9d1a0e1 | 2023-09-20 01:43:20 -0700 | [diff] [blame] | 227 | struct netact_reqmsg *reqmsg = malloc(sizeof(struct netact_reqmsg)); |
| 228 | assert(reqmsg); |
| 229 | char *p[2] = {&reqmsg->extcid, &reqmsg->act_type}; |
lh | 9ed821d | 2023-04-07 01:36:19 -0700 | [diff] [blame] | 230 | char *at_str = NULL; |
xf.li | 9d1a0e1 | 2023-09-20 01:43:20 -0700 | [diff] [blame] | 231 | memset(reqmsg, 0x00, sizeof(struct comm_reqmsg)); |
| 232 | if (2 != parse_param2("%d,%d", at_paras, p)) |
| 233 | { |
lh | 9ed821d | 2023-04-07 01:36:19 -0700 | [diff] [blame] | 234 | free(reqmsg); |
xf.li | 9d1a0e1 | 2023-09-20 01:43:20 -0700 | [diff] [blame] | 235 | at_str = malloc(32); |
| 236 | assert(at_str); |
| 237 | memset(at_str, 0x00, 32); |
| 238 | sprintf(at_str, "\r\nERROR: 980\r\n"); |
| 239 | *res_msg = at_str; |
| 240 | *res_msglen = strlen(at_str); |
| 241 | return AT_END; |
| 242 | } |
lh | 9ed821d | 2023-04-07 01:36:19 -0700 | [diff] [blame] | 243 | |
xf.li | 9d1a0e1 | 2023-09-20 01:43:20 -0700 | [diff] [blame] | 244 | *res_msg = reqmsg; |
| 245 | *res_msglen = sizeof(struct netact_reqmsg); |
| 246 | return AT_CONTINUE; |
lh | 9ed821d | 2023-04-07 01:36:19 -0700 | [diff] [blame] | 247 | } |
| 248 | int ext_netact_rsp(void *rsp_msg, void**ret, int *retlen) |
| 249 | { |
xf.li | 9d1a0e1 | 2023-09-20 01:43:20 -0700 | [diff] [blame] | 250 | comm_rspmsg_proc(rsp_msg, ret, retlen); |
lh | 9ed821d | 2023-04-07 01:36:19 -0700 | [diff] [blame] | 251 | |
xf.li | 9d1a0e1 | 2023-09-20 01:43:20 -0700 | [diff] [blame] | 252 | return AT_END; |
lh | 9ed821d | 2023-04-07 01:36:19 -0700 | [diff] [blame] | 253 | } |
| 254 | |
| 255 | /*Èí¹Ø»ú*/ |
| 256 | int ext_poweroff_req(int at_fd, char * at_paras, void **res_msg, int * res_msglen) |
| 257 | { |
xf.li | 9d1a0e1 | 2023-09-20 01:43:20 -0700 | [diff] [blame] | 258 | return AT_CONTINUE; |
lh | 9ed821d | 2023-04-07 01:36:19 -0700 | [diff] [blame] | 259 | } |
| 260 | |
| 261 | |
| 262 | |
| 263 | int ext_i_act_func(int at_fd, char * at_paras, void * *res_msg, int * res_msglen) |
| 264 | { |
xf.li | 9d1a0e1 | 2023-09-20 01:43:20 -0700 | [diff] [blame] | 265 | char *at_str = NULL; |
lh | 9ed821d | 2023-04-07 01:36:19 -0700 | [diff] [blame] | 266 | |
xf.li | 9d1a0e1 | 2023-09-20 01:43:20 -0700 | [diff] [blame] | 267 | at_str = malloc(128); |
| 268 | assert(at_str); |
| 269 | memset(at_str, 0, 128); |
| 270 | sprintf((char*)at_str, "\r\nLQBS\r\nLQ300V3\r\nREVISION V1.0.0\r\nOK\r\n"); |
lh | 9ed821d | 2023-04-07 01:36:19 -0700 | [diff] [blame] | 271 | |
xf.li | 9d1a0e1 | 2023-09-20 01:43:20 -0700 | [diff] [blame] | 272 | *res_msg = at_str; |
| 273 | *res_msglen = strlen(*res_msg); |
| 274 | return AT_END; |
lh | 9ed821d | 2023-04-07 01:36:19 -0700 | [diff] [blame] | 275 | } |
| 276 | int ext_myband_set_func(char *at_paras, void ** res_msg) |
| 277 | { |
xf.li | 9d1a0e1 | 2023-09-20 01:43:20 -0700 | [diff] [blame] | 278 | if (unix_send_proc(get_default_sockfd(), MODULE_ID_SOCKET_PROXY, MSG_CMD_MYBAND_SET_REQ, strlen(at_paras), |
| 279 | (unsigned char *)at_paras, 0)) |
| 280 | { |
| 281 | softap_assert(""); |
| 282 | } |
| 283 | return AT_CONTINUE; |
lh | 9ed821d | 2023-04-07 01:36:19 -0700 | [diff] [blame] | 284 | } |
| 285 | |
| 286 | int ext_myband_query_func(char *at_paras, void ** res_msg) |
| 287 | { |
xf.li | 9d1a0e1 | 2023-09-20 01:43:20 -0700 | [diff] [blame] | 288 | if (unix_send_proc(get_default_sockfd(), MODULE_ID_SOCKET_PROXY, MSG_CMD_MYBAND_QUERY_REQ, 0, NULL, 0)) |
| 289 | { |
| 290 | softap_assert(""); |
| 291 | } |
| 292 | return AT_CONTINUE; |
lh | 9ed821d | 2023-04-07 01:36:19 -0700 | [diff] [blame] | 293 | } |
| 294 | |
| 295 | int ext_beeh_act_func(int at_fd, char * at_paras, void * *res_msg, int * res_msglen) |
| 296 | { |
xf.li | 9d1a0e1 | 2023-09-20 01:43:20 -0700 | [diff] [blame] | 297 | *res_msg = at_ok_build(); |
| 298 | *res_msglen = strlen(*res_msg); |
| 299 | return AT_END; |
lh | 9ed821d | 2023-04-07 01:36:19 -0700 | [diff] [blame] | 300 | } |
| 301 | |
| 302 | int ext_poweroff_rsp(void *rsp_msg, void**ret, int *retlen) |
| 303 | { |
xf.li | 9d1a0e1 | 2023-09-20 01:43:20 -0700 | [diff] [blame] | 304 | char *at_str = NULL; |
lh | 9ed821d | 2023-04-07 01:36:19 -0700 | [diff] [blame] | 305 | |
xf.li | 9d1a0e1 | 2023-09-20 01:43:20 -0700 | [diff] [blame] | 306 | at_str = at_ok_build(); |
lh | 9ed821d | 2023-04-07 01:36:19 -0700 | [diff] [blame] | 307 | |
xf.li | 9d1a0e1 | 2023-09-20 01:43:20 -0700 | [diff] [blame] | 308 | *ret = at_str; |
| 309 | *retlen = strlen(at_str); |
lh | 9ed821d | 2023-04-07 01:36:19 -0700 | [diff] [blame] | 310 | |
xf.li | 9d1a0e1 | 2023-09-20 01:43:20 -0700 | [diff] [blame] | 311 | return AT_END; |
lh | 9ed821d | 2023-04-07 01:36:19 -0700 | [diff] [blame] | 312 | } |
| 313 | |
| 314 | /*¶ÁÈí¼þÍⲿ°æ±¾ºÅ*/ |
| 315 | int ext_gmr_act_func(int at_fd, char * at_paras, void * *res_msg, int * res_msglen) |
| 316 | { |
xf.li | 9d1a0e1 | 2023-09-20 01:43:20 -0700 | [diff] [blame] | 317 | char hwver[32] = {0}; |
| 318 | char swver[32] = {0}; |
| 319 | char *at_str = NULL; |
lh | 9ed821d | 2023-04-07 01:36:19 -0700 | [diff] [blame] | 320 | |
xf.li | 9d1a0e1 | 2023-09-20 01:43:20 -0700 | [diff] [blame] | 321 | //sc_cfg_get(NV_HW_VERSION, hwver, sizeof(hwver)); |
| 322 | //sc_cfg_get(NV_WA_VERSION, swver, sizeof(swver)); |
| 323 | //³§ÉÌ´úºÅ¡¢Ä£¿éÐͺš¢Ó²¼þ·¢²¼ÈÕÆÚ¡¢Èí¼þ·¢²¼ÈÕÆÚÈçºÎ»ñÈ¡ |
| 324 | at_str = malloc(128); |
| 325 | assert(at_str); |
| 326 | memset(at_str, 0, 128); |
| 327 | sprintf((char*)at_str, "\r\nLQBS\r\nLQ300V3\r\nV1.0.0\r\n151017\r\nV1.0\r\n151017\r\nOK\r\n"); |
| 328 | *res_msg = at_str; |
| 329 | *res_msglen = strlen(*res_msg); |
| 330 | return AT_END; |
lh | 9ed821d | 2023-04-07 01:36:19 -0700 | [diff] [blame] | 331 | } |
| 332 | /*»ñÈ¡SIM¿¨ÐòÁкÅ*/ |
| 333 | int ext_ccid_act_func(int at_fd, char * at_paras, void * *res_msg, int * res_msglen) |
| 334 | { |
xf.li | 9d1a0e1 | 2023-09-20 01:43:20 -0700 | [diff] [blame] | 335 | char iccid[32] = {0}; |
| 336 | char *at_str = NULL; |
lh | 9ed821d | 2023-04-07 01:36:19 -0700 | [diff] [blame] | 337 | |
xf.li | 9d1a0e1 | 2023-09-20 01:43:20 -0700 | [diff] [blame] | 338 | at_str = malloc(64); |
| 339 | assert(at_str); |
| 340 | memset(at_str, 0, 64); |
| 341 | sc_cfg_get(NV_ZICCID, iccid, sizeof(iccid)); |
| 342 | //at_print(1,"ext_ccid_act_func: iccid = %s\n",iccid); |
| 343 | sprintf((char*)at_str, "\r\n$MYCCID: \"%s\"\r\nOK\r\n", iccid); |
| 344 | *res_msg = at_str; |
| 345 | *res_msglen = strlen(*res_msg); |
| 346 | return AT_END; |
lh | 9ed821d | 2023-04-07 01:36:19 -0700 | [diff] [blame] | 347 | } |
| 348 | int ext_netcon_query_func(int at_fd, char *at_paras, void ** res_msg, int *res_msglen) |
| 349 | { |
xf.li | 9d1a0e1 | 2023-09-20 01:43:20 -0700 | [diff] [blame] | 350 | char *at_str = NULL; |
| 351 | int offset = 0; |
lh | 9ed821d | 2023-04-07 01:36:19 -0700 | [diff] [blame] | 352 | |
xf.li | 9d1a0e1 | 2023-09-20 01:43:20 -0700 | [diff] [blame] | 353 | if (netcon_extcid == -1) |
| 354 | { |
| 355 | at_str = malloc(32); |
| 356 | assert(at_str); |
| 357 | memset(at_str, 0x00, 32); |
| 358 | sprintf(at_str, "\r\nERROR\r\n"); |
| 359 | } |
| 360 | else |
| 361 | { |
| 362 | at_str = malloc(32 + sizeof(netcon_extcid) + sizeof(netcon_configname) + sizeof(netcon_value_char)); |
| 363 | assert(at_str); |
| 364 | memset(at_str, 0, 32 + sizeof(netcon_extcid) + sizeof(netcon_configname) + sizeof(netcon_value_char)); |
| 365 | offset += sprintf(at_str + offset, "\r\n$MYNETCON: %d,\"%s\",", netcon_extcid, netcon_configname); |
| 366 | if (0 == at_strncmp(netcon_configname, "APN", strlen("APN")) |
| 367 | || 0 == at_strncmp(netcon_configname, "USERPWD", strlen("USERPWD"))) |
| 368 | { |
| 369 | offset += sprintf(at_str + offset, "\"%s\"\r\nOK\r\n", netcon_value_char); |
| 370 | } |
| 371 | else |
| 372 | { |
| 373 | offset += sprintf(at_str + offset, "%d\r\nOK\r\n", netcon_value_int); |
| 374 | } |
| 375 | } |
lh | 9ed821d | 2023-04-07 01:36:19 -0700 | [diff] [blame] | 376 | |
xf.li | 9d1a0e1 | 2023-09-20 01:43:20 -0700 | [diff] [blame] | 377 | *res_msg = at_str; |
| 378 | *res_msglen = strlen(*res_msg); |
| 379 | return AT_END; |
lh | 9ed821d | 2023-04-07 01:36:19 -0700 | [diff] [blame] | 380 | |
| 381 | } |
| 382 | |
| 383 | int ext_gmr_query_func(char *at_paras, void ** res_msg) |
| 384 | { |
xf.li | 9d1a0e1 | 2023-09-20 01:43:20 -0700 | [diff] [blame] | 385 | if (unix_send_proc(get_default_sockfd(), MODULE_ID_SOCKET_PROXY, MSG_CMD_GMR_QUERY_REQ, 0, NULL, 0)) |
| 386 | { |
| 387 | softap_assert(""); |
| 388 | } |
| 389 | return AT_CONTINUE; |
lh | 9ed821d | 2023-04-07 01:36:19 -0700 | [diff] [blame] | 390 | } |
| 391 | int ext_gmr_func(int at_fd, char * at_paras, void * *res_msg, int * res_msglen) |
| 392 | { |
xf.li | 9d1a0e1 | 2023-09-20 01:43:20 -0700 | [diff] [blame] | 393 | *res_msg = at_ok_build(); |
| 394 | *res_msglen = strlen(*res_msg); |
| 395 | return AT_END; |
lh | 9ed821d | 2023-04-07 01:36:19 -0700 | [diff] [blame] | 396 | } |
| 397 | |
| 398 | int ext_mysysinfo_query_func(char *at_paras, void ** res_msg) |
| 399 | { |
xf.li | 9d1a0e1 | 2023-09-20 01:43:20 -0700 | [diff] [blame] | 400 | if (unix_send_proc(get_default_sockfd(), MODULE_ID_SOCKET_PROXY, MSG_CMD_MYSYSINFO_QUERY_REQ, 0, NULL, 0)) |
| 401 | { |
| 402 | softap_assert(""); |
| 403 | } |
| 404 | return AT_CONTINUE; |
lh | 9ed821d | 2023-04-07 01:36:19 -0700 | [diff] [blame] | 405 | } |
| 406 | |
| 407 | int ext_mynetinfo_set_func(char *at_paras, void ** res_msg) |
| 408 | { |
xf.li | 9d1a0e1 | 2023-09-20 01:43:20 -0700 | [diff] [blame] | 409 | if (unix_send_proc(get_default_sockfd(), MODULE_ID_SOCKET_PROXY, MSG_CMD_MYNETINFO_SET_REQ, strlen(at_paras), |
| 410 | (unsigned char *)at_paras, 0)) |
| 411 | { |
| 412 | softap_assert(""); |
| 413 | } |
| 414 | return AT_CONTINUE; |
lh | 9ed821d | 2023-04-07 01:36:19 -0700 | [diff] [blame] | 415 | } |
| 416 | |
| 417 | int ext_mynetinfo_query_func(char *at_paras, void ** res_msg) |
| 418 | { |
xf.li | 9d1a0e1 | 2023-09-20 01:43:20 -0700 | [diff] [blame] | 419 | if (unix_send_proc(get_default_sockfd(), MODULE_ID_SOCKET_PROXY, MSG_CMD_MYNETINFO_QUERY_REQ, 0, NULL, 0)) |
| 420 | { |
| 421 | softap_assert(""); |
| 422 | } |
| 423 | return AT_CONTINUE; |
lh | 9ed821d | 2023-04-07 01:36:19 -0700 | [diff] [blame] | 424 | } |
| 425 | |
| 426 | int ext_urcsysinfo_act_func(char *at_paras, void ** res_msg) |
| 427 | { |
xf.li | 9d1a0e1 | 2023-09-20 01:43:20 -0700 | [diff] [blame] | 428 | int flag = 0; |
| 429 | void *p[1] = {&flag}; |
| 430 | int ret = 0; |
| 431 | ret = parse_param("%d", at_paras, p); |
| 432 | if (ret != AT_PARSE_OK) |
| 433 | { |
| 434 | return AT_END; |
| 435 | } |
| 436 | if (1 == flag) |
| 437 | { |
| 438 | urcsysinfo = 1; |
| 439 | *res_msg = at_ok_build(); |
| 440 | } |
| 441 | else |
| 442 | { |
| 443 | *res_msg = at_err_build(0); |
| 444 | } |
| 445 | return AT_END; |
lh | 9ed821d | 2023-04-07 01:36:19 -0700 | [diff] [blame] | 446 | } |
| 447 | |
| 448 | int mode_inform_act(char *at_paras, int is_query_report) |
| 449 | { |
xf.li | 9d1a0e1 | 2023-09-20 01:43:20 -0700 | [diff] [blame] | 450 | int mode = 0; |
| 451 | void *p[1] = {&mode}; |
| 452 | int ret = 0; |
| 453 | ret = parse_param("%d", at_paras, p); |
| 454 | if (ret != AT_PARSE_OK) |
| 455 | { |
| 456 | return AT_END; |
| 457 | } |
| 458 | if ((mode != urcinfo.mode) && (urcsysinfo == 1)) |
| 459 | { |
| 460 | urcinfo.mode = mode; |
| 461 | if (unix_send_proc(get_default_sockfd(), MODULE_ID_SOCKET_PROXY, MSG_CMD_MYURCSYSINFO_INFORM_REQ, 0, NULL, 0)) |
| 462 | { |
| 463 | softap_assert(""); |
| 464 | } |
| 465 | } |
| 466 | return AT_END; |
lh | 9ed821d | 2023-04-07 01:36:19 -0700 | [diff] [blame] | 467 | } |
| 468 | |
| 469 | int net_state_transfer(int state) |
| 470 | { |
xf.li | 9d1a0e1 | 2023-09-20 01:43:20 -0700 | [diff] [blame] | 471 | if ((state == 1) || (state == 5)) |
| 472 | { |
| 473 | return 1; |
| 474 | } |
| 475 | else |
| 476 | { |
| 477 | return 0; |
| 478 | } |
lh | 9ed821d | 2023-04-07 01:36:19 -0700 | [diff] [blame] | 479 | } |
| 480 | int creg_inform_act(char *at_paras, int is_query_report) |
| 481 | { |
xf.li | 9d1a0e1 | 2023-09-20 01:43:20 -0700 | [diff] [blame] | 482 | int state = 0; |
| 483 | void *p[1] = {&state}; |
| 484 | int ret = 0; |
| 485 | ret = parse_param("%d", at_paras, p); |
| 486 | if (ret != AT_PARSE_OK) |
| 487 | { |
| 488 | return AT_END; |
| 489 | } |
| 490 | state = net_state_transfer(state); |
| 491 | if ((state != urcinfo.creg) && (urcsysinfo == 1)) |
| 492 | { |
| 493 | urcinfo.creg = state; |
| 494 | if (unix_send_proc(get_default_sockfd(), MODULE_ID_SOCKET_PROXY, MSG_CMD_MYURCSYSINFO_INFORM_REQ, 0, NULL, 0)) |
| 495 | { |
| 496 | softap_assert(""); |
| 497 | } |
| 498 | } |
| 499 | return AT_END; |
lh | 9ed821d | 2023-04-07 01:36:19 -0700 | [diff] [blame] | 500 | } |
| 501 | int cgreg_inform_act(char *at_paras, int is_query_report) |
| 502 | { |
xf.li | 9d1a0e1 | 2023-09-20 01:43:20 -0700 | [diff] [blame] | 503 | int state = 0; |
| 504 | void *p[1] = {&state}; |
| 505 | int ret = 0; |
| 506 | ret = parse_param("%d", at_paras, p); |
| 507 | if (ret != AT_PARSE_OK) |
| 508 | { |
| 509 | return AT_END; |
| 510 | } |
| 511 | state = net_state_transfer(state); |
| 512 | if ((state != urcinfo.cgreg) && (urcsysinfo == 1)) |
| 513 | { |
| 514 | urcinfo.cgreg = state; |
| 515 | if (unix_send_proc(get_default_sockfd(), MODULE_ID_SOCKET_PROXY, MSG_CMD_MYURCSYSINFO_INFORM_REQ, 0, NULL, 0)) |
| 516 | { |
| 517 | softap_assert(""); |
| 518 | } |
| 519 | } |
| 520 | return AT_END; |
lh | 9ed821d | 2023-04-07 01:36:19 -0700 | [diff] [blame] | 521 | } |
| 522 | int cereg_inform_act(char *at_paras, int is_query_report) |
| 523 | { |
xf.li | 9d1a0e1 | 2023-09-20 01:43:20 -0700 | [diff] [blame] | 524 | int state = 0; |
| 525 | void *p[1] = {&state}; |
| 526 | int ret = 0; |
| 527 | ret = parse_param("%d", at_paras, p); |
| 528 | if (ret != AT_PARSE_OK) |
| 529 | { |
| 530 | return AT_END; |
| 531 | } |
| 532 | state = net_state_transfer(state); |
| 533 | if ((state != urcinfo.cereg) && (urcsysinfo == 1)) |
| 534 | { |
| 535 | urcinfo.cereg = state; |
| 536 | if (unix_send_proc(get_default_sockfd(), MODULE_ID_SOCKET_PROXY, MSG_CMD_MYURCSYSINFO_INFORM_REQ, 0, NULL, 0)) |
| 537 | { |
| 538 | softap_assert(""); |
| 539 | } |
| 540 | } |
| 541 | return AT_END; |
lh | 9ed821d | 2023-04-07 01:36:19 -0700 | [diff] [blame] | 542 | } |
| 543 | |
| 544 | int ext_time_set_func(char *at_paras, void ** res_msg) |
xf.li | 9d1a0e1 | 2023-09-20 01:43:20 -0700 | [diff] [blame] | 545 | { |
| 546 | char settime[32] = {0}; |
| 547 | void *p[] = {settime}; |
| 548 | int ret = 0; |
| 549 | char *at_str = NULL; |
| 550 | at_str = malloc(16); |
| 551 | assert(at_str); |
| 552 | memset(at_str, 0, 16); |
| 553 | struct tm set_tm = {0}; |
| 554 | struct timeval time_tv = {0}; |
| 555 | struct timezone time_tz = {0, 0}; |
| 556 | |
| 557 | ret = parse_param("%32s", at_paras, p); |
| 558 | if (ret != AT_PARSE_OK) |
| 559 | { |
| 560 | sprintf(at_str, "\r\nERROR: 980\r\n"); |
| 561 | *res_msg = at_str; |
| 562 | return AT_END; |
| 563 | } |
| 564 | sscanf(settime, "%2d/%2d/%2d,%2d:%2d:%2d", &set_tm.tm_year, |
| 565 | &set_tm.tm_mon, &set_tm.tm_mday, &set_tm.tm_hour, &set_tm.tm_min, &set_tm.tm_sec); |
| 566 | at_print(1, "ext_time_set_func: %2d/%2d/%2d,%2d:%2d:%2d\n", set_tm.tm_year, |
| 567 | set_tm.tm_mon, set_tm.tm_mday, set_tm.tm_hour, set_tm.tm_min, set_tm.tm_sec); |
lh | 9ed821d | 2023-04-07 01:36:19 -0700 | [diff] [blame] | 568 | |
| 569 | #if 1 // kw 3 |
xf.li | 9d1a0e1 | 2023-09-20 01:43:20 -0700 | [diff] [blame] | 570 | if (set_tm.tm_year < 0 || set_tm.tm_year > 5000) |
lh | 9ed821d | 2023-04-07 01:36:19 -0700 | [diff] [blame] | 571 | { |
| 572 | set_tm.tm_year = 1970; |
| 573 | } |
| 574 | |
xf.li | 9d1a0e1 | 2023-09-20 01:43:20 -0700 | [diff] [blame] | 575 | if (set_tm.tm_mon < 0 || set_tm.tm_mon > 13) |
lh | 9ed821d | 2023-04-07 01:36:19 -0700 | [diff] [blame] | 576 | { |
| 577 | set_tm.tm_mon = 1; |
| 578 | } |
| 579 | #endif |
xf.li | 9d1a0e1 | 2023-09-20 01:43:20 -0700 | [diff] [blame] | 580 | set_tm.tm_year = set_tm.tm_year + 100; |
| 581 | set_tm.tm_mon = set_tm.tm_mon - 1; |
lh | 9ed821d | 2023-04-07 01:36:19 -0700 | [diff] [blame] | 582 | |
xf.li | 9d1a0e1 | 2023-09-20 01:43:20 -0700 | [diff] [blame] | 583 | time_tv.tv_sec = mktime(&set_tm); |
| 584 | if (time_tv.tv_sec < 0) // cov M |
lh | 9ed821d | 2023-04-07 01:36:19 -0700 | [diff] [blame] | 585 | { |
| 586 | time_tv.tv_sec = 0; |
| 587 | } |
xf.li | 9d1a0e1 | 2023-09-20 01:43:20 -0700 | [diff] [blame] | 588 | |
| 589 | // time_tv.tv_sec = time_tv.tv_sec; // cov M |
| 590 | struct tm * new_time = gmtime(&time_tv.tv_sec); |
| 591 | if (new_time) |
| 592 | { |
| 593 | time_tz.tz_minuteswest = (mktime(new_time) - (time_tv.tv_sec)) / 60; |
| 594 | } |
| 595 | |
| 596 | if (0 != settimeofday(&time_tv, &time_tz)) |
| 597 | { |
| 598 | at_print(AT_ERR, "zmmi_auto_act,set time of system wrong"); |
| 599 | sprintf(at_str, "\r\nERROR: 981\r\n"); |
| 600 | *res_msg = at_str; |
| 601 | return AT_END; |
| 602 | } |
| 603 | rtc_set_time(MODULE_ID_AT_CTL); |
| 604 | sprintf(at_str, "\r\nOK\r\n"); |
| 605 | *res_msg = at_str; |
| 606 | return AT_END; |
lh | 9ed821d | 2023-04-07 01:36:19 -0700 | [diff] [blame] | 607 | } |
| 608 | |
| 609 | int ext_time_query_func(char *at_paras, void ** res_msg) |
xf.li | 9d1a0e1 | 2023-09-20 01:43:20 -0700 | [diff] [blame] | 610 | { |
| 611 | struct tm *p; |
| 612 | time_t timep; |
| 613 | char buf[32] = {0}; |
| 614 | char *at_str = NULL; |
| 615 | at_str = malloc(64); |
| 616 | assert(at_str); |
| 617 | memset(at_str, 0, 64); |
| 618 | time(&timep); |
| 619 | p = localtime(&timep); |
| 620 | assert(p); |
| 621 | snprintf(buf, 32, "%02d/%02d/%02d,%02d:%02d:%02d", (1900 + p->tm_year) % 100, 1 + p->tm_mon, p->tm_mday, p->tm_hour, |
| 622 | p->tm_min, p->tm_sec); |
| 623 | at_print(1, "ext_time_query_func: time: %s\n", buf); |
| 624 | sprintf(at_str, "\r\n+CCLK: \"%s\"\r\nOK\r\n", buf); |
| 625 | *res_msg = at_str; |
| 626 | return AT_END; |
lh | 9ed821d | 2023-04-07 01:36:19 -0700 | [diff] [blame] | 627 | } |
| 628 | |
xf.li | 9d1a0e1 | 2023-09-20 01:43:20 -0700 | [diff] [blame] | 629 | #ifdef USE_CAP_SUPPORT |
| 630 | int ext_nitz_query_func(char *at_paras, void ** res_msg) |
| 631 | { |
| 632 | struct tm *p = 0; |
| 633 | time_t timep; |
| 634 | char buf[32] = {0}; |
| 635 | char time_zone[16] = {0}; |
| 636 | char sav_time[16] = {0}; |
| 637 | char nitz_valid[16] = {0}; |
| 638 | char *at_str = NULL; |
| 639 | |
| 640 | sc_cfg_get("nitz_time_zone", time_zone, sizeof(time_zone) - 1); |
| 641 | sc_cfg_get("nitz_sav_time", sav_time, sizeof(sav_time) - 1); |
| 642 | |
| 643 | at_str = malloc(64); |
| 644 | assert(at_str); |
| 645 | memset(at_str, 0, 64); |
| 646 | |
| 647 | sc_cfg_get("nitz_is_valid", nitz_valid, sizeof(nitz_valid) - 1); |
| 648 | if (1 != atoi(nitz_valid)) |
| 649 | { |
| 650 | sprintf(at_str, "\r\n+ZNITZ: 0,0,\"\"\r\nOK\r\n"); |
| 651 | *res_msg = at_str; |
| 652 | return AT_END; |
| 653 | } |
| 654 | |
| 655 | time(&timep); |
| 656 | p = gmtime(&timep); |
| 657 | assert(p); |
| 658 | snprintf(buf, 32, "%02d/%02d/%02d,%02d:%02d:%02d", (1900 + p->tm_year) % 100, 1 + p->tm_mon, p->tm_mday, p->tm_hour, |
| 659 | p->tm_min, p->tm_sec); |
| 660 | |
| 661 | at_print(1, "ext_nitz_query_func: time: %s\n", buf); |
| 662 | |
| 663 | sprintf(at_str, "\r\n+ZNITZ: %s,%s,\"%s\"\r\nOK\r\n", time_zone, sav_time, buf); |
| 664 | |
| 665 | *res_msg = at_str; |
| 666 | |
| 667 | return AT_END; |
| 668 | } |
| 669 | #endif |
| 670 | |
lh | 9ed821d | 2023-04-07 01:36:19 -0700 | [diff] [blame] | 671 | int ext_user_modem_regist(void) |
| 672 | { |
xf.li | 9d1a0e1 | 2023-09-20 01:43:20 -0700 | [diff] [blame] | 673 | //#ifdef GUODIAN |
| 674 | if (g_customer_type == CUSTOMER_GUODIAN) |
| 675 | { |
| 676 | //PDP¼¤»î |
| 677 | register_serv_func2("MYNETCON=", MODULE_ID_SOCKET_PROXY, MSG_CMD_NETCON_REQ, MSG_CMD_NETCON_RSP, ext_netcon_req, |
| 678 | ext_netcon_rsp); |
| 679 | register_serv_func2("MYNETACT=", MODULE_ID_SOCKET_PROXY, MSG_CMD_NETACT_REQ, MSG_CMD_NETACT_RSP, ext_netact_req, |
| 680 | ext_netact_rsp); |
| 681 | register_serv_func2("MYPOWEROFF", MODULE_ID_MAIN_CTRL, MSG_CMD_POWEROFF_REQUEST, MSG_CMD_POWEROFF_RSP, ext_poweroff_req, |
| 682 | ext_poweroff_rsp); |
lh | 9ed821d | 2023-04-07 01:36:19 -0700 | [diff] [blame] | 683 | |
xf.li | 9d1a0e1 | 2023-09-20 01:43:20 -0700 | [diff] [blame] | 684 | register_serv_func2("MYGMR", 0, 0, 0, ext_gmr_act_func, NULL); |
| 685 | register_serv_func2("MYCCID", 0, 0, 0, ext_ccid_act_func, NULL); |
| 686 | register_serv_func2("ATI", 0, 0, 0, ext_i_act_func, NULL); |
lh | 9ed821d | 2023-04-07 01:36:19 -0700 | [diff] [blame] | 687 | |
xf.li | 9d1a0e1 | 2023-09-20 01:43:20 -0700 | [diff] [blame] | 688 | register_serv_func2("MYBCCH?", 0, 0, 0, ext_beeh_act_func, NULL); |
| 689 | register_serv_func2("MYBCCH=?", 0, 0, 0, ext_beeh_act_func, NULL); |
| 690 | register_serv_func2("MYBCCH=", 0, 0, 0, ext_beeh_act_func, NULL); |
lh | 9ed821d | 2023-04-07 01:36:19 -0700 | [diff] [blame] | 691 | |
xf.li | 9d1a0e1 | 2023-09-20 01:43:20 -0700 | [diff] [blame] | 692 | register_serv_func("MYBAND=", MODULE_ID_SOCKET_PROXY, ext_myband_set_func); |
| 693 | register_serv_func("MYBAND?", MODULE_ID_SOCKET_PROXY, ext_myband_query_func); |
lh | 9ed821d | 2023-04-07 01:36:19 -0700 | [diff] [blame] | 694 | |
xf.li | 9d1a0e1 | 2023-09-20 01:43:20 -0700 | [diff] [blame] | 695 | register_serv_func2("MYNETCON?", 0, 0, 0, ext_netcon_query_func, NULL); |
lh | 9ed821d | 2023-04-07 01:36:19 -0700 | [diff] [blame] | 696 | |
xf.li | 9d1a0e1 | 2023-09-20 01:43:20 -0700 | [diff] [blame] | 697 | register_serv_func("GMR", MODULE_ID_SOCKET_PROXY, ext_gmr_query_func); |
| 698 | register_serv_func2("GMR=?", 0, 0, 0, ext_gmr_func, NULL); |
| 699 | } |
| 700 | else if (g_customer_type == CUSTOMER_NANDIAN) |
| 701 | { |
| 702 | register_serv_func2("MYPOWEROFF", MODULE_ID_MAIN_CTRL, MSG_CMD_POWEROFF_REQUEST, MSG_CMD_POWEROFF_RSP, ext_poweroff_req, |
| 703 | ext_poweroff_rsp); |
| 704 | register_serv_func2("MYNETCON=", MODULE_ID_SOCKET_PROXY, MSG_CMD_NETCON_REQ, MSG_CMD_NETCON_RSP, ext_netcon_req, |
| 705 | ext_netcon_rsp); |
| 706 | register_serv_func2("MYNETCON?", 0, 0, 0, ext_netcon_query_func, NULL); |
| 707 | register_serv_func2("MYNETACT=", MODULE_ID_SOCKET_PROXY, MSG_CMD_NETACT_REQ, MSG_CMD_NETACT_RSP, ext_netact_req, |
| 708 | ext_netact_rsp); |
lh | 9ed821d | 2023-04-07 01:36:19 -0700 | [diff] [blame] | 709 | |
xf.li | 9d1a0e1 | 2023-09-20 01:43:20 -0700 | [diff] [blame] | 710 | register_serv_func2("MYGMR", 0, 0, 0, ext_gmr_act_func, NULL); |
| 711 | register_serv_func2("MYCCID", 0, 0, 0, ext_ccid_act_func, NULL); |
lh | 9ed821d | 2023-04-07 01:36:19 -0700 | [diff] [blame] | 712 | |
xf.li | 9d1a0e1 | 2023-09-20 01:43:20 -0700 | [diff] [blame] | 713 | register_serv_func2("ATI", 0, 0, 0, ext_i_act_func, NULL); |
| 714 | register_serv_func("GMR", MODULE_ID_SOCKET_PROXY, ext_gmr_query_func); |
| 715 | register_serv_func2("GMR=?", 0, 0, 0, ext_gmr_func, NULL); |
lh | 9ed821d | 2023-04-07 01:36:19 -0700 | [diff] [blame] | 716 | |
xf.li | 9d1a0e1 | 2023-09-20 01:43:20 -0700 | [diff] [blame] | 717 | register_serv_func("MYURCSYSINFO=", 0, ext_urcsysinfo_act_func); |
| 718 | register_serv_func("MYSYSINFO", MODULE_ID_SOCKET_PROXY, ext_mysysinfo_query_func); |
| 719 | register_serv_func("MYNETINFO=", MODULE_ID_SOCKET_PROXY, ext_mynetinfo_set_func); |
| 720 | register_serv_func("MYNETINFO?", MODULE_ID_SOCKET_PROXY, ext_mynetinfo_query_func); |
lh | 9ed821d | 2023-04-07 01:36:19 -0700 | [diff] [blame] | 721 | |
xf.li | 9d1a0e1 | 2023-09-20 01:43:20 -0700 | [diff] [blame] | 722 | register_inform_func("CEREG", cereg_inform_act); |
| 723 | register_inform_func("CGREG", cgreg_inform_act); |
| 724 | register_inform_func("CREG", creg_inform_act); |
| 725 | register_inform_func("MODE", mode_inform_act); |
| 726 | } |
| 727 | register_serv_func("CCLK=", 0, ext_time_set_func); |
| 728 | register_serv_func("CCLK?", 0, ext_time_query_func); |
| 729 | |
| 730 | #ifdef USE_CAP_SUPPORT |
| 731 | register_serv_func("ZNITZ?", 0, ext_nitz_query_func); |
| 732 | #endif |
| 733 | return 0; |
lh | 9ed821d | 2023-04-07 01:36:19 -0700 | [diff] [blame] | 734 | } |
| 735 | |
| 736 | #endif |