T108 sim Voie data network sms 支持双卡 ql 接口第一版
Change-Id: If5a9fb81971258bb5a3d811f3e4562b2df351853
diff --git a/mbtk/libql_lib_v2_rilv2/ql_voice.c b/mbtk/libql_lib_v2_rilv2/ql_voice.c
index 367753d..4ce0151 100755
--- a/mbtk/libql_lib_v2_rilv2/ql_voice.c
+++ b/mbtk/libql_lib_v2_rilv2/ql_voice.c
@@ -99,7 +99,7 @@
};
-
+/*
static int end_reason_mbtk_to_ql(char* mbtk_reason, int* ql_reason)
{
int bufefer_i = 0;
@@ -118,7 +118,47 @@
return 0;
}
+*/
+static mbtk_sim_type_enum s_voice_slot = MBTK_SIM_1;
+
+static bool check_slot_valid(QL_SIM_SLOT_E slot)
+{
+ if (slot !=QL_SIM_SLOT_1 && slot != QL_SIM_SLOT_2)
+ {
+ LOG("bad slot: %d, slot should be 1 or 2", slot);
+ return false;
+ }
+
+ return true;
+}
+
+static void ql_slot_convert_to_mbtk(QL_SIM_SLOT_E ql_slot,mbtk_sim_type_enum *mbtk_slot)
+{
+ if(ql_slot == QL_SIM_SLOT_1)
+ {
+ *mbtk_slot = MBTK_SIM_1;
+ }
+
+ if(ql_slot == QL_SIM_SLOT_2)
+ {
+ *mbtk_slot = MBTK_SIM_2;
+ }
+ return;
+
+}
+
+int ql_set_voice_slot(QL_SIM_SLOT_E log_slot)
+{
+ if(!check_slot_valid(log_slot))
+ {
+ LOG("[%s] check_slot_valid failed.", __func__);
+ return QL_ERR_INVALID_ARG;
+ }
+ ql_slot_convert_to_mbtk(log_slot,&s_voice_slot);
+ LOG("s_net_slot is %d",s_voice_slot);
+ return QL_ERR_OK;
+}
static void ql_voice_state_change_cb(const void* data, int data_len)
{
@@ -133,16 +173,16 @@
return;
}
- mbtk_call_info_t *reg = (mbtk_call_info_t *)data;
+ mbtk_ril_call_state_info_t *reg = (mbtk_ril_call_state_info_t *)data;
int ql_reason = 0;
- end_reason_mbtk_to_ql((char*)reg->end_reason, &ql_reason);
+ //end_reason_mbtk_to_ql((char*)reg->end_reason, &ql_reason);
LOG("ql_voice_state_change_cb ql_reason:%d", ql_reason);
if(MBTK_RIL_CALL_STATE_DISCONNECT != reg->state)
{
- LOG("ql_voice_state_change_cb : %d, %d, %d, %d, %d, %s, %d, %s", reg->dir1, reg->dir, reg->state, reg->mode, reg->mpty, reg->phone_number, reg->type, reg->end_reason);
+ LOG("ql_voice_state_change_cb : %d, %d, %d, %d, %s", reg->call_id, reg->dir, reg->state, reg->num_type, reg->call_number);
switch(reg->state)
{
@@ -167,27 +207,29 @@
case 7:
voice_handle->state_t = QL_VOICE_STATE_END;
break;
+ default:
+ break;
}
- if (voice_handle->record_array.records[0].id == 0 || voice_handle->record_array.records[0].id == reg->dir1)
+ if (voice_handle->record_array.records[0].id == 0 || voice_handle->record_array.records[0].id == reg->call_id)
{
voice_handle->record_array.len = 1;
- voice_handle->record_array.records[0].id = reg->dir1;
+ voice_handle->record_array.records[0].id = reg->call_id;
voice_handle->record_array.records[0].tech = 1;
voice_handle->record_array.records[0].dir = reg->dir;
voice_handle->record_array.records[0].end_reason = ql_reason;
voice_handle->record_array.records[0].state = voice_handle->state_t;
- memcpy(voice_handle->record_array.records[0].number, reg->phone_number, strlen(reg->phone_number));
+ memcpy(voice_handle->record_array.records[0].number, reg->call_number, strlen((char *)reg->call_number));
}
- else if (voice_handle->record_array.records[0].id != reg->dir1)
+ else if (voice_handle->record_array.records[0].id != reg->call_id)
{
voice_handle->record_array.len = 2;
- voice_handle->record_array.records[1].id = reg->dir1;
+ voice_handle->record_array.records[1].id = reg->call_id;
voice_handle->record_array.records[1].tech = 1;
voice_handle->record_array.records[1].dir = reg->dir;
voice_handle->record_array.records[1].end_reason = ql_reason;
voice_handle->record_array.records[1].state = voice_handle->state_t;
- memcpy(voice_handle->record_array.records[1].number, reg->phone_number, strlen(reg->phone_number));
+ memcpy(voice_handle->record_array.records[1].number, reg->call_number, strlen((char *)reg->call_number));
}
voice_handle->call_cb(&voice_handle->record_array);
@@ -197,18 +239,18 @@
LOGI("RING : call dis connected!");
voice_handle->record_array.records[0].end_reason = ql_reason;
voice_handle->record_array.records[1].end_reason = ql_reason;
- if(voice_handle->record_array.records[0].id == reg->dir1)
+ if(voice_handle->record_array.records[0].id == reg->call_id)
{
voice_handle->record_array.records[0].state = QL_VOICE_STATE_END;
voice_handle->record_array.records[0].id = 0;
}
- if(voice_handle->record_array.records[1].id == reg->dir1)
+ if(voice_handle->record_array.records[1].id == reg->call_id)
{
voice_handle->record_array.records[1].state = QL_VOICE_STATE_END;
voice_handle->record_array.records[1].id = 0;
voice_handle->record_array.len = 1;
}
- if (reg->disconnected_id == voice_handle->record_array.records[1].id)
+ if (reg->call_id == voice_handle->record_array.records[1].id)
voice_handle->call_cb(&voice_handle->record_array);
else
voice_handle->call_cb(&voice_handle->record_array);
@@ -218,14 +260,10 @@
static void ql_voice_server_change_cb(const void* data, int data_len)
{
- if(data_len != sizeof(int))
+ if(data)
{
- LOGE("[ql_voice_server_change_cb] data_len[%d] than int[%d] fail. ", data_len, sizeof(int));
- }
- else
- {
- int server_state = *(int *)data;
- if(server_state == 1 && voice_handle->server_cb)
+ mbtk_ril_ser_state_enum server_state = *(mbtk_ril_ser_state_enum *)data;
+ if(voice_handle->server_cb && server_state == MBTK_RIL_SER_STATE_EXIT)
{
voice_handle->server_cb(QL_ERR_ABORTED);
}
@@ -255,7 +293,7 @@
return QL_ERR_FAILED;
}
- voice_handle->handle = mbtk_ril_open(MBTK_AT_PORT_DEF);
+ voice_handle->handle = mbtk_ril_open(MBTK_AT_PORT_VOICE);
if(NULL == voice_handle->handle)
{
LOGE("[ql_voice_init] mbtk handle init fail.");
@@ -267,13 +305,24 @@
}
}
- int ret = mbtk_call_state_change_cb_reg( ql_voice_state_change_cb);
+ int ret = mbtk_ds_call_state_change_cb_reg(MBTK_SIM_1,ql_voice_state_change_cb);
if(ret != MBTK_ERR_OK)
{
LOGE("[ql_voice_init] set voice state cb fail.[%d]", ret);
if(voice_handle->handle)
{
- mbtk_ril_close(MBTK_AT_PORT_DEF);
+ mbtk_ril_close(MBTK_AT_PORT_VOICE);
+ voice_handle->handle = NULL;
+ return QL_ERR_FAILED;
+ }
+ }
+ ret = mbtk_ds_call_state_change_cb_reg(MBTK_SIM_2,ql_voice_state_change_cb);
+ if(ret != MBTK_ERR_OK)
+ {
+ LOGE("[ql_voice_init] set voice state cb fail.[%d]", ret);
+ if(voice_handle->handle)
+ {
+ mbtk_ril_close(MBTK_AT_PORT_VOICE);
voice_handle->handle = NULL;
return QL_ERR_FAILED;
}
@@ -285,7 +334,7 @@
LOGE("[ql_sim_init] set sim server cb fail.[%d]", ret);
if(voice_handle->handle)
{
- mbtk_ril_close(MBTK_AT_PORT_DEF);
+ mbtk_ril_close(MBTK_AT_PORT_VOICE);
voice_handle->handle = NULL;
return QL_ERR_FAILED;
}
@@ -320,7 +369,7 @@
if(NULL != voice_handle->handle)
{
- ret = mbtk_ril_close(MBTK_AT_PORT_DEF);
+ ret = mbtk_ril_close(MBTK_AT_PORT_VOICE);
if(ret != MBTK_ERR_OK)
{
LOGE("[ql_voice_deinit] mbtk handle deinit fail.[%d]", ret);
@@ -376,7 +425,7 @@
phone_num_t = num;
- err = mbtk_call_start(voice_handle->handle, phone_num_t);
+ err = mbtk_ds_call_start(voice_handle->handle, s_voice_slot,phone_num_t);
if(err)
{
LOGE("Error : %d\n", err);
@@ -387,7 +436,7 @@
LOGI("Call success.");
}
- mbtk_call_reg_get(voice_handle->handle, ®);
+ mbtk_ds_call_reg_get(voice_handle->handle, s_voice_slot,®);
*id = reg.dir1;
LOG("ql_voice_dial call_id: %d\n", reg.dir1, *id);
@@ -656,7 +705,7 @@
dtmf->duration = 300;
dtmf->character = callnum_c;
- ret = mbtk_dtmf_send(voice_handle->handle, dtmf);
+ ret = mbtk_ds_dtmf_send(voice_handle->handle,s_voice_slot, dtmf);
if (ret)
{
LOGE("mbtk_dtmf_send Error : %d", ret);