[Bugfix][TAT-27][AT]AT+LGMDS/AT+LRNDISHANDLE
Change-Id: I2d0c623dd829a3ae75093c75f26861a4540c51c8
diff --git a/lib/liblynq-at-common/lynq_at_common.cpp b/lib/liblynq-at-common/lynq_at_common.cpp
index 5f5afbb..ce8476a 100755
--- a/lib/liblynq-at-common/lynq_at_common.cpp
+++ b/lib/liblynq-at-common/lynq_at_common.cpp
@@ -40,31 +40,6 @@
handle_output(str, strlen(str), Response);
}
-static int lynq_catrndis_mode(void)
-{
- FILE *fp;
- char buf[2];
- fp = popen("cat /data/rndis.conf","r");
- fgets(buf,sizeof(buf),fp);
- if(buf != NULL)
- {
- if(buf[0] == '0')
- {
- return 0;
- }
- if(buf[0] == '1')
- {
- return 1;
- }
- else
- {
- return 2;//not config
- }
- }
- pclose(fp);
- return;
-}
-
static void lynq_get_poepn_buf(char *cmd)
{
FILE *fp;
@@ -254,11 +229,115 @@
return;
}
+void lynq_display_modem_mode(const char *cmd)
+{
+ FILE *fp;
+ char buf[128] = {0};
+ fp = popen(cmd,"r");
+ while(fgets(buf, sizeof(buf), fp) != NULL){}
+ pclose(fp);
+ RLOGD("buf is %s size %d\n", buf, sizeof(buf));
+ char tmp[16] = {0};
+ sprintf(tmp, "+LGMDS: %c", buf[4]);
+ handle_output(tmp, strlen(tmp), Response);
+ return;
+}
+
+void lynq_handle_modem_status(char *input,int type)
+{
+ RLOGD("lynq_handle_modem_status type %d\n", type);
+ if(type == AT_ACTIVE_MODE)//active
+ {
+ lynq_display_modem_mode("cat /sys/kernel/ccci/boot");
+ lynq_response_ok();
+ }
+ return;
+}
+
+void lynq_tmp_handle_rndis(char *input,int type)
+{
+ RLOGD("lynq_tmp_handle_rndis type %d\n", type);
+ char *connman_cmd1 = NULL;
+ char *connman_cmd2 = NULL;
+ if(type == AT_SET_MODE)//set
+ {
+ if (SYS_FAIL == atci_at_to_equal(&input))
+ {
+ lynq_response_error();
+ return ;
+ }
+ if (SYS_FAIL == atci_at_get_next_key(&input, &connman_cmd1))
+ {
+ lynq_response_error();
+ return ;
+ }
+ if (SYS_FAIL == atci_at_get_next_key(&input, &connman_cmd2))
+ {
+ //lynq_response_error();
+ //return SYS_FAIL;
+ }
+ if((connman_cmd1 != NULL) && (connman_cmd2 != NULL))
+ {
+ if(!strcmp(connman_cmd1, "connmanctl enable gadget"))
+ {
+ system("connmanctl enable gadget");
+ }
+ else
+ {
+ lynq_response_error();
+ return;
+ }
+ if(!strcmp(connman_cmd2, "connmanctl tether gadget on"))
+ {
+ system("connmanctl tether gadget on");
+ }
+ else
+ {
+ lynq_response_error();
+ return;
+ }
+ lynq_response_ok();
+ }
+ if(connman_cmd2 == NULL)
+ {
+ if(!strcmp(connman_cmd1, "connmanctl disable gadget"))
+ {
+ system("connmanctl disable gadget");
+ }
+ else
+ {
+ lynq_response_error();
+ return;
+ }
+ lynq_response_ok();
+ }
+ }
+ // else if(type == AT_TEST_MODE)//list
+ // {
+ // sprintf(buf,"+MNETCALL:(0-1)");
+ // handle_output(buf, strlen(buf), Response);
+ // lynq_response_ok();
+ // }
+ // else if(type == AT_READ_MODE)//get
+ // {
+ // sprintf(buf,"+MNETCALL:%d", g_mnetcall_mode);
+ // handle_output(buf, strlen(buf), Response);
+ // lynq_response_ok();
+ // }
+ else
+ {
+ lynq_response_error();
+ }
+ return;
+}
+
static Command commands[] =
{
{"at+mnetcall",lynq_handle_rndis},
{"at+gtarndis",lynq_handle_rndis_configure},
{"at+cgir",lynq_handle_version},
+{"at+lgmds",lynq_handle_modem_status},
+{"at+lrndishandle",lynq_tmp_handle_rndis},//tmp plan
{NULL, NULL}
};
@@ -291,7 +370,7 @@
prefix = atci_get_cmd_prefix(input);
if (NULL == prefix) {
RLOGD("atci_cut_cmd_prefix error");
- return SYS_FAIL;
+ return;
}
RLOGD("find prefix [%s]", prefix);
Command *cmd = find_command(prefix);