[Feature][T108][task-view-1808] V2 mbtk_rild and libmbtk_ril compatible ss
Only Configure: No
Affected branch: YUNDONG_BASE1.0
Affected module: RIL
Is it affected on IC: only ASR
Self-test: yes
Doc Update: no
Change-Id: I5f13ec772e31487d13b762856c7404c5bf2b7fca
diff --git a/mbtk/libmbtk_lib/ril/v2/mbtk_ril_api.c b/mbtk/libmbtk_lib/ril/v2/mbtk_ril_api.c
index 6e648ef..f0abfd0 100755
--- a/mbtk/libmbtk_lib/ril/v2/mbtk_ril_api.c
+++ b/mbtk/libmbtk_lib/ril/v2/mbtk_ril_api.c
@@ -484,7 +484,11 @@
bool is_async,
int timeout)
{
+ #ifdef LYNQ_DSDS_SUPPORT
ril_msg_pack_info_t* pack = ril_msg_pack_creat(sim_id, port, RIL_MSG_TYPE_REQ, id, RIL_MSG_INDEX_AUTO, req, req_len);
+ #else
+ ril_msg_pack_info_t* pack = ril_msg_pack_creat(MBTK_SIM_1, port, RIL_MSG_TYPE_REQ, id, RIL_MSG_INDEX_AUTO, req, req_len);
+ #endif
if(pack == NULL)
{
return MBTK_RIL_ERR_MEMORY;
diff --git a/mbtk/libmbtk_lib/ril/v2/ril_utils.c b/mbtk/libmbtk_lib/ril/v2/ril_utils.c
index fc9e723..d1c153a 100755
--- a/mbtk/libmbtk_lib/ril/v2/ril_utils.c
+++ b/mbtk/libmbtk_lib/ril/v2/ril_utils.c
@@ -44,7 +44,7 @@
if(read_len > 0)
{
- log_hex("DATA_RECV", msg, read_len);
+ //log_hex("DATA_RECV", msg, read_len);
return read_len;
}
else
diff --git a/mbtk/mbtk_rild_v2/src/main.c b/mbtk/mbtk_rild_v2/src/main.c
index c4befdf..0447e25 100755
--- a/mbtk/mbtk_rild_v2/src/main.c
+++ b/mbtk/mbtk_rild_v2/src/main.c
@@ -72,6 +72,16 @@
#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 MBTK_RILD_REQ_SLOT1_CHANNEL0 "/tmp/atcmd_at" //SIM 1 channel 0 request socket
+#define MBTK_RILD_REQ_SLOT1_CHANNEL1 "/tmp/atcmd_at_1" //SIM 1 channel 1 request socket
+#define MBTK_RILD_REQ_SLOT1_CHANNEL2 "/tmp/atcmd_at_2" //SIM 1 channel 2 request socket
+#define MBTK_RILD_URC_SLOT1 "/tmp/atcmd_urc" //SIM 1 unsolicite socket
+
+#define MBTK_RILD_REQ_SLOT2_CHANNEL0 "/tmp/atcmd_at1" //SIM 2 channel 0 request socket
+#define MBTK_RILD_REQ_SLOT2_CHANNEL1 "/tmp/atcmd_at1_2" //SIM 2 channel 1 request socket
+#define MBTK_RILD_REQ_SLOT2_CHANNEL2 "/tmp/atcmd_at2_2" //SIM 2 channel 2 request socket
+#define MBTK_RILD_URC_SLOT2 "/tmp/atcmd_urc1" //SIM 2 unsolicite socket
+
#define RIL_CALL_NUM_MAX 10
static bool ril_net_ready = FALSE; // Only one time.
@@ -80,6 +90,7 @@
ril_info_t ril_info;
static mbtk_ril_call_state_info_t call_list[RIL_CALL_NUM_MAX];
static bool cmt_found = FALSE;
+//#define LYNQ_DSDS_SUPPORT 1
extern mbtk_cell_pack_info_t cell_info;
extern ril_cgact_wait_t cgact_wait;
@@ -116,9 +127,11 @@
at_close(ATPORTID_SIM1_0);
at_close(ATPORTID_SIM1_1);
at_close(ATPORTID_SIM1_2);
+#ifdef LYNQ_DSDS_SUPPORT
at_close(ATPORTID_SIM2_0);
at_close(ATPORTID_SIM2_1);
at_close(ATPORTID_SIM2_2);
+#endif
}
/* Called on command or reader thread */
@@ -128,9 +141,11 @@
at_close(ATPORTID_SIM1_0);
at_close(ATPORTID_SIM1_1);
at_close(ATPORTID_SIM1_2);
+#ifdef LYNQ_DSDS_SUPPORT
at_close(ATPORTID_SIM2_0);
at_close(ATPORTID_SIM2_1);
at_close(ATPORTID_SIM2_2);
+#endif
}
static void sock_cli_free_func(void *data)
@@ -2416,13 +2431,13 @@
{
onUnsolicited(MBTK_SIM_1, s, sms_pdu);
}
-
+#ifdef LYNQ_DSDS_SUPPORT
static void onUnsolicited2(const char *s, const char *sms_pdu)
{
onUnsolicited(MBTK_SIM_2, s, sms_pdu);
}
-
-static int openSocket(const char* sockname)
+#endif
+static int openSocket(const char* sockname, bool with_wait)
{
int sock = socket(AF_UNIX, SOCK_STREAM, 0);
if (sock < 0)
@@ -2434,10 +2449,20 @@
memset(&addr, 0, sizeof(addr));
addr.sun_family = AF_UNIX;
strncpy(addr.sun_path, sockname, sizeof(addr.sun_path));
- while (TEMP_FAILURE_RETRY(connect(sock,(const struct sockaddr*)&addr, sizeof(addr))) != 0)
+ if(with_wait) {
+ while (TEMP_FAILURE_RETRY(connect(sock,(const struct sockaddr*)&addr, sizeof(addr))) != 0)
+ {
+ LOGE("Error connect to socket %s: %s, try again", sockname, strerror(errno));
+ sleep(1);
+ }
+ }
+ else
{
- LOGE("Error connect to socket %s: %s, try again", sockname, strerror(errno));
- sleep(1);
+ if (TEMP_FAILURE_RETRY(connect(sock,(const struct sockaddr*)&addr, sizeof(addr))) != 0)
+ {
+ LOGE("Error connect to socket %s: %s, try again", sockname, strerror(errno));
+ // sleep(1);
+ }
}
#if 0
@@ -2461,7 +2486,7 @@
{
at_send_command(portType_2_portId(MBTK_SIM_1, ATPORTTYPE_0), "AT+CEREG=2", NULL);
}
-
+#ifdef LYNQ_DSDS_SUPPORT
// SIM2 radio state config.
ril_info.radio_state[MBTK_SIM_2] = ril_radio_state_get(MBTK_SIM_2, ATPORTTYPE_0);
if (ril_info.radio_state[MBTK_SIM_2] != MBTK_RADIO_STATE_FULL_FUNC)
@@ -2473,7 +2498,7 @@
{
at_send_command(portType_2_portId(MBTK_SIM_2, ATPORTTYPE_0), "AT+CEREG=2", NULL);
}
-
+#endif
// SIM1 state config.
ril_info.sim_state[MBTK_SIM_1] = ril_sim_state_get(MBTK_SIM_1, ATPORTTYPE_0);
if(ril_info.sim_state[MBTK_SIM_1] == MBTK_SIM_STATE_READY)
@@ -2488,12 +2513,12 @@
{
LOGE("SIM1 NOT READY!");
}
-
+#ifdef LYNQ_DSDS_SUPPORT
// SIM2 state config.
ril_info.sim_state[MBTK_SIM_2] = ril_sim_state_get(MBTK_SIM_2, ATPORTTYPE_0);
if(ril_info.sim_state[MBTK_SIM_2] == MBTK_SIM_STATE_READY)
{
- LOGD("SIM1 READY!");
+ LOGD("SIM2 READY!");
at_send_command(portType_2_portId(MBTK_SIM_2, ATPORTTYPE_0), "AT+COPS=3", NULL);
// Set APN from prop.
@@ -2501,9 +2526,9 @@
}
else
{
- LOGE("SIM1 NOT READY!");
+ LOGE("SIM2 NOT READY!");
}
-
+#endif
if(req_dual_sim_get(ATPORTTYPE_0, &(ril_info.cur_sim_id), NULL)) {
LOGE("req_dual_sim_get() fail, so set to SIM1.");
ril_info.cur_sim_id = MBTK_SIM_1;
@@ -2687,6 +2712,7 @@
else // Set band success.
{
LOGD("Set SIM1 band success.");
+ #ifdef LYNQ_DSDS_SUPPORT
cme_err = MBTK_RIL_ERR_CME_NON;
if(req_band_set(MBTK_SIM_2, ATPORTTYPE_0, &band_info.band_support, &cme_err) || cme_err != MBTK_RIL_ERR_CME_NON)
{
@@ -2696,6 +2722,7 @@
{
LOGD("Set SIM2 band success.");
// log_hex("BAND-2", &band_set_info, sizeof(band_set_info_t));
+ #endif
band_info.band_set_success = TRUE;
if(band_info.band_area == MBTK_MODEM_BAND_AREA_CN) {
property_set("persist.mbtk.band_config", "CN");
@@ -2706,7 +2733,9 @@
} else {
property_set("persist.mbtk.band_config", "ALL");
}
+ #ifdef LYNQ_DSDS_SUPPORT
}
+ #endif
}
break;
}
@@ -2838,14 +2867,23 @@
// Update AT port in the first.
cli_info->port = (ATPortType_enum)((*pack_ptr)->at_port);
cli_info->sim_id = (mbtk_sim_type_enum)((*pack_ptr)->sim_id);
- if(cli_info->sim_id == MBTK_SIM_AUTO) {
- cli_info->sim_id = ril_info.cur_sim_id;
- LOGD("Auto sim => %d", cli_info->sim_id);
+ #ifndef LYNQ_DSDS_SUPPORT
+ if(cli_info->sim_id == MBTK_SIM_2)
+ {
+ ril_error_pack_send(cli_info->sim_id, cli_info->port, cli_info->fd,(*pack_ptr)->msg_id , (*pack_ptr)->msg_index, MBTK_RIL_ERR_UNSUPPORTED);
}
+ else
+ #endif
+ {
+ if(cli_info->sim_id == MBTK_SIM_AUTO) {
+ cli_info->sim_id = ril_info.cur_sim_id;
+ LOGD("Auto sim => %d", cli_info->sim_id);
+ }
- pack_distribute(cli_info, *pack_ptr);
- // Not free,will free in pack_process() or packet process thread.
- //mbtk_info_pack_free(pack_ptr);
+ pack_distribute(cli_info, *pack_ptr);
+ // Not free,will free in pack_process() or packet process thread.
+ //mbtk_info_pack_free(pack_ptr);
+ }
pack_ptr++;
}
@@ -3228,61 +3266,62 @@
ready_state_update();
- int at_sock = openSocket("/tmp/atcmd_at");
+ // Must wait for atcmdsrv ready.
+ int at_sock = openSocket(MBTK_RILD_REQ_SLOT1_CHANNEL0, TRUE);
if(at_sock < 0)
{
LOGE("Open AT Socket Fail[%d].", errno);
return -1;
}
- int uart_sock = openSocket("/tmp/atcmd_urc");
+ int uart_sock = openSocket(MBTK_RILD_URC_SLOT1, FALSE);
if(uart_sock < 0)
{
LOGE("Open Uart Socket Fail[%d].", errno);
return -1;
}
- int at_sock_1 = openSocket("/tmp/atcmd_at_1");
+ int at_sock_1 = openSocket(MBTK_RILD_REQ_SLOT1_CHANNEL1, FALSE);
if(at_sock_1 < 0)
{
LOGE("Open AT Socket Fail[%d].", errno);
return -1;
}
- int at_sock_2 = openSocket("/tmp/atcmd_at_2");
+ int at_sock_2 = openSocket(MBTK_RILD_REQ_SLOT1_CHANNEL2, FALSE);
if(at_sock_2 < 0)
{
LOGE("Open AT Socket Fail[%d].", errno);
return -1;
}
-
- int uart_sock1 = openSocket("/tmp/atcmd_urc1");
+#ifdef LYNQ_DSDS_SUPPORT
+ int uart_sock1 = openSocket(MBTK_RILD_URC_SLOT2, FALSE);
if(uart_sock1 < 0)
{
LOGE("Open Uart Socket Fail[%d].", errno);
return -1;
}
- int at_sock1 = openSocket("/tmp/atcmd_at1");
+ int at_sock1 = openSocket(MBTK_RILD_REQ_SLOT2_CHANNEL0, FALSE);
if(at_sock1 < 0)
{
LOGE("Open AT Socket Fail[%d].", errno);
return -1;
}
- int at_sock1_1 = openSocket("/tmp/atcmd_at1_1");
+ int at_sock1_1 = openSocket(MBTK_RILD_REQ_SLOT2_CHANNEL1, FALSE);
if(at_sock1_1 < 0)
{
LOGE("Open AT Socket Fail[%d].", errno);
return -1;
}
- int at_sock1_2 = openSocket("/tmp/atcmd_at1_2");
+ int at_sock1_2 = openSocket(MBTK_RILD_REQ_SLOT2_CHANNEL2, FALSE);
if(at_sock1_2 < 0)
{
LOGE("Open AT Socket Fail[%d].", errno);
return -1;
}
-
+#endif
at_set_on_reader_closed(onATReaderClosed);
at_set_on_timeout(onATTimeout);
@@ -3312,21 +3351,22 @@
LOGD("SIM1 AT OK.");
+#ifdef LYNQ_DSDS_SUPPORT
if(at_open(ATPORTID_SIM2_0, at_sock1, uart_sock1, onUnsolicited2))
{
- LOGE("Start AT_0 thread fail.");
+ LOGE("Start ATPORTID_SIM2_0 thread fail.");
return -1;
}
if(at_open(ATPORTID_SIM2_1, at_sock1_1, uart_sock1, onUnsolicited2))
{
- LOGE("Start AT_1 thread fail.");
+ LOGE("Start ATPORTID_SIM2_1 thread fail.");
return -1;
}
if(at_open(ATPORTID_SIM2_2, at_sock1_2, uart_sock1, onUnsolicited2))
{
- LOGE("Start AT_1 thread fail.");
+ LOGE("Start ATPORTID_SIM2_2 thread fail.");
return -1;
}
@@ -3339,7 +3379,7 @@
}
LOGD("SIM2 AT OK.");
-
+#endif
if(ril_server_start())
{
LOGE("ril_server_start() fail.");