[Feature][ZXW-192]Add asynchronous setup_data_call interface
Only Configure: No
Affected branch: master
Affected module: data
Is it affected on both ZXIC and MTK: only ZXIC
Self-test: Yes
Doc Update: Yes
Change-Id: If97bccaeedba046911f9f2bb4743fa381f12133e
diff --git a/cap/zx297520v3/src/lynq/framework/lynq-ril-service/src/data/data.cpp b/cap/zx297520v3/src/lynq/framework/lynq-ril-service/src/data/data.cpp
index 71bc7f1..2522423 100755
--- a/cap/zx297520v3/src/lynq/framework/lynq-ril-service/src/data/data.cpp
+++ b/cap/zx297520v3/src/lynq/framework/lynq-ril-service/src/data/data.cpp
@@ -780,10 +780,11 @@
{
/*此处直接返回response,给client成功的结果码,并返回iface*/
p.writeInt32(0);
- p.writeInt32(0);
+ p.writeInt32(pRI->uToken);//utoken
p.writeInt32(pRI->pCI->requestNumber);
p.writeInt32(socket_id);
p.writeInt32(0);//error
+ writeStringToParcel(p, lynq_apn_cid_table[i].apntype);//apntype
p.writeInt32(0);//version
p.writeInt32(0);//num
p.writeInt32(0);//status
@@ -811,20 +812,22 @@
memcpy(lynq_apn_cid_table[i].apn, apn, strlen(apn) + 1);
memcpy(lynq_apn_cid_table[i].apntype, apntype, strlen(apntype) + 1);
lynq_apn_cid_table[i].dialing = 1;
- RLOGD("DATA: apn_table[%d].apn = %s, apntype = %s, dialing = %d\n", i, lynq_apn_cid_table[i].apn, lynq_apn_cid_table[i].apntype, lynq_apn_cid_table[i].dialing);
+ lynq_apn_cid_table[i].uToken = pRI->uToken;
+ RLOGD("DATA: apn_table[%d].apn = %s, apntype = %s, dialing = %d, utoken = %d\n", i, lynq_apn_cid_table[i].apn, lynq_apn_cid_table[i].apntype, lynq_apn_cid_table[i].dialing, lynq_apn_cid_table[i].uToken = pRI->uToken);
break;
}
}
RLOGD("setupDataCall end, lynq_apn_cid_table content:\n");
for(int i = 0; i < LYNQ_APN_CHANNEL_MAX; i++)
{
- RLOGD("lynq_apn_cid_table[%d],apntype:%s,apnstatus:%d,ifaceName:%s,used=%d,address=%s,dialing=%d\n",
+ RLOGD("lynq_apn_cid_table[%d],apntype:%s,apnstatus:%d,ifaceName:%s,used=%d,address=%s,dialing=%d,uToken=%d\n",
i,lynq_apn_cid_table[i].apntype,
lynq_apn_cid_table[i].status,
lynq_apn_cid_table[i].ifaceName,
lynq_apn_cid_table[i].used,
lynq_apn_cid_table[i].address,
- lynq_apn_cid_table[i].dialing);
+ lynq_apn_cid_table[i].dialing,
+ lynq_apn_cid_table[i].uToken);
}
result = setupDataCallargc(argc,argv,socket_id,pRI);
return result;
@@ -1555,6 +1558,7 @@
lynq_apn_cid_table[j].used = -1;
lynq_apn_cid_table[j].status = -1;
lynq_apn_cid_table[j].dialing = -1;
+ lynq_apn_cid_table[j].uToken = -1;
//break;
}
}
@@ -1655,7 +1659,8 @@
lynq_apn_cid_table[j].ifaceName,
lynq_apn_cid_table[j].used,
lynq_apn_cid_table[j].address,
- lynq_apn_cid_table[j].dialing);
+ lynq_apn_cid_table[j].dialing,
+ lynq_apn_cid_table[j].uToken);
//add update lynq_apn_cid_list at there for every used = 1, if cid = p_cur.cid, update, else delete lynq_apn_cid_table[i]
@@ -1697,6 +1702,7 @@
lynq_apn_cid_table[j].used = -1;
lynq_apn_cid_table[j].status = -1;
lynq_apn_cid_table[j].dialing = -1;
+ lynq_apn_cid_table[j].uToken = -1;
RLOGD("clean end\n");
}
}
diff --git a/cap/zx297520v3/src/lynq/framework/lynq-ril-service/src/lynq_common.cpp b/cap/zx297520v3/src/lynq/framework/lynq-ril-service/src/lynq_common.cpp
index b476b01..ad0cfad 100755
--- a/cap/zx297520v3/src/lynq/framework/lynq-ril-service/src/lynq_common.cpp
+++ b/cap/zx297520v3/src/lynq/framework/lynq-ril-service/src/lynq_common.cpp
@@ -34,14 +34,14 @@
//xf.il@20230610 modify for T106 data start
#ifdef MOBILETEK_TARGET_PLATFORM_T106
extern lynq_apn_cid_table_t lynq_apn_cid_table[LYNQ_APN_CHANNEL_MAX] = {
- {-1, "", "", "", -1, -1, -1, ""}, \
- {-1, "", "", "", -1, -1, -1, ""}, \
- {-1, "", "", "", -1, -1, -1, ""}, \
- {-1, "", "", "", -1, -1, -1, ""}, \
- {-1, "", "", "", -1, -1, -1, ""}, \
- {-1, "", "", "", -1, -1, -1, ""}, \
- {-1, "", "", "", -1, -1, -1, ""}, \
- {-1, "", "", "", -1, -1, -1, ""},
+ {-1, "", "", "", -1, -1, -1, -1, ""}, \
+ {-1, "", "", "", -1, -1, -1, -1, ""}, \
+ {-1, "", "", "", -1, -1, -1, -1, ""}, \
+ {-1, "", "", "", -1, -1, -1, -1, ""}, \
+ {-1, "", "", "", -1, -1, -1, -1, ""}, \
+ {-1, "", "", "", -1, -1, -1, -1, ""}, \
+ {-1, "", "", "", -1, -1, -1, -1, ""}, \
+ {-1, "", "", "", -1, -1, -1, -1, ""},
};
#endif
//xf.il@20230610 modify for T106 data end
diff --git a/cap/zx297520v3/src/lynq/framework/lynq-ril-service/src/lynq_common.h b/cap/zx297520v3/src/lynq/framework/lynq-ril-service/src/lynq_common.h
index 6d207d3..c8d56cf 100755
--- a/cap/zx297520v3/src/lynq/framework/lynq-ril-service/src/lynq_common.h
+++ b/cap/zx297520v3/src/lynq/framework/lynq-ril-service/src/lynq_common.h
@@ -109,6 +109,7 @@
int used;//0:not use,1:used.
int dialing;
int status;
+ int uToken;
//int apnstatus;//1:has enable;0:need disable.
//int pdpstate;//lei add for at+elapnact? refer to T800 AT COMMANDS:+lapnact
char address[LYNQ_ADDRESS_LEN_MAX];
diff --git a/cap/zx297520v3/src/lynq/framework/lynq-ril-service/src/ril.cpp b/cap/zx297520v3/src/lynq/framework/lynq-ril-service/src/ril.cpp
index 6b5a7d4..ed165e0 100755
--- a/cap/zx297520v3/src/lynq/framework/lynq-ril-service/src/ril.cpp
+++ b/cap/zx297520v3/src/lynq/framework/lynq-ril-service/src/ril.cpp
@@ -4144,22 +4144,41 @@
p.writeInt32 (e);
#ifdef MOBILETEK_TARGET_PLATFORM_T106
//xf.li@20231102 add for t106 data start
- if(response == NULL && pRI->pCI->requestNumber == RIL_REQUEST_SETUP_DATA_CALL)
+ if(pRI->pCI->requestNumber == RIL_REQUEST_SETUP_DATA_CALL)
{
- for(int j = 0; j < LYNQ_APN_CHANNEL_MAX; j++)
+ if(response == NULL)
{
- if(lynq_apn_cid_table[j].used == 1 && lynq_apn_cid_table[j].dialing == 1)
+ for(int j = 0; j < LYNQ_APN_CHANNEL_MAX; j++)
{
- //delete
- bzero(lynq_apn_cid_table[j].apn,LYNQ_APN_LEN_MAX);
- bzero(lynq_apn_cid_table[j].apntype,LYNQ_APNTPYE_LEN_MAX);
- bzero(lynq_apn_cid_table[j].ifaceName,LYNQ_IFNAME_LEN_MAX);
- bzero(lynq_apn_cid_table[j].address,LYNQ_ADDRESS_LEN_MAX);
- lynq_apn_cid_table[j].cid = -1;
- lynq_apn_cid_table[j].used = -1;
- lynq_apn_cid_table[j].status = -1;
- lynq_apn_cid_table[j].dialing = -1;
- break;
+ if(lynq_apn_cid_table[j].used == 1 && lynq_apn_cid_table[j].dialing == 1 && lynq_apn_cid_table[j].uToken == pRI->uToken)
+ {
+ RLOGD("[DATA]delete apntype is %s",lynq_apn_cid_table[j].apntype);
+ writeStringToParcel(p,lynq_apn_cid_table[j].apntype);
+ //delete
+ bzero(lynq_apn_cid_table[j].apn,LYNQ_APN_LEN_MAX);
+ bzero(lynq_apn_cid_table[j].apntype,LYNQ_APNTPYE_LEN_MAX);
+ bzero(lynq_apn_cid_table[j].ifaceName,LYNQ_IFNAME_LEN_MAX);
+ bzero(lynq_apn_cid_table[j].address,LYNQ_ADDRESS_LEN_MAX);
+ lynq_apn_cid_table[j].cid = -1;
+ lynq_apn_cid_table[j].used = -1;
+ lynq_apn_cid_table[j].status = -1;
+ lynq_apn_cid_table[j].dialing = -1;
+ lynq_apn_cid_table[j].uToken = -1;
+ break;
+ }
+ }
+ }
+ else
+ {
+ for(int j = 0; j < LYNQ_APN_CHANNEL_MAX; j++)
+ {
+ if(lynq_apn_cid_table[j].used == 1 && lynq_apn_cid_table[j].dialing == 1 && lynq_apn_cid_table[j].uToken == pRI->uToken)
+ {
+ //set apn type
+ RLOGD("[DATA]response apntype is %s",lynq_apn_cid_table[j].apntype);
+ writeStringToParcel(p,lynq_apn_cid_table[j].apntype);
+ break;
+ }
}
}
}
diff --git a/cap/zx297520v3/src/lynq/lib/liblynq-data/include/libdata/lynq_data.h b/cap/zx297520v3/src/lynq/lib/liblynq-data/include/libdata/lynq_data.h
index 1ee15ba..42fa806 100755
--- a/cap/zx297520v3/src/lynq/lib/liblynq-data/include/libdata/lynq_data.h
+++ b/cap/zx297520v3/src/lynq/lib/liblynq-data/include/libdata/lynq_data.h
@@ -68,6 +68,7 @@
int lynq_deactive_data_call(int *handle);
int lynq_setup_data_call_sp(int *handle,char *apn,char *apnType,char *user,char *password,char *authType,char *normalProtocol,char *roamingProtocol);
int lynq_setup_data_call_sp_t106(int *handle,char *apn,char *apnType,char *user,char *password,char *authType,char *normalProtocol,char *roamingProtocol);
+int lynq_setup_data_call_sp_t106_async(int *handle,char *apn,char *apnType,char *user,char *password,char *authType,char *normalProtocol,char *roamingProtocol);
//int lynq_deactive_data_call_sp(int *handle,char *apnType);
int lynq_get_data_call_list(int *handle,lynq_data_call_response_v11_t *dataCallList);
int lynq_wait_data_call_state_change(int *handle);
diff --git a/cap/zx297520v3/src/lynq/lib/liblynq-data/lynq_data.cpp b/cap/zx297520v3/src/lynq/lib/liblynq-data/lynq_data.cpp
index d84687d..b497527 100755
--- a/cap/zx297520v3/src/lynq/lib/liblynq-data/lynq_data.cpp
+++ b/cap/zx297520v3/src/lynq/lib/liblynq-data/lynq_data.cpp
@@ -24,6 +24,8 @@
#define LYQN_SEDN_BUF 1024*8+sizeof(int)*3
#define USER_LOG_TAG "LYNQ_DATA"
+#define LYNQ_DATA_TIME_OUT 1000*120
+
#define LYNQ_DATA_UCI_BUF 258
#define LYNQ_ADDRESS "127.0.0.1"
@@ -49,6 +51,8 @@
/*Failed to execute sql statement*/
LYNQ_E_SMS_SQL_FAIL = 8006,
LYNQ_E_SMS_NOT_FIND = 8007,
+ LYNQ_E_GET_RESP_FAIL = 8008,
+ LYNQ_E_REPETITIVE_APN = 8009,
/* The logic conflict*/
LYNQ_E_CONFLICT=9000,
/*Null anomaly*/
@@ -61,7 +65,9 @@
int lynq_data_socket_server_addr_len;
int lynq_data_call_change_id = -1;
+int module_rc_status = 1;
pthread_t lynq_data_tid =-1;
+pthread_t module_rc_tid = -1;
static pthread_mutex_t s_data_call_state_change_mutex = PTHREAD_MUTEX_INITIALIZER;
static pthread_cond_t s_data_call_state_change_cond = PTHREAD_COND_INITIALIZER;
@@ -69,6 +75,8 @@
static pthread_cond_t s_lynq_apn_change_cond = PTHREAD_COND_INITIALIZER;
static pthread_mutex_t s_lynq_urc_vector_mutex = PTHREAD_MUTEX_INITIALIZER;
static pthread_cond_t s_lynq_urc_vector_cond = PTHREAD_COND_INITIALIZER;
+static pthread_mutex_t s_lynq_rc_vector_mutex = PTHREAD_MUTEX_INITIALIZER;
+static pthread_cond_t s_lynq_rc_vector_cond = PTHREAD_COND_INITIALIZER;
/**g_lynq_data_sendto_mutex
* @brief mark data send request mutex
*/
@@ -90,9 +98,11 @@
* @brief temp of apn result info
*/
char g_lynq_apn_result[1024] = {};
+int g_setup_utoken = -1;
+int g_data_call_timeout_value = LYNQ_DATA_TIME_OUT;
static std::vector<int> s_data_urc_wait_list;
-
+static int lynq_start_data_call_rc_socket_thread();
typedef struct
{
char apn[LYNQ_APN_MAX_LEN];
@@ -343,14 +353,98 @@
}
return 0;
}
-int JumpHeader(Parcel &p,int *resp_type,int *request,int *slot_id,int *error)
+/**@brief get utoken in range 0 to 10000
+* @return utoken
+*/
+int get_utoken()
{
- if(p.dataAvail() > 0)
+ return (Global_uToken++)%10000;/*0-10000*/
+}
+/**@brief wait response with expected token and write msg to parcel in some time
+* @param fd [IN]: socket fd
+* @param p [OUT]: quote the parcel,if return success need delete p.
+* @param token [IN]: the expected token for the response msg
+* @return
+* 0:success
+* other:failure
+*/
+int wait_response(int sockfd,Parcel *& p,int utoken)
+{
+ int len = 0;
+ int flag = 1;
+ int count = 0;
+ int in_utoken = -1;
+ int resp_type = -1;
+ Parcel *temp = NULL;
+ char recvline[LYNQ_REC_BUF];
+ //Sometimes the socket is abnormal, causing the socket buffer to store the response of the last request.
+ //Here it does not return until the response corresponding to the request is read.
+ while(flag && (count < 20))//why?
{
- p.readInt32(resp_type);
- p.readInt32(request);
- p.readInt32(slot_id);
- p.readInt32(error);
+ bzero(recvline,LYNQ_REC_BUF);
+ count++;
+ LYINFLOG("wait_response,count:%d",count);
+ len = recvfrom(sockfd,recvline,LYNQ_REC_BUF,0,(struct sockaddr *)&lynq_data_socket_server_addr,(socklen_t *)&lynq_data_socket_server_addr_len);
+ if(len == -1)
+ {
+ LYERRLOG("wait_response fail,errno:%d",errno);
+ return LYNQ_E_GET_RESP_FAIL;
+ }
+ if (len != 0)
+ {
+ temp = new Parcel;
+ int i = 0;
+ while((NULL == temp) && (i < 100))
+ {
+ usleep(1000);
+ temp = new Parcel;
+ i++;
+ }
+ if((i >= 100) || (NULL == temp))
+ {
+ LYERRLOG("wait_response i:%d",i);
+ return LYNQ_E_GET_RESP_FAIL;
+ }
+ temp->setData((uint8_t *)recvline,len); // p.setData((uint8_t *) buffer, buflen);
+ temp->setDataPosition(0);
+ temp->readInt32(&resp_type);
+ temp->readInt32(&in_utoken);
+ LYINFLOG("[%s]in_utoken:%d,utoken:%d",__FUNCTION__,in_utoken,utoken);
+ if (in_utoken != utoken)
+ {
+ delete temp;
+ temp = NULL;
+ in_utoken = 0;
+ continue;
+ }
+ temp->setDataPosition(0);
+ p = temp;
+ flag = 0;
+ return 0;
+ }
+ else
+ {
+ LYERRLOG("recvline is null,errno:%d",errno);
+ return LYNQ_E_GET_RESP_FAIL;
+ }
+ }
+ return LYNQ_E_GET_RESP_FAIL;
+}
+
+int JumpHeader(Parcel *p,int *resp_type,int *utoken,int *request,int *slot_id,int *error)
+{
+ if(NULL == p)
+ {
+ LYERRLOG("JumpHeader is null");
+ return -1;
+ }
+ if(p->dataAvail() > 0)
+ {
+ p->readInt32(resp_type);
+ p->readInt32(utoken);
+ p->readInt32(request);
+ p->readInt32(slot_id);
+ p->readInt32(error);
return 0;
}
else
@@ -358,13 +452,21 @@
return -1;
}
}
+void free_parcel(Parcel *p)
+{
+ if(p)
+ {
+ delete p;
+ p = NULL;
+ }
+}
int send_request(int sockfd,lynq_client_t *client_tmp)
{
int ret=0;
- ret = write(sockfd, client_tmp, LYQN_SEDN_BUF);
+ ret = sendto(sockfd,client_tmp,LYQN_SEDN_BUF,0,(struct sockaddr *)&lynq_data_socket_server_addr,lynq_data_socket_server_addr_len);
if(ret==-1)
{
- perror("write error");
+ LYERRLOG("%s:errno code:%d",__FUNCTION__,errno);
return -1;
}
return 0;
@@ -385,8 +487,21 @@
/*Warren add for T800 platform 2021/11/19 start*/
int lynq_socket_client_start()
{
- /* init lynq_socket_server_addr */
+ int ret;
+ struct timeval timeOut;
+ struct sockaddr_in liblynq_data_socket;
+
+ ret = 0;
+ timeOut.tv_sec = 30;
+ timeOut.tv_usec = 0;
+ bzero(&liblynq_data_socket, sizeof(liblynq_data_socket));
bzero(&lynq_data_socket_server_addr, sizeof(lynq_data_socket_server_addr));
+
+ //set this lib socket config
+ liblynq_data_socket.sin_family = AF_INET;
+ liblynq_data_socket.sin_addr.s_addr = inet_addr(LYNQ_ADDRESS);
+
+ //set ril service socket config
lynq_data_socket_server_addr.sin_family = AF_INET;
lynq_data_socket_server_addr.sin_port = htons(LYNQ_SERVICE_PORT);
lynq_data_socket_server_addr.sin_addr.s_addr = inet_addr(LYNQ_ADDRESS);
@@ -399,18 +514,15 @@
}
*/
lynq_client_sockfd = socket(AF_INET, SOCK_DGRAM, 0);
- struct timeval timeOut;
-
- timeOut.tv_sec = 30;
- timeOut.tv_usec = 0;
-
+ ret = bind(lynq_client_sockfd, (struct sockaddr *)&liblynq_data_socket, sizeof(liblynq_data_socket));
+ if (-1 == ret)
+ {
+ LYERRLOG("liblynq_data_socket bind fail,errno:%d",errno);
+ return -1;
+ }
if (setsockopt(lynq_client_sockfd, SOL_SOCKET, SO_RCVTIMEO, &timeOut, sizeof(timeOut)) < 0)
{
- LYERRLOG("time out setting failed");
- }
- if(connect(lynq_client_sockfd, (struct sockaddr *)&lynq_data_socket_server_addr, sizeof(lynq_data_socket_server_addr)) == -1)
- {
- perror("connect error");
+ LYERRLOG("time out setting failed,errno:%d",errno);
return -1;
}
return 0;
@@ -914,6 +1026,13 @@
LYERRLOG("init socket urc fail!!!");
return -1;
}
+
+ result = lynq_start_data_call_rc_socket_thread();
+ if(result != 0)
+ {
+ LYERRLOG("init socket client fail!!!");
+ return -1;
+ }
result = create_urc_vector_signal_thread();
if(result!=0)
@@ -922,10 +1041,20 @@
return -1;
}
memset(lynq_apn_table,0,sizeof(lynq_apn_table));
- LYDBGLOG("lynq init call success!!!");
+ LYDBGLOG("lynq init data success!!!");
return 0;
}
+
+static void lynq_deinit_data_call_rc_thread()
+{
+ if (module_rc_tid != -1)
+ {
+ pthread_cond_broadcast(&s_lynq_rc_vector_cond);
+ }
+ return NULL;
+}
+
int lynq_deinit_data()
{
int ret = -1;
@@ -952,6 +1081,7 @@
LYERRLOG("lynq_deinit_data_urc_thread fail");
return ret;
}
+ lynq_deinit_data_call_rc_thread();
pthread_mutex_lock(&s_lynq_urc_vector_mutex);
s_data_urc_wait_list.clear();
pthread_mutex_unlock(&s_lynq_urc_vector_mutex);
@@ -972,7 +1102,7 @@
LYINFLOG("[%s][%d]",__FUNCTION__,__LINE__);
error = lynq_setup_data_call_sp(handle,NULL,"iot_default",NULL,NULL,NULL,NULL,NULL);
#else
- Parcel p;
+ Parcel *p = NULL;
lynq_client_t client;
int resp_type = -1;
int request = -1;
@@ -983,7 +1113,7 @@
LYERRLOG("handle is null!!!");
return LYNQ_E_NULL_ANONALY;
}
- client.uToken = Global_uToken;
+ client.uToken = get_utoken();
client.request = 27;//RIL_REQUEST_SETUP_DATA_CALL
client.paramLen = 0;
bzero(client.param,LYNQ_REQUEST_PARAM_BUF);
@@ -1002,16 +1132,26 @@
{
LYERRLOG("send request fail");
perror("[LYNQ_DATA] send request fail:");
+ pthread_mutex_unlock(&g_lynq_data_sendto_mutex);
return LYNQ_E_NULL_ANONALY+2;
}
- get_response(lynq_client_sockfd,p);
+ //get_response(lynq_client_sockfd,p);
+ error = wait_response(lynq_client_sockfd,p,client.uToken);
+ if(error!=0)
+ {
+ LYERRLOG("wait_response fail,ret:%d",error);
+ printf_apn_table_debug(__FUNCTION__,__LINE__);
+ pthread_mutex_unlock(&g_lynq_data_sendto_mutex);
+ return error;
+ }
pthread_mutex_unlock(&g_lynq_data_sendto_mutex);
- JumpHeader(p,&resp_type,&request,&slot_id,&error);
+ JumpHeader(p,&resp_type,&client.uToken,&request,&slot_id,&error);
+ free_parcel(p);
LYINFLOG("resp_type=%d,request=%d,slot_id=%d,error_code=%d",resp_type,request,slot_id,error);
if(error==0)
{
data_timelimit = 1;
- if (waitDataCallstateChange(60000) == ETIMEDOUT) // 60s
+ if (waitDataCallstateChange(g_data_call_timeout_value) == ETIMEDOUT)
{
error = LYNQ_E_TIME_OUT;
LYERRLOG("timeout:wait data Call state fail!!!");
@@ -1025,6 +1165,13 @@
printf_apn_table_debug(__FUNCTION__,__LINE__);
return error;
}
+ if(lynq_data_call == LYNQ_E_TIME_OUT)
+ {
+ error = LYNQ_E_TIME_OUT;
+ LYERRLOG("PDN_TIMEOUT_CANCLE:wait data Call state fail!!!");
+ printf_apn_table_debug(__FUNCTION__,__LINE__);
+ return error;
+ }
}
printf_apn_table_debug(__FUNCTION__,__LINE__);
#endif //GSW_RIL_CFG
@@ -1032,9 +1179,184 @@
return error;
}
+static void *data_thread_rc_recv(void *p_input)
+{
+ Parcel *p = NULL;
+ lynq_client_t client;
+ int resp_type = -1;
+ int request = -1;
+ int slot_id = -1;
+ int error = -1;
+ int lynq_data_call_id = -1;
+ char *argv[10] = {};
+ //T106 arg
+ int slot_tmp = -1;
+ int version = -1;
+ int num = -1;
+ int status = -1;
+ int suggestedRetryTime = -1;
+ int cid = -1;
+ int active = -1;
+ int utoken = -1;
+ char apntype_response[LYNQ_TYPE_MAX_LEN] = {0};
+ char ifaceName[LYNQ_IFACE_NAME_MAX_LEN] = {0};
+ char type[LYNQ_TYPE_MAX_LEN] = {0};
+ char addresses[LYNQ_ADDRESSES_MAX_LEN] = {0};
+ char dnses[LYNQ_DNSES_MAX_LEN] = {0};
+ char gateways[LYNQ_GATEWAYS_MAX_LEN] = {0};
+ char pcscf[LYNQ_PCSCF_MAX_LEN] = {0};
+
+ char *tmp_msg = NULL;
+ int len = 0;
+
+ LYINFLOG("[data_thread_rc_recv]: in thread_rc_recv");
+ while(module_rc_status)
+ {
+ pthread_mutex_lock(&s_lynq_rc_vector_mutex);
+ pthread_cond_wait(&s_lynq_rc_vector_cond,&s_lynq_rc_vector_mutex);
+ pthread_mutex_unlock(&s_lynq_rc_vector_mutex);
+ LYINFLOG("[data_thread_rc_recv]: pthread_mutex_unlock");
+ if(g_lynq_data_init_flag == 0)
+ {
+ LYINFLOG("has deinit, need exit");
+ return NULL;
+ }
+
+ error = wait_response(lynq_client_sockfd,p,g_setup_utoken);
+ if(error!=0)
+ {
+ LYERRLOG("wait_response fail,ret:%d",error);
+ printf_apn_table();
+ pthread_mutex_unlock(&g_lynq_data_sendto_mutex);
+ for(lynq_data_call_id = 0; lynq_data_call_id < LYNQ_APN_CHANNEL_MAX; lynq_data_call_id++)
+ {
+ if(lynq_apn_table[lynq_data_call_id].hasUsed == 1 && lynq_apn_table[lynq_data_call_id].cid <= 0)
+ {
+ memset(lynq_apn_table[lynq_data_call_id].apn, 0, strlen(lynq_apn_table[lynq_data_call_id].apn) + 1);
+ memset(lynq_apn_table[lynq_data_call_id].apnType, 0, strlen(lynq_apn_table[lynq_data_call_id].apnType) + 1);
+ lynq_apn_table[lynq_data_call_id].hasUsed == 0;
+
+ pthread_mutex_lock(&s_lynq_urc_vector_mutex);
+ s_data_urc_wait_list.push_back(lynq_data_call_id);
+ pthread_mutex_unlock(&s_lynq_urc_vector_mutex);
+ sendSignalPdnChange();
+ }
+ }
+ continue;
+ }
+ pthread_mutex_unlock(&g_lynq_data_sendto_mutex);
+
+ bzero(type,LYNQ_TYPE_MAX_LEN);
+ bzero(ifaceName,LYNQ_IFACE_NAME_MAX_LEN);
+
+ if(p->dataAvail() > 0)
+ {
+ p->readInt32(&resp_type);
+ p->readInt32(&utoken);
+ p->readInt32(&request);
+ p->readInt32(&slot_id);
+ p->readInt32(&error);
+
+ tmp_msg = strdupReadString(*p);
+ len = strlen(tmp_msg);
+ if(len < LYNQ_TYPE_MAX_LEN-1)
+ {
+ memcpy(apntype_response,tmp_msg,len+1);
+ }
+ free(tmp_msg);
+
+ p->readInt32(&version);
+ p->readInt32(&num);
+ p->readInt32(&status);
+ p->readInt32(&suggestedRetryTime);
+ p->readInt32(&cid);
+
+ LYINFLOG("resp_type=%d,utoken=%d,request=%d,socket_id=%d,error_code=%d,version=%d,num=%d,status=%d,suggestedRetryTime=%d,cid=%d,apntype=%s\n",resp_type,utoken,request,slot_id,error,version,num,status,suggestedRetryTime,cid,apntype_response);
+ }
+ else
+ {
+ LYINFLOG("avail <= 0\n");
+ for(lynq_data_call_id = 0; lynq_data_call_id < LYNQ_APN_CHANNEL_MAX; lynq_data_call_id++)
+ {
+ if(lynq_apn_table[lynq_data_call_id].hasUsed == 1 && lynq_apn_table[lynq_data_call_id].cid <= 0)
+ {
+ memset(lynq_apn_table[lynq_data_call_id].apn, 0, strlen(lynq_apn_table[lynq_data_call_id].apn) + 1);
+ memset(lynq_apn_table[lynq_data_call_id].apnType, 0, strlen(lynq_apn_table[lynq_data_call_id].apnType) + 1);
+ lynq_apn_table[lynq_data_call_id].hasUsed == 0;
+
+ pthread_mutex_lock(&s_lynq_urc_vector_mutex);
+ s_data_urc_wait_list.push_back(lynq_data_call_id);
+ pthread_mutex_unlock(&s_lynq_urc_vector_mutex);
+ sendSignalPdnChange();
+ }
+ }
+ continue;
+ }
+
+ for(lynq_data_call_id = 0; lynq_data_call_id < LYNQ_APN_CHANNEL_MAX; lynq_data_call_id++)
+ {
+ if(lynq_apn_table[lynq_data_call_id].hasUsed == 1 && lynq_apn_table[lynq_data_call_id].cid <= 0 && strcmp(apntype_response, lynq_apn_table[lynq_data_call_id].apnType) == 0)
+ {
+ break;
+ }
+ }
+ LYINFLOG("lynq_data_call_id is %d", lynq_data_call_id);
+ if (lynq_data_call_id == LYNQ_APN_CHANNEL_MAX)
+ {
+ LYERRLOG("update apn table fail error id = %d",lynq_data_call_id);
+ free_parcel(p);
+ continue;
+ }
+
+ if(error==0)
+ {
+ //the cid out of lynq_apn_table, need add a new item
+ if(version != 0)//version = 0, this apn has been called in ril-service. Didn't return active and type.
+ {
+ p->readInt32(&active);
+
+ tmp_msg = strdupReadString(*p);
+ len = strlen(tmp_msg);
+ if(len < LYNQ_TYPE_MAX_LEN-1)
+ {
+ memcpy(type,tmp_msg,len+1);
+ }
+ free(tmp_msg);
+ }
+ tmp_msg = strdupReadString(*p);
+ len = strlen(tmp_msg);
+ if(len < LYNQ_IFACE_NAME_MAX_LEN-1)
+ {
+ memcpy(ifaceName,tmp_msg,len+1);
+ }
+ free(tmp_msg);
+ LYINFLOG("resp_type=%d,utoken=%d,request=%d,socket_id=%d,error_code=%d,version=%d,num=%d,status=%d,suggestedRetryTime=%d,cid=%d,active=%d,type=%s,ifname=%s\n",
+ resp_type,utoken,request,slot_id,error,version,num,status,suggestedRetryTime,cid,active,type,ifaceName);
+
+ //*handle = lynq_data_call_id;
+ lynq_apn_table[lynq_data_call_id].cid = cid;
+ memcpy(lynq_apn_table[lynq_data_call_id].ifaceName, ifaceName, strlen(ifaceName) + 1);
+ //lynq_apn_table[lynq_data_call_id].hasUsed = 1;
+ printf_apn_table();
+ }
+ else
+ {
+ memset(lynq_apn_table[lynq_data_call_id].apn, 0, strlen(lynq_apn_table[lynq_data_call_id].apn) + 1);
+ memset(lynq_apn_table[lynq_data_call_id].apnType, 0, strlen(lynq_apn_table[lynq_data_call_id].apnType) + 1);
+ lynq_apn_table[lynq_data_call_id].hasUsed == 0;
+ }
+UpdateHandle:
+ free_parcel(p);
+ pthread_mutex_lock(&s_lynq_urc_vector_mutex);
+ s_data_urc_wait_list.push_back(lynq_data_call_id);
+ pthread_mutex_unlock(&s_lynq_urc_vector_mutex);
+ sendSignalPdnChange();
+ }
+}
+
int lynq_deactive_data_call(int *handle)
{
- Parcel p;
+ Parcel *p = NULL;
lynq_client_t client;
int resp_type = -1;
int request = -1;
@@ -1054,7 +1376,7 @@
return -1;
}
lynq_data_call_id = *handle;
- client.uToken = Global_uToken;
+ client.uToken = get_utoken();
client.request = 41;//RIL_REQUEST_DEACTIVATE_DATA_CALL
//xf.li@20230610 add for T106 data start
#ifndef MOBILETEK_TARGET_PLATFORM_T106
@@ -1084,12 +1406,22 @@
{
LYERRLOG("send request fail");
perror("[LYNQ_DATA] send request fail:");
+ pthread_mutex_unlock(&g_lynq_data_sendto_mutex);
return -1;
}
- get_response(lynq_client_sockfd,p);
+ //get_response(lynq_client_sockfd,p);
+ error = wait_response(lynq_client_sockfd,p,client.uToken);
+ if(error!=0)
+ {
+ LYERRLOG("wait_response fail,ret:%d",error);
+ printf_apn_table_debug(__FUNCTION__,__LINE__);
+ pthread_mutex_unlock(&g_lynq_data_sendto_mutex);
+ return error;
+ }
pthread_mutex_unlock(&g_lynq_data_sendto_mutex);
- JumpHeader(p,&resp_type,&request,&slot_id,&error);
- LYINFLOG("resp_type=%d,request=%d,slot_id=%d,error_code=%d",resp_type,request,slot_id,error);
+ JumpHeader(p,&resp_type,&client.uToken,&request,&slot_id,&error);
+ LYINFLOG("resp_type=%d,uToken=%d,request=%d,slot_id=%d,error_code=%d",resp_type,client.uToken,request,slot_id,error);
+ free_parcel(p);
#ifndef MOBILETEK_TARGET_PLATFORM_T106
cleanOnceApnTable(lynq_data_call_id);
#endif
@@ -1097,9 +1429,137 @@
return error;
}
//xf.li@20230610 add for T106 data start
+static int lynq_start_data_call_rc_socket_thread()
+{
+// pthread_attr_t attr;
+ int ret;
+
+ pthread_mutex_init(&s_lynq_rc_vector_mutex, NULL);
+
+ module_rc_status = 1;
+
+ ret = pthread_create(&module_rc_tid,/*&attr*/NULL,data_thread_rc_recv,NULL);
+ if(ret <0)
+ {
+ LYERRLOG("rc pthread create error");
+ module_rc_status =0;
+ return ret;
+ }
+
+ LYINFLOG("rc start success");
+
+ return 0;
+}
+
+int lynq_setup_data_call_sp_t106_async(int *handle,char *apn,char *apnType,char *user,char *password,char *authType,char *normalProtocol,char *roamingProtocol)
+{
+
+ lynq_client_t client;
+ int lynq_data_call_id = -1;
+ char *argv[10] = {};
+ int slot_tmp = -1;
+ int cid = -1;
+
+ int i;
+
+ LYINFLOG("[%s][%d]",__FUNCTION__,__LINE__);
+ if(handle==NULL)
+ {
+ LYERRLOG("handle is null!!!");
+ return -1;
+ }
+
+ if(user == NULL || strcmp(user, "NULL") == 0)
+ {
+ argv[1] = NULL;
+ }
+ else
+ {
+ argv[1] = user;
+ }
+
+ if(password == NULL || strcmp(password, "NULL") == 0)
+ {
+ argv[2] = NULL;
+ }
+ else
+ {
+ argv[2] = password;
+ }
+
+ if(authType == NULL || strcmp(authType, "NULL") == 0)
+ {
+ argv[3] = NULL;
+ }
+ else
+ {
+ argv[3] = authType;
+ }
+ if(normalProtocol==NULL)
+ {
+ argv[4] = "IPV4V6";
+ }
+ else
+ {
+ argv[4] = normalProtocol;
+ }
+
+ client.uToken = get_utoken();
+ client.request = 27;//RIL_REQUEST_SETUP_DATA_CALL
+ client.paramLen = 7;
+ bzero(client.param,LYNQ_REQUEST_PARAM_BUF);
+ sprintf(client.param,"%s %s %s %s %s %s %s",apn,apnType,argv[1],argv[2],argv[3],argv[4],roamingProtocol);
+ LYINFLOG("uToken=%d,request=%d,paralen=%d,param=%s",client.uToken,client.request,client.paramLen,client.param);
+ //if apn has set up
+ for(i = 0;i < LYNQ_APN_CHANNEL_MAX; i++)
+ {
+ if((lynq_apn_table[i].hasUsed != 0) && (strcmp(lynq_apn_table[i].apn, apn) == 0))
+ {
+ LYERRLOG("has exit this cid %d in slot %d\n", lynq_apn_table[i].cid, i);
+ return LYNQ_E_REPETITIVE_APN;
+ }
+ }
+ //find lynq_data_call_id
+ for(lynq_data_call_id = 0; lynq_data_call_id < LYNQ_APN_CHANNEL_MAX; lynq_data_call_id++)
+ {
+ if(lynq_apn_table[lynq_data_call_id].hasUsed == 0)
+ {
+ break;
+ }
+ }
+ if (lynq_data_call_id == LYNQ_APN_CHANNEL_MAX)
+ {
+ LYERRLOG("update apn table fail error id = %d",lynq_data_call_id);
+ return -1;
+ }
+ LYINFLOG("lynq_data_call_id = %d\n", lynq_data_call_id);
+ //ready to send request
+ pthread_mutex_lock(&g_lynq_data_sendto_mutex);
+
+ if(send_request(lynq_client_sockfd,&client)==-1)
+ {
+ LYERRLOG("send request fail");
+ perror("[LYNQ_DATA] send request fail:");
+ pthread_mutex_unlock(&g_lynq_data_sendto_mutex);
+ return -1;
+ }
+ LYINFLOG("lynq_data_call_id = %d\n", lynq_data_call_id);
+ *handle = lynq_data_call_id;
+ g_setup_utoken = client.uToken;
+ lynq_apn_table[lynq_data_call_id].hasUsed = 1;
+ memcpy(lynq_apn_table[lynq_data_call_id].apn, apn, strlen(apn) + 1);
+ memcpy(lynq_apn_table[lynq_data_call_id].apnType, apnType, strlen(apnType) + 1);
+
+ pthread_mutex_lock(&s_lynq_rc_vector_mutex);
+ pthread_cond_signal(&s_lynq_rc_vector_cond);
+ pthread_mutex_unlock(&s_lynq_rc_vector_mutex);
+
+ return 0;
+}
+
int lynq_setup_data_call_sp_t106(int *handle,char *apn,char *apnType,char *user,char *password,char *authType,char *normalProtocol,char *roamingProtocol)
{
- Parcel p;
+ Parcel *p = NULL;
lynq_client_t client;
int resp_type = -1;
int request = -1;
@@ -1116,6 +1576,7 @@
int cid = -1;
int active = -1;
int utoken = -1;
+ char apntype_response[LYNQ_TYPE_MAX_LEN] = {0};
char ifaceName[LYNQ_IFACE_NAME_MAX_LEN] = {0};
char type[LYNQ_TYPE_MAX_LEN] = {0};
char addresses[LYNQ_ADDRESSES_MAX_LEN] = {0};
@@ -1168,7 +1629,7 @@
argv[4] = normalProtocol;
}
- client.uToken = Global_uToken;
+ client.uToken = get_utoken();
client.request = 27;//RIL_REQUEST_SETUP_DATA_CALL
client.paramLen = 7;
bzero(client.param,LYNQ_REQUEST_PARAM_BUF);
@@ -1181,27 +1642,45 @@
{
LYERRLOG("send request fail");
perror("[LYNQ_DATA] send request fail:");
+ pthread_mutex_unlock(&g_lynq_data_sendto_mutex);
return -1;
}
- get_response(lynq_client_sockfd,p);
+ //get_response(lynq_client_sockfd,p);
+ error = wait_response(lynq_client_sockfd,p,client.uToken);
+ if(error!=0)
+ {
+ LYERRLOG("wait_response fail,ret:%d",error);
+ printf_apn_table();
+ pthread_mutex_unlock(&g_lynq_data_sendto_mutex);
+ return error;
+ }
pthread_mutex_unlock(&g_lynq_data_sendto_mutex);
bzero(type,LYNQ_TYPE_MAX_LEN);
bzero(ifaceName,LYNQ_IFACE_NAME_MAX_LEN);
- if(p.dataAvail() > 0)
+ if(p->dataAvail() > 0)
{
- p.readInt32(&resp_type);
- p.readInt32(&utoken);
- p.readInt32(&request);
- p.readInt32(&slot_id);
- p.readInt32(&error);
- p.readInt32(&version);
- p.readInt32(&num);
- p.readInt32(&status);
- p.readInt32(&suggestedRetryTime);
- p.readInt32(&cid);
+ p->readInt32(&resp_type);
+ p->readInt32(&utoken);
+ p->readInt32(&request);
+ p->readInt32(&slot_id);
+ p->readInt32(&error);
+
+ tmp_msg = strdupReadString(*p);
+ len = strlen(tmp_msg);
+ if(len < LYNQ_TYPE_MAX_LEN-1)
+ {
+ memcpy(apntype_response,tmp_msg,len+1);
+ }
+ free(tmp_msg);
+
+ p->readInt32(&version);
+ p->readInt32(&num);
+ p->readInt32(&status);
+ p->readInt32(&suggestedRetryTime);
+ p->readInt32(&cid);
LYINFLOG("resp_type=%d,utoken=%d,request=%d,socket_id=%d,error_code=%d,version=%d,num=%d,status=%d,suggestedRetryTime=%d,cid=%d\n",resp_type,utoken,request,slot_id,error,version,num,status,suggestedRetryTime,cid);
}
@@ -1219,15 +1698,16 @@
if(slot_tmp >= 0)
{
*handle = slot_tmp;
+ free_parcel(p);
return error;
}
}
//the cid out of lynq_apn_table, need add a new item
if(version != 0)
{
- p.readInt32(&active);
+ p->readInt32(&active);
- tmp_msg = strdupReadString(p);
+ tmp_msg = strdupReadString(*p);
len = strlen(tmp_msg);
if(len < LYNQ_TYPE_MAX_LEN-1)
{
@@ -1235,13 +1715,14 @@
}
free(tmp_msg);
}
- tmp_msg = strdupReadString(p);
+ tmp_msg = strdupReadString(*p);
len = strlen(tmp_msg);
if(len < LYNQ_IFACE_NAME_MAX_LEN-1)
{
memcpy(ifaceName,tmp_msg,len+1);
}
free(tmp_msg);
+ free_parcel(p);
LYINFLOG("resp_type=%d,utoken=%d,request=%d,socket_id=%d,error_code=%d,version=%d,num=%d,status=%d,suggestedRetryTime=%d,cid=%d,active=%d,type=%s,ifname=%s\n",
resp_type,utoken,request,slot_id,error,version,num,status,suggestedRetryTime,cid,active,type,ifaceName);
for(lynq_data_call_id = 0; lynq_data_call_id < LYNQ_APN_CHANNEL_MAX; lynq_data_call_id++)
@@ -1279,7 +1760,7 @@
t106_error = lynq_setup_data_call_sp_t106(handle, apn, apnType, user, password, authType, normalProtocol, roamingProtocol);
return t106_error;
#endif
- Parcel p;
+ Parcel *p = NULL;
lynq_client_t client;
int resp_type = -1;
int request = -1;
@@ -1341,7 +1822,7 @@
{
argv[5] = roamingProtocol;
}
- client.uToken = Global_uToken;
+ client.uToken = get_utoken();
client.request = 27;//RIL_REQUEST_SETUP_DATA_CALL
client.paramLen = 7;
bzero(client.param,LYNQ_REQUEST_PARAM_BUF);
@@ -1371,16 +1852,26 @@
{
LYERRLOG("send request fail");
perror("[LYNQ_DATA] send request fail:");
+ pthread_mutex_unlock(&g_lynq_data_sendto_mutex);
return LYNQ_E_NULL_ANONALY+2;
}
- get_response(lynq_client_sockfd,p);
+ //get_response(lynq_client_sockfd,p);
+ error = wait_response(lynq_client_sockfd,p,client.uToken);
+ if(error!=0)
+ {
+ LYERRLOG("wait_response fail,ret:%d",error);
+ printf_apn_table_debug(__FUNCTION__,__LINE__);
+ pthread_mutex_unlock(&g_lynq_data_sendto_mutex);
+ return error;
+ }
pthread_mutex_unlock(&g_lynq_data_sendto_mutex);
- JumpHeader(p,&resp_type,&request,&slot_id,&error);
- LYINFLOG("resp_type=%d,request=%d,slot_id=%d,error_code=%d",resp_type,request,slot_id,error);
+ JumpHeader(p,&resp_type,&client.uToken,&request,&slot_id,&error);
+ LYINFLOG("resp_type=%d,uToken=%d,request=%d,slot_id=%d,error_code=%d",resp_type,client.uToken,request,slot_id,error);
+ free_parcel(p);
if(error==0)
{
data_timelimit = 1;
- if(waitDataCallstateChange(60000)==ETIMEDOUT)//60s
+ if(waitDataCallstateChange(g_data_call_timeout_value)==ETIMEDOUT)
{
error = LYNQ_E_TIME_OUT;
LYERRLOG("timeout:wait data Call state fail!!!");
@@ -1394,6 +1885,13 @@
printf_apn_table_debug(__FUNCTION__,__LINE__);
return error;
}
+ if(lynq_data_call == LYNQ_E_TIME_OUT)
+ {
+ error = LYNQ_E_TIME_OUT;
+ LYERRLOG("PDN_TIMEOUT_CANCLE:wait data Call state fail!!!");
+ printf_apn_table_debug(__FUNCTION__,__LINE__);
+ return error;
+ }
}
printf_apn_table_debug(__FUNCTION__,__LINE__);
return error;
@@ -1432,7 +1930,7 @@
*/
int getDataCallLists(lynq_data_call_response_v11_t dataCallList[LYNQ_APN_CHANNEL_MAX],int *realNum)
{
- Parcel p;
+ Parcel *p = NULL;
lynq_client_t client;
int resp_type = -1;
int token;
@@ -1447,8 +1945,7 @@
LYERRLOG("dataCallList is null!!!");
return -1;
}
- Global_uToken++;
- client.uToken = Global_uToken;
+ client.uToken = get_utoken();
client.request = 57;//RIL_REQUEST_DATA_CALL_LIST
client.paramLen = 0;
bzero(client.param,LYNQ_REQUEST_PARAM_BUF);
@@ -1458,79 +1955,81 @@
{
LYERRLOG("send request fail");
perror("[LYNQ_DATA] send request fail:");
+ pthread_mutex_unlock(&g_lynq_data_sendto_mutex);
return -1;
}
- get_response(lynq_client_sockfd,p);
+ //get_response(lynq_client_sockfd,p);
+ error = wait_response(lynq_client_sockfd,p,client.uToken);
+ if(error!=0)
+ {
+ LYERRLOG("wait_response fail,ret:%d",error);
+ pthread_mutex_unlock(&g_lynq_data_sendto_mutex);
+ return error;
+ }
pthread_mutex_unlock(&g_lynq_data_sendto_mutex);
- if(p.dataAvail() > 0)
+ if(JumpHeader(p,&resp_type,&client.uToken,&request,&slot_id,&error)!=0)
{
- p.readInt32(&resp_type);
- p.readInt32(&token);
- p.readInt32(&request);
- p.readInt32(&slot_id);
- p.readInt32(&error);
- }
- else
- {
+ LYERRLOG("JumpHeader fail");
return -1;
}
- LYINFLOG("resp_type=%d,uToken=%d,request=%d,slot_id=%d,error_code=%d",resp_type,token,request,slot_id,error);
- p.readInt32(&version);
+ LYINFLOG("resp_type=%d,uToken=%d,request=%d,slot_id=%d,error_code=%d",resp_type,client.uToken,request,slot_id,error);
+ p->readInt32(&version);
if(version==11)
{
- p.readInt32(&num);
+ p->readInt32(&num);
*realNum = num;
for (int i = 0; i < num; i++)
{
- p.readInt32(&dataCallList[i].status);
- p.readInt32(&dataCallList[i].suggestedRetryTime);
- p.readInt32(&dataCallList[i].cid);
- p.readInt32(&dataCallList[i].active);
- temp_char = strdupReadString(p);
+ p->readInt32(&dataCallList[i].status);
+ p->readInt32(&dataCallList[i].suggestedRetryTime);
+ p->readInt32(&dataCallList[i].cid);
+ p->readInt32(&dataCallList[i].active);
+ temp_char = strdupReadString_p(p);
LYINFLOG("[%s][%d]%s",__FUNCTION__,__LINE__,temp_char);
if(temp_char)
{
memcpy(dataCallList[i].type,temp_char,strlen(temp_char)+1);
free(temp_char);
}
- temp_char = strdupReadString(p);
+ temp_char = strdupReadString_p(p);
LYINFLOG("[%s][%d]%s",__FUNCTION__,__LINE__,temp_char);
if(temp_char)
{
memcpy(dataCallList[i].ifname,temp_char,strlen(temp_char)+1);
free(temp_char);
}
- temp_char = strdupReadString(p);
+ temp_char = strdupReadString_p(p);
LYINFLOG("[%s][%d]%s",__FUNCTION__,__LINE__,temp_char);
if(temp_char)
{
memcpy(dataCallList[i].addresses,temp_char,strlen(temp_char)+1);
free(temp_char);
}
- temp_char = strdupReadString(p);
+ temp_char = strdupReadString_p(p);
LYINFLOG("[%s][%d]%s",__FUNCTION__,__LINE__,temp_char);
if(temp_char)
{
memcpy(dataCallList[i].dnses,temp_char,strlen(temp_char)+1);
free(temp_char);
}
- temp_char = strdupReadString(p);
+ temp_char = strdupReadString_p(p);
LYINFLOG("[%s][%d]%s",__FUNCTION__,__LINE__,temp_char);
if(temp_char)
{
memcpy(dataCallList[i].gateways,temp_char,strlen(temp_char)+1);
free(temp_char);
}
- temp_char = strdupReadString(p);
+ temp_char = strdupReadString_p(p);
LYINFLOG("[%s][%d]%s",__FUNCTION__,__LINE__,temp_char);
if(temp_char)
{
memcpy(dataCallList[i].pcscf,temp_char,strlen(temp_char)+1);
free(temp_char);
}
- p.readInt32(&dataCallList[i].mtu);
+ p->readInt32(&dataCallList[i].mtu);
}
}
+ free_parcel(p);
return error;
}
int lynq_get_data_call_list(int *handle,lynq_data_call_response_v11_t *dataCallList)
@@ -1539,18 +2038,24 @@
int number = 0;
int lynq_data_call_id = 0;
int error = 0;
- lynq_data_call_id = *handle;
- if(handle==NULL)
+ if (g_lynq_data_init_flag == 0)
{
- LYERRLOG("handle is NULL");
+ LYERRLOG("[%s][%d]Invalid operation",__FUNCTION__,__LINE__);
+ return -1;
+ }
+ lynq_data_call_id = *handle;
+ if((handle==NULL) || (dataCallList==NULL))
+ {
+ LYERRLOG("[lynq_get_data_call_list] handle or datacalllist is NULL");
return LYNQ_E_NULL_ANONALY;
}
if (*handle<0 && handle>8)
{
- LYERRLOG("handle value error");
+ LYERRLOG("[lynq_get_data_call_list] handle value error");
+ return LYNQ_E_NULL_ANONALY;
}
- LYINFLOG("incoming handle value: %d",*handle);
- memset(interDataCallList,0,sizeof(interDataCallList));
+ LYINFLOG("[lynq_get_data_call_list] incoming handle value: %d",*handle);
+ memset(&interDataCallList,0,sizeof(interDataCallList));
error = getDataCallLists(interDataCallList,&number);
if(error == 0)
{
@@ -1569,7 +2074,12 @@
memcpy(dataCallList->type,interDataCallList[i].type,sizeof(interDataCallList[i].type));
memcpy(dataCallList->gateways,interDataCallList[i].gateways,sizeof(interDataCallList[i].gateways));
memcpy(dataCallList->pcscf,interDataCallList[i].pcscf,sizeof(interDataCallList[i].pcscf));
- LYDBGLOG("ifname:%s,addr:%s",dataCallList->ifname,dataCallList->addresses);
+ //LYINFLOG("ifname:%s,addr:%s",dataCallList->ifname,dataCallList->addresses);
+ LYINFLOG("[lynq_get_data_call_list]: status=%d, suggestedRetryTime=%d, cid=%d, active=%d, type=%s, ifname=%s, addresses=%s, dnses=%s, gateways=%s, pcscf=%s, mtu=%d\n",
+ dataCallList->status, dataCallList->suggestedRetryTime, dataCallList->cid, dataCallList->active,
+ dataCallList->type, dataCallList->ifname, dataCallList->addresses, dataCallList->dnses, dataCallList->gateways, dataCallList->pcscf,
+ dataCallList->mtu);
+
}
}
}
diff --git a/cap/zx297520v3/src/lynq/lib/liblynq-data/lynq_data_urc.cpp b/cap/zx297520v3/src/lynq/lib/liblynq-data/lynq_data_urc.cpp
index 0e68559..5e3e2c7 100755
--- a/cap/zx297520v3/src/lynq/lib/liblynq-data/lynq_data_urc.cpp
+++ b/cap/zx297520v3/src/lynq/lib/liblynq-data/lynq_data_urc.cpp
@@ -173,7 +173,7 @@
urc_msg_process(urc_p);
#endif
//xf.li@20230610 add for T106 data end
- urc_msg_process(urc_p);
+ //urc_msg_process(urc_p);
pthread_mutex_unlock(&s_lynq_urc_mutex);
}
delete urc_p;
diff --git a/cap/zx297520v3/src/lynq/lib/liblynq-qser-data/include/lynq-qser-data.h b/cap/zx297520v3/src/lynq/lib/liblynq-qser-data/include/lynq-qser-data.h
old mode 100644
new mode 100755
index c84ab21..a9e7ca0
--- a/cap/zx297520v3/src/lynq/lib/liblynq-qser-data/include/lynq-qser-data.h
+++ b/cap/zx297520v3/src/lynq/lib/liblynq-qser-data/include/lynq-qser-data.h
@@ -57,7 +57,7 @@
};
typedef struct {
- char profile_idx; /*!< UMTS/CMDA profile ID. */
+ char profile_idx; /*!< apn profile ID. */
char name[16]; /*!< Interface Name. */
qser_data_call_ip_family_e ip_family; /*!< IP version. */
qser_data_call_state_e state; /*!< The dial status. */
@@ -74,7 +74,7 @@
typedef void (*qser_data_call_evt_cb_t)(qser_data_call_state_s *state);
typedef struct {
- char profile_idx; /*!< UMTS/CMDA profile ID. */
+ char profile_idx; /*!< apn profile ID. */
bool reconnect; /*!< Whether to re-dial after disconnecting the network. */
qser_data_call_ip_family_e ip_family; /*!< IP version. */
char cdma_username[QSER_APN_USERNAME_SIZE]; /*!< Username used during data network authentication. */
@@ -107,14 +107,14 @@
};
typedef struct {
- char profile_idx; /*!< UMTS/CDMA profile ID. */
+ char profile_idx; /*!< apn profile ID. */
qser_data_call_ip_family_e ip_family; /*!< IP version. */
struct v4_info v4; /*!< IPv4 information */
struct v6_info v6; /*!< IPv6 information */
} qser_data_call_info_s;
typedef struct {
- unsigned char profile_idx; /*!< UMTS/CDMA profile ID. */
+ unsigned char profile_idx; /*!< apn profile ID. */
qser_apn_pdp_type_e pdp_type; /*!< Packet Data Protocol (PDP) type specifies the type of data payload
exchanged over the airlink when the packet data session is
established with this profile. */
@@ -168,7 +168,7 @@
extern void qser_data_call_destroy(void);
/**
- * Starts a data call. If profile index is zero, it will call CDMA profile.
+ * Starts a data call. If profile index is zero, it will call default profile.
*
* @param [in] data_call The data call parameters
* @param [out] error Error code returned by data call
@@ -180,6 +180,18 @@
extern int qser_data_call_start(qser_data_call_s *data_call, qser_data_call_error_e *err);
/**
+ * Starts a data call asynchronously. If profile index is zero, it will call default profile.
+ *
+ * @param [in] data_call The data call parameters
+ * @param [out] error Error code returned by data call
+ *
+ * @return
+ * On success, 0 is returned. On error, -1 is returned.
+ *
+ */
+extern int qser_data_call_start_async(qser_data_call_s *data_call, qser_data_call_error_e *err);
+
+/**
* Stop a data call.
*
* @param [in] profile_idx UMTS/CDMA profile ID
diff --git a/cap/zx297520v3/src/lynq/lib/liblynq-qser-data/lynq-qser-data.cpp b/cap/zx297520v3/src/lynq/lib/liblynq-qser-data/lynq-qser-data.cpp
index 138514d..cae5273 100755
--- a/cap/zx297520v3/src/lynq/lib/liblynq-qser-data/lynq-qser-data.cpp
+++ b/cap/zx297520v3/src/lynq/lib/liblynq-qser-data/lynq-qser-data.cpp
@@ -834,7 +834,7 @@
{
int handle = -1;
int ret = 0;
- lynq_data_call_response_v11_t data_urc_info;
+ lynq_data_call_response_v11_t data_urc_info = {0};
qser_data_call_state_s data_cb_state;
while (s_qser_data_cb_thread_status)
{
@@ -848,11 +848,16 @@
{
continue;
}
-
+ LYINFLOG("[thread_wait_cb_status]: handle = %d", handle);
+ memset(&data_urc_info, 0, sizeof(data_urc_info));
+ memset(&data_cb_state, 0, sizeof(data_cb_state));
lynq_get_data_call_list(&handle,&data_urc_info);
/*compare paramter*/
data_cb_state.profile_idx = (char)handle;
-
+ LYINFLOG("[thread_wait_cb_status]: status=%d, suggestedRetryTime=%d, cid=%d, active=%d, type=%s, ifname=%s, addresses=%s, dnses=%s, gateways=%s, pcscf=%s, mtu=%d\n",
+ data_urc_info.status, data_urc_info.suggestedRetryTime, data_urc_info.cid, data_urc_info.active,
+ data_urc_info.type, data_urc_info.ifname, data_urc_info.addresses, data_urc_info.dnses, data_urc_info.gateways, data_urc_info.pcscf,
+ data_urc_info.mtu);
memcpy(data_cb_state.name,data_urc_info.ifname,strlen(data_urc_info.ifname)+1);
if ((strcmp(data_urc_info.type,"IPV4") == 0) || (strcmp(data_urc_info.type,"IP") == 0))
{
@@ -862,17 +867,16 @@
{
data_cb_state.ip_family = QSER_DATA_CALL_TYPE_IPV6;
}
- else if (strcmp(data_urc_info.type,"IPV4V6"))
+ else if (!strcmp(data_urc_info.type,"IPV4V6"))
{
data_cb_state.ip_family = QSER_DATA_CALL_TYPE_IPV4V6;
}
else
{
- LYERRLOG("unknow data call type");
- continue;
+ LYERRLOG("unknow data call type: %s", data_urc_info.type);
}
- if (data_urc_info.status != 0)
+ if (data_urc_info.active != 0)
{
data_cb_state.state = QSER_DATA_CALL_CONNECTED;
}
@@ -1037,6 +1041,44 @@
return ret;
}
+int qser_data_call_start_async(qser_data_call_s *data_call, qser_data_call_error_e *err)
+{
+ int ret = -1;
+ int handle = 0;
+ if (NULL == data_call || NULL == err)
+ {
+ LYERRLOG("call start incoming paramters error");
+ if(err != NULL)
+ {
+ *err = QSER_DATA_CALL_ERROR_INVALID_PARAMS;
+ }
+ return ret;
+ }
+ if (data_call->profile_idx == 0)
+ {
+ ret = lynq_setup_data_call_sp_t106_async(&handle,"default","default",NULL,NULL,NULL,NULL,NULL);
+ }
+ else
+ {
+ char pdptype[16];
+ qser_apn_info_s apn_info;
+ ret = qser_apn_get(data_call->profile_idx,&apn_info);
+ if (ret != 0)
+ {
+ LYERRLOG("qser_apn_get error");
+ *err = QSER_DATA_CALL_ERROR_INVALID_PARAMS;
+ return ret;
+ }
+ judge_pdp_type(apn_info.pdp_type,pdptype);
+ ret = lynq_setup_data_call_sp_t106_async(&handle,apn_info.apn_name,apn_info.apn_type,apn_info.username,apn_info.password,NULL,pdptype,pdptype);
+ }
+ if (ret != 0)
+ {
+ *err = QSER_DATA_CALL_ERROR_INVALID_PARAMS;
+ }
+ return ret;
+}
+
int qser_data_call_stop(char profile_idx, qser_data_call_ip_family_e ip_family, qser_data_call_error_e *err)
{
int ret = 0;
diff --git a/cap/zx297520v3/src/lynq/packages/apps/Mobiletek_Tester_RDIT/data.cpp b/cap/zx297520v3/src/lynq/packages/apps/Mobiletek_Tester_RDIT/data.cpp
index 01ba78e..92cf3a8 100755
--- a/cap/zx297520v3/src/lynq/packages/apps/Mobiletek_Tester_RDIT/data.cpp
+++ b/cap/zx297520v3/src/lynq/packages/apps/Mobiletek_Tester_RDIT/data.cpp
@@ -104,7 +104,7 @@
, inet_ntoa(state->v4.ip));
printf("LYNQ_QSER_DATA_INIT: v4.gateway=%s\n"
, inet_ntoa(state->v4.gateway));
- printf("LYNQ_QSER_DATA_INIT: v4.pri_dns=%s, v4.sec_dns=%s\n"
+ printf("LYNQ_QSER_DATA_INIT: v4.pri_dns=%s\n"
, inet_ntoa(state->v4.pri_dns));
printf("LYNQ_QSER_DATA_INIT: v4.sec_dns=%s\n"
, inet_ntoa(state->v4.sec_dns));
@@ -171,6 +171,43 @@
printf("%s%d\n",TEST_RESULT,ret);
return ret;
}
+int qser_setup_data_call_async(int argc, char *argv[], int sp_test)
+{
+ printf("[%s][%d] enter!\n",__FUNCTION__,__LINE__);
+ int ret = -1;
+ qser_data_call_s datacall;
+ qser_data_call_error_e err = QSER_DATA_CALL_ERROR_NONE;
+ int ip_family_flag = atoi(argv[3]);
+
+ datacall.profile_idx = atoi(argv[1]);
+ datacall.reconnect = (bool)atoi(argv[2]);
+
+ if(strcmp(argv[3], "QSER_DATA_CALL_TYPE_IPV4") == 0)
+ {
+ datacall.ip_family = QSER_DATA_CALL_TYPE_IPV4;
+ }
+ else if(strcmp(argv[3], "QSER_DATA_CALL_TYPE_IPV6") == 0)
+ {
+ datacall.ip_family = QSER_DATA_CALL_TYPE_IPV6;
+ }
+ else if(strcmp(argv[3], "QSER_DATA_CALL_TYPE_IPV4V6") == 0)
+ {
+ datacall.ip_family = QSER_DATA_CALL_TYPE_IPV4V6;
+ }
+ else
+ {
+ printf("LYNQ_QSER_SETUP_DATA_CALL_ASYNC: ip_family input error\n");
+ return ret;
+ }
+
+ memcpy(datacall.cdma_username, argv[4], QSER_APN_USERNAME_SIZE);
+ memcpy(datacall.cdma_password, argv[5], QSER_APN_PASSWORD_SIZE);
+
+ ret = qser_data_call_start_async(&datacall, &err);
+ printf("LYNQ_QSER_SETUP_DATA_CALL_ASYNC err = %d\n", err);
+ printf("%s%d\n",TEST_RESULT,ret);
+ return ret;
+}
int qser_deactivte_data_call(int argc, char *argv[], int sp_test)
{
printf("[%s][%d] enter!\n",__FUNCTION__,__LINE__);
diff --git a/cap/zx297520v3/src/lynq/packages/apps/Mobiletek_Tester_RDIT/data.h b/cap/zx297520v3/src/lynq/packages/apps/Mobiletek_Tester_RDIT/data.h
index af70f2e..33364fb 100755
--- a/cap/zx297520v3/src/lynq/packages/apps/Mobiletek_Tester_RDIT/data.h
+++ b/cap/zx297520v3/src/lynq/packages/apps/Mobiletek_Tester_RDIT/data.h
@@ -9,6 +9,7 @@
int qser_init_data(int argc, char *argv[], int sp_test);
int qser_deinit_data(int argc, char *argv[], int sp_test);
int qser_setup_data_call(int argc, char *argv[], int sp_test);
+int qser_setup_data_call_async(int argc, char *argv[], int sp_test);
int qser_deactivte_data_call(int argc, char *argv[], int sp_test);
int qser_get_data_call_list(int argc, char *argv[], int sp_test);
int lynq_qser_apn_set(int argc, char *argv[], int sp_test);
diff --git a/cap/zx297520v3/src/lynq/packages/apps/Mobiletek_Tester_RDIT/lynq.h b/cap/zx297520v3/src/lynq/packages/apps/Mobiletek_Tester_RDIT/lynq.h
index 4e2e985..19ec1f0 100755
--- a/cap/zx297520v3/src/lynq/packages/apps/Mobiletek_Tester_RDIT/lynq.h
+++ b/cap/zx297520v3/src/lynq/packages/apps/Mobiletek_Tester_RDIT/lynq.h
@@ -59,6 +59,7 @@
#define LYNQ_QSER_APN_ADD LYNQ_QSER_DATA + 8
#define LYNQ_QSER_APN_DEL LYNQ_QSER_DATA + 9
#define LYNQ_QSER_APN_GET_LIST LYNQ_QSER_DATA + 10
+#define LYNQ_QSER_SETUP_DATA_CALL_ASYNC LYNQ_QSER_DATA + 11
#define LYNQ_QSER_NETWORK LYNQ_BASE + 100
diff --git a/cap/zx297520v3/src/lynq/packages/apps/Mobiletek_Tester_RDIT/req_commands.h b/cap/zx297520v3/src/lynq/packages/apps/Mobiletek_Tester_RDIT/req_commands.h
index 17d61e0..108fc82 100755
--- a/cap/zx297520v3/src/lynq/packages/apps/Mobiletek_Tester_RDIT/req_commands.h
+++ b/cap/zx297520v3/src/lynq/packages/apps/Mobiletek_Tester_RDIT/req_commands.h
@@ -44,6 +44,7 @@
{"LYNQ_QSER_DATA_INIT",qser_init_data, "init the data lib", LYNQ_QSER_DATA_INIT},
{"LYNQ_QSER_DATA_DEINIT",qser_deinit_data, "deinit the data lib", LYNQ_QSER_DATA_DEINIT},
{"LYNQ_QSER_SETUP_DATA_CALL",qser_setup_data_call, "set up data call", LYNQ_QSER_SETUP_DATA_CALL},
+ {"LYNQ_QSER_SETUP_DATA_CALL_ASYNC",qser_setup_data_call_async, "set up data call asynchronously", LYNQ_QSER_SETUP_DATA_CALL_ASYNC},
{"LYNQ_QSER_DEACTIVATE_DATA_CALL",qser_deactivte_data_call, "deactive data call", LYNQ_QSER_DEACTIVATE_DATA_CALL},
{"LYNQ_QSER_GET_DATA_CALL_LIST",qser_get_data_call_list, "get data call list", LYNQ_QSER_GET_DATA_CALL_LIST},
{"LYNQ_QSER_APN_SET",lynq_qser_apn_set, "set apn", LYNQ_QSER_APN_SET},