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