add new api for mbtk,get modem version
Change-Id: I8cebf6552ee47eef2c8d2e980a0d6436c9a55ef8
diff --git a/mbtk/include/mbtk/mbtk_info_api.h b/mbtk/include/mbtk/mbtk_info_api.h
index 2983371..8a90395 100755
--- a/mbtk/include/mbtk/mbtk_info_api.h
+++ b/mbtk/include/mbtk/mbtk_info_api.h
@@ -1055,4 +1055,6 @@
int mbtk_sms_cnmi_set(mbtk_info_handle_t* handle);
+int mbtk_get_modem_version(mbtk_info_handle_t* handle, void *modem_version);
+
#endif /* _MBTK_INFO_API_H */
diff --git a/mbtk/libmbtk_lib/ril/mbtk_info.c b/mbtk/libmbtk_lib/ril/mbtk_info.c
index b61a3b0..58358ca 100755
--- a/mbtk/libmbtk_lib/ril/mbtk_info.c
+++ b/mbtk/libmbtk_lib/ril/mbtk_info.c
@@ -213,6 +213,9 @@
case MBTK_INFO_ID_DEV_VERSION_REQ:
case MBTK_INFO_ID_DEV_VERSION_RSP:
return "VERSION";
+ case MBTK_INFO_ID_DEV_MD_VERSION_REQ:
+ case MBTK_INFO_ID_DEV_MD_VERSION_RSP:
+ return "MD_VERSION";
case MBTK_INFO_ID_DEV_MODEL_REQ:
case MBTK_INFO_ID_DEV_MODEL_RSP:
return "MODEL";
diff --git a/mbtk/libmbtk_lib/ril/mbtk_info.h b/mbtk/libmbtk_lib/ril/mbtk_info.h
index d58c498..f1679f2 100755
--- a/mbtk/libmbtk_lib/ril/mbtk_info.h
+++ b/mbtk/libmbtk_lib/ril/mbtk_info.h
@@ -59,7 +59,10 @@
MBTK_INFO_ID_DEV_MODEM_REQ,
MBTK_INFO_ID_DEV_MODEM_RSP,
-
+
+ MBTK_INFO_ID_DEV_MD_VERSION_REQ,
+ MBTK_INFO_ID_DEV_MD_VERSION_RSP,
+
MBTK_INFO_ID_DEV_END,
// Sim Information
diff --git a/mbtk/libmbtk_lib/ril/mbtk_info_api.c b/mbtk/libmbtk_lib/ril/mbtk_info_api.c
index 99fb91f..1dc3464 100755
--- a/mbtk/libmbtk_lib/ril/mbtk_info_api.c
+++ b/mbtk/libmbtk_lib/ril/mbtk_info_api.c
@@ -17,11 +17,14 @@
#include "time.h"
+
+
#define EPOLL_LISTEN_MAX 100
#define EPOLL_LISTEN_MAX 100
static mbtk_info_callback_func ril_server_state_cb = NULL;
+
#if 0
struct
{
@@ -2629,3 +2632,19 @@
}
+int mbtk_get_modem_version(mbtk_info_handle_t* handle, void *modem_version)
+{
+ if(handle == NULL || modem_version == NULL)
+ {
+ LOGE("ARG error.");
+ return -1;
+ }
+
+ if(info_item_process(handle, MBTK_INFO_ID_DEV_MD_VERSION_REQ, NULL, 0, modem_version) > 0) {
+ LOG("Version : %s", modem_version);
+ return 0;
+ } else {
+ return handle->info_err;
+ }
+}
+
diff --git a/mbtk/mbtk_rild/src/mbtk_info_server.c b/mbtk/mbtk_rild/src/mbtk_info_server.c
index d582fb4..f09e33c 100755
--- a/mbtk/mbtk_rild/src/mbtk_info_server.c
+++ b/mbtk/mbtk_rild/src/mbtk_info_server.c
@@ -1202,6 +1202,61 @@
return err;
}
+
+static int req_md_version_get(void *data, int *cme_err)
+{
+ ATResponse *response = NULL;
+ int err = at_send_command_multiline("AT*CGMR", "", &response);
+
+ if (err < 0 || response->success == 0 || !response->p_intermediates)
+ {
+ *cme_err = at_get_cme_error(response);
+ goto exit;
+ }
+
+ ATLine* lines_ptr = response->p_intermediates;
+ char *line = NULL;
+ while(lines_ptr)
+ {
+ line = lines_ptr->line;
+ char *start = strstr(line, "FALCON_CP_SDK");
+ if(start)
+ {
+ char *end = strstr(start, "_Linux");
+ if(end)
+ {
+ end += strlen("_Linux");
+ int length = end - start;
+ if (length)
+ {
+ strncpy(data, start, length);
+ ((char*)data)[length] = '\0';
+ break;
+ }
+ else
+ {
+ err = -1;
+ goto exit;
+
+ }
+ }
+ else
+ {
+ err = -1;
+ goto exit;
+ }
+ }
+ lines_ptr = lines_ptr->p_next;
+ }
+
+ goto exit;
+exit:
+ at_response_free(response);
+ return err;
+}
+
+
+
/*
ATI
Manufacturer:"LYNQ"
@@ -4224,6 +4279,33 @@
}
break;
}
+ case MBTK_INFO_ID_DEV_MD_VERSION_REQ:
+ {
+ if(pack->data_len == 0 || pack->data == NULL) // Get VERSION
+ {
+ char version[50] = {0};
+ if(req_md_version_get(version, &cme_err) || strlen(version) == 0 || 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 Version fail.");
+ }
+ else
+ {
+ pack_rsp_send(cli_info->fd, MBTK_INFO_ID_DEV_MD_VERSION_RSP, version, strlen(version));
+ }
+ }
+ else // Set MD_VERSION(Unsupport).
+ {
+ err = MBTK_INFO_ERR_UNSUPPORTED;
+ LOG("Unsupport set MD_VERSION.");
+ }
+ break;
+
+ }
case MBTK_INFO_ID_DEV_MODEL_REQ: //MODEL
{
if(pack->data_len == 0 || pack->data == NULL) // Get MODEL