上库irq模块和dtmf和ims的api接口

Change-Id: I6dfbdb0b8ed0dd6543474d3fc10eef91ca1a2f2f
diff --git a/mbtk/mbtk_rild/src/mbtk_info_server.c b/mbtk/mbtk_rild/src/mbtk_info_server.c
index 5345fa9..4c8c6ee 100755
--- a/mbtk/mbtk_rild/src/mbtk_info_server.c
+++ b/mbtk/mbtk_rild/src/mbtk_info_server.c
@@ -2926,6 +2926,72 @@
     return err;
 }
 
+
+static int net_ims_set(uint8 reg, int *cme_err)
+{
+    ATResponse *response = NULL;
+    char cmd[30] = {0};
+    int err = -1;
+
+    sprintf(cmd, "AT+CIREG=%d", reg);
+    err = at_send_command(cmd, &response);
+    LOG("cmd : %s", cmd);
+
+    if (err < 0 || response->success == 0){
+        *cme_err = at_get_cme_error(response);
+        goto exit;
+    }
+
+exit:
+    at_response_free(response);
+    return err;
+}
+
+
+static int net_ims_get(int *reg, int *cme_err)
+{
+    ATResponse *response = NULL;
+    int tmp_int, tmp_reg;
+    int err;
+    char *tmp_str = NULL;
+
+    err = at_send_command_multiline("AT+CIREG?", "+CIREG:", &response);
+    if (err < 0 || response->success == 0 || !response->p_intermediates){
+        tmp_reg = 0;
+        err = 0;
+        goto exit;
+    }
+    char *line = response->p_intermediates->line;
+    err = at_tok_start(&line);
+    if (err < 0)
+    {
+        goto exit;
+    }
+    err = at_tok_nextint(&line, &tmp_int); // n/stat
+    if (err < 0)
+    {
+        goto exit;
+    }
+    if(at_tok_hasmore(&line)) {
+        err = at_tok_nextint(&line, &tmp_int);// stat
+        if (err < 0)
+        {
+            goto exit;
+        }
+        tmp_reg = tmp_int;
+    } else {
+        tmp_reg = tmp_int;
+    }
+
+    LOG("net_ims_get reg : %u", tmp_reg);
+
+exit:
+    at_response_free(response);
+    *reg = tmp_reg;
+    return err;
+}
+
+
 /*
 AT+CGDCONT?
 +CGDCONT: 1,"IPV4V6","cmnet.MNC000.MCC460.GPRS","10.131.67.146 254.128.0.0.0.0.0.0.0.1.0.2.200.2.158.0",0,0,,,,
@@ -5246,6 +5312,46 @@
                 }
                 break;
             }
+            case MBTK_INFO_ID_NET_IMS_REQ:
+            {
+                if(pack->data_len == 0 || pack->data == NULL) //Get
+                {
+                    int reg = -1;
+                    if(net_ims_get(&reg, &cme_err) || cme_err != MBTK_INFO_ERR_CME_NON)
+                    {
+                        if(cme_err != MBTK_INFO_ERR_CME_NON) {
+                            err = MBTK_INFO_ERR_CME + cme_err;
+                        } else {
+                            err = MBTK_INFO_ERR_UNKNOWN;
+                        }
+                        LOG("Get net ims fail.");
+                    }
+                    else
+                    {
+                        uint8 reg_type = (uint8)reg;
+                        pack_rsp_send(cli_info->fd, MBTK_INFO_ID_NET_IMS_RSP, &reg_type, sizeof(uint8));
+                    }
+                }
+                else
+                {
+                    uint8 ims = *(pack->data);
+
+                    if(net_ims_set(ims, &cme_err) || cme_err != MBTK_INFO_ERR_CME_NON)
+                    {
+                        if(cme_err != MBTK_INFO_ERR_CME_NON) {
+                            err = MBTK_INFO_ERR_CME + cme_err;
+                        } else {
+                            err = MBTK_INFO_ERR_UNKNOWN;
+                        }
+                        LOG("Set net ims fail.");
+                    }
+                    else
+                    {
+                        pack_rsp_send(cli_info->fd, MBTK_INFO_ID_NET_IMS_RSP, NULL, 0);
+                    }
+                }
+                break;
+            }
             case MBTK_INFO_ID_WAKEUP_STA_REQ:
             {
                 if(pack->data_len == 0 || pack->data == NULL)