Reset 5G support.
Change-Id: I0d8f3f6962ef7c1e17892afabbcce6c93a2e698d
diff --git a/mbtk/mbtk_rild_v2/src/main.c b/mbtk/mbtk_rild_v2/src/main.c
index c196470..da1e040 100755
--- a/mbtk/mbtk_rild_v2/src/main.c
+++ b/mbtk/mbtk_rild_v2/src/main.c
@@ -121,14 +121,14 @@
at_close(ATPORTTYPE_2);
}
-static void sock_cli_free_func(void *data)
-{
- if (data)
- {
+static void sock_cli_free_func(void *data)
+{
+ if (data)
+ {
sock_cli_info_t *info = (sock_cli_info_t*) data;
LOGD("Free Socket client[fd = %d].", info->fd);
- free(info);
- }
+ free(info);
+ }
}
bool asr_auto_data_call_enable()
@@ -256,109 +256,109 @@
}
static sock_cli_info_t* cli_find(int fd)
-{
+{
sock_cli_info_t *result = NULL;
list_first(ril_info.sock_client_list);
while ((result = (sock_cli_info_t*) list_next(ril_info.sock_client_list)))
- {
- if (result->fd == fd)
- return result;
- }
-
- return NULL;
+ {
+ if (result->fd == fd)
+ return result;
+ }
+
+ return NULL;
}
static void cli_close(sock_cli_info_t* client)
-{
- struct epoll_event ev;
- memset(&ev,0,sizeof(struct epoll_event));
- ev.data.fd = client->fd;
- ev.events = EPOLLIN | EPOLLERR | EPOLLET;
+{
+ struct epoll_event ev;
+ memset(&ev,0,sizeof(struct epoll_event));
+ ev.data.fd = client->fd;
+ ev.events = EPOLLIN | EPOLLERR | EPOLLET;
epoll_ctl(ril_info.epoll_fd, EPOLL_CTL_DEL, client->fd, &ev);
-
- close(client->fd);
-
+
+ close(client->fd);
+
if(list_remove(ril_info.sock_client_list, client))
- {
- sock_cli_free_func(client);
- }
-}
-
+ {
+ sock_cli_free_func(client);
+ }
+}
+
static void ril_error_pack_send(ATPortType_enum port, int fd, int ril_id, int msg_index, int err)
-{
+{
ril_msg_pack_info_t* pack = ril_msg_pack_creat(port, RIL_MSG_TYPE_RSP, ril_id, msg_index, NULL, 0);
- if(pack)
+ if(pack)
{
pack->err = (uint16)err;
ril_pack_send(fd, pack);
ril_msg_pack_free(pack);
- }
- else
- {
+ }
+ else
+ {
LOGW("ril_msg_pack_creat() fail.");
- }
-}
-
+ }
+}
+
void ril_rsp_pack_send(ATPortType_enum port, int fd, int ril_id, int msg_index, const void* data, int data_len)
{
ril_msg_pack_info_t* pack = ril_msg_pack_creat(port, RIL_MSG_TYPE_RSP, ril_id, msg_index, data, data_len);
- if(pack)
- {
+ if(pack)
+ {
pack->err = (uint16)MBTK_RIL_ERR_SUCCESS;
#if 0
- if(data != NULL && data_len > 0)
- {
- pack->data_len = (uint16)data_len;
+ if(data != NULL && data_len > 0)
+ {
+ pack->data_len = (uint16)data_len;
pack->data = (uint8*)mbtk_memcpy(data, data_len);
}
#endif
ril_pack_send(fd, pack);
ril_msg_pack_free(pack);
- }
- else
- {
+ }
+ else
+ {
LOGW("ril_msg_pack_creat() fail.");
- }
+ }
}
void ril_ind_pack_send(int fd, int msg_id, const void* data, int data_len)
-{
+{
ril_msg_pack_info_t* pack = ril_msg_pack_creat(ATPORTTYPE_NON, RIL_MSG_TYPE_IND, msg_id, RIL_MSG_INDEX_INVALID, data, data_len);
- if(pack)
- {
+ if(pack)
+ {
pack->err = (uint16)0;
#if 0
- if(data != NULL && data_len > 0)
- {
- pack->data_len = (uint16)data_len;
+ if(data != NULL && data_len > 0)
+ {
+ pack->data_len = (uint16)data_len;
pack->data = (uint8*)mbtk_memcpy(data, data_len);
}
#endif
ril_pack_send(fd, pack);
ril_msg_pack_free(pack);
- }
- else
- {
+ }
+ else
+ {
LOGW("ril_msg_pack_creat() fail.");
- }
+ }
}
void ril_state_change(ril_msg_id_enum msg_id, const 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_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;
- }
- }
- }
- }
+ break;
+ }
+ }
+ }
+ }
}
static int urc_msg_distribute(bool async_process, ril_msg_id_enum msg_id, const void *data, int data_len)
@@ -378,7 +378,7 @@
}
// Async process urc msg.
- if(async_process) {
+ 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;
@@ -721,7 +721,6 @@
// $CREG: 1, "8330", "06447347", 7,"0d4", 2, 0
// $CREG: 1, "8010", "000060a7", 0,, 2, 0
// +CGREG: 1
-// +C5GREG: 1,"00280386","07e920010",11,1,"01"
static void urc_net_reg_state_change_process(const char *s, const char *sms_pdu)
{
mbtk_ril_net_reg_state_info_t state;
@@ -733,8 +732,6 @@
state.type = MBTK_NET_REG_TYPE_CALL;
} else if(strStartsWith(s, "+CGREG:")) {
state.type = MBTK_NET_REG_TYPE_DATA_GSM_WCDMA;
- } else if(strStartsWith(s, "+C5GREG:")) {
- state.type = MBTK_NET_REG_TYPE_DATA_NR;
} else {
state.type = MBTK_NET_REG_TYPE_DATA_LTE;
}
@@ -752,24 +749,23 @@
goto CGREG_EXIT;
}
state.reg_state = (mbtk_net_reg_state_enum)tmp_int; // Reg State.
- if (state.reg_state && at_tok_hasmore(&line)) // Reg
+ if (state.reg_state) // Reg
{
- if (at_tok_nextstr(&line, &tmp_str) < 0) // tac
+ if (at_tok_nextstr(&line, &tmp_str) < 0)
{
goto CGREG_EXIT;
}
- state.tac = (uint64)strtoull(tmp_str, NULL, 16);
- if (at_tok_nextstr(&line, &tmp_str) < 0) // ci
+ if (at_tok_nextstr(&line, &tmp_str) < 0)
{
goto CGREG_EXIT;
}
- state.ci = (uint64)strtoull(tmp_str, NULL, 16);
if (at_tok_nextint(&line, &tmp_int) < 0)
{
goto CGREG_EXIT;
}
+
state.tech = (mbtk_radio_technology_enum)tmp_int; // AcT
}
@@ -1091,286 +1087,6 @@
static void urc_cell_info_process(const char *s, const char *sms_pdu)
{
- // +EEMNRSVC: <mcc>,<lenOfMnc>,<mnc>,<tac>,<phyCellId>,<dlNrArfcn>,<dlScs>,<ulNrArfcn>,<ulScs>,<sulNrArfcn>,<sulScs>,<band>,<dlBandwidth>,<cellId>,<IsRedCapCell>,<longDRXCyclePresent>,<shortDRXCyclePresent>,<longDRXCycle>,<shortDRXCycle>,<pagingCycle>,
- // <rsrp>,<rsrq>,<sinr>,<rssi>,<qRxLevMin>,<qQualMin>,<srxlev>,
- // <pathLoss>,
- // <dlBler>,<averDlPRB>,<averDlMcs>,<averDlPortNum>,<averCQI>,<averLi>,<averRi>,<dlThroughPut>,<dlPeakThroughPut>,
- // <ulBler>,<averUlPRB>,<averUlMcs>,<averUlPortNum>,<currPuschTxPower>,<currPucchTxPower>,<grantTotal>,<ulThroughPut>,<ulPeakThroughPut>,
- // <nrrcModeState>,<nmmState>,<serviceState>,<IsSingleNmmRejectCause>,<NMMRejectCause>,<amfRegionId>,<amfSetId>,<amfPointer>,<nrTmsi>,
- // <ulBandwidth>,<dlInitialBwpFreq>,<ulInitialBwpFreq>
- /*
- +EEMNRSVC: 1120, 2, 0, 2622342, 137, 158650, 0, 146678, 0, 0, 255, 28, 79, 620598788208, 0, 0, 0, 0, 0, 64,
- 86, 65, 86, 51, 20, 0, 49,
- 0,
- 0, 0, 0, 0, 38, 0, 8, 0, 0,
- 0, 256, 24, 16, 13, 20, 2, 2, 0,
- 1, 10, 0, 1, 0, 9, 128, 5, 2358781729,
- 79, 788390, 733390
- */
- if(strStartsWith(s, "+EEMNRSVC:")) {
- // mcc,lenOfMnc,mnc,tac,PCI,dlNrArfcn,ulNrArfcn,band,rsrp,rsrq,sinr,rssi
- // cellID
- if(cell_info.running) {
- int tmp_int;
- int i = 0;
- char* tmp_s = memdup(s,strlen(s) + 1);
- char* free_ptr = tmp_s;
- char *line = tmp_s;
- char *tmp_str;
- if (at_tok_start(&line) < 0)
- {
- goto EEMNRSVC_EXIT;
- }
-
- if (at_tok_nextint(&line, &tmp_int) < 0) // mcc
- {
- goto EEMNRSVC_EXIT;
- }
- cell_info.cell_list.cell[cell_info.cell_list.num].value1 = (uint32)tmp_int;
-
- if (at_tok_nextint(&line, &tmp_int) < 0) // lenOfMnc
- {
- goto EEMNRSVC_EXIT;
- }
- cell_info.cell_list.cell[cell_info.cell_list.num].value2 = (uint32)tmp_int;
- if (at_tok_nextint(&line, &tmp_int) < 0) // mnc
- {
- goto EEMNRSVC_EXIT;
- }
- cell_info.cell_list.cell[cell_info.cell_list.num].value3 = (uint32)tmp_int;
-
- if (at_tok_nextint(&line, &tmp_int) < 0) // tac
- {
- goto EEMNRSVC_EXIT;
- }
- cell_info.cell_list.cell[cell_info.cell_list.num].value4 = (uint32)tmp_int;
-
- if (at_tok_nextint(&line, &tmp_int) < 0) // pci
- {
- goto EEMNRSVC_EXIT;
- }
- cell_info.cell_list.cell[cell_info.cell_list.num].value5 = (uint32)tmp_int;
-
- if (at_tok_nextint(&line, &tmp_int) < 0) // dlNrArfcn
- {
- goto EEMNRSVC_EXIT;
- }
- cell_info.cell_list.cell[cell_info.cell_list.num].value6 = (uint32)tmp_int;
-
- if (at_tok_nextint(&line, &tmp_int) < 0) // dlScs
- {
- goto EEMNRSVC_EXIT;
- }
-
- if (at_tok_nextint(&line, &tmp_int) < 0) // ulNrArfcn
- {
- goto EEMNRSVC_EXIT;
- }
- cell_info.cell_list.cell[cell_info.cell_list.num].value7 = (uint32)tmp_int;
-
- // <ulScs>,<sulNrArfcn>,<sulScs>
- for(i =0; i < 3; i++)
- {
- if (at_tok_nextint(&line, &tmp_int) < 0)
- {
- goto EEMNRSVC_EXIT;
- }
- }
-
- if (at_tok_nextint(&line, &tmp_int) < 0) // band
- {
- goto EEMNRSVC_EXIT;
- }
- cell_info.cell_list.cell[cell_info.cell_list.num].value8 = (uint32)tmp_int;
-
-
- if (at_tok_nextint(&line, &tmp_int) < 0) // dlBandwidth
- {
- goto EEMNRSVC_EXIT;
- }
-
-
- if (at_tok_nextstr(&line, &tmp_str) < 0) // cellId
- {
- goto EEMNRSVC_EXIT;
- }
- // LOGD("cellID-str : %s", tmp_str);
- cell_info.cell_list.cell[cell_info.cell_list.num].value64_1 = (uint64)strtoull(tmp_str, NULL, 10);
- // LOGD("cellID : %llu", cell_info.cell_list.cell[cell_info.cell_list.num].value64_1);
-
- // <IsRedCapCell>,<longDRXCyclePresent>,<shortDRXCyclePresent>,<longDRXCycle>,<shortDRXCycle>,<pagingCycle>
- for(i =0; i < 6; i++)
- {
- if (at_tok_nextint(&line, &tmp_int) < 0)
- {
- goto EEMNRSVC_EXIT;
- }
- }
-
- if (at_tok_nextint(&line, &tmp_int) < 0) // <rsrp>
- {
- goto EEMNRSVC_EXIT;
- }
- cell_info.cell_list.cell[cell_info.cell_list.num].value9 = (uint32)tmp_int;
-
- if (at_tok_nextint(&line, &tmp_int) < 0) // <rsrq>
- {
- goto EEMNRSVC_EXIT;
- }
- cell_info.cell_list.cell[cell_info.cell_list.num].value10 = (uint32)tmp_int;
-
- if (at_tok_nextint(&line, &tmp_int) < 0) // <sinr>
- {
- goto EEMNRSVC_EXIT;
- }
- cell_info.cell_list.cell[cell_info.cell_list.num].value11 = (uint32)tmp_int;
-
- if (at_tok_nextint(&line, &tmp_int) < 0) // <rssi>
- {
- goto EEMNRSVC_EXIT;
- }
- cell_info.cell_list.cell[cell_info.cell_list.num].value12 = (uint32)tmp_int;
-
- cell_info.cell_list.num++;
-
-EEMNRSVC_EXIT:
- free(free_ptr);
- }
- }
- // +EEMNRINTER: <index>,<phyCellId>,<nrArfcn>,<dlScs>,<rsrp>,<rsrq>,<sinr>,<srxlev>,<mcc>,<lenOfMnc>,<mnc>,<tac>,<cellId>
- /* +EEMNRINTER: 0, 508, 723360, 0, 39, 64, -8, 1, 0, 0, 0, 0, 4294967295 */
- /* +EEMNRINTER: 1, 254, 723360, 0, 45, 72, 1, 7, 0, 0, 0, 0, 4294967295 */
- /* +EEMNRINTER: 2, 595, 723360, 0, 40, 65, -5, 3, 0, 0, 0, 0, 4294967295 */
- else if(strStartsWith(s, "+EEMNRINTER:")) {
- // phyCellId,nrArfcn,rsrp,rsrq
- if(cell_info.running) {
- int tmp_int;
- char* tmp_s = memdup(s,strlen(s) + 1);
- char* free_ptr = tmp_s;
- char *line = tmp_s;
- if (at_tok_start(&line) < 0)
- {
- goto EEMNRINTER_EXIT;
- }
- if (at_tok_nextint(&line, &tmp_int) < 0) // index
- {
- goto EEMNRINTER_EXIT;
- }
- if (at_tok_nextint(&line, &tmp_int) < 0 || tmp_int < 0 || tmp_int > 1007) // phyCellId (0 - 1007)
- {
- goto EEMNRINTER_EXIT;
- }
- cell_info.cell_list.cell[cell_info.cell_list.num].value1 = (uint32)tmp_int;
- if (at_tok_nextint(&line, &tmp_int) < 0) // nrArfcn
- {
- goto EEMNRINTER_EXIT;
- }
- cell_info.cell_list.cell[cell_info.cell_list.num].value2 = (uint32)tmp_int;
- if (at_tok_nextint(&line, &tmp_int) < 0) // dlScs
- {
- goto EEMNRINTER_EXIT;
- }
- if (at_tok_nextint(&line, &tmp_int) < 0) // rsrp
- {
- goto EEMNRINTER_EXIT;
- }
- cell_info.cell_list.cell[cell_info.cell_list.num].value3 = (uint32)tmp_int;
- if (at_tok_nextint(&line, &tmp_int) < 0) // rsrq
- {
- goto EEMNRINTER_EXIT;
- }
- cell_info.cell_list.cell[cell_info.cell_list.num].value4 = (uint32)tmp_int;
-
- cell_info.cell_list.num++;
-EEMNRINTER_EXIT:
- free(free_ptr);
- }
- }
- // +EEMNRINTERRAT:<net_type>,<numInterRATEutra>,
- // <earfcn>,<physCellId>,<rsrp>,<rsrq>,<sinr>,<mcc>,<lenOfMnc>,<mnc>,<tac>
- // ......
- // <earfcn>,<physCellId>,<rsrp>,<rsrq>,<sinr>,<mcc>,<lenOfMnc>,<mnc>,<tac>
- /*
- +EEMNRINTERRAT: 2, 6, // LTE
- 1300, 423, 0, 0, 0, 0, 0, 0, 0,
- 1300, 137, 0, 0, 0, 0, 0, 0, 0,
- 1300, 149, 0, 0, 0, 0, 0, 0, 0,
- 1300, 494, 0, 0, 0, 0, 0, 0, 0,
- 1300, 337, 0, 0, 0, 0, 0, 0, 0,
- 1300, 288, 0, 0, 0, 0, 0, 0, 0
- */
- /*
- +EEMNRINTERRAT: 1, 0 // UMTS
- */
- else if(strStartsWith(s, "+EEMNRINTERRAT:")) {
- // phyCellId,nrArfcn,rsrp,rsrq
- if(cell_info.running) {
- int tmp_int;
- char* tmp_s = memdup(s,strlen(s) + 1);
- char* free_ptr = tmp_s;
- char *line = tmp_s;
- if (at_tok_start(&line) < 0)
- {
- goto EEMNRINTERRAT_EXIT;
- }
- if (at_tok_nextint(&line, &tmp_int) < 0) // net_type
- {
- goto EEMNRINTERRAT_EXIT;
- }
-
-#define CI_DEV_EM_NETWORK_LTE 2
-
- // Only support LTE.
- if(tmp_int == CI_DEV_EM_NETWORK_LTE) { // LTE
- int num;
- int i, j;
- if (at_tok_nextint(&line, &num) < 0) // numInterRATEutra
- {
- goto EEMNRINTERRAT_EXIT;
- }
- LOGD("LTE-RAT num : %d", num);
- for(i = 0; i < num; i++) {
- if (at_tok_nextint(&line, &tmp_int) < 0) // earfcn
- {
- goto EEMNRINTERRAT_EXIT;
- }
- cell_info.cell_list.cell[cell_info.cell_list.num].value2 = (uint32)tmp_int;
-
- if (at_tok_nextint(&line, &tmp_int) < 0) // physCellId
- {
- goto EEMNRINTERRAT_EXIT;
- }
- cell_info.cell_list.cell[cell_info.cell_list.num].value1 = (uint32)tmp_int;
-
- if (at_tok_nextint(&line, &tmp_int) < 0) // rsrp
- {
- goto EEMNRINTERRAT_EXIT;
- }
- cell_info.cell_list.cell[cell_info.cell_list.num].value3 = (uint32)tmp_int;
-
- if (at_tok_nextint(&line, &tmp_int) < 0) // rsrq
- {
- goto EEMNRINTERRAT_EXIT;
- }
- cell_info.cell_list.cell[cell_info.cell_list.num].value4 = (uint32)tmp_int;
-
- // Jump 5 items.
- j = 0;
- while(j < 5) {
- if (at_tok_nextint(&line, &tmp_int) < 0)
- {
- goto EEMNRINTERRAT_EXIT;
- }
- j++;
- }
-
- cell_info.cell_list.num++;
- }
- }
-EEMNRINTERRAT_EXIT:
- free(free_ptr);
- }
- }
/*
// <mcc>, <length of mnc>, <mnc>, <tac>, <PCI>, <dlEuarfcn>, < ulEuarfcn >, <band>, <dlBandwidth>,
// <rsrp>,<rsrq>, <sinr>,
@@ -1389,7 +1105,7 @@
0, 0,
7, 44
*/
- else if(strStartsWith(s, "+EEMLTESVC:")) // LTE Server Cell
+ if(strStartsWith(s, "+EEMLTESVC:")) // LTE Server Cell
{
// tac, PCI, dlEuarfcn, ulEuarfcn, band
if(cell_info.running) {
@@ -2019,9 +1735,7 @@
} else if(strStartsWith(s, "CONNECT") || strStartsWith(s, "+CGEV:")) {
urc_pdp_state_change_process(s, sms_pdu);
- } else if(strStartsWith(s, "+EEMNRSVC:") || strStartsWith(s, "+EEMNRINTER:")
- || strStartsWith(s, "+EEMNRINTERRAT:")
- || strStartsWith(s, "+EEMLTESVC:") || strStartsWith(s, "+EEMLTEINTER:")
+ } else if(strStartsWith(s, "+EEMLTESVC:") || strStartsWith(s, "+EEMLTEINTER:")
|| strStartsWith(s, "+EEMLTEINTRA:") || strStartsWith(s, "+EEMLTEINTERRAT:")
|| strStartsWith(s, "+EEMUMTSSVC:") || strStartsWith(s, "+EEMUMTSINTRA:")
|| strStartsWith(s, "+EEMUMTSINTERRAT:") || strStartsWith(s, "+EEMGINFOBASIC:")
@@ -2052,11 +1766,9 @@
// $CREG: 1, "8330", "06447347", 7,"0d4", 2, 0
// $CREG: 1, "8010", "000060a7", 0,, 2, 0
// +CGREG: 1
- // +C5GREG: 1,"00280386","07e920010",11,1,"01"
else if(strStartsWith(s, "+CGREG:") // GMS/WCDMA data registed.
|| strStartsWith(s, "+CEREG:") // LTE data registed.
- || strStartsWith(s, "+CREG:") // GMS/WCDMA/LTE CS registed.
- || strStartsWith(s, "+C5GREG:")) // NR data registed.
+ || strStartsWith(s, "+CREG:")) // GMS/WCDMA/LTE CS registed.
{
urc_net_reg_state_change_process(s, sms_pdu);
}
@@ -2412,57 +2124,57 @@
return sock;
}
-static void ril_at_ready_process()
-{
+static void ril_at_ready_process()
+{
ril_info.radio_state = ril_radio_state_get(ATPORTTYPE_0);
if (ril_info.radio_state != MBTK_RADIO_STATE_FULL_FUNC)
- {
+ {
ril_radio_state_set(ATPORTTYPE_0, MBTK_RADIO_STATE_FULL_FUNC, FALSE);
}
-
+
if(ril_info.radio_state == MBTK_RADIO_STATE_FULL_FUNC)
{
at_send_command(ATPORTTYPE_0, "AT+CEREG=2", NULL);
- }
-
+ }
+
ril_info.sim_state = ril_sim_state_get(ATPORTTYPE_0);
if(ril_info.sim_state == MBTK_SIM_STATE_READY)
- {
- LOGD("SIM READY!");
+ {
+ LOGD("SIM READY!");
at_send_command(ATPORTTYPE_0, "AT+COPS=3", NULL);
// Set APN from prop.
apn_auto_conf_from_prop(ATPORTTYPE_0);
- }
- else
- {
- LOGE("SIM NOT READY!");
+ }
+ else
+ {
+ LOGE("SIM NOT READY!");
}
}
static void ind_regisger(sock_cli_info_t* cli_info, uint16 ind)
-{
- uint32 i = 0;
- while(i < cli_info->ind_num)
- {
- if(cli_info->ind_register[i] == ind)
- break;
- i++;
- }
-
- if(i == cli_info->ind_num) // No found IND
- {
- cli_info->ind_register[i] = ind;
- cli_info->ind_num++;
+{
+ uint32 i = 0;
+ while(i < cli_info->ind_num)
+ {
+ if(cli_info->ind_register[i] == ind)
+ break;
+ i++;
+ }
+
+ if(i == cli_info->ind_num) // No found IND
+ {
+ cli_info->ind_register[i] = ind;
+ cli_info->ind_num++;
LOGD("Register IND : %s", id2str(ind));
- }
- else
- {
+ }
+ else
+ {
LOGW("IND had exist.");
- }
+ }
}
-// Process AT URC data
+// Process AT URC data
static int send_pack_to_queue(sock_cli_info_t* cli_info, void* pack)
{
if(cli_info) {
@@ -2478,14 +2190,14 @@
return -1;
}
}
-
+
ril_msg_queue_info_t *item = (ril_msg_queue_info_t*)malloc(sizeof(ril_msg_queue_info_t));
- if(!item)
- {
+ if(!item)
+ {
LOGE("malloc() fail[%d].", errno);
- return -1;
- }
- item->cli_info = cli_info;
+ return -1;
+ }
+ item->cli_info = cli_info;
item->pack = pack;
if(cli_info) {
@@ -2503,14 +2215,14 @@
pthread_cond_signal(&(ril_info.msg_cond[ATPORTTYPE_0]));
pthread_mutex_unlock(&(ril_info.msg_mutex[ATPORTTYPE_0]));
}
-
- return 0;
+
+ return 0;
}
static void pack_distribute(sock_cli_info_t* cli_info, ril_msg_pack_info_t* pack)
-{
- // Register IND Message.
+{
+ // Register IND Message.
if(pack->msg_type == RIL_MSG_TYPE_REQ)
{
if(pack->msg_id > RIL_MSG_ID_IND_BEGIN
@@ -2547,10 +2259,10 @@
}
}
-// Return MBTK_INFO_ERR_SUCCESS,will call pack_error_send() to send RSP.
-// Otherwise, do not call pack_error_send().
+// Return MBTK_INFO_ERR_SUCCESS,will call pack_error_send() to send RSP.
+// Otherwise, do not call pack_error_send().
static mbtk_ril_err_enum pack_req_process(sock_cli_info_t* cli_info, ril_msg_pack_info_t* pack)
-{
+{
if(pack->msg_id > RIL_MSG_ID_DEV_BEGIN && pack->msg_id < RIL_MSG_ID_DEV_END) {
return dev_pack_req_process(cli_info, pack);
} else if(pack->msg_id > RIL_MSG_ID_SIM_BEGIN && pack->msg_id < RIL_MSG_ID_SIM_END) {
@@ -2574,19 +2286,19 @@
}
static void urc_msg_process(ril_urc_msg_info_t *msg)
-{
+{
// data can be NULL (For RIL_URC_MSG_BAND_SET)
if(!msg->data || msg->data_len <= 0) {
LOGW("URC data is NULL.");
// return;
}
- switch(msg->msg) {
+ switch(msg->msg) {
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;
+ break;
}
case RIL_MSG_ID_IND_SIM_STATE_CHANGE:
{
@@ -2629,95 +2341,95 @@
}
break;
}
- default:
- {
- LOGE("Unknown URC : %d", msg->msg);
- break;
- }
- }
+ default:
+ {
+ LOGE("Unknown URC : %d", msg->msg);
+ break;
+ }
+ }
}
// Read client conn/msg and push into ril_info.msg_queue.
static void* ril_read_pthread(void* arg)
-{
- UNUSED(arg);
+{
+ UNUSED(arg);
ril_info.epoll_fd = epoll_create(SOCK_CLIENT_MAX + 1);
if(ril_info.epoll_fd < 0)
- {
+ {
LOGE("epoll_create() fail[%d].", errno);
- return NULL;
- }
-
- uint32 event = EPOLLIN | EPOLLET;
- struct epoll_event ev;
+ return NULL;
+ }
+
+ uint32 event = EPOLLIN | EPOLLET;
+ struct epoll_event ev;
ev.data.fd = ril_info.sock_listen_fd;
- ev.events = event; //EPOLLIN | EPOLLERR | EPOLLET;
+ ev.events = event; //EPOLLIN | EPOLLERR | EPOLLET;
epoll_ctl(ril_info.epoll_fd, EPOLL_CTL_ADD, ril_info.sock_listen_fd, &ev);
-
- int nready = -1;
- struct epoll_event epoll_events[EPOLL_LISTEN_MAX];
- while(1)
- {
+
+ int nready = -1;
+ struct epoll_event epoll_events[EPOLL_LISTEN_MAX];
+ while(1)
+ {
nready = epoll_wait(ril_info.epoll_fd, epoll_events, EPOLL_LISTEN_MAX, -1);
- if(nready > 0)
- {
+ if(nready > 0)
+ {
sock_cli_info_t *cli_info = NULL;
- int i;
- for(i = 0; i < nready; i++)
- {
- LOG("fd[%d] event = %x",epoll_events[i].data.fd, epoll_events[i].events);
- if(epoll_events[i].events & EPOLLHUP) // Client Close.
- {
- if((cli_info = cli_find(epoll_events[i].data.fd)) != NULL)
- {
- cli_close(cli_info);
- }
- else
- {
- LOG("Unknown client[fd = %d].", epoll_events[i].data.fd);
- }
- }
- else if(epoll_events[i].events & EPOLLIN)
- {
+ int i;
+ for(i = 0; i < nready; i++)
+ {
+ LOG("fd[%d] event = %x",epoll_events[i].data.fd, epoll_events[i].events);
+ if(epoll_events[i].events & EPOLLHUP) // Client Close.
+ {
+ if((cli_info = cli_find(epoll_events[i].data.fd)) != NULL)
+ {
+ cli_close(cli_info);
+ }
+ else
+ {
+ LOG("Unknown client[fd = %d].", epoll_events[i].data.fd);
+ }
+ }
+ else if(epoll_events[i].events & EPOLLIN)
+ {
if(epoll_events[i].data.fd == ril_info.sock_listen_fd) // New clients connected.
- {
- int client_fd = -1;
- while(1)
- {
- struct sockaddr_in cliaddr;
- socklen_t clilen = sizeof(cliaddr);
- client_fd = accept(epoll_events[i].data.fd, (struct sockaddr *) &cliaddr, &clilen);
- if(client_fd < 0)
- {
- if(errno == EAGAIN)
- {
- LOG("All client connect get.");
- }
- else
- {
- LOG("accept() error[%d].", errno);
- }
- break;
- }
- // Set O_NONBLOCK
- int flags = fcntl(client_fd, F_GETFL, 0);
- if (flags > 0)
- {
- flags |= O_NONBLOCK;
- if (fcntl(client_fd, F_SETFL, flags) < 0)
- {
- LOG("Set flags error:%d", errno);
- }
- }
-
- memset(&ev,0,sizeof(struct epoll_event));
- ev.data.fd = client_fd;
- ev.events = event;//EPOLLIN | EPOLLERR | EPOLLET;
+ {
+ int client_fd = -1;
+ while(1)
+ {
+ struct sockaddr_in cliaddr;
+ socklen_t clilen = sizeof(cliaddr);
+ client_fd = accept(epoll_events[i].data.fd, (struct sockaddr *) &cliaddr, &clilen);
+ if(client_fd < 0)
+ {
+ if(errno == EAGAIN)
+ {
+ LOG("All client connect get.");
+ }
+ else
+ {
+ LOG("accept() error[%d].", errno);
+ }
+ break;
+ }
+ // Set O_NONBLOCK
+ int flags = fcntl(client_fd, F_GETFL, 0);
+ if (flags > 0)
+ {
+ flags |= O_NONBLOCK;
+ if (fcntl(client_fd, F_SETFL, flags) < 0)
+ {
+ LOG("Set flags error:%d", errno);
+ }
+ }
+
+ memset(&ev,0,sizeof(struct epoll_event));
+ ev.data.fd = client_fd;
+ ev.events = event;//EPOLLIN | EPOLLERR | EPOLLET;
epoll_ctl(ril_info.epoll_fd, EPOLL_CTL_ADD, client_fd, &ev);
-
+
sock_cli_info_t *info = (sock_cli_info_t*)malloc(sizeof(sock_cli_info_t));
- if(info)
- {
+ if(info)
+ {
memset(info, 0, sizeof(sock_cli_info_t));
info->fd = client_fd;
@@ -2730,101 +2442,160 @@
// 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
- {
- LOG("malloc() fail.");
- }
- }
- }
- else if((cli_info = cli_find(epoll_events[i].data.fd)) != NULL) // Client data arrive.
- {
- // Read and process every message.
+ }
+ else
+ {
+ LOG("malloc() fail.");
+ }
+ }
+ }
+ else if((cli_info = cli_find(epoll_events[i].data.fd)) != NULL) // Client data arrive.
+ {
+ // Read and process every message.
mbtk_ril_err_enum err = MBTK_RIL_ERR_SUCCESS;
ril_msg_pack_info_t** pack = ril_pack_recv(cli_info->fd, true, &err);
- // Parse packet error,send error response to client.
- if(pack == NULL)
- {
+ // Parse packet error,send error response to client.
+ if(pack == NULL)
+ {
ril_error_pack_send(cli_info->port, cli_info->fd, RIL_MSG_ID_UNKNOWN, RIL_MSG_INDEX_INVALID, err);
- }
- else
- {
+ }
+ else
+ {
ril_msg_pack_info_t** pack_ptr = pack;
- while(*pack_ptr)
+ while(*pack_ptr)
{
// Update AT port in the first.
cli_info->port = (ATPortType_enum)((*pack_ptr)->at_port);
- 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++;
- }
-
- free(pack);
- }
- }
- else
- {
- LOG("Unknown socket : %d", epoll_events[i].data.fd);
- }
- }
- else
- {
- LOG("Unknown event : %x", epoll_events[i].events);
- }
- }
- }
- else
- {
- LOG("epoll_wait() fail[%d].", errno);
- }
- }
-
- return NULL;
+ 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++;
+ }
+
+ free(pack);
+ }
+ }
+ else
+ {
+ LOG("Unknown socket : %d", epoll_events[i].data.fd);
+ }
+ }
+ else
+ {
+ LOG("Unknown event : %x", epoll_events[i].events);
+ }
+ }
+ }
+ else
+ {
+ LOG("epoll_wait() fail[%d].", errno);
+ }
+ }
+
+ return NULL;
}
-static void band_support_init()
-{
- mbtk_device_info_modem_t info_modem;
+static void* ril_process_thread(void* arg)
+{
+ UNUSED(arg);
+ ATPortType_enum *port = (ATPortType_enum*)arg;
+ ril_msg_queue_info_t* item = NULL;
+
+ pthread_mutex_lock(&(ril_info.msg_mutex[*port]));
+ while(TRUE)
+ {
+ if(mbtk_queue_empty(&(ril_info.msg_queue[*port])))
+ {
+ LOG("[Port-%d]Packet process wait...", *port);
+ pthread_cond_wait(&(ril_info.msg_cond[*port]), &(ril_info.msg_mutex[*port]));
+ LOG("[Port-%d]Packet process continue...", *port);
+ }
+ else
+ {
+ LOG("Packet process queue not empty,continue...");
+ }
+
+ // Process all information request.
+ mbtk_ril_err_enum err;
+ while((item = (ril_msg_queue_info_t*)mbtk_queue_get(&(ril_info.msg_queue[*port]))) != NULL)
+ {
+ if(item->cli_info) { // REQ form client.
+ ril_msg_pack_info_t *pack = (ril_msg_pack_info_t*)item->pack;
+ LOGD("Process REQ %s.", id2str(pack->msg_id));
+ ril_info.at_process[*port] = true;
+ err = pack_req_process(item->cli_info, pack);
+ if(err != MBTK_RIL_ERR_SUCCESS)
+ {
+ ril_error_pack_send(item->cli_info->port, item->cli_info->fd, pack->msg_id, pack->msg_index, err);
+ }
+ ril_info.at_process[*port] = false;
+ ril_msg_pack_free(pack);
+ free(item);
+ } 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);
+ }
+ }
+ }
+ }
+ pthread_mutex_unlock(&(ril_info.msg_mutex[*port]));
+
+ free(port);
+
+ return NULL;
+}
+
+/*
+AT*BAND=15,78,147,482,134742231
+
+OK
+*/
+static void* band_config_thread()
+{
+ mbtk_device_info_modem_t info_modem;
memset(&band_info.band_support, 0, sizeof(mbtk_band_info_t));
- memset(&info_modem, 0, sizeof(mbtk_device_info_modem_t));
-#ifdef MBTK_DEV_INFO_VERSION_2
- if(mbtk_dev_info_read(MBTK_DEVICE_INFO_ITEM_MODEM, &(info_modem), sizeof(mbtk_device_info_modem_t))) {
+ memset(&info_modem, 0, sizeof(mbtk_device_info_modem_t));
+ band_info.band_set_success = FALSE;
+ if(mbtk_dev_info_read(MBTK_DEVICE_INFO_ITEM_MODEM, &(info_modem), sizeof(mbtk_device_info_modem_t))) {
LOGD("mbtk_dev_info_read(MODEM) fail, use default band.");
band_info.band_area = MBTK_MODEM_BAND_AREA_ALL;
+#ifdef MBTK_DEV_INFO_VERSION_2
+
#ifdef MBTK_5G_SUPPORT
band_info.band_support.net_pref = MBTK_NET_PREF_LTE_NR_NR_PREF; // 19
band_info.net_support = MBTK_NET_SUPPORT_4G | MBTK_NET_SUPPORT_5G;
-
- band_info.band_support.gsm_band = 0;
- band_info.band_support.umts_band = 0;
- band_info.band_support.tdlte_band = MBTK_BAND_ALL_TDLTE_DEFAULT;
- band_info.band_support.fddlte_band = MBTK_BAND_ALL_FDDLTE_DEFAULT;
- band_info.band_support.lte_ext_band = MBTK_BAND_ALL_EXT_LTE_DEFAULT;
-
- band_info.band_support.nr_3_band = MBTK_BAND_ALL_NR_3_DEFAULT;
- band_info.band_support.nr_2_band = MBTK_BAND_ALL_NR_2_DEFAULT;
- band_info.band_support.nr_1_band = MBTK_BAND_ALL_NR_1_DEFAULT;
- band_info.band_support.nr_0_band = MBTK_BAND_ALL_NR_0_DEFAULT;
#else
band_info.band_support.net_pref = MBTK_NET_PREF_GSM_UMTS_LTE_LTE_PREF; // 15
band_info.net_support = MBTK_NET_SUPPORT_2G | MBTK_NET_SUPPORT_3G | MBTK_NET_SUPPORT_4G;
+#endif
+#else
+
+ band_info.band_support.net_pref = MBTK_NET_PREF_GSM_UMTS_LTE_LTE_PREF; // 15
+
+#endif
band_info.band_support.gsm_band = MBTK_BAND_ALL_GSM_DEFAULT;
band_info.band_support.umts_band = MBTK_BAND_ALL_WCDMA_DEFAULT;
band_info.band_support.tdlte_band = MBTK_BAND_ALL_TDLTE_DEFAULT;
band_info.band_support.fddlte_band = MBTK_BAND_ALL_FDDLTE_DEFAULT;
band_info.band_support.lte_ext_band = MBTK_BAND_ALL_EXT_LTE_DEFAULT;
- band_info.band_support.nr_3_band = 0;
- band_info.band_support.nr_2_band = 0;
- band_info.band_support.nr_1_band = 0;
- band_info.band_support.nr_0_band = 0;
+#ifdef MBTK_DEV_INFO_VERSION_2
+ band_info.band_support.nr_3_band = MBTK_BAND_ALL_NR_3_DEFAULT;
+ band_info.band_support.nr_2_band = MBTK_BAND_ALL_NR_2_DEFAULT;
+ band_info.band_support.nr_1_band = MBTK_BAND_ALL_NR_1_DEFAULT;
+ band_info.band_support.nr_0_band = MBTK_BAND_ALL_NR_0_DEFAULT;
#endif
- } else {
+ } else {
band_info.band_area = info_modem.band_area;
+#ifdef MBTK_DEV_INFO_VERSION_2
band_info.net_support = info_modem.net_support;
if(info_modem.net_pref < MBTK_NET_PREF_MAX) {
band_info.band_support.net_pref = info_modem.net_pref;
@@ -2835,115 +2606,22 @@
band_info.band_support.net_pref = MBTK_NET_PREF_GSM_UMTS_LTE_LTE_PREF; // 15
}
}
+#else
+ band_info.band_support.net_pref = MBTK_NET_PREF_GSM_UMTS_LTE_LTE_PREF; // 15
+#endif
band_info.band_support.gsm_band = info_modem.band_gsm;
band_info.band_support.umts_band = info_modem.band_wcdma;
band_info.band_support.tdlte_band = info_modem.band_tdlte;
band_info.band_support.fddlte_band = info_modem.band_fddlte;
band_info.band_support.lte_ext_band = info_modem.band_lte_ext;
-
+#ifdef MBTK_DEV_INFO_VERSION_2
band_info.band_support.nr_3_band = info_modem.band_nr_3;
band_info.band_support.nr_2_band = info_modem.band_nr_2;
band_info.band_support.nr_1_band = info_modem.band_nr_1;
band_info.band_support.nr_0_band = info_modem.band_nr_0;
- }
-#else
- if(mbtk_dev_info_read(MBTK_DEVICE_INFO_ITEM_MODEM, &(info_modem), sizeof(mbtk_device_info_modem_t))) {
- LOGD("mbtk_dev_info_read(MODEM) fail, use default band.");
- band_info.band_area = MBTK_MODEM_BAND_AREA_ALL;
- band_info.band_support.net_pref = MBTK_NET_PREF_GSM_UMTS_LTE_LTE_PREF; // 15
- band_info.net_support = MBTK_NET_SUPPORT_2G | MBTK_NET_SUPPORT_3G | MBTK_NET_SUPPORT_4G;
-
- band_info.band_support.gsm_band = MBTK_BAND_ALL_GSM_DEFAULT;
- band_info.band_support.umts_band = MBTK_BAND_ALL_WCDMA_DEFAULT;
- band_info.band_support.tdlte_band = MBTK_BAND_ALL_TDLTE_DEFAULT;
- band_info.band_support.fddlte_band = MBTK_BAND_ALL_FDDLTE_DEFAULT;
- band_info.band_support.lte_ext_band = MBTK_BAND_ALL_EXT_LTE_DEFAULT;
-
- band_info.band_support.nr_3_band = 0;
- band_info.band_support.nr_2_band = 0;
- band_info.band_support.nr_1_band = 0;
- band_info.band_support.nr_0_band = 0;
- } else {
- band_info.band_area = info_modem.band_area;
- band_info.net_support = MBTK_NET_SUPPORT_2G | MBTK_NET_SUPPORT_3G | MBTK_NET_SUPPORT_4G;
- band_info.band_support.net_pref = MBTK_NET_PREF_GSM_UMTS_LTE_LTE_PREF; // 15
- band_info.band_support.gsm_band = info_modem.band_gsm;
- band_info.band_support.umts_band = info_modem.band_wcdma;
- band_info.band_support.tdlte_band = info_modem.band_tdlte;
- band_info.band_support.fddlte_band = info_modem.band_fddlte;
- band_info.band_support.lte_ext_band = info_modem.band_lte_ext;
-
- band_info.band_support.nr_3_band = 0;
- band_info.band_support.nr_2_band = 0;
- band_info.band_support.nr_1_band = 0;
- band_info.band_support.nr_0_band = 0;
- }
#endif
-}
-
-static void* ril_process_thread(void* arg)
-{
- UNUSED(arg);
- ATPortType_enum *port = (ATPortType_enum*)arg;
- ril_msg_queue_info_t* item = NULL;
-
- pthread_mutex_lock(&(ril_info.msg_mutex[*port]));
- while(TRUE)
- {
- if(mbtk_queue_empty(&(ril_info.msg_queue[*port])))
- {
- LOG("[Port-%d]Packet process wait...", *port);
- pthread_cond_wait(&(ril_info.msg_cond[*port]), &(ril_info.msg_mutex[*port]));
- LOG("[Port-%d]Packet process continue...", *port);
- }
- else
- {
- LOG("Packet process queue not empty,continue...");
- }
-
- // Process all information request.
- mbtk_ril_err_enum err;
- while((item = (ril_msg_queue_info_t*)mbtk_queue_get(&(ril_info.msg_queue[*port]))) != NULL)
- {
- if(item->cli_info) { // REQ form client.
- ril_msg_pack_info_t *pack = (ril_msg_pack_info_t*)item->pack;
- LOGD("Process REQ %s.", id2str(pack->msg_id));
- ril_info.at_process[*port] = true;
- err = pack_req_process(item->cli_info, pack);
- if(err != MBTK_RIL_ERR_SUCCESS)
- {
- ril_error_pack_send(item->cli_info->port, item->cli_info->fd, pack->msg_id, pack->msg_index, err);
- }
- ril_info.at_process[*port] = false;
- ril_msg_pack_free(pack);
- free(item);
- } 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);
- }
- }
- }
- }
- pthread_mutex_unlock(&(ril_info.msg_mutex[*port]));
-
- free(port);
-
- return NULL;
-}
-
-/*
-AT*BAND=15,78,147,482,134742231
-
-OK
-*/
-static void* band_config_thread()
-{
- band_info.band_set_success = FALSE;
+ }
+
// bool is_first = TRUE;
while(!band_info.band_set_success) {
// Set band.
@@ -2954,14 +2632,14 @@
msg->data = NULL;//mbtk_memcpy(&band_info, sizeof(ril_band_info_t));
msg->data_len = 0; //sizeof(ril_band_info_t);
#if 0
- if(msg->data == NULL) {
- LOGE("mbtk_memcpy() fail.");
- break;
- }
+ if(msg->data == NULL) {
+ LOGE("mbtk_memcpy() fail.");
+ break;
+ }
#endif
send_pack_to_queue(NULL, msg);
- sleep(5);
+ sleep(5);
} else {
LOG("malloc() fail[%d].", errno);
break;
@@ -2969,136 +2647,133 @@
#else
sleep(5);
#endif
- }
-
- LOGD("Set Band thread exit.");
- return NULL;
-}
+ }
+
+ LOGD("Set Band thread exit.");
+ return NULL;
+}
int ril_server_start()
-{
+{
signal(SIGPIPE, SIG_IGN);
memset(&ril_info, 0, sizeof(ril_info_t));
memset(&band_info, 0, sizeof(ril_band_info_t));
memset(&band_info.band_support, 0xFF, sizeof(mbtk_band_info_t));
-
- //check cfun and sim card status
- ril_at_ready_process();
-
- // Init support band.
- band_support_init();
-
- //any AT instruction that is not sent through pack_process_thread needs to precede the thread
- //thread create
+
+ //check cfun and sim card status
+ ril_at_ready_process();
+
+ //any AT instruction that is not sent through pack_process_thread needs to precede the thread
+ //thread create
if(ril_info.sock_listen_fd > 0)
- {
+ {
LOGE("Information Server Has Started.");
- return -1;
- }
-
- struct sockaddr_un server_addr;
+ return -1;
+ }
+
+ struct sockaddr_un server_addr;
ril_info.sock_listen_fd = socket(AF_LOCAL, SOCK_STREAM, 0);
if(ril_info.sock_listen_fd < 0)
- {
+ {
LOGE("socket() fail[%d].", errno);
- return -1;
- }
-
- // Set O_NONBLOCK
+ return -1;
+ }
+
+ // Set O_NONBLOCK
int flags = fcntl(ril_info.sock_listen_fd, F_GETFL, 0);
- if (flags < 0)
- {
+ if (flags < 0)
+ {
LOGE("Get flags error:%d", errno);
- goto error;
- }
- flags |= O_NONBLOCK;
+ goto error;
+ }
+ flags |= O_NONBLOCK;
if (fcntl(ril_info.sock_listen_fd, F_SETFL, flags) < 0)
- {
+ {
LOGE("Set flags error:%d", errno);
- goto error;
- }
-
+ goto error;
+ }
+
unlink(RIL_SOCK_NAME);
- memset(&server_addr, 0, sizeof(struct sockaddr_un));
- server_addr.sun_family = AF_LOCAL;
+ memset(&server_addr, 0, sizeof(struct sockaddr_un));
+ server_addr.sun_family = AF_LOCAL;
strcpy(server_addr.sun_path, RIL_SOCK_NAME);
if(bind(ril_info.sock_listen_fd, (struct sockaddr *)&server_addr, sizeof(server_addr)))
- {
+ {
LOGE("bind() fail[%d].", errno);
- goto error;
- }
-
+ goto error;
+ }
+
if(listen(ril_info.sock_listen_fd, SOCK_CLIENT_MAX))
- {
+ {
LOGE("listen() fail[%d].", errno);
- goto error;
- }
-
+ goto error;
+ }
+
ril_info.sock_client_list = list_create(sock_cli_free_func);
if(ril_info.sock_client_list == NULL)
- {
+ {
LOGE("list_create() fail.");
- goto error;
+ goto error;
}
mbtk_queue_init(&(ril_info.msg_queue[ATPORTTYPE_0]));
pthread_mutex_init(&(ril_info.msg_mutex[ATPORTTYPE_0]), NULL);
pthread_cond_init(&(ril_info.msg_cond[ATPORTTYPE_0]), NULL);
-
+
pthread_t info_pid, pack_pid/*, monitor_pid, urc_pid, bootconn_pid*/;
- pthread_attr_t thread_attr;
- pthread_attr_init(&thread_attr);
- if(pthread_attr_setdetachstate(&thread_attr, PTHREAD_CREATE_DETACHED))
- {
+ pthread_attr_t thread_attr;
+ pthread_attr_init(&thread_attr);
+ if(pthread_attr_setdetachstate(&thread_attr, PTHREAD_CREATE_DETACHED))
+ {
LOGE("pthread_attr_setdetachstate() fail.");
- goto error;
- }
-
+ goto error;
+ }
+
if(pthread_create(&info_pid, &thread_attr, ril_read_pthread, NULL))
- {
+ {
LOGE("pthread_create() fail.");
- goto error;
- }
+ goto error;
+ }
ATPortType_enum *port_0 = (ATPortType_enum*)malloc(sizeof(ATPortType_enum));
*port_0 = ATPORTTYPE_0;
if(pthread_create(&pack_pid, &thread_attr, ril_process_thread, port_0))
- {
+ {
LOGE("pthread_create() fail.");
- goto error;
+ goto error;
}
ATPortType_enum *port_1 = (ATPortType_enum*)malloc(sizeof(ATPortType_enum));
*port_1 = ATPORTTYPE_1;
if(pthread_create(&pack_pid, &thread_attr, ril_process_thread, port_1))
- {
+ {
LOGE("pthread_create() fail.");
- goto error;
+ goto error;
}
ATPortType_enum *port_2 = (ATPortType_enum*)malloc(sizeof(ATPortType_enum));
*port_2 = ATPORTTYPE_2;
if(pthread_create(&pack_pid, &thread_attr, ril_process_thread, port_2))
- {
+ {
LOGE("pthread_create() fail.");
- goto error;
+ goto error;
}
-
- // Set Band
- // AT*BAND=15,78,147,482,134742231
- char buff[10];
- memset(buff, 0, 10);
- property_get("persist.mbtk.band_config", buff, "");
- if(strlen(buff) == 0) {
- pthread_t band_pid;
- if(pthread_create(&band_pid, &thread_attr, band_config_thread, NULL))
- {
+
+ // Set Band
+ // AT*BAND=15,78,147,482,134742231
+ char buff[10];
+ memset(buff, 0, 10);
+ property_get("persist.mbtk.band_config", buff, "");
+ if(strlen(buff) == 0) {
+ pthread_t band_pid;
+ if(pthread_create(&band_pid, &thread_attr, band_config_thread, NULL))
+ {
LOGE("pthread_create() fail.");
- }
- }
-
+ }
+ }
+
pthread_attr_destroy(&thread_attr);
if(asr_auto_data_call_enable()) {
@@ -3121,10 +2796,10 @@
} else {
ril_cid_start = MBTK_RIL_CID_DEF;
}
-
+
LOGD("MBTK Ril Server Start[CID start with : %d]...", ril_cid_start);
-
- return 0;
+
+ return 0;
error:
if(ril_info.sock_client_list) {
list_free(ril_info.sock_client_list);
@@ -3135,7 +2810,7 @@
close(ril_info.sock_listen_fd);
ril_info.sock_listen_fd = -1;
}
- return -1;
+ return -1;
}
int main(int argc, char *argv[])