Fix SMS CMT for ril v2.
Change-Id: I95a289df6ab4d14dd23f3a7ebaa8183862d44de0
diff --git a/mbtk/include/mbtk/mbtk_ril_api.h b/mbtk/include/mbtk/mbtk_ril_api.h
old mode 100644
new mode 100755
index 23ba64e..8bf6848
--- a/mbtk/include/mbtk/mbtk_ril_api.h
+++ b/mbtk/include/mbtk/mbtk_ril_api.h
@@ -659,7 +659,8 @@
typedef struct
{
-
+ uint16 pdu_len;
+ uint8 pdu[1024];
} mbtk_ril_sms_state_info_t;
typedef enum
diff --git a/mbtk/libmbtk_lib/ril/inc/mbtk_ril.h b/mbtk/libmbtk_lib/ril/inc/mbtk_ril.h
old mode 100644
new mode 100755
index e7971b2..3631b67
--- a/mbtk/libmbtk_lib/ril/inc/mbtk_ril.h
+++ b/mbtk/libmbtk_lib/ril/inc/mbtk_ril.h
@@ -208,7 +208,7 @@
RIL_MSG_ID_IND_NET_REG_STATE_CHANGE,
// <uint8> State
RIL_MSG_ID_IND_CALL_STATE_CHANGE,
- // <uint8> State
+ // mbtk_ril_sms_state_info_t
RIL_MSG_ID_IND_SMS_STATE_CHANGE,
// mbtk_ril_radio_state_info_t
RIL_MSG_ID_IND_RADIO_STATE_CHANGE,
diff --git a/mbtk/libmbtk_lib/ril/v2/mbtk_ril_api.c b/mbtk/libmbtk_lib/ril/v2/mbtk_ril_api.c
index 9c14459..05f9def 100755
--- a/mbtk/libmbtk_lib/ril/v2/mbtk_ril_api.c
+++ b/mbtk/libmbtk_lib/ril/v2/mbtk_ril_api.c
@@ -19,7 +19,7 @@
typedef struct {
ATPortType_enum port;
- bool enable;
+// bool enable;
int open_count;
} ril_at_port_info_t;
@@ -444,7 +444,7 @@
return FALSE;
}
- return ril_cli.ports[port].port == port && ril_cli.ports[port].enable;
+ return ril_cli.ports[port].port == port && ril_cli.ports[port].open_count > 0;
}
mbtk_ril_handle* mbtk_ril_open(ATPortType_enum port)
@@ -462,7 +462,7 @@
return &(ril_cli.ports[port]);
} else {
ril_cli.ports[port].port = port;
- ril_cli.ports[port].enable = TRUE;
+ // ril_cli.ports[port].enable = TRUE;
ril_cli.ports[port].open_count++;
return &(ril_cli.ports[port]);
}
@@ -552,12 +552,12 @@
// Auto open default port.
ril_cli.ports[MBTK_AT_PORT_DEF].port = MBTK_AT_PORT_DEF;
- ril_cli.ports[MBTK_AT_PORT_DEF].enable = TRUE;
+ //ril_cli.ports[MBTK_AT_PORT_DEF].enable = TRUE;
ril_cli.ports[MBTK_AT_PORT_DEF].open_count++;
if(port != MBTK_AT_PORT_DEF) {
ril_cli.ports[port].port = port;
- ril_cli.ports[port].enable = TRUE;
+ //ril_cli.ports[port].enable = TRUE;
ril_cli.ports[port].open_count++;
return &(ril_cli.ports[port]);
} else {
@@ -597,14 +597,15 @@
}
LOGD("Will close port %d", port);
- ril_cli.ports[port].enable = FALSE;
+ // ril_cli.ports[port].enable = FALSE;
ril_cli.ports[port].port = ATPORTTYPE_NON;
ril_cli.ports[port].open_count = 0;
// All port is close ???
int i = ATPORTTYPE_0;
for(; i < ATPORTTYPE_NUM; i++) {
- if(ril_cli.ports[i].enable)
+ //if(ril_cli.ports[i].enable)
+ if(ril_cli.ports[i].open_count > 0)
break;
}
diff --git a/mbtk/mbtk_rild_v2/src/main.c b/mbtk/mbtk_rild_v2/src/main.c
index a17e3d7..438c748 100755
--- a/mbtk/mbtk_rild_v2/src/main.c
+++ b/mbtk/mbtk_rild_v2/src/main.c
@@ -78,6 +78,8 @@
ril_band_info_t band_info;
ril_info_t ril_info;
static mbtk_ril_call_state_info_t call_list[RIL_CALL_NUM_MAX];
+static bool cmt_found = FALSE;
+
extern mbtk_cell_pack_info_t cell_info;
extern ril_cgact_wait_t cgact_wait;
extern int ril_cid_start;
@@ -684,7 +686,29 @@
// 0891683108200855F6240D91688189911196F10000221130717445230331D90C
static void urc_sms_state_change_process(const char *s, const char *sms_pdu)
{
+ mbtk_ril_sms_state_info_t sms_info;
+ memset(&sms_info, 0, sizeof(mbtk_ril_sms_state_info_t));
+ char* tmp_s = memdup(s,strlen(s) + 1);
+ char *line = tmp_s;
+ char *tmp_str;
+ if (at_tok_start(&line) < 0)
+ {
+ goto CMT_EXIT;
+ }
+ if (at_tok_nextstr(&line, &tmp_str) < 0)
+ {
+ goto CMT_EXIT;
+ }
+ if (at_tok_nextstr(&line, &tmp_str) < 0)
+ {
+ goto CMT_EXIT;
+ }
+ sms_info.pdu_len = (uint16)atoi(tmp_str);
+ memcpy(sms_info.pdu, sms_pdu, strlen(sms_pdu));
+ urc_msg_distribute(false, RIL_MSG_ID_IND_SMS_STATE_CHANGE, &sms_info, sizeof(mbtk_ril_sms_state_info_t));
+CMT_EXIT:
+ free(tmp_s);
}
// +CREG: 1, "8010", "000060a5", 0, 2, 0
@@ -1697,8 +1721,13 @@
{
LOGV("URC : %s", s);
// MBTK_AT_READY
- if (strStartsWith(s, "MBTK_AT_READY")) // AT ready.
- {
+ // +CMT: ,23
+ // 0891683108200855F6240D91688189911196F10000221130717445230331D90C
+ // Get PDU data.
+ if(cmt_found) {
+ cmt_found = FALSE;
+ urc_sms_state_change_process(s, sms_pdu);
+ } else if (strStartsWith(s, "MBTK_AT_READY")) { // AT ready.
} else if(strStartsWith(s, "CONNECT") || strStartsWith(s, "+CGEV:")) {
urc_pdp_state_change_process(s, sms_pdu);
@@ -1754,6 +1783,7 @@
}
else if(strStartsWith(s, "+CMT:"))
{
+ cmt_found = TRUE;
urc_sms_state_change_process(s, sms_pdu);
}
else if(strStartsWith(s, "*ECALLDATA:"))
@@ -2540,7 +2570,7 @@
band_info.band_support.lte_ext_band = MBTK_BAND_ALL_EXT_LTE_DEFAULT;
} else {
band_info.band_area = info_modem.band_area;
-#ifdef MBTK_DEV_INFO_VERSION_2
+#ifdef MBTK_DEV_INFO_VERSION_2
if(info_modem.net_pref < MBTK_NET_PREF_MAX) {
band_info.band_support.net_pref = info_modem.net_pref;
} else {
diff --git a/mbtk/test/libmbtk_ril/mbtk_ril_test.c b/mbtk/test/libmbtk_ril/mbtk_ril_test.c
index 35c29f3..83d05b2 100755
--- a/mbtk/test/libmbtk_ril/mbtk_ril_test.c
+++ b/mbtk/test/libmbtk_ril/mbtk_ril_test.c
@@ -139,7 +139,10 @@
static void sms_state_change_cb(const void* data, int data_len)
{
-
+ if(data) {
+ mbtk_ril_sms_state_info_t *state = (mbtk_ril_sms_state_info_t*)data;
+ printf("SMS PDU(%d) : %s\n", state->pdu_len, state->pdu);
+ }
}
static void radio_state_change_cb(const void* data, int data_len)