Add ril v2 support.
Change-Id: I14f4d5f3650f0d397c38a72e8bea2600c17b07de
diff --git a/mbtk/mbtk_rild_v2/src/main.c b/mbtk/mbtk_rild_v2/src/main.c
index 5565621..f0dfb60 100755
--- a/mbtk/mbtk_rild_v2/src/main.c
+++ b/mbtk/mbtk_rild_v2/src/main.c
@@ -46,11 +46,13 @@
#define MBTK_RILD_PID_FILE "/var/run/mbtk_rild.pid"
#define MBTK_RILD_FILE_NET_READY "/tmp/mbtk_rild.net_ready"
#define MBTK_RILD_FILE_SER_READY "/tmp/mbtk_rild.ser_ready"
+#define RIL_CALL_NUM_MAX 10
static bool ril_net_ready = FALSE; // Only one time.
static bool ril_server_ready = FALSE; // Only one time.
ril_band_info_t band_info;
ril_info_t ril_info;
+static mbtk_ril_call_state_info_t call_list[RIL_CALL_NUM_MAX];
extern mbtk_cell_pack_info_t cell_info;
extern ril_cgact_wait_t cgact_wait;
@@ -61,8 +63,13 @@
mbtk_ril_err_enum call_pack_req_process(sock_cli_info_t* cli_info, ril_msg_pack_info_t* pack);
mbtk_ril_err_enum sim_pack_req_process(sock_cli_info_t* cli_info, ril_msg_pack_info_t* pack);
mbtk_ril_err_enum net_pack_req_process(sock_cli_info_t* cli_info, ril_msg_pack_info_t* pack);
+mbtk_ril_err_enum data_call_pack_req_process(sock_cli_info_t* cli_info, ril_msg_pack_info_t* pack);
mbtk_ril_err_enum pb_pack_req_process(sock_cli_info_t* cli_info, ril_msg_pack_info_t* pack);
mbtk_ril_err_enum sms_pack_req_process(sock_cli_info_t* cli_info, ril_msg_pack_info_t* pack);
+mbtk_ril_err_enum ecall_pack_req_process(sock_cli_info_t* cli_info, ril_msg_pack_info_t* pack);
+
+void data_call_state_change_cb(int cid, bool action, bool auto_change, int reason);
+static int send_pack_to_queue(sock_cli_info_t* cli_info, void* pack);
/* Called on command thread */
static void onATTimeout()
@@ -283,7 +290,401 @@
}
}
-static void urc_pdp_state_process(const char *s, const char *sms_pdu)
+static void ril_state_change(ril_msg_id_enum msg_id, void *data, int data_len)
+{
+ sock_cli_info_t *cli = NULL;
+ list_first(ril_info.sock_client_list);
+ while ((cli = (sock_cli_info_t*) list_next(ril_info.sock_client_list)))
+ {
+ if(cli->ind_num > 0) {
+ int i;
+ for(i = 0; i < IND_REGISTER_MAX; i++) {
+ if(cli->ind_register[i] == msg_id) {
+ ril_ind_pack_send(cli->fd, msg_id, data, data_len);
+ break;
+ }
+ }
+ }
+ }
+}
+
+static int urc_msg_distribute(bool async_process, ril_msg_id_enum msg_id, void *data, int data_len)
+{
+ // Send urc msg to client.
+ if(msg_id > RIL_MSG_ID_IND_BEGIN && msg_id < RIL_MSG_ID_IND_END) {
+ ril_state_change(msg_id, data, data_len);
+ }
+
+ // Async process urc msg.
+ if(async_process) {
+ ril_urc_msg_info_t *msg = (ril_urc_msg_info_t*)malloc(sizeof(ril_urc_msg_info_t));
+ if(msg) {
+ msg->msg = msg_id;
+ msg->data = mbtk_memcpy(data, data_len);
+ msg->data_len = data_len;
+ if(msg->data == NULL) {
+ LOGE("mbtk_memcpy() fail.");
+ return -1;
+ }
+
+ return send_pack_to_queue(NULL, msg);
+ } else {
+ LOGE("malloc() fail.");
+ return -1;
+ }
+ }
+
+ return 0;
+}
+
+// *SIMDETEC:1,SIM
+// *EUICC:1
+// +CPIN: SIM PIN
+static void urc_sim_state_change_process(const char *s, const char *sms_pdu)
+{
+ mbtk_ril_sim_state_info_t state;
+ memset(&state, 0, sizeof(mbtk_ril_sim_state_info_t));
+ state.sim_type = MBTK_UNKNOWN;
+
+ char* tmp_s = memdup(s,strlen(s));
+ char *line = tmp_s;
+ int tmp_int;
+ char *tmp_str;
+
+ if(strStartsWith(s, "*SIMDETEC:")) {
+ if (at_tok_start(&line) < 0)
+ {
+ goto SIM_STATE_EXIT;
+ }
+ if (at_tok_nextint(&line, &tmp_int) < 0)
+ {
+ goto SIM_STATE_EXIT;
+ }
+ if (at_tok_nextstr(&line, &tmp_str) < 0)
+ {
+ goto SIM_STATE_EXIT;
+ }
+
+ if(tmp_str) {
+ if(strcmp(tmp_str, "NOS") == 0) {
+ state.sim_type = ril_info.sim_type;
+ state.sim_state = MBTK_SIM_STATE_ABSENT;
+ ril_info.sim_state = MBTK_SIM_STATE_ABSENT;
+ urc_msg_distribute(false, RIL_MSG_ID_IND_SIM_STATE_CHANGE, &state, sizeof(mbtk_ril_sim_state_info_t));
+ } else if(strcmp(tmp_str, "SIM") == 0) {
+ state.sim_type = ril_info.sim_type;
+ state.sim_state = MBTK_SIM_STATE_NOT_READY;
+ ril_info.sim_state = MBTK_SIM_STATE_NOT_READY;
+ urc_msg_distribute(false, RIL_MSG_ID_IND_SIM_STATE_CHANGE, &state, sizeof(mbtk_ril_sim_state_info_t));
+ }
+ }
+ } else if(strStartsWith(s, "+CPIN:")){
+ if(strStartsWith(s, "+CPIN: READY"))
+ {
+ state.sim_state = MBTK_SIM_STATE_READY;
+ }
+ else if(strStartsWith(s, "+CPIN: SIM PIN"))
+ {
+ state.sim_state = MBTK_SIM_STATE_SIM_PIN;
+ }
+ else if(strStartsWith(s, "+CPIN: SIM PUK"))
+ {
+ state.sim_state = MBTK_SIM_STATE_SIM_PUK;
+ }
+ else if(strStartsWith(s, "+CPIN: PH-SIMLOCK PIN"))
+ {
+ state.sim_state = MBTK_SIM_STATE_PH_SIMLOCK_PIN;
+ }
+ else if(strStartsWith(s, "+CPIN: PH-SIMLOCK PUK"))
+ {
+ state.sim_state = MBTK_SIM_STATE_PH_SIMLOCK_PUK;
+ }
+ else if(strStartsWith(s, "+CPIN: PH-FSIM PIN"))
+ {
+ state.sim_state = MBTK_SIM_STATE_PH_FSIM_PIN;
+ }
+ else if(strStartsWith(s, "+CPIN: PH-FSIM PUK"))
+ {
+ state.sim_state = MBTK_SIM_STATE_PH_FSIM_PUK;
+ }
+ else if(strStartsWith(s, "+CPIN: SIM PIN2"))
+ {
+ state.sim_state = MBTK_SIM_STATE_SIM_PIN2;
+ }
+ else if(strStartsWith(s, "+CPIN: SIM PUK2"))
+ {
+ state.sim_state = MBTK_SIM_STATE_SIM_PUK2;
+ }
+ else if(strStartsWith(s, "+CPIN: PH-NET PIN"))
+ {
+ state.sim_state = MBTK_SIM_STATE_PH_NET_PIN;
+ }
+ else if(strStartsWith(s, "+CPIN: PH-NET PUK"))
+ {
+ state.sim_state = MBTK_SIM_STATE_PH_NET_PUK;
+ }
+ else if(strStartsWith(s, "+CPIN: PH-NETSUB PIN"))
+ {
+ state.sim_state = MBTK_SIM_STATE_PH_NETSUB_PIN;
+ }
+ else if(strStartsWith(s, "+CPIN: PH-NETSUB PUK"))
+ {
+ state.sim_state = MBTK_SIM_STATE_PH_NETSUB_PUK;
+ }
+ else if(strStartsWith(s, "+CPIN: PH-SP PIN"))
+ {
+ state.sim_state = MBTK_SIM_STATE_PH_SP_PIN;
+ }
+ else if(strStartsWith(s, "+CPIN: PH-SP PUK"))
+ {
+ state.sim_state = MBTK_SIM_STATE_PH_SP_PUK;
+ }
+ else if(strStartsWith(s, "+CPIN: PH-CORP PIN"))
+ {
+ state.sim_state = MBTK_SIM_STATE_PH_CORP_PIN;
+ }
+ else if(strStartsWith(s, "+CPIN: PH-CORP PUK"))
+ {
+ state.sim_state = MBTK_SIM_STATE_PH_CORP_PUK;
+ }
+ else if(strStartsWith(s, "+CPIN: SIM REMOVED"))
+ {
+ state.sim_state = MBTK_SIM_STATE_ABSENT;
+ }
+
+ state.sim_type = ril_info.sim_type;
+ ril_info.sim_state = state.sim_state;
+
+ urc_msg_distribute(false, RIL_MSG_ID_IND_SIM_STATE_CHANGE, &state, sizeof(mbtk_ril_sim_state_info_t));
+ } else if(strStartsWith(s, "*EUICC:")){
+ if (at_tok_start(&line) < 0)
+ {
+ goto SIM_STATE_EXIT;
+ }
+ if (at_tok_nextint(&line, &tmp_int) < 0)
+ {
+ goto SIM_STATE_EXIT;
+ }
+ ril_info.sim_type = (mbtk_sim_card_type_enum)tmp_int;
+ } else {
+ LOGW("Unknown URC.");
+ }
+
+SIM_STATE_EXIT:
+ free(tmp_s);
+}
+
+// +CLCC: 1, 1, 6, 0, 0, "18981911691", 129, "",, 0
+// +CALLDISCONNECT: 1
+// +CPAS: 4
+static void urc_call_state_change_process(const char *s, const char *sms_pdu)
+{
+ char* tmp_s = memdup(s,strlen(s));
+ char *line = tmp_s;
+ int tmp_int;
+ char *tmp_str;
+
+ if(strStartsWith(s, "+CLCC:")) {
+ if (at_tok_start(&line) < 0)
+ {
+ goto CALL_STATE_EXIT;
+ }
+ if (at_tok_nextint(&line, &tmp_int) < 0) // call id
+ {
+ goto CALL_STATE_EXIT;
+ }
+
+ int i = 0;
+ while(i < RIL_CALL_NUM_MAX) {
+ if(call_list[i].call_id == tmp_int)
+ break;
+ i++;
+ }
+ if(i == RIL_CALL_NUM_MAX) { // No found this call id.
+ i = 0;
+ while(i < RIL_CALL_NUM_MAX) { // Find next empty call item.
+ if(call_list[i].call_id == 0)
+ break;
+ i++;
+ }
+ call_list[i].call_id = tmp_int;
+ }
+
+ LOGD("Found call id : %d", call_list[i].call_id);
+
+ if (at_tok_nextint(&line, &tmp_int) < 0) // dir
+ {
+ goto CALL_STATE_EXIT;
+ }
+ call_list[i].dir = (mbtk_ril_call_dir_enum)tmp_int;
+
+ if (at_tok_nextint(&line, &tmp_int) < 0) // state
+ {
+ goto CALL_STATE_EXIT;
+ }
+ call_list[i].state = (mbtk_ril_call_state_enum)tmp_int;
+
+ if (at_tok_nextint(&line, &tmp_int) < 0) // mode
+ {
+ goto CALL_STATE_EXIT;
+ }
+
+ if (at_tok_nextint(&line, &tmp_int) < 0) // mpty
+ {
+ goto CALL_STATE_EXIT;
+ }
+
+ if (at_tok_nextstr(&line, &tmp_str) < 0) // number
+ {
+ goto CALL_STATE_EXIT;
+ }
+ memset(call_list[i].call_number, 0, sizeof(call_list[i].call_number));
+ if(tmp_str && strlen(tmp_str) > 0) {
+ memcpy(call_list[i].call_number, tmp_str, strlen(tmp_str));
+ }
+
+ if (at_tok_nextint(&line, &tmp_int) < 0) // type
+ {
+ goto CALL_STATE_EXIT;
+ }
+ call_list[i].num_type = (mbtk_ril_call_num_type_enum)tmp_int;
+
+ urc_msg_distribute(false, RIL_MSG_ID_IND_CALL_STATE_CHANGE, &(call_list[i]), sizeof(mbtk_ril_call_state_info_t));
+ } else if(strStartsWith(s, "+CALLDISCONNECT:")){
+ if (at_tok_start(&line) < 0)
+ {
+ goto CALL_STATE_EXIT;
+ }
+ if (at_tok_nextint(&line, &tmp_int) < 0) // call id
+ {
+ goto CALL_STATE_EXIT;
+ }
+
+ int i = 0;
+ while(i < RIL_CALL_NUM_MAX) {
+ if(call_list[i].call_id == tmp_int)
+ break;
+ i++;
+ }
+
+ if(i == RIL_CALL_NUM_MAX) { // No found this call id.
+ LOGE("No found this call id : %d", tmp_int);
+ goto CALL_STATE_EXIT;
+ }
+
+ call_list[i].state = MBTK_RIL_CALL_STATE_DISCONNECT;
+
+ urc_msg_distribute(false, RIL_MSG_ID_IND_CALL_STATE_CHANGE, &(call_list[i]), sizeof(mbtk_ril_call_state_info_t));
+
+ // Reset after call disconnect.
+ memset(&(call_list[i]), 0, sizeof(mbtk_ril_call_state_info_t));
+ } else if(strStartsWith(s, "+CPAS:")){
+
+ } else {
+ LOGW("Unknown URC.");
+ }
+
+CALL_STATE_EXIT:
+ free(tmp_s);
+}
+
+// *ECALLDATA: <urc_id>[,<urc_data>]
+static void urc_ecall_state_change_process(const char *s, const char *sms_pdu)
+{
+ mbtk_ril_ecall_state_info_t ecall_state;
+ memset(&ecall_state, 0, sizeof(mbtk_ril_ecall_state_info_t));
+
+ char* tmp_s = memdup(s,strlen(s));
+ char *line = tmp_s;
+ int tmp_int;
+ char *tmp_str;
+ if (at_tok_start(&line) < 0)
+ {
+ goto ECALLDATA_EXIT;
+ }
+ if (at_tok_nextint(&line, &tmp_int) < 0)
+ {
+ goto ECALLDATA_EXIT;
+ }
+ ecall_state.urc_id = (uint8)tmp_int; // urc_id
+ if (at_tok_nextstr(&line, &tmp_str) < 0)
+ {
+ goto ECALLDATA_EXIT;
+ }
+
+ if(tmp_str && strlen(tmp_str) > 0) {
+ memcpy(ecall_state.urc_data, tmp_str, strlen(tmp_str));
+ }
+
+ urc_msg_distribute(false, RIL_MSG_ID_IND_ECALL_STATE_CHANGE, &ecall_state, sizeof(mbtk_ril_ecall_state_info_t));
+ECALLDATA_EXIT:
+ free(tmp_s);
+}
+
+// +CMT: ,23
+// 0891683108200855F6240D91688189911196F10000221130717445230331D90C
+static void urc_sms_state_change_process(const char *s, const char *sms_pdu)
+{
+
+}
+
+// +CREG: 1, "8010", "000060a5", 0, 2, 0
+// +CREG: 1, "8330", "06447347", 7, 2, 0
+// +CEREG: 1, "8330", "06447347", 7
+// $CREG: 1, "8330", "06447347", 7,"0d4", 2, 0
+// $CREG: 1, "8010", "000060a7", 0,, 2, 0
+// +CGREG: 1
+static void urc_net_reg_state_change_process(const char *s, const char *sms_pdu)
+{
+ mbtk_ril_net_reg_state_info_t state;
+ memset(&state, 0, sizeof(mbtk_ril_net_reg_state_info_t));
+ state.tech = MBTK_RADIO_TECH_UNKNOWN;
+
+ if(strStartsWith(s, "+CREG:"))
+ {
+ state.type = MBTK_NET_REG_TYPE_CALL;
+ } else if(strStartsWith(s, "+CGREG:")) {
+ state.type = MBTK_NET_REG_TYPE_DATA_GSM_WCDMA;
+ } else {
+ state.type = MBTK_NET_REG_TYPE_DATA_LTE;
+ }
+
+ char* tmp_s = memdup(s,strlen(s));
+ char *line = tmp_s;
+ int tmp_int;
+ char *tmp_str;
+ if (at_tok_start(&line) < 0)
+ {
+ goto CGREG_EXIT;
+ }
+ if (at_tok_nextint(&line, &tmp_int) < 0)
+ {
+ goto CGREG_EXIT;
+ }
+ state.reg_state = (mbtk_net_reg_state_enum)tmp_int; // Reg State.
+ if (state.reg_state) // Reg
+ {
+ if (at_tok_nextstr(&line, &tmp_str) < 0)
+ {
+ goto CGREG_EXIT;
+ }
+ if (at_tok_nextstr(&line, &tmp_str) < 0)
+ {
+ goto CGREG_EXIT;
+ }
+ if (at_tok_nextint(&line, &tmp_int) < 0)
+ {
+ goto CGREG_EXIT;
+ }
+ state.tech = (mbtk_radio_technology_enum)tmp_int; // AcT
+ }
+
+ urc_msg_distribute(false, RIL_MSG_ID_IND_NET_REG_STATE_CHANGE, &state, sizeof(mbtk_ril_net_reg_state_info_t));
+CGREG_EXIT:
+ free(tmp_s);
+}
+
+static void urc_pdp_state_change_process(const char *s, const char *sms_pdu)
{
// "CONNECT"
if(strStartsWith(s, "CONNECT"))
@@ -346,41 +747,47 @@
// "+CGEV: EPS PDN ACT ")) { // +CGEV: EPS PDN ACT <cid>
// "+CGEV: ME PDN DEACT ")) { // +CGEV: EPS PDN DEACT <cid>
// "+CGEV: ME PDN ACT ")) { // +CGEV: ME PDN ACT <cid>,1
- int cid = -1;
- int reason = -1;
- bool act = FALSE;
- if (sscanf(s, "+CGEV: NW PDN DEACT %d", &cid) == 1) {
- act = FALSE;
- } else if (sscanf(s, "+CGEV: ME PDN DEACT %d", &cid) == 1) {
- act = FALSE;
- } else if(sscanf(s, "+CGEV: ME PDN ACT %d,%d", &cid, &reason) == 2
- || sscanf(s, "+CGEV: ME PDN ACT %d", &cid) == 1) {
- act = TRUE;
+ mbtk_ril_pdp_state_info_t cgev_info;
+ memset(&cgev_info, 0, sizeof(mbtk_ril_pdp_state_info_t));
+ if (sscanf(s, "+CGEV: NW PDN DEACT %d", &(cgev_info.cid)) == 1) {
+ cgev_info.action = FALSE;
+ } else if (sscanf(s, "+CGEV: ME PDN DEACT %d", &(cgev_info.cid)) == 1) {
+ cgev_info.action = FALSE;
+ } else if(sscanf(s, "+CGEV: ME PDN ACT %d,%d", &(cgev_info.cid), &(cgev_info.reason)) == 2
+ || sscanf(s, "+CGEV: ME PDN ACT %d", &(cgev_info.cid)) == 1) {
+ cgev_info.action = TRUE;
} else if (!strcmp(s, "+CGEV: ME DETACH")) {
if(cgact_wait.waitting) {
- cid = cgact_wait.cid;
+ cgev_info.cid = cgact_wait.cid;
}
- act = FALSE;
- } else if (sscanf(s, "+CGEV: NW MODIFY %d,%d", &cid, &reason) == 2) {
- act = TRUE;
- } else if(sscanf(s, "+CGEV: EPS PDN ACT %d", &cid) == 1) {
- act = TRUE;
+ cgev_info.action = FALSE;
+ } else if (sscanf(s, "+CGEV: NW MODIFY %d,%d", &(cgev_info.cid), &(cgev_info.reason)) == 2) {
+ cgev_info.action = TRUE;
+ } else if(sscanf(s, "+CGEV: EPS PDN ACT %d", &(cgev_info.cid)) == 1) {
+ cgev_info.action = TRUE;
} else {
LOGD(">>>>>>>>>No process +CGEV <<<<<<<<<");
return;
}
+ cgev_info.auto_change = !cgact_wait.waitting;
if(cgact_wait.act) {
- if(cgact_wait.waitting && act && cgact_wait.cid == cid) {
+ if(cgact_wait.waitting && cgev_info.action && cgact_wait.cid == cgev_info.cid) {
cgact_wait.waitting = false;
}
} else {
- if(cgact_wait.waitting && !act && cgact_wait.cid == cid) {
+ if(cgact_wait.waitting && !cgev_info.action && cgact_wait.cid == cgev_info.cid) {
cgact_wait.waitting = false;
}
}
- LOGD("+CGEV:cid - %d, act - %d, reason - %d", cid, act, reason);
+ LOGD("+CGEV:cid - %d, act - %d, auto_change - %d, reason - %d", cgev_info.cid, cgev_info.action,
+ cgev_info.auto_change, cgev_info.reason);
+
+ if(cgev_info.cid >= MBTK_APN_CID_MIN && cgev_info.cid <= MBTK_APN_CID_MAX) {
+ urc_msg_distribute(false, RIL_MSG_ID_IND_PDP_STATE_CHANGE, &cgev_info, sizeof(mbtk_ril_pdp_state_info_t));
+ }
+
#else
if(at_process) {
if(cgact_wait.act) {
@@ -1217,7 +1624,7 @@
{
} else if(strStartsWith(s, "CONNECT") || strStartsWith(s, "+CGEV:")) {
- urc_pdp_state_process(s, sms_pdu);
+ urc_pdp_state_change_process(s, sms_pdu);
} else if(strStartsWith(s, "+EEMLTESVC:") || strStartsWith(s, "+EEMLTEINTER:")
|| strStartsWith(s, "+EEMLTEINTRA:") || strStartsWith(s, "+EEMLTEINTERRAT:")
|| strStartsWith(s, "+EEMUMTSSVC:") || strStartsWith(s, "+EEMUMTSINTRA:")
@@ -1226,7 +1633,6 @@
|| strStartsWith(s, "+EEMGINFONC:")) {
urc_cell_info_process(s, sms_pdu);
}
-#if 0
else if(strStartsWith(s, "*RADIOPOWER:")) // "*RADIOPOWER: 1"
{
const char* ptr = s + strlen("*RADIOPOWER:");
@@ -1235,114 +1641,14 @@
ptr++;
}
- uint8 state;
+ mbtk_ril_radio_state_info_t state;
+ memset(&state, 0, sizeof(mbtk_ril_radio_state_info_t));
if(*ptr == '1') {
- //net_info.radio_state = MBTK_RADIO_STATE_ON;
- // mbtk_radio_ready_cb();
- state = (uint8)1;
+ state.radio_state = MBTK_RADIO_STATE_FULL_FUNC;
} else {
- //net_info.radio_state = MBTK_RADIO_STATE_OFF;
- state = (uint8)0;
+ state.radio_state = MBTK_RADIO_STATE_MINI_FUNC;
}
- urc_msg_distribute(true, INFO_URC_MSG_RADIO_STATE, &state, sizeof(uint8));
- }
- else {
- // apn_state_set
-
- // +CGEV: NW PDN DEACT <cid>
-
- // +CGEV: EPS PDN ACT 1
- // +CGEV: ME PDN ACT 8,1
-
- // +CGEV: ME PDN ACT 2,4
- uint8 data[2] = {0xFF};
- if(strStartsWith(s, "+CGEV: NW PDN DEACT ")) { // +CGEV: NW PDN DEACT <cid>
- //apn_state_set(atoi(s + 20), false);
- data[0] = (uint8)0;
- data[1] = (uint8)atoi(s + 20);
-
- uint8 data_pdp;
- data_pdp = 0; //
- urc_msg_distribute(false, INFO_URC_MSG_PDP_STATE, &data_pdp, sizeof(uint8));
- data_pdp = data[1] + 100;
- urc_msg_distribute(false, INFO_URC_MSG_PDP_STATE, &data_pdp, sizeof(uint8));
- } else if(strStartsWith(s, "+CGEV: EPS PDN ACT ")) { // +CGEV: EPS PDN ACT <cid>
- //apn_state_set(atoi(s + 19), true);
- data[0] = (uint8)1;
- data[1] = (uint8)atoi(s + 19);
- } else if(strStartsWith(s, "+CGEV: ME PDN DEACT ")) { // +CGEV: EPS PDN DEACT <cid>
- //apn_state_set(atoi(s + 19), true);
- data[0] = (uint8)0;
- data[1] = (uint8)atoi(s + 20);
-
- uint8 data_pdp;
- data_pdp = 0; //
- urc_msg_distribute(false, INFO_URC_MSG_PDP_STATE, &data_pdp, sizeof(uint8));
- data_pdp = data[1] + 100;
- urc_msg_distribute(false, INFO_URC_MSG_PDP_STATE, &data_pdp, sizeof(uint8));
- } else if(strStartsWith(s, "+CGEV: ME PDN ACT ")) { // +CGEV: ME PDN ACT <cid>,1
- //apn_state_set(atoi(s + 18), true);
- data[0] = (uint8)1;
- data[1] = (uint8)atoi(s + 18);
-
- uint8 data_pdp;
- char* tmp_s = memdup(s + 18,strlen(s + 18));
- char* free_ptr = tmp_s;
- char *line = tmp_s;
- int tmp_int;
- if (at_tok_start(&line) < 0)
- {
- goto PDP_CREG_EXIT;
- }
- if (at_tok_nextint(&line, &tmp_int) < 0)
- {
- goto PDP_CREG_EXIT;
- }
- if (at_tok_nextint(&line, &tmp_int) < 0)
- {
- goto PDP_CREG_EXIT;
- }
- data_pdp = tmp_int;
-PDP_CREG_EXIT:
- free(free_ptr);
- //data_pdp = (uint8)atoi(s + 20); //reason
- if(data[1] >= 1 && data[1] < 8)
- {
- if(data_pdp == 0)
- {
- data_pdp = 25;
- urc_msg_distribute(false, INFO_URC_MSG_PDP_STATE, &data_pdp, sizeof(uint8));
- }
- else if(data_pdp == 1)
- {
- data_pdp = 26;
- urc_msg_distribute(false, INFO_URC_MSG_PDP_STATE, &data_pdp, sizeof(uint8));
- }
- else if(data_pdp == 2)
- {
- data_pdp = 27;
- urc_msg_distribute(false, INFO_URC_MSG_PDP_STATE, &data_pdp, sizeof(uint8));
- }
- else if(data_pdp == 3)
- {
- data_pdp = 27;
- urc_msg_distribute(false, INFO_URC_MSG_PDP_STATE, &data_pdp, sizeof(uint8));
- }
- else
- {
-
- }
-
- data_pdp = data[1] + 200;
- urc_msg_distribute(false, INFO_URC_MSG_PDP_STATE, &data_pdp, sizeof(uint8));
- data[1] = 0;
- }
- } else {
- LOGI("No process : %s", s);
- }
-
- urc_msg_distribute(true, INFO_URC_MSG_CGEV, data, sizeof(uint8) * 2);
- }
+ urc_msg_distribute(true, RIL_MSG_ID_IND_RADIO_STATE_CHANGE, &state, sizeof(mbtk_ril_radio_state_info_t));
}
// +CREG: 1, "8010", "000060a5", 0, 2, 0
// +CREG: 1, "8330", "06447347", 7, 2, 0
@@ -1351,105 +1657,33 @@
// $CREG: 1, "8010", "000060a7", 0,, 2, 0
// +CGREG: 1
else if(strStartsWith(s, "+CGREG:") // GMS/WCDMA data registed.
- || strStartsWith(s, "+CEREG:")) // LTE data registed.
+ || strStartsWith(s, "+CEREG:") // LTE data registed.
+ || strStartsWith(s, "+CREG:")) // GMS/WCDMA/LTE CS registed.
{
- char* tmp_s = s + 7;
- static bool net_led_gms_wcdma = FALSE;
- static bool net_led_lte = FALSE;
- while(*tmp_s && *tmp_s == ' ')
- tmp_s++;
- uint8 data[2];
- data[0] = (uint8)atoi(tmp_s); // Reg State.
-
- if(strStartsWith(s, "+CGREG:"))
- {
- data[1] = 0; // GMS/WCDMA
- if(data[0] == 1)
- {
- net_led_gms_wcdma = TRUE;
- }
- else
- {
- net_led_gms_wcdma = FALSE;
- }
-
- }
- else
- {
- data[1] = 1; // LTE
- if(data[0] == 1)
- {
- net_led_lte = TRUE;
- }
- else
- {
- net_led_lte = FALSE;
- }
- }
-
- if(FALSE == net_led_gms_wcdma && FALSE == net_led_lte)
- {
- //mbtk_net_led_set(MBTK_NET_LED_SEARCH_NETWORK);
- }
- else
- {
- //mbtk_net_led_set(MBTK_NET_LED_NET_CONNECT);
- mbtk_net_ready();
- }
-
- urc_msg_distribute(true, INFO_URC_MSG_NET_PS_REG_STATE, data, sizeof(data));
- urc_msg_distribute(true, INFO_URC_MSG_NET_STATE_LOG, NULL, 0);
+ urc_net_reg_state_change_process(s, sms_pdu);
}
- // +CREG: 1, "8010", "000060a5", 0, 2, 0
- // +CREG: 1, "8330", "06447347", 7, 2, 0
- // +CREG: 0
- else if(strStartsWith(s, "+CREG:")) // GMS/WCDMA/LTE CS registed.
+ // +CLCC: 1, 1, 6, 0, 0, "18981911691", 129, "",, 0
+ else if(strStartsWith(s, "+CLCC:")
+ || strStartsWith(s, "+CPAS:")
+ || strStartsWith(s, "+CALLDISCONNECT:"))
{
- uint8 data[3];
- data[0] = (uint8)MBTK_NET_CS_STATE;
- char* tmp_s = memdup(s,strlen(s));
- char* free_ptr = tmp_s;
- char *line = tmp_s;
- int tmp_int;
- char *tmp_str;
- if (at_tok_start(&line) < 0)
- {
- goto CREG_EXIT;
- }
- if (at_tok_nextint(&line, &tmp_int) < 0)
- {
- goto CREG_EXIT;
- }
- data[1] = (uint8)tmp_int; // Reg State.
- if (data[1])
- {
- if (at_tok_nextstr(&line, &tmp_str) < 0)
- {
- goto CREG_EXIT;
- }
- if (at_tok_nextstr(&line, &tmp_str) < 0)
- {
- goto CREG_EXIT;
- }
- if (at_tok_nextint(&line, &tmp_int) < 0)
- {
- goto CREG_EXIT;
- }
- data[2] = (uint8)tmp_int; // AcT
- } else {
- data[2] = (uint8)0xFF; // AcT
- }
- if(data[1] == 5)
- {
- uint8 data_pdp;
- data_pdp = 5; //
- urc_msg_distribute(false, INFO_URC_MSG_PDP_STATE, &data_pdp, sizeof(uint8));
- }
- urc_msg_distribute(false, INFO_URC_MSG_NET_CS_REG_STATE, data, sizeof(data));
- urc_msg_distribute(true, INFO_URC_MSG_NET_STATE_LOG, NULL, 0);
-CREG_EXIT:
- free(free_ptr);
+ urc_call_state_change_process(s, sms_pdu);
}
+ else if(strStartsWith(s, "*SIMDETEC:")
+ || strStartsWith(s, "*EUICC:")
+ || strStartsWith(s, "+CPIN:"))
+ {
+ urc_sim_state_change_process(s, sms_pdu);
+ }
+ else if(strStartsWith(s, "+CMT:"))
+ {
+ urc_sms_state_change_process(s, sms_pdu);
+ }
+ else if(strStartsWith(s, "*ECALLDATA:"))
+ {
+ urc_ecall_state_change_process(s, sms_pdu);
+ }
+#if 0
// +CLCC: 1, 1, 6, 0, 0, "18981911691", 129, "",, 0
else if(strStartsWith(s, "+CLCC:"))
{
@@ -1742,32 +1976,6 @@
printf("+CMT() sms_cmt:%d, s:%s, len:%d\n",sms_cmt, s, strlen(s));
urc_msg_distribute(false, INFO_URC_MSG_SMS_STATE, s, strlen(s));
}
-#if 0
- // LTE data registed.
- // +CEREG: 1, "8330", "06447347", 7
- else if(strStartsWith(s, "+CEREG:"))
- {
- char* tmp_s = memdup(s,strlen(s));
- char* free_ptr = tmp_s;
- char *line = tmp_s;
- int tmp_int;
- char *tmp_str;
- if (at_tok_start(&line) < 0)
- {
- goto CREG_EXIT;
- }
- if (at_tok_nextint(&line, &tmp_int) < 0)
- {
- goto CREG_EXIT;
- }
- uint8 data = (uint8)tmp_int; // Reg State.
-
- urc_msg_distribute(INFO_URC_MSG_NET_REG_STATE, &data, sizeof(uint8));
-CREG_EXIT:
- free(free_ptr);
- }
-#endif
-
#endif
else if(strStartsWith(s, "+ZGIPDNS:")) // +ZGIPDNS: 1,"IPV4V6","10.156.239.245","10.156.239.246","223.87.253.100","223.87.253.253","fe80:0000:0000:0000:0001:0001:9b8c:7c0c","fe80::1:1:9b8c:7c0d","2409:8062:2000:2::1","2409:8062:2000:2::2"
{
@@ -1886,37 +2094,40 @@
static void pack_distribute(sock_cli_info_t* cli_info, ril_msg_pack_info_t* pack)
{
// Register IND Message.
- if(pack->msg_type == RIL_MSG_TYPE_IND)
- {
- mbtk_ril_err_enum err = MBTK_RIL_ERR_SUCCESS;
- if(cli_info->ind_num >= IND_REGISTER_MAX)
- {
- LOGE("IND if full.");
- err = MBTK_RIL_ERR_IND_FULL;
- }
- else
- {
- ind_regisger(cli_info, pack->msg_id);
- }
-
- ril_error_pack_send(cli_info->fd, pack->msg_id, pack->msg_index, err);
-
- ril_msg_pack_free(pack);
- }
- else // Request Information.
- {
- LOGD("Start process REQ(%s), Length : %d", id2str(pack->msg_id), pack->data_len);
- if(0 && pack->data_len > 0)
- {
- log_hex("DATA", pack->data, pack->data_len);
- }
-
- // Send to REQ_process_thread process.
- send_pack_to_queue(cli_info, pack);
-
- // For test.
- // pack_error_send(cli_info->fd, pack->info_id + 1, MBTK_INFO_ERR_SUCCESS);
- }
+ if(pack->msg_type == RIL_MSG_TYPE_REQ)
+ {
+ if(pack->msg_id > RIL_MSG_ID_IND_BEGIN
+ && pack->msg_id < RIL_MSG_ID_IND_END) {
+ mbtk_ril_err_enum err = MBTK_RIL_ERR_SUCCESS;
+ if(cli_info->ind_num >= IND_REGISTER_MAX)
+ {
+ LOGE("IND if full.");
+ err = MBTK_RIL_ERR_IND_FULL;
+ }
+ else
+ {
+ ind_regisger(cli_info, pack->msg_id);
+ }
+
+ ril_error_pack_send(cli_info->fd, pack->msg_id, pack->msg_index, err);
+
+ ril_msg_pack_free(pack);
+ } else {
+ LOGD("Start process REQ(%s), Length : %d", id2str(pack->msg_id), pack->data_len);
+ if(0 && pack->data_len > 0)
+ {
+ log_hex("DATA", pack->data, pack->data_len);
+ }
+
+ // Send to REQ_process_thread process.
+ send_pack_to_queue(cli_info, pack);
+
+ // For test.
+ // pack_error_send(cli_info->fd, pack->info_id + 1, MBTK_INFO_ERR_SUCCESS);
+ }
+ } else {
+ LOGE("Pack type error : %d", pack->msg_type);
+ }
}
// Return MBTK_INFO_ERR_SUCCESS,will call pack_error_send() to send RSP.
@@ -1929,12 +2140,16 @@
return sim_pack_req_process(cli_info, pack);
} else if(pack->msg_id > RIL_MSG_ID_NET_BEGIN && pack->msg_id < RIL_MSG_ID_NET_END) {
return net_pack_req_process(cli_info, pack);
+ } else if(pack->msg_id > RIL_MSG_ID_DATA_CALL_BEGIN && pack->msg_id < RIL_MSG_ID_DATA_CALL_END) {
+ return data_call_pack_req_process(cli_info, pack);
} else if(pack->msg_id > RIL_MSG_ID_CALL_BEGIN && pack->msg_id < RIL_MSG_ID_CALL_END) {
return call_pack_req_process(cli_info, pack);
} else if(pack->msg_id > RIL_MSG_ID_SMS_BEGIN && pack->msg_id < RIL_MSG_ID_SMS_END) {
return sms_pack_req_process(cli_info, pack);
} else if(pack->msg_id > RIL_MSG_ID_PB_BEGIN && pack->msg_id < RIL_MSG_ID_PB_END) {
return pb_pack_req_process(cli_info, pack);
+ } else if(pack->msg_id > RIL_MSG_ID_ECALL_BEGIN && pack->msg_id < RIL_MSG_ID_ECALL_END) {
+ return ecall_pack_req_process(cli_info, pack);
} else {
LOGW("Unknown msg id : %d", pack->msg_id);
return MBTK_RIL_ERR_FORMAT;
@@ -1943,15 +2158,18 @@
static void urc_msg_process(ril_urc_msg_info_t *msg)
{
- uint8 *data = NULL;
- if(msg->data) {
- data = (uint8*)msg->data;
- }
+ if(!msg->data || msg->data_len <= 0) {
+ LOGE("URC data is NULL.");
+ return;
+ }
+
switch(msg->msg) {
- case RIL_URC_MSG_RADIO_STATE:
- {
+ case RIL_MSG_ID_IND_RADIO_STATE_CHANGE:
+ {
+ mbtk_ril_radio_state_info_t *state = (mbtk_ril_radio_state_info_t*)msg->data;
+ LOGD("Radio state : %d", state->radio_state);
break;
- }
+ }
default:
{
LOGE("Unknown URC : %d", msg->msg);
@@ -2046,8 +2264,9 @@
list_add(ril_info.sock_client_list, info);
LOG("Add New Client FD Into List.");
- // Send msg RIL_MSG_ID_IND_SER_READY to client.
- ril_ind_pack_send(client_fd, RIL_MSG_ID_IND_SER_READY, NULL, 0);
+ // Send msg RIL_MSG_ID_IND_SER_STATE_CHANGE to client.
+ mbtk_ril_ser_state_enum state = MBTK_RIL_SER_STATE_READY;
+ ril_ind_pack_send(client_fd, RIL_MSG_ID_IND_SER_STATE_CHANGE, &state, 1);
}
else
{
@@ -2135,13 +2354,15 @@
ril_info.at_process = false;
ril_msg_pack_free(pack);
free(item);
- } else { // REQ from myself.
- ril_urc_msg_info_t *urc = (ril_urc_msg_info_t*)item->pack;
- LOGD("Process URC %d.", urc->msg);
- urc_msg_process(urc);
- if(urc->data)
- free(urc->data);
- free(urc);
+ } else { // REQ from myself.
+ if(item->pack) {
+ ril_urc_msg_info_t *urc = (ril_urc_msg_info_t*)item->pack;
+ LOGD("Process URC %d.", urc->msg);
+ urc_msg_process(urc);
+ if(urc->data)
+ free(urc->data);
+ free(urc);
+ }
}
}
}