Fix auto data call for ril v2
Change-Id: I753b1c8ac7bcbeabd316734b54b4e79224537dea
diff --git a/mbtk/mbtk_rild_v2/src/atchannel.c b/mbtk/mbtk_rild_v2/src/atchannel.c
index 8a19159..f959a59 100755
--- a/mbtk/mbtk_rild_v2/src/atchannel.c
+++ b/mbtk/mbtk_rild_v2/src/atchannel.c
@@ -478,11 +478,11 @@
/* read error encountered or EOF reached */
if(count == 0)
{
- LOGD("atchannel: EOF reached");
+ LOGD("atchannel[Port-%d]: EOF reached", port);
}
else
{
- LOGD("atchannel: read error %s", strerror(errno));
+ LOGD("atchannel[Port-%d]: read error %s", port, strerror(errno));
}
return NULL;
}
@@ -495,11 +495,11 @@
s_ATBufferCur[port] = p_eol + 1; /* this will always be <= p_read, */
/* and there will be a \0 at *p_read */
- LOGD("AT< %s", ret);
+ LOGD("[Port-%d]AT< %s", port, ret);
return ret;
}
-static const char *readlineUrc()
+static const char *readlineUrc(ATPortType_enum port)
{
ssize_t count;
@@ -597,7 +597,7 @@
s_UartBufferCur = p_eol + 1; /* this will always be <= p_read, */
/* and there will be a \0 at *p_read */
- LOGD("URC< %s", ret);
+ LOGD("[Port-%d]URC< %s", port, ret);
return ret;
}
@@ -641,6 +641,8 @@
if (line == NULL)
{
+ //usleep(50000);
+ //continue;
break;
}
@@ -697,7 +699,7 @@
{
const char *line;
- line = readlineUrc();
+ line = readlineUrc(*port);
if (line == NULL)
{
@@ -733,7 +735,7 @@
return AT_ERROR_CHANNEL_CLOSED;
}
- LOGD("AT> %s", s);
+ LOGD("[Port-%d]AT> %s", port, s);
AT_DUMP( ">> ", s, strlen(s) );
@@ -865,12 +867,14 @@
return -1;
}
- pthread_t uart_tid_reader;
- ret = pthread_create(&uart_tid_reader, &attr, readerUrcLoop, urc_port_ptr);
- if (ret < 0)
- {
- LOGE("Uart thread create fail.");
- return -1;
+ if(port == ATPORTTYPE_0) { // URC only for ATPORTTYPE_0
+ pthread_t uart_tid_reader;
+ ret = pthread_create(&uart_tid_reader, &attr, readerUrcLoop, urc_port_ptr);
+ if (ret < 0)
+ {
+ LOGE("Uart thread create fail.");
+ return -1;
+ }
}
return 0;
diff --git a/mbtk/mbtk_rild_v2/src/main.c b/mbtk/mbtk_rild_v2/src/main.c
index 34d5656..0068bd3 100755
--- a/mbtk/mbtk_rild_v2/src/main.c
+++ b/mbtk/mbtk_rild_v2/src/main.c
@@ -1,3 +1,25 @@
+/*
+* main.c
+*
+* mbtk_rild main file.
+*
+* The main functions are as follows:
+* 1. Execute boot script /etc/init.d/mbtk_boot_server_ready after AT is ready(Only execute one time).
+* 2. Execute boot script /etc/init.d/mbtk_boot_net_ready after network is ready(Only execute one time).
+* 3. Set the frequency band based on the relevant information in the "device_info" partition.
+* 4. Create socket server(The client implementation in API).
+* 5. Create 3 connections between atcmdsrv, related devices: /tmp/atcmd_at ,
+* /tmp/atcmd_at_1 , /tmp/atcmd_at_2
+*/
+/******************************************************************************
+
+ EDIT HISTORY FOR FILE
+
+ WHEN WHO WHAT,WHERE,WHY
+-------- -------- -------------------------------------------------------
+2024/08/13 LiuBin Initial version
+
+******************************************************************************/
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
@@ -31,6 +53,7 @@
#include "mbtk_ril.h"
#include "mbtk_str.h"
#include "mbtk_queue.h"
+#include "mbtk_file.h"
#ifndef TEMP_FAILURE_RETRY
#define TEMP_FAILURE_RETRY(exp) ({ \
@@ -57,6 +80,7 @@
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;
+extern int ril_cid_start;
// int urc_msg_distribute(bool async_process, info_urc_msg_id_enum msg, void *data, int data_len);
// int mbtk_signal_log(char *data);
@@ -80,6 +104,8 @@
{
LOGI("AT channel timeout; closing\n");
at_close(ATPORTTYPE_0);
+ at_close(ATPORTTYPE_1);
+ at_close(ATPORTTYPE_2);
}
/* Called on command or reader thread */
@@ -87,6 +113,8 @@
{
LOGI("AT channel closed\n");
at_close(ATPORTTYPE_0);
+ at_close(ATPORTTYPE_1);
+ at_close(ATPORTTYPE_2);
}
static void sock_cli_free_func(void *data)
@@ -99,6 +127,23 @@
}
}
+bool asr_auto_data_call_enable()
+{
+ /*
+ uci show wan_default.default.enable
+ wan_default.default.enable='1'
+
+ uci get wan_default.default.enable
+ 1
+ */
+ char buff[128] = {0};
+ if(mbtk_cmd_line("uci get wan_default.default.enable", buff, sizeof(buff)) && strlen(buff) > 0) {
+ return buff[0] == '1' ? TRUE : FALSE;
+ } else {
+ return FALSE;
+ }
+}
+
/*
* Will exec mbtk_boot_server_ready and mbtk_boot_net_ready if is_first_boot is true.
*/
@@ -294,7 +339,7 @@
}
}
-static void ril_state_change(ril_msg_id_enum msg_id, const void *data, int data_len)
+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);
@@ -316,7 +361,16 @@
{
// 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);
+ if(msg_id == RIL_MSG_ID_IND_PDP_STATE_CHANGE) {
+ mbtk_ril_pdp_state_info_t *info = (mbtk_ril_pdp_state_info_t*)data;
+ if(info->action && !info->ip_info_valid) {
+ LOGD("PDP action but no IP information, not send.");
+ } else {
+ ril_state_change(msg_id, data, data_len);
+ }
+ } else {
+ ril_state_change(msg_id, data, data_len);
+ }
}
// Async process urc msg.
@@ -350,7 +404,7 @@
memset(&state, 0, sizeof(mbtk_ril_sim_state_info_t));
state.sim_type = MBTK_UNKNOWN;
- char* tmp_s = memdup(s,strlen(s));
+ char* tmp_s = memdup(s,strlen(s) + 1);
char *line = tmp_s;
int tmp_int;
char *tmp_str;
@@ -459,7 +513,7 @@
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));
+ urc_msg_distribute(true, 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)
{
@@ -483,7 +537,7 @@
// +CPAS: 4
static void urc_call_state_change_process(const char *s, const char *sms_pdu)
{
- char* tmp_s = memdup(s,strlen(s));
+ char* tmp_s = memdup(s,strlen(s) + 1);
char *line = tmp_s;
int tmp_int;
char *tmp_str;
@@ -598,7 +652,7 @@
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* tmp_s = memdup(s,strlen(s) + 1);
char *line = tmp_s;
int tmp_int;
char *tmp_str;
@@ -653,7 +707,7 @@
state.type = MBTK_NET_REG_TYPE_DATA_LTE;
}
- char* tmp_s = memdup(s,strlen(s));
+ char* tmp_s = memdup(s,strlen(s) + 1);
char *line = tmp_s;
int tmp_int;
char *tmp_str;
@@ -672,14 +726,17 @@
{
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
}
@@ -1025,7 +1082,7 @@
if(cell_info.running) {
int tmp_int;
int i = 0;
- char* tmp_s = memdup(s,strlen(s));
+ char* tmp_s = memdup(s,strlen(s) + 1);
char* free_ptr = tmp_s;
char *line = tmp_s;
if (at_tok_start(&line) < 0)
@@ -1122,7 +1179,7 @@
// phyCellId,euArfcn,rsrp,rsrq
if(cell_info.running) {
int tmp_int;
- char* tmp_s = memdup(s,strlen(s));
+ char* tmp_s = memdup(s,strlen(s) + 1);
char* free_ptr = tmp_s;
char *line = tmp_s;
if (at_tok_start(&line) < 0)
@@ -1212,7 +1269,7 @@
if(cell_info.running) {
int tmp_int;
int i = 0;
- char* tmp_s = memdup(s,strlen(s));
+ char* tmp_s = memdup(s,strlen(s) + 1);
char* free_ptr = tmp_s;
char *line = tmp_s;
if (at_tok_start(&line) < 0)
@@ -1296,7 +1353,7 @@
if(cell_info.running) {
int tmp_int;
int i = 0;
- char* tmp_s = memdup(s,strlen(s));
+ char* tmp_s = memdup(s,strlen(s) + 1);
char* free_ptr = tmp_s;
char *line = tmp_s;
if (at_tok_start(&line) < 0)
@@ -1349,7 +1406,7 @@
if(cell_info.running) {
int tmp_int;
int i = 0;
- char* tmp_s = memdup(s,strlen(s));
+ char* tmp_s = memdup(s,strlen(s) + 1);
char* free_ptr = tmp_s;
char *line = tmp_s;
if (at_tok_start(&line) < 0)
@@ -1425,7 +1482,7 @@
if(cell_info.running) {
int tmp_int;
int i = 0;
- char* tmp_s = memdup(s,strlen(s));
+ char* tmp_s = memdup(s,strlen(s) + 1);
char* free_ptr = tmp_s;
char *line = tmp_s;
if (at_tok_start(&line) < 0)
@@ -1538,7 +1595,7 @@
if(cell_info.running) {
int tmp_int;
int i = 0;
- char* tmp_s = memdup(s,strlen(s));
+ char* tmp_s = memdup(s,strlen(s) + 1);
char* free_ptr = tmp_s;
char *line = tmp_s;
if (at_tok_start(&line) < 0)
@@ -1637,7 +1694,7 @@
static void onUnsolicited(const char *s, const char *sms_pdu)
{
- LOGD("URC : %s", s);
+ LOGV("URC : %s", s);
// MBTK_AT_READY
if (strStartsWith(s, "MBTK_AT_READY")) // AT ready.
{
@@ -2207,6 +2264,17 @@
LOGD("Radio state : %d", state->radio_state);
break;
}
+ case RIL_MSG_ID_IND_SIM_STATE_CHANGE:
+ {
+ mbtk_ril_sim_state_info_t *state = (mbtk_ril_sim_state_info_t*)msg->data;
+ if(state->sim_state == MBTK_SIM_STATE_READY) {
+ LOGD("SIM READY!");
+ at_send_command(ATPORTTYPE_0, "AT+COPS=3", NULL);
+
+ // Set APN from prop.
+ apn_auto_conf_from_prop(ATPORTTYPE_0);
+ }
+ }
case RIL_MSG_ID_IND_NET_REG_STATE_CHANGE:
{
mbtk_ril_net_reg_state_info_t *reg_state = (mbtk_ril_net_reg_state_info_t*)msg->data;
@@ -2380,9 +2448,9 @@
{
if(mbtk_queue_empty(&(ril_info.msg_queue[*port])))
{
- LOG("[Port - %d]Packet process wait...", *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);
+ LOG("[Port-%d]Packet process continue...", *port);
}
else
{
@@ -2584,15 +2652,15 @@
LOGE("pthread_create() fail.");
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];
@@ -2606,9 +2674,30 @@
}
}
- pthread_attr_destroy(&thread_attr);
+ pthread_attr_destroy(&thread_attr);
+
+ if(asr_auto_data_call_enable()) {
+ ril_cid_start = MBTK_RIL_CID_2;
+
+ char def_cid[10] = {0};
+ char prop_data[100] = {0};
+ int cid = -1;
+ sprintf(def_cid, "%d", MBTK_RIL_CID_DEF); // Default route and DNS is CID 1.
+ memset(prop_data, 0, sizeof(prop_data));
+ if(property_get(MBTK_DEF_DNS_CID, prop_data, def_cid) > 0 && !str_empty(prop_data)) {
+ cid = atoi(prop_data);
+ }
+
+ if(cid == MBTK_RIL_CID_DEF) {
+ if(file_link("/tmp/resolv.conf", "/etc/resolv.conf")) {
+ LOGE("Create link file fail.");
+ }
+ }
+ } else {
+ ril_cid_start = MBTK_RIL_CID_DEF;
+ }
- LOGD("MBTK Ril Server Start...");
+ LOGD("MBTK Ril Server Start[CID start with : %d]...", ril_cid_start);
return 0;
error:
diff --git a/mbtk/mbtk_rild_v2/src/ril_data_call.c b/mbtk/mbtk_rild_v2/src/ril_data_call.c
index 210141b..9cb630a 100755
--- a/mbtk/mbtk_rild_v2/src/ril_data_call.c
+++ b/mbtk/mbtk_rild_v2/src/ril_data_call.c
@@ -1,3 +1,22 @@
+/*
+* ril_data_call.c
+*
+* Implementation of APN and Data Call related functions.
+*
+* The general structure is as follows:
+* API --- mbtk_rild --- atcmdsrv --- modem
+*
+*/
+/******************************************************************************
+
+ EDIT HISTORY FOR FILE
+
+ WHEN WHO WHAT,WHERE,WHY
+-------- -------- -------------------------------------------------------
+2024/10/10 LiuBin Initial version
+2024/11/13 LiuBin Add auto data call while network changed.
+
+******************************************************************************/
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
@@ -20,9 +39,12 @@
#include "ril_info.h"
#include "mbtk_ifc.h"
#include "mbtk_str.h"
+#include "mbtk_file.h"
ril_cgact_wait_t cgact_wait;
static ril_data_call_info_t info_list[MBTK_APN_CID_MAX];
+int ril_cid_start = MBTK_APN_CID_MIN;
+
static int req_apn_get(ATPortType_enum port, bool get_def_cid, mbtk_apn_info_array_t *apns, int *cme_err);
static int req_apn_set(ATPortType_enum port, mbtk_apn_info_t *apn, int *cme_err);
@@ -30,6 +52,8 @@
void ril_rsp_pack_send(ATPortType_enum port, int fd, int ril_id, int msg_index, const void* data, int data_len);
static int req_data_call_start(ATPortType_enum port, mbtk_ril_cid_enum cid, int *cme_err);
static int req_data_call_state_get(ATPortType_enum port, mbtk_ril_cid_enum cid, mbtk_ip_info_t *ip_info, int *cme_err);
+void ril_state_change(ril_msg_id_enum msg_id, const void *data, int data_len);
+bool asr_auto_data_call_enable();
/*
IPv4 : 10.255.74.26
@@ -52,6 +76,19 @@
}
}
+static int dns_cid_get()
+{
+ int cid = MBTK_RIL_CID_DEF;
+ char def_cid[10] = {0};
+ sprintf(def_cid, "%d", MBTK_RIL_CID_DEF); // Default route and DNS is CID 1.
+ char buffer[20] = {0};
+ if(property_get(MBTK_DEF_DNS_CID, buffer, def_cid) > 0 && !str_empty(buffer)) {
+ cid = atoi(buffer);
+ }
+
+ return cid;
+}
+
static void net_if_as_def_route(mbtk_ril_cid_enum cid)
{
if(cid != MBTK_RIL_CID_NUL) {
@@ -64,6 +101,8 @@
memset(buf, 0, sizeof(buf));
sprintf(buf, "route add default dev ccinet%d", cid - 1);
mbtk_system(buf);
+
+ LOGD("Add CID %d to default route.", cid);
}
}
@@ -115,22 +154,45 @@
if(offset > 0)
{
- fd = open("/tmp/resolv.conf", O_WRONLY | O_TRUNC);
- if(fd < 0)
- {
- LOGE("/tmp/resolv.conf : open fail.");
- return -1;
- }
+ int dns_cid = dns_cid_get();
+ char *dns_file_path = NULL;
- int ret = write(fd, buf, offset);
- if(ret < 0)
- {
- LOGE("/tmp/resolv.conf : write fail.");
- close(fd);
- return -1;
- }
+ // ASR auto data call enable and DNS server not change by MBTK.
+ if(asr_auto_data_call_enable() && dns_cid == MBTK_RIL_CID_DEF) {
+ dns_file_path = "/tmp/resolv.conf";
- close(fd);
+ if(file_link(dns_file_path, "/etc/resolv.conf")) {
+ LOGE("Create link file fail.");
+ return -1;
+ }
+ } else {
+ dns_file_path = "/tmp/mbtk_resolv.conf";
+
+ if(file_link(dns_file_path, "/etc/resolv.conf")) {
+ LOGE("Create link file fail.");
+ return -1;
+ } else {
+ // mbtk_system("chmod 644 /tmp/mbtk_resolv.conf");
+ fd = open(dns_file_path, O_WRONLY | O_TRUNC | O_CREAT, 0644);
+ if(fd < 0)
+ {
+ LOGE("%s : open fail.", dns_file_path);
+ return -1;
+ }
+
+ int ret = write(fd, buf, offset);
+ if(ret < 0)
+ {
+ LOGE("%s : write fail.", dns_file_path);
+ close(fd);
+ return -1;
+ }
+
+ LOGD("Update DNS success.");
+ close(fd);
+ // mbtk_system("chmod 444 /tmp/mbtk_resolv.conf");
+ }
+ }
}
return 0;
}
@@ -268,7 +330,6 @@
}
}
-
void apn_auto_conf_from_prop(ATPortType_enum port)
{
mbtk_apn_info_array_t apns;
@@ -304,19 +365,10 @@
static bool apn_conf_support(mbtk_ril_cid_enum cid)
{
if(cid == MBTK_RIL_CID_DEF) {
- /*
- uci show wan_default.default.enable
- wan_default.default.enable='1'
-
- uci get wan_default.default.enable
- 1
- */
- char buff[128] = {0};
- if(mbtk_cmd_line("uci get wan_default.default.enable", buff, sizeof(buff)) && strlen(buff) > 0) {
- return buff[0] == '1' ? FALSE : TRUE;
- }
+ return !asr_auto_data_call_enable();
+ } else {
+ return TRUE;
}
- return TRUE;
}
static int apn_check_and_cid_reset(ATPortType_enum port, mbtk_apn_info_t *apn)
@@ -326,7 +378,7 @@
if(apn->cid == MBTK_RIL_CID_NUL)
return -1;
- if(!apn_conf_support(MBTK_RIL_CID_DEF) && apn->cid == MBTK_RIL_CID_DEF)
+ if(asr_auto_data_call_enable() && apn->cid == MBTK_RIL_CID_DEF)
return -1;
// The cid no use,so can not delete.
@@ -349,16 +401,10 @@
return -1;
}
} else { // Add or change APN.
- int start_cid;
- bool asr_auto_call_open = !apn_conf_support(MBTK_RIL_CID_DEF);
+ int start_cid = ril_cid_start;;
mbtk_apn_info_array_t apns;
int cme_err = MBTK_RIL_ERR_CME_NON;
- if(asr_auto_call_open) {
- start_cid = MBTK_RIL_CID_2;
- } else {
- start_cid = MBTK_APN_CID_MIN;
- }
memset(&apns, 0, sizeof(mbtk_apn_info_array_t));
if(req_apn_get(port, TRUE, &apns, &cme_err) || cme_err != MBTK_RIL_ERR_CME_NON)
{
@@ -405,6 +451,17 @@
}
}
+ if(apn->cid == MBTK_RIL_CID_1) {
+#if 1
+ apn->auto_boot_call = 0; // Reset to 0 for CID 1.
+#else
+ if(apn->auto_boot_call) {
+ LOGE("CID 1 not support auto boot data call(Please open \"wan_default.default.enable\").");
+ return -1;
+ }
+#endif
+ }
+
// Is add,the APN can't same.
if(!is_change) {
index = 0;
@@ -425,21 +482,11 @@
{
char prop_name[128] = {0};
char prop_data[1024] = {0};
- int cid;
+ int cid = ril_cid_start;
memset(apns, 0, sizeof(mbtk_apn_info_array_t));
- bool asr_auto_call_open = !apn_conf_support(MBTK_RIL_CID_DEF);
-
- // If auto data call is open,the default route is CID 1.
- if(asr_auto_call_open) {
- //apns->cid_for_def_route = MBTK_RIL_CID_DEF;
- //apns->cid_for_def_dns = MBTK_RIL_CID_DEF;
- cid = MBTK_RIL_CID_2;
- } else {
- cid = MBTK_APN_CID_MIN;
- }
char def_cid[10] = {0};
- sprintf(def_cid, "%d", MBTK_RIL_CID_DEF);
+ sprintf(def_cid, "%d", MBTK_RIL_CID_DEF); // Default route and DNS is CID 1.
if(property_get(MBTK_DEF_ROUTE_CID, prop_data, def_cid) > 0 && !str_empty(prop_data)) {
apns->cid_for_def_route = (mbtk_ril_cid_enum)atoi(prop_data);
}
@@ -490,6 +537,11 @@
}
ptr_1++; // Jump ',' to apn
+ // Reset auto_boot_call to 0 for CID 1.
+ if(apns->apns[apns->num].cid == MBTK_RIL_CID_1) {
+ apns->apns[apns->num].auto_boot_call = 0;
+ }
+
char *ptr_2 = strstr(ptr_1, ",");
if(!ptr_2) {
continue;
@@ -563,6 +615,11 @@
}
ptr_1++; // Jump ',' to apn
+ // Reset auto_boot_call to 0 for CID 1.
+ if(apn->cid == MBTK_RIL_CID_1) {
+ apn->auto_boot_call = 0;
+ }
+
char *ptr_2 = strstr(ptr_1, ",");
if(!ptr_2) {
return -1;
@@ -634,6 +691,11 @@
}
ptr_1++; // Jump ',' to apn
+ // Reset auto_boot_call to 0 for CID 1.
+ if(cid == MBTK_RIL_CID_1) {
+ apn->auto_boot_call = 0;
+ }
+
char *ptr_2 = strstr(ptr_1, ",");
if(!ptr_2) {
return -1;
@@ -666,6 +728,7 @@
if(memcmp(ptr_1, "NULL", 4)) { // Not "NULL"
memcpy(apn->type, ptr_2, strlen(ptr_2)); // pass
}
+
return 0;
} else {
apn->auto_save = (uint8)0;
@@ -679,6 +742,11 @@
char prop_data[1024] = {0};
int ret = -1;
if(apn->auto_save) {
+ // auto_boot_call must be 0 for CID 1.
+ if(apn->cid == MBTK_RIL_CID_1) {
+ apn->auto_boot_call = 0;
+ }
+
sprintf(prop_name, "%s_%d", MBTK_APN_PROP, apn->cid);
// Delete apn
if(!str_empty(apn->apn)) {
@@ -700,15 +768,45 @@
#endif
}
- if(!ret && apn->def_route) {
+ if(!ret) {
memset(prop_data, 0, sizeof(prop_data));
- prop_data[0] = '0' + apn->cid;
- ret = property_set(MBTK_DEF_ROUTE_CID, prop_data);
+ if(apn->def_route) {
+ prop_data[0] = '0' + apn->cid;
+ ret = property_set(MBTK_DEF_ROUTE_CID, prop_data);
+ } else {
+ char def_cid[10] = {0};
+ int cid = -1;
+ sprintf(def_cid, "%d", MBTK_RIL_CID_DEF); // Default route and DNS is CID 1.
+ memset(prop_data, 0, sizeof(prop_data));
+ if(property_get(MBTK_DEF_ROUTE_CID, prop_data, def_cid) > 0 && !str_empty(prop_data)) {
+ cid = atoi(prop_data);
+ }
+
+ if(apn->cid == cid) { // The route cid should reset to default.
+ prop_data[0] = '0' + MBTK_RIL_CID_DEF;
+ ret = property_set(MBTK_DEF_ROUTE_CID, prop_data);
+ }
+ }
}
- if(!ret && apn->as_dns) {
+ if(!ret) {
memset(prop_data, 0, sizeof(prop_data));
- prop_data[0] = '0' + apn->cid;
- ret = property_set(MBTK_DEF_DNS_CID, prop_data);
+ if(apn->as_dns) {
+ prop_data[0] = '0' + apn->cid;
+ ret = property_set(MBTK_DEF_DNS_CID, prop_data);
+ } else {
+ char def_cid[10] = {0};
+ int cid = -1;
+ sprintf(def_cid, "%d", MBTK_RIL_CID_DEF); // Default route and DNS is CID 1.
+ memset(prop_data, 0, sizeof(prop_data));
+ if(property_get(MBTK_DEF_DNS_CID, prop_data, def_cid) > 0 && !str_empty(prop_data)) {
+ cid = atoi(prop_data);
+ }
+
+ if(apn->cid == cid) { // The dns cid should reset to default.
+ prop_data[0] = '0' + MBTK_RIL_CID_DEF;
+ ret = property_set(MBTK_DEF_DNS_CID, prop_data);
+ }
+ }
}
// Update apn info in buffer.
@@ -773,12 +871,24 @@
if(reg_state->tech >= MBTK_RADIO_TECH_UTRAN) { // No for GSM(No GPRS)
if(reg_state->reg_state == MBTK_NET_REG_STATE_HOME
|| reg_state->reg_state == MBTK_NET_REG_STATE_ROAMING) { // Only Home and Roaming network.
- int cid = MBTK_APN_CID_MIN;
- mbtk_ip_info_t ip_info;
+ int cid = ril_cid_start;
+ // mbtk_ip_info_t ip_info;
+ mbtk_ril_pdp_state_info_t pdp_info;
for(; cid <= MBTK_APN_CID_MAX; cid++) {
LOGV("cid - %d, valid - %d, act_state - %d", cid, info_list[cid - 1].valid,
info_list[cid - 1].act_state);
- if(info_list[cid - 1].valid && info_list[cid - 1].act_state == RIL_ACT_STATE_CONNECTED_RETRY) {
+ if(info_list[cid - 1].valid &&
+ (info_list[cid - 1].act_state == RIL_ACT_STATE_CONNECTED_RETRY
+ || info_list[cid - 1].apn_info.auto_boot_call)) { // Auto data call when boot.
+ memset(&pdp_info, 0, sizeof(mbtk_ril_pdp_state_info_t));
+ pdp_info.action = TRUE;
+ pdp_info.cid = cid;
+
+ if(!apn_conf_support(pdp_info.cid)) {
+ LOGD("Can not data call for CID : %d", pdp_info.cid);
+ continue;
+ }
+
// Reset ip information.
char dev[20] = {0};
sprintf(dev, "ccinet%d", cid - 1);
@@ -804,9 +914,9 @@
}
// Get Ip informations.
- memset(&ip_info, 0, sizeof(ip_info));
+ // memset(&ip_info, 0, sizeof(ip_info));
cme_err = MBTK_RIL_ERR_CME_NON;
- if(req_data_call_state_get(port, cid, &ip_info, &cme_err) || cme_err != MBTK_RIL_ERR_CME_NON)
+ if(req_data_call_state_get(port, cid, &(pdp_info.ip_info), &cme_err) || cme_err != MBTK_RIL_ERR_CME_NON)
{
LOGE("Get net informations fail.");
return;
@@ -814,15 +924,21 @@
else
{
// Config network informations.
- LOGV("def_route - %d, as_dns - %d", info_list[cid - 1].apn_info.def_route,
- info_list[cid - 1].apn_info.as_dns);
+ LOGD("def_route - %d, as_dns - %d, ipv4_valid - %d, ipv6_valid - %d",
+ info_list[cid - 1].apn_info.def_route,
+ info_list[cid - 1].apn_info.as_dns,
+ pdp_info.ip_info.ipv4.valid, pdp_info.ip_info.ipv6.valid);
if(net_ifc_reconfig(cid, info_list[cid - 1].apn_info.def_route,
- info_list[cid - 1].apn_info.as_dns, &ip_info)) {
+ info_list[cid - 1].apn_info.as_dns, &(pdp_info.ip_info))) {
LOGE("Set net informations fail.");
return;
}
info_list[cid - 1].act_state = RIL_ACT_STATE_CONNECTED;
+
+ pdp_info.ip_info_valid = TRUE;
+
+ ril_state_change(RIL_MSG_ID_IND_PDP_STATE_CHANGE, &pdp_info, sizeof(mbtk_ril_pdp_state_info_t));
}
}
}
@@ -859,14 +975,10 @@
int tmp_int;
char *tmp_str = NULL;
int cid_start;
- if(apn_conf_support(MBTK_RIL_CID_DEF)) {
+ if(get_def_cid) {
cid_start = MBTK_RIL_CID_DEF;
} else {
- if(get_def_cid) {
- cid_start = MBTK_RIL_CID_DEF;
- } else {
- cid_start = MBTK_RIL_CID_2;
- }
+ cid_start = ril_cid_start;
}
/*
<apn_num[1]><cid[1]><ip_type[1]><apn_len[2]><apn><user_len[2]><user><pass_len[2]><pass><auth_len[2]><auth>...
@@ -926,7 +1038,7 @@
// char prop_name[128] = {0};
char prop_data[1024] = {0};
char def_cid[10] = {0};
- sprintf(def_cid, "%d", MBTK_RIL_CID_DEF);
+ sprintf(def_cid, "%d", MBTK_RIL_CID_DEF); // Default route and DNS is CID 1.
if(property_get(MBTK_DEF_ROUTE_CID, prop_data, def_cid) > 0 && !str_empty(prop_data)) {
apns->cid_for_def_route = (mbtk_ril_cid_enum)atoi(prop_data);
diff --git a/mbtk/mbtk_rild_v2/src/ril_ecall.c b/mbtk/mbtk_rild_v2/src/ril_ecall.c
index 60b64c5..a3ff510 100755
--- a/mbtk/mbtk_rild_v2/src/ril_ecall.c
+++ b/mbtk/mbtk_rild_v2/src/ril_ecall.c
@@ -1,3 +1,24 @@
+/*
+* ril_ecall.c
+*
+* Implementation of ecall related functions.
+*
+* The general structure is as follows:
+* API --- mbtk_rild --- atcmdsrv --- modem
+* |
+ |
+* ecall_daemon
+*
+*/
+/******************************************************************************
+
+ EDIT HISTORY FOR FILE
+
+ WHEN WHO WHAT,WHERE,WHY
+-------- -------- -------------------------------------------------------
+2024/11/04 LiuBin Initial version
+
+******************************************************************************/
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>