blob: 782ed7d65d172c33c34f2cdd0701c36332657fe0 [file] [log] [blame]
lh9ed821d2023-04-07 01:36:19 -07001#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
7int netcon_extcid = -1;
8char netcon_configname[10] = {0};
9int netcon_value_int = 0;
10char netcon_value_char[70] = {0};
11extern char* normal_getzversion();
12int urcsysinfo = 0;
xf.li9d1a0e12023-09-20 01:43:20 -070013typedef struct
14{
15 int mode;
16 int creg;
17 int cgreg;
18 int cereg;
lh9ed821d2023-04-07 01:36:19 -070019} EXT_NETSTATE_INFO;
20EXT_NETSTATE_INFO urcinfo = {0};
21//========================================================================================================//
22//¹úµçsocket·½°¸º¯ÊýʵÏÖÇø
23//========================================================================================================//
24static int gsmband = 0;
25
26static void comm_rspmsg_proc(void *rsp_msg, void**ret, int *retlen)
27{
xf.li9d1a0e12023-09-20 01:43:20 -070028 AT_COMM_RSPMSG *msg = (AT_COMM_RSPMSG*)rsp_msg;
29 char *at_str = NULL;
30 int offset = 0;
lh9ed821d2023-04-07 01:36:19 -070031
xf.li9d1a0e12023-09-20 01:43:20 -070032 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 }
lh9ed821d2023-04-07 01:36:19 -070065
xf.li9d1a0e12023-09-20 01:43:20 -070066 *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);
lh9ed821d2023-04-07 01:36:19 -070074
75}
76
77
78int ext_netcon_req(int at_fd, char *at_paras, void ** res_msg, int *res_msglen)
79{
xf.li9d1a0e12023-09-20 01:43:20 -070080 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;
lh9ed821d2023-04-07 01:36:19 -070086
xf.li9d1a0e12023-09-20 01:43:20 -070087 //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;
lh9ed821d2023-04-07 01:36:19 -070093
xf.li9d1a0e12023-09-20 01:43:20 -070094 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, "\"");
lh9ed821d2023-04-07 01:36:19 -0700105
xf.li9d1a0e12023-09-20 01:43:20 -0700106 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;
lh9ed821d2023-04-07 01:36:19 -0700117 }
xf.li9d1a0e12023-09-20 01:43:20 -0700118 r_quota = strstr(l_quota + 1, "\"");
119 if (r_quota == NULL)
120 {
121 goto error;
lh9ed821d2023-04-07 01:36:19 -0700122 }
xf.li9d1a0e12023-09-20 01:43:20 -0700123 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;
lh9ed821d2023-04-07 01:36:19 -0700133 }
xf.li9d1a0e12023-09-20 01:43:20 -0700134 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);
lh9ed821d2023-04-07 01:36:19 -0700151
xf.li9d1a0e12023-09-20 01:43:20 -0700152 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;
lh9ed821d2023-04-07 01:36:19 -0700209error:
210 free(reqmsg);
xf.li9d1a0e12023-09-20 01:43:20 -0700211 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;
lh9ed821d2023-04-07 01:36:19 -0700218}
219int ext_netcon_rsp(void *rsp_msg, void**ret, int *retlen)
220{
xf.li9d1a0e12023-09-20 01:43:20 -0700221 comm_rspmsg_proc(rsp_msg, ret, retlen);
222 return AT_END;
lh9ed821d2023-04-07 01:36:19 -0700223}
224
225int ext_netact_req(int at_fd, char *at_paras, void ** res_msg, int *res_msglen)
226{
xf.li9d1a0e12023-09-20 01:43:20 -0700227 struct netact_reqmsg *reqmsg = malloc(sizeof(struct netact_reqmsg));
228 assert(reqmsg);
229 char *p[2] = {&reqmsg->extcid, &reqmsg->act_type};
lh9ed821d2023-04-07 01:36:19 -0700230 char *at_str = NULL;
xf.li9d1a0e12023-09-20 01:43:20 -0700231 memset(reqmsg, 0x00, sizeof(struct comm_reqmsg));
232 if (2 != parse_param2("%d,%d", at_paras, p))
233 {
lh9ed821d2023-04-07 01:36:19 -0700234 free(reqmsg);
xf.li9d1a0e12023-09-20 01:43:20 -0700235 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 }
lh9ed821d2023-04-07 01:36:19 -0700243
xf.li9d1a0e12023-09-20 01:43:20 -0700244 *res_msg = reqmsg;
245 *res_msglen = sizeof(struct netact_reqmsg);
246 return AT_CONTINUE;
lh9ed821d2023-04-07 01:36:19 -0700247}
248int ext_netact_rsp(void *rsp_msg, void**ret, int *retlen)
249{
xf.li9d1a0e12023-09-20 01:43:20 -0700250 comm_rspmsg_proc(rsp_msg, ret, retlen);
lh9ed821d2023-04-07 01:36:19 -0700251
xf.li9d1a0e12023-09-20 01:43:20 -0700252 return AT_END;
lh9ed821d2023-04-07 01:36:19 -0700253}
254
255/*Èí¹Ø»ú*/
256int ext_poweroff_req(int at_fd, char * at_paras, void **res_msg, int * res_msglen)
257{
xf.li9d1a0e12023-09-20 01:43:20 -0700258 return AT_CONTINUE;
lh9ed821d2023-04-07 01:36:19 -0700259}
260
261
262
263int ext_i_act_func(int at_fd, char * at_paras, void * *res_msg, int * res_msglen)
264{
xf.li9d1a0e12023-09-20 01:43:20 -0700265 char *at_str = NULL;
lh9ed821d2023-04-07 01:36:19 -0700266
xf.li9d1a0e12023-09-20 01:43:20 -0700267 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");
lh9ed821d2023-04-07 01:36:19 -0700271
xf.li9d1a0e12023-09-20 01:43:20 -0700272 *res_msg = at_str;
273 *res_msglen = strlen(*res_msg);
274 return AT_END;
lh9ed821d2023-04-07 01:36:19 -0700275}
276int ext_myband_set_func(char *at_paras, void ** res_msg)
277{
xf.li9d1a0e12023-09-20 01:43:20 -0700278 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;
lh9ed821d2023-04-07 01:36:19 -0700284}
285
286int ext_myband_query_func(char *at_paras, void ** res_msg)
287{
xf.li9d1a0e12023-09-20 01:43:20 -0700288 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;
lh9ed821d2023-04-07 01:36:19 -0700293}
294
295int ext_beeh_act_func(int at_fd, char * at_paras, void * *res_msg, int * res_msglen)
296{
xf.li9d1a0e12023-09-20 01:43:20 -0700297 *res_msg = at_ok_build();
298 *res_msglen = strlen(*res_msg);
299 return AT_END;
lh9ed821d2023-04-07 01:36:19 -0700300}
301
302int ext_poweroff_rsp(void *rsp_msg, void**ret, int *retlen)
303{
xf.li9d1a0e12023-09-20 01:43:20 -0700304 char *at_str = NULL;
lh9ed821d2023-04-07 01:36:19 -0700305
xf.li9d1a0e12023-09-20 01:43:20 -0700306 at_str = at_ok_build();
lh9ed821d2023-04-07 01:36:19 -0700307
xf.li9d1a0e12023-09-20 01:43:20 -0700308 *ret = at_str;
309 *retlen = strlen(at_str);
lh9ed821d2023-04-07 01:36:19 -0700310
xf.li9d1a0e12023-09-20 01:43:20 -0700311 return AT_END;
lh9ed821d2023-04-07 01:36:19 -0700312}
313
314/*¶ÁÈí¼þÍⲿ°æ±¾ºÅ*/
315int ext_gmr_act_func(int at_fd, char * at_paras, void * *res_msg, int * res_msglen)
316{
xf.li9d1a0e12023-09-20 01:43:20 -0700317 char hwver[32] = {0};
318 char swver[32] = {0};
319 char *at_str = NULL;
lh9ed821d2023-04-07 01:36:19 -0700320
xf.li9d1a0e12023-09-20 01:43:20 -0700321 //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;
lh9ed821d2023-04-07 01:36:19 -0700331}
332/*»ñÈ¡SIM¿¨ÐòÁкÅ*/
333int ext_ccid_act_func(int at_fd, char * at_paras, void * *res_msg, int * res_msglen)
334{
xf.li9d1a0e12023-09-20 01:43:20 -0700335 char iccid[32] = {0};
336 char *at_str = NULL;
lh9ed821d2023-04-07 01:36:19 -0700337
xf.li9d1a0e12023-09-20 01:43:20 -0700338 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;
lh9ed821d2023-04-07 01:36:19 -0700347}
348int ext_netcon_query_func(int at_fd, char *at_paras, void ** res_msg, int *res_msglen)
349{
xf.li9d1a0e12023-09-20 01:43:20 -0700350 char *at_str = NULL;
351 int offset = 0;
lh9ed821d2023-04-07 01:36:19 -0700352
xf.li9d1a0e12023-09-20 01:43:20 -0700353 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 }
lh9ed821d2023-04-07 01:36:19 -0700376
xf.li9d1a0e12023-09-20 01:43:20 -0700377 *res_msg = at_str;
378 *res_msglen = strlen(*res_msg);
379 return AT_END;
lh9ed821d2023-04-07 01:36:19 -0700380
381}
382
383int ext_gmr_query_func(char *at_paras, void ** res_msg)
384{
xf.li9d1a0e12023-09-20 01:43:20 -0700385 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;
lh9ed821d2023-04-07 01:36:19 -0700390}
391int ext_gmr_func(int at_fd, char * at_paras, void * *res_msg, int * res_msglen)
392{
xf.li9d1a0e12023-09-20 01:43:20 -0700393 *res_msg = at_ok_build();
394 *res_msglen = strlen(*res_msg);
395 return AT_END;
lh9ed821d2023-04-07 01:36:19 -0700396}
397
398int ext_mysysinfo_query_func(char *at_paras, void ** res_msg)
399{
xf.li9d1a0e12023-09-20 01:43:20 -0700400 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;
lh9ed821d2023-04-07 01:36:19 -0700405}
406
407int ext_mynetinfo_set_func(char *at_paras, void ** res_msg)
408{
xf.li9d1a0e12023-09-20 01:43:20 -0700409 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;
lh9ed821d2023-04-07 01:36:19 -0700415}
416
417int ext_mynetinfo_query_func(char *at_paras, void ** res_msg)
418{
xf.li9d1a0e12023-09-20 01:43:20 -0700419 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;
lh9ed821d2023-04-07 01:36:19 -0700424}
425
426int ext_urcsysinfo_act_func(char *at_paras, void ** res_msg)
427{
xf.li9d1a0e12023-09-20 01:43:20 -0700428 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;
lh9ed821d2023-04-07 01:36:19 -0700446}
447
448int mode_inform_act(char *at_paras, int is_query_report)
449{
xf.li9d1a0e12023-09-20 01:43:20 -0700450 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;
lh9ed821d2023-04-07 01:36:19 -0700467}
468
469int net_state_transfer(int state)
470{
xf.li9d1a0e12023-09-20 01:43:20 -0700471 if ((state == 1) || (state == 5))
472 {
473 return 1;
474 }
475 else
476 {
477 return 0;
478 }
lh9ed821d2023-04-07 01:36:19 -0700479}
480int creg_inform_act(char *at_paras, int is_query_report)
481{
xf.li9d1a0e12023-09-20 01:43:20 -0700482 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;
lh9ed821d2023-04-07 01:36:19 -0700500}
501int cgreg_inform_act(char *at_paras, int is_query_report)
502{
xf.li9d1a0e12023-09-20 01:43:20 -0700503 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;
lh9ed821d2023-04-07 01:36:19 -0700521}
522int cereg_inform_act(char *at_paras, int is_query_report)
523{
xf.li9d1a0e12023-09-20 01:43:20 -0700524 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;
lh9ed821d2023-04-07 01:36:19 -0700542}
543
544int ext_time_set_func(char *at_paras, void ** res_msg)
xf.li9d1a0e12023-09-20 01:43:20 -0700545{
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);
lh9ed821d2023-04-07 01:36:19 -0700568
569#if 1 // kw 3
xf.li9d1a0e12023-09-20 01:43:20 -0700570 if (set_tm.tm_year < 0 || set_tm.tm_year > 5000)
lh9ed821d2023-04-07 01:36:19 -0700571 {
572 set_tm.tm_year = 1970;
573 }
574
xf.li9d1a0e12023-09-20 01:43:20 -0700575 if (set_tm.tm_mon < 0 || set_tm.tm_mon > 13)
lh9ed821d2023-04-07 01:36:19 -0700576 {
577 set_tm.tm_mon = 1;
578 }
579#endif
xf.li9d1a0e12023-09-20 01:43:20 -0700580 set_tm.tm_year = set_tm.tm_year + 100;
581 set_tm.tm_mon = set_tm.tm_mon - 1;
lh9ed821d2023-04-07 01:36:19 -0700582
xf.li9d1a0e12023-09-20 01:43:20 -0700583 time_tv.tv_sec = mktime(&set_tm);
584 if (time_tv.tv_sec < 0) // cov M
lh9ed821d2023-04-07 01:36:19 -0700585 {
586 time_tv.tv_sec = 0;
587 }
xf.li9d1a0e12023-09-20 01:43:20 -0700588
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;
lh9ed821d2023-04-07 01:36:19 -0700607}
608
609int ext_time_query_func(char *at_paras, void ** res_msg)
xf.li9d1a0e12023-09-20 01:43:20 -0700610{
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;
lh9ed821d2023-04-07 01:36:19 -0700627}
628
xf.li9d1a0e12023-09-20 01:43:20 -0700629#ifdef USE_CAP_SUPPORT
630int 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
lh9ed821d2023-04-07 01:36:19 -0700671int ext_user_modem_regist(void)
672{
xf.li9d1a0e12023-09-20 01:43:20 -0700673 //#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);
lh9ed821d2023-04-07 01:36:19 -0700683
xf.li9d1a0e12023-09-20 01:43:20 -0700684 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);
lh9ed821d2023-04-07 01:36:19 -0700687
xf.li9d1a0e12023-09-20 01:43:20 -0700688 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);
lh9ed821d2023-04-07 01:36:19 -0700691
xf.li9d1a0e12023-09-20 01:43:20 -0700692 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);
lh9ed821d2023-04-07 01:36:19 -0700694
xf.li9d1a0e12023-09-20 01:43:20 -0700695 register_serv_func2("MYNETCON?", 0, 0, 0, ext_netcon_query_func, NULL);
lh9ed821d2023-04-07 01:36:19 -0700696
xf.li9d1a0e12023-09-20 01:43:20 -0700697 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);
lh9ed821d2023-04-07 01:36:19 -0700709
xf.li9d1a0e12023-09-20 01:43:20 -0700710 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);
lh9ed821d2023-04-07 01:36:19 -0700712
xf.li9d1a0e12023-09-20 01:43:20 -0700713 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);
lh9ed821d2023-04-07 01:36:19 -0700716
xf.li9d1a0e12023-09-20 01:43:20 -0700717 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);
lh9ed821d2023-04-07 01:36:19 -0700721
xf.li9d1a0e12023-09-20 01:43:20 -0700722 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;
lh9ed821d2023-04-07 01:36:19 -0700734}
735
736#endif