lh | f81a46f | 2022-02-13 23:57:37 -0800 | [diff] [blame] | 1 | #include <stdio.h> |
| 2 | #include <sys/types.h> |
| 3 | #include <sys/socket.h> |
| 4 | #include <arpa/inet.h> |
| 5 | #include <fcntl.h> |
| 6 | #include <string.h> |
| 7 | #include <stdlib.h> |
| 8 | #include <unistd.h> |
| 9 | #include <binder/Parcel.h> |
| 10 | #include <log/log.h> |
| 11 | #include "lynq_data.h" |
| 12 | #include <cutils/jstring.h> |
| 13 | #include <pthread.h> |
| 14 | #include "liblog/lynq_deflog.h" |
| 15 | #include <sys/time.h> |
rjw | 0cdacbc | 2022-06-22 10:51:07 +0800 | [diff] [blame] | 16 | #include <include/lynq_uci.h> |
rjw | 747deea | 2022-07-01 18:25:30 +0800 | [diff] [blame] | 17 | #include <errno.h> |
rjw | 7ee7bb4 | 2023-01-18 11:34:28 +0800 | [diff] [blame] | 18 | #include <vector> |
| 19 | #include "lynq_data_urc.h" |
| 20 | |
lh | f81a46f | 2022-02-13 23:57:37 -0800 | [diff] [blame] | 21 | #define LYNQ_SERVICE_PORT 8088 |
lh | f81a46f | 2022-02-13 23:57:37 -0800 | [diff] [blame] | 22 | #define LYNQ_REC_BUF 8192 |
| 23 | #define LYNQ_REQUEST_PARAM_BUF 8192 |
| 24 | #define LYQN_SEDN_BUF 1024*8+sizeof(int)*3 |
| 25 | #define USER_LOG_TAG "LYNQ_DATA" |
| 26 | |
rjw | 0cdacbc | 2022-06-22 10:51:07 +0800 | [diff] [blame] | 27 | #define LYNQ_DATA_UCI_BUF 258 |
rjw | 61fcae3 | 2022-08-18 14:03:39 +0800 | [diff] [blame] | 28 | |
lh | f81a46f | 2022-02-13 23:57:37 -0800 | [diff] [blame] | 29 | using ::android::Parcel; |
| 30 | typedef struct{ |
| 31 | int uToken; |
| 32 | int request; |
| 33 | int paramLen; |
| 34 | char param[LYNQ_REQUEST_PARAM_BUF]; |
| 35 | }lynq_client_t; |
lh | 1358661 | 2022-01-11 21:58:58 -0800 | [diff] [blame] | 36 | typedef enum{ |
| 37 | LYNQ_E_CARDSTATE_ERROR=8000, |
| 38 | /* The voice service state is out of service*/ |
| 39 | LYNQ_E_STATE_OUT_OF_SERVICE=8001, |
| 40 | /* The voice service state is EMERGENCY_ONLY*/ |
| 41 | LYNQ_E_STATE_EMERGENCY_ONLY=8002, |
| 42 | /* The radio power is power off*/ |
| 43 | LYNQ_E_STATE_POWER_OFF=8003, |
| 44 | LYNQ_E_TIME_OUT=8004, |
| 45 | /*create or open sms DB fail */ |
| 46 | LYNQ_E_SMS_DB_FAIL=8005, |
| 47 | /*Failed to execute sql statement*/ |
| 48 | LYNQ_E_SMS_SQL_FAIL = 8006, |
| 49 | LYNQ_E_SMS_NOT_FIND = 8007, |
| 50 | /* The logic conflict*/ |
| 51 | LYNQ_E_CONFLICT=9000, |
| 52 | /*Null anomaly*/ |
| 53 | LYNQ_E_NULL_ANONALY=9001 |
lh | f81a46f | 2022-02-13 23:57:37 -0800 | [diff] [blame] | 54 | }LYNQ_E; |
| 55 | |
| 56 | int lynq_client_sockfd = 0; |
| 57 | int Global_uToken = 0; |
Hong_Liu | 7e1b85e | 2023-05-16 05:51:57 -0700 | [diff] [blame] | 58 | struct sockaddr_in lynq_data_socket_server_addr; |
| 59 | int lynq_data_socket_server_addr_len; |
rjw | 7ee7bb4 | 2023-01-18 11:34:28 +0800 | [diff] [blame] | 60 | |
lh | f81a46f | 2022-02-13 23:57:37 -0800 | [diff] [blame] | 61 | int lynq_data_call_change_id = -1; |
| 62 | pthread_t lynq_data_tid =-1; |
| 63 | static pthread_mutex_t s_data_call_state_change_mutex = PTHREAD_MUTEX_INITIALIZER; |
| 64 | static pthread_cond_t s_data_call_state_change_cond = PTHREAD_COND_INITIALIZER; |
rjw | 7ee7bb4 | 2023-01-18 11:34:28 +0800 | [diff] [blame] | 65 | |
rjw | 20006d1 | 2022-04-21 16:29:04 +0800 | [diff] [blame] | 66 | static pthread_mutex_t s_lynq_apn_change_mutex = PTHREAD_MUTEX_INITIALIZER; |
| 67 | static pthread_cond_t s_lynq_apn_change_cond = PTHREAD_COND_INITIALIZER; |
rjw | 7ee7bb4 | 2023-01-18 11:34:28 +0800 | [diff] [blame] | 68 | static pthread_mutex_t s_lynq_urc_vector_mutex = PTHREAD_MUTEX_INITIALIZER; |
| 69 | static pthread_cond_t s_lynq_urc_vector_cond = PTHREAD_COND_INITIALIZER; |
rjw | ed00d04 | 2022-05-25 09:18:16 +0800 | [diff] [blame] | 70 | /**g_lynq_data_sendto_mutex |
| 71 | * @brief mark data send request mutex |
| 72 | */ |
| 73 | static pthread_mutex_t g_lynq_data_sendto_mutex; |
rjw | f9ec383 | 2023-04-12 10:59:15 +0800 | [diff] [blame] | 74 | /*This value data the state of the wait*/ |
rjw | c3d6e58 | 2023-03-28 17:19:11 +0800 | [diff] [blame] | 75 | static int data_waiting_status = 0; |
rjw | f9ec383 | 2023-04-12 10:59:15 +0800 | [diff] [blame] | 76 | /*The value indicates that 8085 error occurs in data*/ |
rjw | c63abb4 | 2023-03-31 18:22:42 +0800 | [diff] [blame] | 77 | static int data_invaild_error = 0; |
rjw | f9ec383 | 2023-04-12 10:59:15 +0800 | [diff] [blame] | 78 | /*This value ensure the data call timing is correct*/ |
| 79 | static int data_timelimit = 0; |
rjw | c63abb4 | 2023-03-31 18:22:42 +0800 | [diff] [blame] | 80 | |
rjw | 22947c2 | 2022-03-15 09:21:29 +0800 | [diff] [blame] | 81 | /**g_lynq_data_init_flag |
| 82 | * @brief mark data initialization state |
| 83 | * 0:deinit status |
| 84 | * 1:init state |
| 85 | */ |
| 86 | static int g_lynq_data_init_flag = 0; |
rjw | 20006d1 | 2022-04-21 16:29:04 +0800 | [diff] [blame] | 87 | /**g_lynq_apn_result |
| 88 | * @brief temp of apn result info |
| 89 | */ |
| 90 | char g_lynq_apn_result[1024] = {}; |
rjw | 747deea | 2022-07-01 18:25:30 +0800 | [diff] [blame] | 91 | |
rjw | 7ee7bb4 | 2023-01-18 11:34:28 +0800 | [diff] [blame] | 92 | static std::vector<int> s_data_urc_wait_list; |
| 93 | |
rjw | 20006d1 | 2022-04-21 16:29:04 +0800 | [diff] [blame] | 94 | typedef struct |
| 95 | { |
lh | f81a46f | 2022-02-13 23:57:37 -0800 | [diff] [blame] | 96 | char apn[LYNQ_APN_MAX_LEN]; |
| 97 | char apnType[LYNQ_APN_TYPE_MAX_LEN]; |
| 98 | char ifaceName[LYNQ_IFACE_NAME_MAX_LEN]; |
| 99 | int hasUsed; |
| 100 | int hasTimeout; |
| 101 | }lynq_apn_t; |
| 102 | lynq_apn_t lynq_apn_table[LYNQ_APN_CHANNEL_MAX] = {}; |
| 103 | lynq_data_call_response_v11_t lynq_data_call_lists[LYNQ_APN_CHANNEL_MAX] = {}; |
| 104 | int lynq_data_call = 0; |
lh | f81a46f | 2022-02-13 23:57:37 -0800 | [diff] [blame] | 105 | |
lh | f81a46f | 2022-02-13 23:57:37 -0800 | [diff] [blame] | 106 | int getLynqApnID(char apnType[]) |
| 107 | { |
| 108 | int ret = 0; |
rjw | c63abb4 | 2023-03-31 18:22:42 +0800 | [diff] [blame] | 109 | int len = 0; |
lh | f81a46f | 2022-02-13 23:57:37 -0800 | [diff] [blame] | 110 | for(ret;ret<LYNQ_APN_CHANNEL_MAX;ret++) |
| 111 | { |
rjw | c63abb4 | 2023-03-31 18:22:42 +0800 | [diff] [blame] | 112 | len = strlen(lynq_apn_table[ret].apnType)<strlen(apnType) ? strlen(lynq_apn_table[ret].apnType):strlen(apnType); |
Hong_Liu | 6149f18 | 2023-05-12 02:15:14 -0700 | [diff] [blame] | 113 | LYINFLOG("apn_table[%d].apnType:%s,input apntype:%s,len:%d",ret,lynq_apn_table[ret].apnType,apnType,len); |
rjw | c63abb4 | 2023-03-31 18:22:42 +0800 | [diff] [blame] | 114 | if(strncmp(lynq_apn_table[ret].apnType,apnType,len)==0) |
lh | 1358661 | 2022-01-11 21:58:58 -0800 | [diff] [blame] | 115 | { |
lh | f81a46f | 2022-02-13 23:57:37 -0800 | [diff] [blame] | 116 | return ret; |
| 117 | } |
| 118 | } |
| 119 | return -1; |
| 120 | } |
rjw | 7ee7bb4 | 2023-01-18 11:34:28 +0800 | [diff] [blame] | 121 | |
lh | f81a46f | 2022-02-13 23:57:37 -0800 | [diff] [blame] | 122 | void updateApnTable(lynq_apn_t *apn_table,char apn[],char apntype[],char ifaceName[]) |
| 123 | { |
| 124 | LYDBGLOG("[updateApnTable] apn:%s,apntype:%s,ifaceName:%s",apn,apntype,ifaceName); |
| 125 | if(apn_table==NULL) |
| 126 | { |
| 127 | LYERRLOG("apn_table is null"); |
| 128 | return; |
| 129 | } |
| 130 | memcpy(apn_table->apn,apn,strlen(apn)+1); |
| 131 | memcpy(apn_table->apnType,apntype,strlen(apntype)+1); |
| 132 | memcpy(apn_table->ifaceName,ifaceName,strlen(ifaceName)+1); |
| 133 | apn_table->hasTimeout = 0; |
| 134 | apn_table->hasUsed = 1; |
| 135 | return; |
| 136 | } |
rjw | 7ee7bb4 | 2023-01-18 11:34:28 +0800 | [diff] [blame] | 137 | |
lh | f81a46f | 2022-02-13 23:57:37 -0800 | [diff] [blame] | 138 | void cleanOnceApnTable(int apnId) |
| 139 | { |
| 140 | LYDBGLOG("apn id:%d",apnId); |
| 141 | if((apnId < 0) || (apnId > LYNQ_APN_CHANNEL_MAX-1)) |
| 142 | { |
| 143 | LYERRLOG("apn id is invalid!!!"); |
| 144 | return; |
| 145 | } |
| 146 | lynq_apn_table[apnId].hasTimeout = 0; |
| 147 | lynq_apn_table[apnId].hasUsed = 0; |
| 148 | bzero(lynq_apn_table[apnId].apn,LYNQ_APN_MAX_LEN); |
| 149 | //bzero(lynq_apn_table[apnId].apnType,LYNQ_APN_TYPE_MAX_LEN); |
| 150 | bzero(lynq_apn_table[apnId].ifaceName,LYNQ_IFACE_NAME_MAX_LEN); |
| 151 | return; |
| 152 | } |
| 153 | int getUnusedElement() |
| 154 | { |
rjw | c63abb4 | 2023-03-31 18:22:42 +0800 | [diff] [blame] | 155 | if (lynq_apn_table == NULL) |
| 156 | { |
| 157 | LYERRLOG("get UnusedElemnt apn_table is null"); |
| 158 | return -1; |
| 159 | } |
lh | f81a46f | 2022-02-13 23:57:37 -0800 | [diff] [blame] | 160 | for(int i=0;i < LYNQ_APN_CHANNEL_MAX; i++) |
| 161 | { |
| 162 | if(lynq_apn_table[i].hasUsed!=1) |
| 163 | { |
| 164 | return i; |
| 165 | } |
| 166 | } |
rjw | c63abb4 | 2023-03-31 18:22:42 +0800 | [diff] [blame] | 167 | LYERRLOG("None of get unused Element"); |
lh | f81a46f | 2022-02-13 23:57:37 -0800 | [diff] [blame] | 168 | return -1; |
| 169 | } |
| 170 | int updateApn(char apnType[]) |
| 171 | { |
| 172 | int ret = 0; |
| 173 | ret = getUnusedElement(); |
Hong_Liu | 5566871 | 2023-05-16 21:49:17 -0700 | [diff] [blame^] | 174 | if(ret >= 0) |
Hong_Liu | 7e1b85e | 2023-05-16 05:51:57 -0700 | [diff] [blame] | 175 | { |
| 176 | memcpy(lynq_apn_table[ret].apnType,apnType,strlen(apnType)+1); |
| 177 | lynq_apn_table[ret].hasUsed = 1; |
| 178 | } |
lh | f81a46f | 2022-02-13 23:57:37 -0800 | [diff] [blame] | 179 | return ret; |
| 180 | } |
rjw | 1309e23 | 2022-07-22 09:54:06 +0800 | [diff] [blame] | 181 | |
| 182 | int handleCheck(int handle) |
| 183 | { |
| 184 | if (lynq_apn_table[handle].hasUsed == 1) |
| 185 | { |
| 186 | return 0; |
| 187 | } |
| 188 | else |
| 189 | { |
| 190 | return -1; |
| 191 | } |
| 192 | } |
rjw | 20006d1 | 2022-04-21 16:29:04 +0800 | [diff] [blame] | 193 | int waitApnResult() |
| 194 | { |
| 195 | int ret = 0; |
| 196 | LYINFLOG("start wait apn result!!!"); |
| 197 | int sec = 0; |
| 198 | int usec = 0; |
| 199 | struct timeval now; |
| 200 | struct timespec timeout; |
| 201 | gettimeofday(&now, NULL); |
| 202 | sec = 20000 / 1000; |
| 203 | usec = 20000 % 1000; |
| 204 | timeout.tv_sec = now.tv_sec + sec; |
| 205 | timeout.tv_nsec = now.tv_usec * 1000 + usec * 1000000; |
| 206 | pthread_mutex_lock(&s_lynq_apn_change_mutex); |
| 207 | ret = pthread_cond_timedwait(&s_lynq_apn_change_cond, &s_lynq_apn_change_mutex, &timeout); |
| 208 | pthread_mutex_unlock(&s_lynq_apn_change_mutex); |
| 209 | return ret; |
| 210 | } |
| 211 | |
| 212 | void sendSignalApnChange() |
| 213 | { |
| 214 | LYINFLOG("start send Signal Apn Change"); |
| 215 | pthread_mutex_lock(&s_lynq_apn_change_mutex); |
| 216 | pthread_cond_signal(&s_lynq_apn_change_cond); |
| 217 | pthread_mutex_unlock(&s_lynq_apn_change_mutex); |
| 218 | return; |
| 219 | } |
lh | f81a46f | 2022-02-13 23:57:37 -0800 | [diff] [blame] | 220 | |
| 221 | int waitPdnChange() |
| 222 | { |
| 223 | int ret = 0; |
rjw | 7ee7bb4 | 2023-01-18 11:34:28 +0800 | [diff] [blame] | 224 | pthread_mutex_lock(&s_lynq_urc_vector_mutex); |
| 225 | ret = pthread_cond_wait(&s_lynq_urc_vector_cond,&s_lynq_urc_vector_mutex); |
| 226 | pthread_mutex_unlock(&s_lynq_urc_vector_mutex); |
lh | f81a46f | 2022-02-13 23:57:37 -0800 | [diff] [blame] | 227 | return ret; |
| 228 | } |
| 229 | int waitDataCallstateChange(int mtime) |
| 230 | { |
| 231 | int ret = 0; |
| 232 | int sec = 0; |
| 233 | int usec = 0; |
| 234 | struct timeval now; |
| 235 | struct timespec timeout; |
| 236 | gettimeofday(&now,NULL); |
| 237 | sec = mtime/1000; |
| 238 | usec = mtime%1000; |
| 239 | timeout.tv_sec = now.tv_sec+sec; |
| 240 | timeout.tv_nsec = now.tv_usec*1000+usec*1000000; |
| 241 | pthread_mutex_lock(&s_data_call_state_change_mutex); |
| 242 | ret = pthread_cond_timedwait(&s_data_call_state_change_cond,&s_data_call_state_change_mutex,&timeout); |
| 243 | pthread_mutex_unlock(&s_data_call_state_change_mutex); |
| 244 | return ret; |
| 245 | } |
| 246 | void sendSignalDataCallStateChange() |
| 247 | { |
| 248 | pthread_mutex_lock(&s_data_call_state_change_mutex); |
| 249 | pthread_cond_signal(&s_data_call_state_change_cond); |
| 250 | pthread_mutex_unlock(&s_data_call_state_change_mutex); |
| 251 | return; |
| 252 | } |
| 253 | void sendSignalPdnChange() |
| 254 | { |
rjw | 7ee7bb4 | 2023-01-18 11:34:28 +0800 | [diff] [blame] | 255 | pthread_mutex_lock(&s_lynq_urc_vector_mutex); |
| 256 | pthread_cond_signal(&s_lynq_urc_vector_cond); |
| 257 | pthread_mutex_unlock(&s_lynq_urc_vector_mutex); |
lh | f81a46f | 2022-02-13 23:57:37 -0800 | [diff] [blame] | 258 | return; |
| 259 | } |
| 260 | |
| 261 | int get_response(int sockfd,Parcel &p) |
| 262 | { |
| 263 | int len = 0; |
| 264 | char recvline[LYNQ_REC_BUF]; |
| 265 | bzero(recvline,LYNQ_REC_BUF); |
| 266 | /* receive data from server */ |
Hong_Liu | 7e1b85e | 2023-05-16 05:51:57 -0700 | [diff] [blame] | 267 | len = recvfrom(sockfd,recvline,LYNQ_REC_BUF,0,(struct sockaddr *)&lynq_data_socket_server_addr,(socklen_t *)&lynq_data_socket_server_addr_len); |
| 268 | //len = read(sockfd, recvline, LYNQ_REC_BUF); |
rjw | 0852868 | 2022-07-04 21:28:02 +0800 | [diff] [blame] | 269 | if(len == -1) |
lh | f81a46f | 2022-02-13 23:57:37 -0800 | [diff] [blame] | 270 | { |
Hong_Liu | 7e1b85e | 2023-05-16 05:51:57 -0700 | [diff] [blame] | 271 | LYERRLOG("get_response fail,errno:%d",errno); |
lh | f81a46f | 2022-02-13 23:57:37 -0800 | [diff] [blame] | 272 | return -1; |
| 273 | } |
| 274 | if (recvline != NULL) { |
| 275 | p.setData((uint8_t *)recvline,len); // p.setData((uint8_t *) buffer, buflen); |
| 276 | p.setDataPosition(0); |
| 277 | } |
| 278 | return 0; |
| 279 | } |
rjw | fa53297 | 2022-09-16 13:39:41 +0800 | [diff] [blame] | 280 | int JumpHeader(Parcel &p,int *resp_type,int *request,int *slot_id,int *error) |
lh | f81a46f | 2022-02-13 23:57:37 -0800 | [diff] [blame] | 281 | { |
| 282 | if(p.dataAvail() > 0) |
| 283 | { |
| 284 | p.readInt32(resp_type); |
| 285 | p.readInt32(request); |
| 286 | p.readInt32(slot_id); |
| 287 | p.readInt32(error); |
| 288 | return 0; |
| 289 | } |
| 290 | else |
| 291 | { |
| 292 | return -1; |
| 293 | } |
| 294 | } |
| 295 | int send_request(int sockfd,lynq_client_t *client_tmp) |
| 296 | { |
| 297 | int ret=0; |
| 298 | ret = write(sockfd, client_tmp, LYQN_SEDN_BUF); |
| 299 | if(ret==-1) |
| 300 | { |
| 301 | perror("write error"); |
| 302 | return -1; |
| 303 | } |
| 304 | return 0; |
| 305 | } |
| 306 | static char *strdupReadString(Parcel &p) { |
| 307 | size_t stringlen; |
| 308 | const char16_t *s16; |
| 309 | s16 = p.readString16Inplace(&stringlen); |
| 310 | return strndup16to8(s16, stringlen); |
| 311 | } |
| 312 | static char *strdupReadString_p(Parcel *p) { |
| 313 | size_t stringlen; |
| 314 | const char16_t *s16; |
| 315 | s16 = p->readString16Inplace(&stringlen); |
| 316 | return strndup16to8(s16, stringlen); |
| 317 | } |
| 318 | |
lh | f81a46f | 2022-02-13 23:57:37 -0800 | [diff] [blame] | 319 | /*Warren add for T800 platform 2021/11/19 start*/ |
| 320 | int lynq_socket_client_start() |
| 321 | { |
lh | f81a46f | 2022-02-13 23:57:37 -0800 | [diff] [blame] | 322 | /* init lynq_socket_server_addr */ |
rjw | 747deea | 2022-07-01 18:25:30 +0800 | [diff] [blame] | 323 | bzero(&lynq_data_socket_server_addr, sizeof(lynq_data_socket_server_addr)); |
| 324 | lynq_data_socket_server_addr.sin_family = AF_INET; |
| 325 | lynq_data_socket_server_addr.sin_port = htons(LYNQ_SERVICE_PORT); |
jb.qi | ce04d00 | 2023-05-16 18:28:06 -0700 | [diff] [blame] | 326 | lynq_data_socket_server_addr.sin_addr.s_addr = htons(INADDR_ANY); |
Hong_Liu | 7e1b85e | 2023-05-16 05:51:57 -0700 | [diff] [blame] | 327 | lynq_data_socket_server_addr_len = sizeof(lynq_data_socket_server_addr); |
lh | f81a46f | 2022-02-13 23:57:37 -0800 | [diff] [blame] | 328 | /* |
| 329 | if(inet_pton(AF_INET,"127.0.0.1", &lynq_socket_server_addr.sin_addr) <= 0) |
| 330 | { |
| 331 | printf("[%s] is not a valid IPaddress\n", argv[1]); |
| 332 | exit(1); |
| 333 | } |
| 334 | */ |
| 335 | lynq_client_sockfd = socket(AF_INET, SOCK_DGRAM, 0); |
rjw | 747deea | 2022-07-01 18:25:30 +0800 | [diff] [blame] | 336 | struct timeval timeOut; |
| 337 | |
rjw | a59bf31 | 2022-07-05 11:50:31 +0800 | [diff] [blame] | 338 | timeOut.tv_sec = 30; |
rjw | 747deea | 2022-07-01 18:25:30 +0800 | [diff] [blame] | 339 | timeOut.tv_usec = 0; |
| 340 | |
| 341 | if (setsockopt(lynq_client_sockfd, SOL_SOCKET, SO_RCVTIMEO, &timeOut, sizeof(timeOut)) < 0) |
| 342 | { |
Hong_Liu | 7e1b85e | 2023-05-16 05:51:57 -0700 | [diff] [blame] | 343 | LYERRLOG("time out setting failed"); |
rjw | 747deea | 2022-07-01 18:25:30 +0800 | [diff] [blame] | 344 | } |
| 345 | if(connect(lynq_client_sockfd, (struct sockaddr *)&lynq_data_socket_server_addr, sizeof(lynq_data_socket_server_addr)) == -1) |
lh | f81a46f | 2022-02-13 23:57:37 -0800 | [diff] [blame] | 346 | { |
| 347 | perror("connect error"); |
| 348 | return -1; |
| 349 | } |
| 350 | return 0; |
| 351 | } |
rjw | 7ee7bb4 | 2023-01-18 11:34:28 +0800 | [diff] [blame] | 352 | |
| 353 | bool is_support_urc(int urc_id) |
lh | f81a46f | 2022-02-13 23:57:37 -0800 | [diff] [blame] | 354 | { |
rjw | 7ee7bb4 | 2023-01-18 11:34:28 +0800 | [diff] [blame] | 355 | switch(urc_id) |
| 356 | { |
| 357 | case LYNQ_URC_DATA_CALL_STATUS_IND: |
| 358 | |
| 359 | case LYNQ_URC_MODIFY_APNDB: |
| 360 | case LYNQ_URC_RESET_APNDB: |
| 361 | return true; |
| 362 | default: |
| 363 | return false; |
| 364 | } |
| 365 | } |
| 366 | |
rjw | c63abb4 | 2023-03-31 18:22:42 +0800 | [diff] [blame] | 367 | int printf_apn_table() |
| 368 | { |
| 369 | int ret = 0; |
Hong_Liu | 6149f18 | 2023-05-12 02:15:14 -0700 | [diff] [blame] | 370 | if (lynq_apn_table == NULL) |
| 371 | { |
| 372 | LYERRLOG("apn table is null"); |
| 373 | return -1; |
| 374 | } |
rjw | c63abb4 | 2023-03-31 18:22:42 +0800 | [diff] [blame] | 375 | for(ret;ret<LYNQ_APN_CHANNEL_MAX;ret++) |
| 376 | { |
Hong_Liu | 6149f18 | 2023-05-12 02:15:14 -0700 | [diff] [blame] | 377 | LYINFLOG("[%s][%d] apn=%s ;apntype=%s ;ifname=%s ;hasTimeout = %d ; hasUsed = %d",__FUNCTION__,ret, \ |
rjw | c63abb4 | 2023-03-31 18:22:42 +0800 | [diff] [blame] | 378 | lynq_apn_table[ret].apn,lynq_apn_table[ret].apnType,lynq_apn_table[ret].ifaceName, \ |
| 379 | lynq_apn_table[ret].hasTimeout,lynq_apn_table[ret].hasUsed); |
| 380 | } |
| 381 | return 0; |
| 382 | } |
| 383 | |
Hong_Liu | 6149f18 | 2023-05-12 02:15:14 -0700 | [diff] [blame] | 384 | void printf_apn_table_debug(const char *fun,int line) |
| 385 | { |
| 386 | LYINFLOG("[%s][%d]apn_table msg",fun,line); |
| 387 | printf_apn_table(); |
| 388 | } |
rjw | c63abb4 | 2023-03-31 18:22:42 +0800 | [diff] [blame] | 389 | |
rjw | 7ee7bb4 | 2023-01-18 11:34:28 +0800 | [diff] [blame] | 390 | void urc_msg_process(Parcel *p) |
| 391 | { |
| 392 | int len; |
| 393 | int resp_type; |
| 394 | int urcid; |
| 395 | int slot_id; |
rjw | f9ec383 | 2023-04-12 10:59:15 +0800 | [diff] [blame] | 396 | int check_count = 0; |
rjw | 7ee7bb4 | 2023-01-18 11:34:28 +0800 | [diff] [blame] | 397 | |
| 398 | int pdnState = 0; |
lh | f81a46f | 2022-02-13 23:57:37 -0800 | [diff] [blame] | 399 | char apn[LYNQ_APN_MAX_LEN]; |
| 400 | char apnType[LYNQ_APN_TYPE_MAX_LEN]; |
lh | f81a46f | 2022-02-13 23:57:37 -0800 | [diff] [blame] | 401 | char ifaceName[LYNQ_IFACE_NAME_MAX_LEN]; |
lh | f81a46f | 2022-02-13 23:57:37 -0800 | [diff] [blame] | 402 | char *urc_msg = NULL; |
rjw | 7ee7bb4 | 2023-01-18 11:34:28 +0800 | [diff] [blame] | 403 | |
| 404 | int size = p->dataSize(); |
| 405 | p->readInt32(&resp_type); |
| 406 | p->readInt32(&urcid); |
| 407 | p->readInt32(&slot_id); |
| 408 | LYINFLOG("data lib recv urc:resp_type=%d,urcid=%d,slot_id=%d,size=%d\n",resp_type,urcid,slot_id,size); |
| 409 | switch(urcid) |
lh | f81a46f | 2022-02-13 23:57:37 -0800 | [diff] [blame] | 410 | { |
rjw | 7ee7bb4 | 2023-01-18 11:34:28 +0800 | [diff] [blame] | 411 | case LYNQ_URC_DATA_CALL_STATUS_IND: |
| 412 | p->readInt32(&pdnState); |
| 413 | bzero(apn,LYNQ_APN_MAX_LEN); |
| 414 | bzero(apnType,LYNQ_APN_TYPE_MAX_LEN); |
| 415 | bzero(ifaceName,LYNQ_IFACE_NAME_MAX_LEN); |
| 416 | if(pdnState!=4)//PDN_DISCONNECTED |
lh | f81a46f | 2022-02-13 23:57:37 -0800 | [diff] [blame] | 417 | { |
rjw | 20006d1 | 2022-04-21 16:29:04 +0800 | [diff] [blame] | 418 | urc_msg = strdupReadString_p(p); |
rjw | 7ee7bb4 | 2023-01-18 11:34:28 +0800 | [diff] [blame] | 419 | int len = strlen(urc_msg); |
Hong_Liu | 6149f18 | 2023-05-12 02:15:14 -0700 | [diff] [blame] | 420 | if((len < LYNQ_APN_MAX_LEN-1) && (len > 0)) |
rjw | 20006d1 | 2022-04-21 16:29:04 +0800 | [diff] [blame] | 421 | { |
rjw | 7ee7bb4 | 2023-01-18 11:34:28 +0800 | [diff] [blame] | 422 | memcpy(apn,urc_msg,len+1); |
rjw | 20006d1 | 2022-04-21 16:29:04 +0800 | [diff] [blame] | 423 | } |
Hong_Liu | 6149f18 | 2023-05-12 02:15:14 -0700 | [diff] [blame] | 424 | free(urc_msg); |
rjw | 7ee7bb4 | 2023-01-18 11:34:28 +0800 | [diff] [blame] | 425 | urc_msg = strdupReadString_p(p); |
| 426 | len = strlen(urc_msg); |
Hong_Liu | 6149f18 | 2023-05-12 02:15:14 -0700 | [diff] [blame] | 427 | if((len < LYNQ_APN_TYPE_MAX_LEN-1) && (len > 0)) |
rjw | 7ee7bb4 | 2023-01-18 11:34:28 +0800 | [diff] [blame] | 428 | { |
| 429 | memcpy(apnType,urc_msg,len+1); |
| 430 | } |
Hong_Liu | 6149f18 | 2023-05-12 02:15:14 -0700 | [diff] [blame] | 431 | free(urc_msg); |
rjw | 7ee7bb4 | 2023-01-18 11:34:28 +0800 | [diff] [blame] | 432 | urc_msg = strdupReadString_p(p); |
| 433 | len = strlen(urc_msg); |
Hong_Liu | 6149f18 | 2023-05-12 02:15:14 -0700 | [diff] [blame] | 434 | if((len < LYNQ_IFACE_NAME_MAX_LEN-1) && (len > 0)) |
rjw | 7ee7bb4 | 2023-01-18 11:34:28 +0800 | [diff] [blame] | 435 | { |
| 436 | memcpy(ifaceName,urc_msg,strlen(urc_msg)+1); |
| 437 | } |
Hong_Liu | 6149f18 | 2023-05-12 02:15:14 -0700 | [diff] [blame] | 438 | free(urc_msg); |
rjw | 7ee7bb4 | 2023-01-18 11:34:28 +0800 | [diff] [blame] | 439 | //sendSignalDataCallStateChange(); |
| 440 | int apnId = getLynqApnID(apnType); |
Hong_Liu | 6149f18 | 2023-05-12 02:15:14 -0700 | [diff] [blame] | 441 | LYINFLOG("URC apnType:%s,ifaceName:%s,apn:%s pdnState:%d,handle:%d",apnType,ifaceName,apn,pdnState,apnId); |
rjw | 7ee7bb4 | 2023-01-18 11:34:28 +0800 | [diff] [blame] | 442 | if(apnId >= 0) |
| 443 | { |
| 444 | if(lynq_apn_table[apnId].hasTimeout==1) |
| 445 | { |
rjw | c63abb4 | 2023-03-31 18:22:42 +0800 | [diff] [blame] | 446 | /*whether timeout?,real or not,*/ |
| 447 | printf_apn_table(); |
rjw | 7ee7bb4 | 2023-01-18 11:34:28 +0800 | [diff] [blame] | 448 | LYERRLOG("apn:%s has time out,deacive this apn",lynq_apn_table[apnId].apn); |
rjw | 3938f26 | 2023-03-08 16:09:28 +0800 | [diff] [blame] | 449 | if (NULL != lynq_apn_table[apnId].apn && NULL != lynq_apn_table[apnId].apnType && strlen(lynq_apn_table[apnId].apn)>0) |
rjw | 7ee7bb4 | 2023-01-18 11:34:28 +0800 | [diff] [blame] | 450 | { |
| 451 | LYERRLOG("deactive this time out APN"); |
| 452 | lynq_deactive_data_call(&apnId); |
| 453 | } |
rjw | c63abb4 | 2023-03-31 18:22:42 +0800 | [diff] [blame] | 454 | else |
rjw | 7ee7bb4 | 2023-01-18 11:34:28 +0800 | [diff] [blame] | 455 | { |
rjw | c63abb4 | 2023-03-31 18:22:42 +0800 | [diff] [blame] | 456 | /*if apn lose,update apn and deactive all apn*/ |
| 457 | LYERRLOG("this table is invalid update APN table"); |
rjw | 7ee7bb4 | 2023-01-18 11:34:28 +0800 | [diff] [blame] | 458 | } |
| 459 | break; |
| 460 | } |
rjw | acdb215 | 2023-02-07 14:12:49 +0800 | [diff] [blame] | 461 | updateApnTable(&lynq_apn_table[apnId],apn,apnType,ifaceName); |
Hong_Liu | 6149f18 | 2023-05-12 02:15:14 -0700 | [diff] [blame] | 462 | printf_apn_table_debug(__FUNCTION__,__LINE__); |
rjw | 7ee7bb4 | 2023-01-18 11:34:28 +0800 | [diff] [blame] | 463 | } |
| 464 | /*To be completed*/ |
rjw | 20006d1 | 2022-04-21 16:29:04 +0800 | [diff] [blame] | 465 | else |
| 466 | { |
Hong_Liu | 6149f18 | 2023-05-12 02:15:14 -0700 | [diff] [blame] | 467 | data_invaild_error = 1; |
rjw | c63abb4 | 2023-03-31 18:22:42 +0800 | [diff] [blame] | 468 | printf_apn_table(); |
| 469 | LYERRLOG("invalid apnId:%d",apnId); |
rjw | 7ee7bb4 | 2023-01-18 11:34:28 +0800 | [diff] [blame] | 470 | break; |
rjw | 20006d1 | 2022-04-21 16:29:04 +0800 | [diff] [blame] | 471 | } |
rjw | 7ee7bb4 | 2023-01-18 11:34:28 +0800 | [diff] [blame] | 472 | pthread_mutex_lock(&s_lynq_urc_vector_mutex); |
| 473 | s_data_urc_wait_list.push_back(apnId); |
| 474 | pthread_mutex_unlock(&s_lynq_urc_vector_mutex); |
| 475 | lynq_data_call_change_id = apnId; |
rjw | c3d6e58 | 2023-03-28 17:19:11 +0800 | [diff] [blame] | 476 | sendSignalPdnChange(); |
rjw | 7ee7bb4 | 2023-01-18 11:34:28 +0800 | [diff] [blame] | 477 | LYDBGLOG("data call state:%d",lynq_data_call); |
| 478 | if(lynq_data_call==1) |
| 479 | { |
rjw | f9ec383 | 2023-04-12 10:59:15 +0800 | [diff] [blame] | 480 | while (data_timelimit == 0) |
| 481 | { |
| 482 | LYINFLOG("client not ready to wait"); |
| 483 | for (check_count = 0;check_count < 500;check_count++) |
| 484 | { |
| 485 | /*wait 10ms*/ |
| 486 | usleep(10*1000); |
| 487 | } |
| 488 | LYERRLOG("client still without res"); |
| 489 | break; |
| 490 | } |
rjw | 7ee7bb4 | 2023-01-18 11:34:28 +0800 | [diff] [blame] | 491 | sendSignalDataCallStateChange(); |
| 492 | lynq_data_call = 0; |
rjw | f9ec383 | 2023-04-12 10:59:15 +0800 | [diff] [blame] | 493 | data_timelimit = 0; |
rjw | 7ee7bb4 | 2023-01-18 11:34:28 +0800 | [diff] [blame] | 494 | } |
Hong_Liu | 6149f18 | 2023-05-12 02:15:14 -0700 | [diff] [blame] | 495 | printf_apn_table_debug(__FUNCTION__,__LINE__); |
rjw | 20006d1 | 2022-04-21 16:29:04 +0800 | [diff] [blame] | 496 | } |
rjw | 7ee7bb4 | 2023-01-18 11:34:28 +0800 | [diff] [blame] | 497 | else |
rjw | 20006d1 | 2022-04-21 16:29:04 +0800 | [diff] [blame] | 498 | { |
rjw | 7ee7bb4 | 2023-01-18 11:34:28 +0800 | [diff] [blame] | 499 | urc_msg = strdupReadString_p(p); |
Hong_Liu | 6149f18 | 2023-05-12 02:15:14 -0700 | [diff] [blame] | 500 | free(urc_msg); |
| 501 | urc_msg = strdupReadString_p(p); |
rjw | 7ee7bb4 | 2023-01-18 11:34:28 +0800 | [diff] [blame] | 502 | len = strlen(urc_msg); |
| 503 | if(len < LYNQ_APN_TYPE_MAX_LEN-1) |
| 504 | { |
| 505 | memcpy(apnType,urc_msg,len+1); |
| 506 | } |
Hong_Liu | 6149f18 | 2023-05-12 02:15:14 -0700 | [diff] [blame] | 507 | free(urc_msg); |
rjw | 7ee7bb4 | 2023-01-18 11:34:28 +0800 | [diff] [blame] | 508 | LYDBGLOG("[data thread_urc_recv] apntype:%s",apnType); |
| 509 | int apnId = getLynqApnID(apnType); |
Hong_Liu | 6149f18 | 2023-05-12 02:15:14 -0700 | [diff] [blame] | 510 | LYINFLOG("URC apnType:%s,ifaceName:%s,apn:%s pdnState:%d,handle:%d",apnType,ifaceName,apn,pdnState,apnId); |
rjw | 7ee7bb4 | 2023-01-18 11:34:28 +0800 | [diff] [blame] | 511 | if(apnId >= 0) |
| 512 | { |
| 513 | lynq_data_call_change_id = apnId; |
| 514 | bzero(lynq_apn_table[apnId].apnType,LYNQ_APN_TYPE_MAX_LEN);//async clean |
rjw | 3938f26 | 2023-03-08 16:09:28 +0800 | [diff] [blame] | 515 | pthread_mutex_lock(&s_lynq_urc_vector_mutex); |
| 516 | s_data_urc_wait_list.push_back(apnId); |
| 517 | pthread_mutex_unlock(&s_lynq_urc_vector_mutex); |
rjw | c3d6e58 | 2023-03-28 17:19:11 +0800 | [diff] [blame] | 518 | sendSignalPdnChange(); |
rjw | 7ee7bb4 | 2023-01-18 11:34:28 +0800 | [diff] [blame] | 519 | } |
rjw | 7ee7bb4 | 2023-01-18 11:34:28 +0800 | [diff] [blame] | 520 | LYDBGLOG("data call state:%d",lynq_data_call); |
| 521 | if(lynq_data_call==1) |
| 522 | { |
rjw | f9ec383 | 2023-04-12 10:59:15 +0800 | [diff] [blame] | 523 | while (data_timelimit == 0) |
| 524 | { |
| 525 | LYINFLOG("client not ready to wait"); |
| 526 | for (check_count = 0;check_count < 500;check_count++) |
| 527 | { |
| 528 | /*wait 10ms*/ |
| 529 | usleep(10*1000); |
| 530 | } |
| 531 | LYERRLOG("client still without res"); |
| 532 | break; |
| 533 | } |
rjw | 7ee7bb4 | 2023-01-18 11:34:28 +0800 | [diff] [blame] | 534 | sendSignalDataCallStateChange(); |
| 535 | lynq_data_call = 0; |
rjw | f9ec383 | 2023-04-12 10:59:15 +0800 | [diff] [blame] | 536 | data_timelimit = 0; |
rjw | 7ee7bb4 | 2023-01-18 11:34:28 +0800 | [diff] [blame] | 537 | } |
Hong_Liu | 6149f18 | 2023-05-12 02:15:14 -0700 | [diff] [blame] | 538 | printf_apn_table_debug(__FUNCTION__,__LINE__); |
rjw | 7ee7bb4 | 2023-01-18 11:34:28 +0800 | [diff] [blame] | 539 | } |
| 540 | break; |
| 541 | case LYNQ_URC_MODIFY_APNDB: |
| 542 | urc_msg = strdupReadString_p(p); |
| 543 | if (NULL == urc_msg) |
| 544 | { |
| 545 | LYERRLOG("error apn msg"); |
| 546 | } |
| 547 | else |
| 548 | { |
| 549 | bzero(g_lynq_apn_result, 1024); |
| 550 | strcpy(g_lynq_apn_result, urc_msg); |
| 551 | sendSignalApnChange(); |
| 552 | } |
Hong_Liu | 6149f18 | 2023-05-12 02:15:14 -0700 | [diff] [blame] | 553 | free(urc_msg); |
rjw | 7ee7bb4 | 2023-01-18 11:34:28 +0800 | [diff] [blame] | 554 | break; |
| 555 | case LYNQ_URC_RESET_APNDB: |
| 556 | { |
rjw | 20006d1 | 2022-04-21 16:29:04 +0800 | [diff] [blame] | 557 | urc_msg = strdupReadString_p(p); |
| 558 | if (NULL == urc_msg) |
| 559 | { |
| 560 | LYERRLOG("error apn msg"); |
| 561 | } |
| 562 | else |
| 563 | { |
| 564 | bzero(g_lynq_apn_result, 1024); |
| 565 | strcpy(g_lynq_apn_result, urc_msg); |
| 566 | sendSignalApnChange(); |
| 567 | } |
Hong_Liu | 6149f18 | 2023-05-12 02:15:14 -0700 | [diff] [blame] | 568 | free(urc_msg); |
rjw | 20006d1 | 2022-04-21 16:29:04 +0800 | [diff] [blame] | 569 | } |
rjw | 7ee7bb4 | 2023-01-18 11:34:28 +0800 | [diff] [blame] | 570 | default: |
| 571 | break; |
lh | f81a46f | 2022-02-13 23:57:37 -0800 | [diff] [blame] | 572 | } |
rjw | 7ee7bb4 | 2023-01-18 11:34:28 +0800 | [diff] [blame] | 573 | |
lh | f81a46f | 2022-02-13 23:57:37 -0800 | [diff] [blame] | 574 | } |
rjw | 7ee7bb4 | 2023-01-18 11:34:28 +0800 | [diff] [blame] | 575 | |
rjw | 7ee7bb4 | 2023-01-18 11:34:28 +0800 | [diff] [blame] | 576 | int create_urc_vector_signal_thread() |
| 577 | { |
| 578 | int ret; |
rjw | 7ee7bb4 | 2023-01-18 11:34:28 +0800 | [diff] [blame] | 579 | pthread_mutex_init(&s_lynq_urc_vector_mutex,NULL); |
rjw | 7ee7bb4 | 2023-01-18 11:34:28 +0800 | [diff] [blame] | 580 | pthread_mutex_lock(&s_lynq_urc_vector_mutex); |
| 581 | s_data_urc_wait_list.clear(); |
| 582 | pthread_mutex_unlock(&s_lynq_urc_vector_mutex); |
lh | f81a46f | 2022-02-13 23:57:37 -0800 | [diff] [blame] | 583 | return 0; |
| 584 | } |
rjw | 7ee7bb4 | 2023-01-18 11:34:28 +0800 | [diff] [blame] | 585 | |
lh | f81a46f | 2022-02-13 23:57:37 -0800 | [diff] [blame] | 586 | int lynq_init_data(int uToken) |
| 587 | { |
rjw | 22947c2 | 2022-03-15 09:21:29 +0800 | [diff] [blame] | 588 | if (g_lynq_data_init_flag == 1) |
| 589 | { |
| 590 | LYERRLOG("init twice is not allowed"); |
| 591 | return -1; |
| 592 | } |
| 593 | g_lynq_data_init_flag = 1; |
lh | f81a46f | 2022-02-13 23:57:37 -0800 | [diff] [blame] | 594 | int result = 0; |
| 595 | Global_uToken = uToken; |
lh | f81a46f | 2022-02-13 23:57:37 -0800 | [diff] [blame] | 596 | LYLOGSET(LOG_INFO); |
| 597 | LYLOGEINIT(USER_LOG_TAG); |
| 598 | result = lynq_socket_client_start(); |
rjw | ed00d04 | 2022-05-25 09:18:16 +0800 | [diff] [blame] | 599 | pthread_mutex_init(&g_lynq_data_sendto_mutex, NULL); |
lh | f81a46f | 2022-02-13 23:57:37 -0800 | [diff] [blame] | 600 | if(result!=0) |
| 601 | { |
| 602 | LYERRLOG("init socket client fail!!!"); |
| 603 | return -1; |
| 604 | } |
rjw | 7ee7bb4 | 2023-01-18 11:34:28 +0800 | [diff] [blame] | 605 | result = lynq_init_data_urc_thread(); |
| 606 | if(result!=0) |
| 607 | { |
| 608 | LYERRLOG("init socket urc fail!!!"); |
| 609 | return -1; |
| 610 | } |
| 611 | |
| 612 | result = create_urc_vector_signal_thread(); |
lh | f81a46f | 2022-02-13 23:57:37 -0800 | [diff] [blame] | 613 | if(result!=0) |
| 614 | { |
| 615 | LYERRLOG("init socket urc fail!!!"); |
| 616 | return -1; |
| 617 | } |
| 618 | memset(lynq_apn_table,0,sizeof(lynq_apn_table)); |
| 619 | LYDBGLOG("lynq init call success!!!"); |
| 620 | return 0; |
| 621 | |
| 622 | } |
| 623 | int lynq_deinit_data() |
| 624 | { |
| 625 | int ret = -1; |
rjw | 22947c2 | 2022-03-15 09:21:29 +0800 | [diff] [blame] | 626 | if (g_lynq_data_init_flag == 0) |
| 627 | { |
| 628 | LYERRLOG("deinit twice is not allowed"); |
| 629 | return ret; |
| 630 | } |
| 631 | g_lynq_data_init_flag = 0; |
lh | f81a46f | 2022-02-13 23:57:37 -0800 | [diff] [blame] | 632 | for(int i =0;i<LYNQ_APN_CHANNEL_MAX;i++) |
| 633 | { |
| 634 | if(strlen(lynq_apn_table[i].apnType)!=0) |
| 635 | { |
| 636 | lynq_deactive_data_call(&i); |
| 637 | } |
| 638 | } |
| 639 | if(lynq_client_sockfd>0) |
| 640 | { |
| 641 | close(lynq_client_sockfd); |
| 642 | } |
rjw | 7ee7bb4 | 2023-01-18 11:34:28 +0800 | [diff] [blame] | 643 | ret = lynq_deinit_data_urc_thread(); |
rjw | eb65a2f | 2023-02-01 16:43:23 +0800 | [diff] [blame] | 644 | if (ret != 0) |
rjw | 22947c2 | 2022-03-15 09:21:29 +0800 | [diff] [blame] | 645 | { |
rjw | 7ee7bb4 | 2023-01-18 11:34:28 +0800 | [diff] [blame] | 646 | LYERRLOG("lynq_deinit_data_urc_thread fail"); |
| 647 | return ret; |
rjw | 22947c2 | 2022-03-15 09:21:29 +0800 | [diff] [blame] | 648 | } |
rjw | c3d6e58 | 2023-03-28 17:19:11 +0800 | [diff] [blame] | 649 | pthread_mutex_lock(&s_lynq_urc_vector_mutex); |
| 650 | s_data_urc_wait_list.clear(); |
| 651 | pthread_mutex_unlock(&s_lynq_urc_vector_mutex); |
lh | f81a46f | 2022-02-13 23:57:37 -0800 | [diff] [blame] | 652 | return 0; |
| 653 | } |
| 654 | int lynq_setup_data_call(int *handle) |
| 655 | { |
Hong_Liu | e54db8c | 2023-04-21 02:37:23 -0700 | [diff] [blame] | 656 | int error = -1; |
| 657 | #ifdef GSW_RIL_CFG //becuase gsw not have connman,data can not be triggered by connman. |
| 658 | LYINFLOG("[%s][%d]",__FUNCTION__,__LINE__); |
Hong_Liu | e987915 | 2023-04-25 20:40:26 -0700 | [diff] [blame] | 659 | error = lynq_setup_data_call_sp(handle,NULL,"default",NULL,NULL,NULL,NULL,NULL); |
Hong_Liu | e54db8c | 2023-04-21 02:37:23 -0700 | [diff] [blame] | 660 | #else |
lh | f81a46f | 2022-02-13 23:57:37 -0800 | [diff] [blame] | 661 | Parcel p; |
| 662 | lynq_client_t client; |
| 663 | int resp_type = -1; |
| 664 | int request = -1; |
| 665 | int slot_id = -1; |
lh | f81a46f | 2022-02-13 23:57:37 -0800 | [diff] [blame] | 666 | int lynq_data_call_id = 0; |
| 667 | if(handle==NULL) |
| 668 | { |
| 669 | LYERRLOG("handle is null!!!"); |
| 670 | return LYNQ_E_NULL_ANONALY; |
| 671 | } |
| 672 | client.uToken = Global_uToken; |
| 673 | client.request = 27;//RIL_REQUEST_SETUP_DATA_CALL |
| 674 | client.paramLen = 0; |
| 675 | bzero(client.param,LYNQ_REQUEST_PARAM_BUF); |
| 676 | LYINFLOG("uToken=%d,request=%d,paralen=%d,param=%s",client.uToken,client.request,client.paramLen,client.param); |
rjw | c63abb4 | 2023-03-31 18:22:42 +0800 | [diff] [blame] | 677 | lynq_data_call_id = updateApn("default"); |
| 678 | if (lynq_data_call_id < 0) |
| 679 | { |
| 680 | LYERRLOG("update apn table fail error id = %d",lynq_data_call_id); |
Hong_Liu | 7e1b85e | 2023-05-16 05:51:57 -0700 | [diff] [blame] | 681 | return LYNQ_E_NULL_ANONALY+1; |
rjw | c63abb4 | 2023-03-31 18:22:42 +0800 | [diff] [blame] | 682 | } |
Hong_Liu | 7e1b85e | 2023-05-16 05:51:57 -0700 | [diff] [blame] | 683 | *handle = lynq_data_call_id;//T8TSK-211 (2023/5/16) why? If it times out, the client application will also try to reconnect. |
| 684 | //Reconnection needs to be deactivated first, and deactivation needs to know which apn to activate. |
rjw | 733b983 | 2023-04-03 10:20:08 +0800 | [diff] [blame] | 685 | lynq_data_call = 1; |
rjw | ed00d04 | 2022-05-25 09:18:16 +0800 | [diff] [blame] | 686 | pthread_mutex_lock(&g_lynq_data_sendto_mutex); |
lh | f81a46f | 2022-02-13 23:57:37 -0800 | [diff] [blame] | 687 | if(send_request(lynq_client_sockfd,&client)==-1) |
| 688 | { |
| 689 | LYERRLOG("send request fail"); |
| 690 | perror("[LYNQ_DATA] send request fail:"); |
Hong_Liu | 7e1b85e | 2023-05-16 05:51:57 -0700 | [diff] [blame] | 691 | return LYNQ_E_NULL_ANONALY+2; |
lh | f81a46f | 2022-02-13 23:57:37 -0800 | [diff] [blame] | 692 | } |
| 693 | get_response(lynq_client_sockfd,p); |
rjw | ed00d04 | 2022-05-25 09:18:16 +0800 | [diff] [blame] | 694 | pthread_mutex_unlock(&g_lynq_data_sendto_mutex); |
rjw | fa53297 | 2022-09-16 13:39:41 +0800 | [diff] [blame] | 695 | JumpHeader(p,&resp_type,&request,&slot_id,&error); |
lh | f81a46f | 2022-02-13 23:57:37 -0800 | [diff] [blame] | 696 | LYINFLOG("resp_type=%d,request=%d,slot_id=%d,error_code=%d",resp_type,request,slot_id,error); |
lh | f81a46f | 2022-02-13 23:57:37 -0800 | [diff] [blame] | 697 | if(error==0) |
| 698 | { |
rjw | f9ec383 | 2023-04-12 10:59:15 +0800 | [diff] [blame] | 699 | data_timelimit = 1; |
rjw | 20006d1 | 2022-04-21 16:29:04 +0800 | [diff] [blame] | 700 | if (waitDataCallstateChange(60000) == ETIMEDOUT) // 60s |
lh | f81a46f | 2022-02-13 23:57:37 -0800 | [diff] [blame] | 701 | { |
| 702 | error = LYNQ_E_TIME_OUT; |
| 703 | LYERRLOG("timeout:wait data Call state fail!!!"); |
| 704 | lynq_apn_table[lynq_data_call_id].hasTimeout = 1; |
Hong_Liu | 6149f18 | 2023-05-12 02:15:14 -0700 | [diff] [blame] | 705 | if (data_invaild_error == 1) |
| 706 | { |
| 707 | data_invaild_error = 0; |
| 708 | LYERRLOG("urc apn info error!!!"); |
| 709 | return 8085; |
| 710 | } |
| 711 | printf_apn_table_debug(__FUNCTION__,__LINE__); |
lh | f81a46f | 2022-02-13 23:57:37 -0800 | [diff] [blame] | 712 | return error; |
| 713 | } |
lh | f81a46f | 2022-02-13 23:57:37 -0800 | [diff] [blame] | 714 | } |
Hong_Liu | 6149f18 | 2023-05-12 02:15:14 -0700 | [diff] [blame] | 715 | printf_apn_table_debug(__FUNCTION__,__LINE__); |
Hong_Liu | e54db8c | 2023-04-21 02:37:23 -0700 | [diff] [blame] | 716 | #endif //GSW_RIL_CFG |
lh | f81a46f | 2022-02-13 23:57:37 -0800 | [diff] [blame] | 717 | return error; |
| 718 | } |
rjw | 7ee7bb4 | 2023-01-18 11:34:28 +0800 | [diff] [blame] | 719 | |
lh | f81a46f | 2022-02-13 23:57:37 -0800 | [diff] [blame] | 720 | int lynq_deactive_data_call(int *handle) |
| 721 | { |
| 722 | Parcel p; |
| 723 | lynq_client_t client; |
| 724 | int resp_type = -1; |
| 725 | int request = -1; |
| 726 | int slot_id = -1; |
| 727 | int error = -1; |
| 728 | int lynq_data_call_id = -1; |
rjw | 1309e23 | 2022-07-22 09:54:06 +0800 | [diff] [blame] | 729 | int ret = 0; |
lh | f81a46f | 2022-02-13 23:57:37 -0800 | [diff] [blame] | 730 | if(handle==NULL) |
| 731 | { |
| 732 | LYERRLOG("handle is null!!!"); |
| 733 | return -1; |
| 734 | } |
rjw | 1309e23 | 2022-07-22 09:54:06 +0800 | [diff] [blame] | 735 | ret = handleCheck(*handle); |
| 736 | if (ret != 0) |
| 737 | { |
| 738 | LYERRLOG("incomming handle is invalid"); |
| 739 | return -1; |
| 740 | } |
| 741 | lynq_data_call_id = *handle; |
lh | f81a46f | 2022-02-13 23:57:37 -0800 | [diff] [blame] | 742 | client.uToken = Global_uToken; |
| 743 | client.request = 41;//RIL_REQUEST_DEACTIVATE_DATA_CALL |
Hong_Liu | e3d3526 | 2023-05-04 00:20:12 -0700 | [diff] [blame] | 744 | client.paramLen = 0; |
| 745 | bzero(client.param,LYNQ_REQUEST_PARAM_BUF); |
| 746 | #ifdef GSW_RIL_CFG |
| 747 | client.paramLen = 1; |
| 748 | sprintf(client.param,"%s",lynq_apn_table[lynq_data_call_id].apnType); |
| 749 | #else |
| 750 | if(strcmp(lynq_apn_table[lynq_data_call_id].apnType,"default")!=0) |
lh | 1358661 | 2022-01-11 21:58:58 -0800 | [diff] [blame] | 751 | { |
lh | f81a46f | 2022-02-13 23:57:37 -0800 | [diff] [blame] | 752 | client.paramLen = 1; |
lh | f81a46f | 2022-02-13 23:57:37 -0800 | [diff] [blame] | 753 | sprintf(client.param,"%s",lynq_apn_table[lynq_data_call_id].apnType); |
| 754 | } |
Hong_Liu | e3d3526 | 2023-05-04 00:20:12 -0700 | [diff] [blame] | 755 | #endif //GSW_RIL_CFG |
lh | f81a46f | 2022-02-13 23:57:37 -0800 | [diff] [blame] | 756 | LYINFLOG("uToken=%d,request=%d,paralen=%d,param=%s",client.uToken,client.request,client.paramLen,client.param); |
rjw | ed00d04 | 2022-05-25 09:18:16 +0800 | [diff] [blame] | 757 | pthread_mutex_lock(&g_lynq_data_sendto_mutex); |
lh | f81a46f | 2022-02-13 23:57:37 -0800 | [diff] [blame] | 758 | if(send_request(lynq_client_sockfd,&client)==-1) |
| 759 | { |
| 760 | LYERRLOG("send request fail"); |
| 761 | perror("[LYNQ_DATA] send request fail:"); |
| 762 | return -1; |
| 763 | } |
| 764 | get_response(lynq_client_sockfd,p); |
rjw | ed00d04 | 2022-05-25 09:18:16 +0800 | [diff] [blame] | 765 | pthread_mutex_unlock(&g_lynq_data_sendto_mutex); |
rjw | fa53297 | 2022-09-16 13:39:41 +0800 | [diff] [blame] | 766 | JumpHeader(p,&resp_type,&request,&slot_id,&error); |
lh | f81a46f | 2022-02-13 23:57:37 -0800 | [diff] [blame] | 767 | LYINFLOG("resp_type=%d,request=%d,slot_id=%d,error_code=%d",resp_type,request,slot_id,error); |
| 768 | cleanOnceApnTable(lynq_data_call_id); |
Hong_Liu | 6149f18 | 2023-05-12 02:15:14 -0700 | [diff] [blame] | 769 | printf_apn_table_debug(__FUNCTION__,__LINE__); |
lh | f81a46f | 2022-02-13 23:57:37 -0800 | [diff] [blame] | 770 | return error; |
| 771 | } |
| 772 | int lynq_setup_data_call_sp(int *handle,char *apn,char *apnType,char *user,char *password,char *authType,char *normalProtocol,char *roamingProtocol) |
| 773 | { |
| 774 | Parcel p; |
| 775 | lynq_client_t client; |
| 776 | int resp_type = -1; |
| 777 | int request = -1; |
| 778 | int slot_id = -1; |
| 779 | int error = -1; |
lh | f81a46f | 2022-02-13 23:57:37 -0800 | [diff] [blame] | 780 | int lynq_data_call_id = -1; |
| 781 | char *argv[10] = {}; |
Hong_Liu | e54db8c | 2023-04-21 02:37:23 -0700 | [diff] [blame] | 782 | #ifdef GSW_RIL_CFG |
| 783 | LYINFLOG("[%s][%d]",__FUNCTION__,__LINE__); |
| 784 | if(handle==NULL||apnType==NULL) |
| 785 | { |
| 786 | LYERRLOG("handle or apntype is null!!!"); |
| 787 | return -1; |
| 788 | } |
| 789 | #else |
lh | f81a46f | 2022-02-13 23:57:37 -0800 | [diff] [blame] | 790 | if(handle==NULL||apn==NULL||apnType==NULL) |
| 791 | { |
| 792 | LYERRLOG("handle ,apn or apntype is null!!!"); |
Hong_Liu | 7e1b85e | 2023-05-16 05:51:57 -0700 | [diff] [blame] | 793 | return LYNQ_E_NULL_ANONALY; |
lh | f81a46f | 2022-02-13 23:57:37 -0800 | [diff] [blame] | 794 | } |
Hong_Liu | e54db8c | 2023-04-21 02:37:23 -0700 | [diff] [blame] | 795 | #endif //GSW_RIL_CFG |
lh | f81a46f | 2022-02-13 23:57:37 -0800 | [diff] [blame] | 796 | if(user==NULL) |
| 797 | { |
| 798 | argv[1] = "null"; |
| 799 | } |
| 800 | else |
| 801 | { |
| 802 | argv[1] = user; |
lh | 1358661 | 2022-01-11 21:58:58 -0800 | [diff] [blame] | 803 | } |
| 804 | if(password==NULL) |
| 805 | { |
lh | f81a46f | 2022-02-13 23:57:37 -0800 | [diff] [blame] | 806 | argv[2] = "null"; |
lh | 1358661 | 2022-01-11 21:58:58 -0800 | [diff] [blame] | 807 | } |
| 808 | else |
| 809 | { |
lh | f81a46f | 2022-02-13 23:57:37 -0800 | [diff] [blame] | 810 | argv[2] = password; |
lh | 1358661 | 2022-01-11 21:58:58 -0800 | [diff] [blame] | 811 | } |
| 812 | if(authType==NULL) |
| 813 | { |
lh | f81a46f | 2022-02-13 23:57:37 -0800 | [diff] [blame] | 814 | argv[3] = "null"; |
lh | 1358661 | 2022-01-11 21:58:58 -0800 | [diff] [blame] | 815 | } |
| 816 | else |
| 817 | { |
lh | f81a46f | 2022-02-13 23:57:37 -0800 | [diff] [blame] | 818 | argv[3] = authType; |
lh | 1358661 | 2022-01-11 21:58:58 -0800 | [diff] [blame] | 819 | } |
| 820 | if(normalProtocol==NULL) |
| 821 | { |
lh | f81a46f | 2022-02-13 23:57:37 -0800 | [diff] [blame] | 822 | argv[4] = "null"; |
lh | 1358661 | 2022-01-11 21:58:58 -0800 | [diff] [blame] | 823 | } |
| 824 | else |
| 825 | { |
lh | f81a46f | 2022-02-13 23:57:37 -0800 | [diff] [blame] | 826 | argv[4] = normalProtocol; |
lh | 1358661 | 2022-01-11 21:58:58 -0800 | [diff] [blame] | 827 | } |
| 828 | if(roamingProtocol==NULL) |
| 829 | { |
lh | f81a46f | 2022-02-13 23:57:37 -0800 | [diff] [blame] | 830 | argv[5] = "null"; |
lh | 1358661 | 2022-01-11 21:58:58 -0800 | [diff] [blame] | 831 | } |
| 832 | else |
| 833 | { |
lh | f81a46f | 2022-02-13 23:57:37 -0800 | [diff] [blame] | 834 | argv[5] = roamingProtocol; |
| 835 | } |
| 836 | client.uToken = Global_uToken; |
| 837 | client.request = 27;//RIL_REQUEST_SETUP_DATA_CALL |
| 838 | client.paramLen = 7; |
| 839 | bzero(client.param,LYNQ_REQUEST_PARAM_BUF); |
Hong_Liu | e54db8c | 2023-04-21 02:37:23 -0700 | [diff] [blame] | 840 | #ifdef GSW_RIL_CFG |
| 841 | if(NULL == apn) |
| 842 | { |
| 843 | sprintf(client.param,"null %s %s %s %s %s %s",apnType,argv[1],argv[2],argv[3],argv[4],argv[5]); |
| 844 | } |
| 845 | else |
| 846 | { |
| 847 | sprintf(client.param,"%s %s %s %s %s %s %s",apn,apnType,argv[1],argv[2],argv[3],argv[4],argv[5]); |
| 848 | } |
| 849 | #else |
lh | f81a46f | 2022-02-13 23:57:37 -0800 | [diff] [blame] | 850 | sprintf(client.param,"%s %s %s %s %s %s %s",apn,apnType,argv[1],argv[2],argv[3],argv[4],argv[5]); |
Hong_Liu | e54db8c | 2023-04-21 02:37:23 -0700 | [diff] [blame] | 851 | #endif //GSW_RIL_CFG |
lh | f81a46f | 2022-02-13 23:57:37 -0800 | [diff] [blame] | 852 | LYINFLOG("uToken=%d,request=%d,paralen=%d,param=%s",client.uToken,client.request,client.paramLen,client.param); |
rjw | c63abb4 | 2023-03-31 18:22:42 +0800 | [diff] [blame] | 853 | lynq_data_call_id = updateApn(apnType); |
| 854 | if (lynq_data_call_id < 0) |
| 855 | { |
| 856 | LYERRLOG("update apn table fail error id = %d",lynq_data_call_id); |
Hong_Liu | 7e1b85e | 2023-05-16 05:51:57 -0700 | [diff] [blame] | 857 | return LYNQ_E_NULL_ANONALY+1; |
rjw | c63abb4 | 2023-03-31 18:22:42 +0800 | [diff] [blame] | 858 | } |
Hong_Liu | 7e1b85e | 2023-05-16 05:51:57 -0700 | [diff] [blame] | 859 | *handle = lynq_data_call_id;//T8TSK-211 (2023/5/16) |
rjw | 733b983 | 2023-04-03 10:20:08 +0800 | [diff] [blame] | 860 | lynq_data_call = 1; |
rjw | ed00d04 | 2022-05-25 09:18:16 +0800 | [diff] [blame] | 861 | pthread_mutex_lock(&g_lynq_data_sendto_mutex); |
lh | f81a46f | 2022-02-13 23:57:37 -0800 | [diff] [blame] | 862 | if(send_request(lynq_client_sockfd,&client)==-1) |
| 863 | { |
| 864 | LYERRLOG("send request fail"); |
| 865 | perror("[LYNQ_DATA] send request fail:"); |
Hong_Liu | 7e1b85e | 2023-05-16 05:51:57 -0700 | [diff] [blame] | 866 | return LYNQ_E_NULL_ANONALY+2; |
lh | f81a46f | 2022-02-13 23:57:37 -0800 | [diff] [blame] | 867 | } |
| 868 | get_response(lynq_client_sockfd,p); |
rjw | ed00d04 | 2022-05-25 09:18:16 +0800 | [diff] [blame] | 869 | pthread_mutex_unlock(&g_lynq_data_sendto_mutex); |
rjw | fa53297 | 2022-09-16 13:39:41 +0800 | [diff] [blame] | 870 | JumpHeader(p,&resp_type,&request,&slot_id,&error); |
lh | f81a46f | 2022-02-13 23:57:37 -0800 | [diff] [blame] | 871 | LYINFLOG("resp_type=%d,request=%d,slot_id=%d,error_code=%d",resp_type,request,slot_id,error); |
lh | f81a46f | 2022-02-13 23:57:37 -0800 | [diff] [blame] | 872 | if(error==0) |
| 873 | { |
Hong_Liu | 7e1b85e | 2023-05-16 05:51:57 -0700 | [diff] [blame] | 874 | data_timelimit = 1; |
rjw | 7ee7bb4 | 2023-01-18 11:34:28 +0800 | [diff] [blame] | 875 | if(waitDataCallstateChange(60000)==ETIMEDOUT)//60s |
lh | f81a46f | 2022-02-13 23:57:37 -0800 | [diff] [blame] | 876 | { |
| 877 | error = LYNQ_E_TIME_OUT; |
| 878 | LYERRLOG("timeout:wait data Call state fail!!!"); |
| 879 | lynq_apn_table[lynq_data_call_id].hasTimeout = 1; |
Hong_Liu | 6149f18 | 2023-05-12 02:15:14 -0700 | [diff] [blame] | 880 | if (data_invaild_error == 1) |
| 881 | { |
| 882 | data_invaild_error = 0; |
| 883 | LYERRLOG("urc apn info error!!!"); |
| 884 | return 8085; |
| 885 | } |
| 886 | printf_apn_table_debug(__FUNCTION__,__LINE__); |
lh | f81a46f | 2022-02-13 23:57:37 -0800 | [diff] [blame] | 887 | return error; |
| 888 | } |
lh | f81a46f | 2022-02-13 23:57:37 -0800 | [diff] [blame] | 889 | } |
Hong_Liu | 6149f18 | 2023-05-12 02:15:14 -0700 | [diff] [blame] | 890 | printf_apn_table_debug(__FUNCTION__,__LINE__); |
lh | f81a46f | 2022-02-13 23:57:37 -0800 | [diff] [blame] | 891 | return error; |
| 892 | } |
| 893 | /* |
| 894 | int lynq_deactive_data_call_sp(int *handle,char *apnType) |
| 895 | { |
| 896 | Parcel p; |
| 897 | lynq_client_t client; |
| 898 | int resp_type = -1; |
| 899 | int request = -1; |
| 900 | int slot_id = -1; |
| 901 | int error = -1; |
| 902 | if(handle==NULL||apnType==NULL) |
| 903 | { |
| 904 | LYERRLOG("handle is null!!!"); |
| 905 | return -1; |
| 906 | } |
| 907 | client.uToken = Global_uToken; |
| 908 | client.request = 41;//RIL_REQUEST_DEACTIVATE_DATA_CALL |
| 909 | client.paramLen = 1; |
| 910 | bzero(client.param,LYNQ_REQUEST_PARAM_BUF); |
| 911 | sprintf(client.param,"%s",apnType); |
| 912 | LYERRLOG("uToken=%d,request=%d,paralen=%d,param=%s",client.uToken,client.request,client.paramLen,client.param); |
| 913 | if(send_request(lynq_client_sockfd,&client)==-1) |
| 914 | { |
| 915 | LYERRLOG("send request fail"); |
| 916 | perror("[LYNQ_DATA] send request fail:"); |
| 917 | return -1; |
| 918 | } |
| 919 | get_response(lynq_client_sockfd,p); |
rjw | fa53297 | 2022-09-16 13:39:41 +0800 | [diff] [blame] | 920 | JumpHeader(p,&resp_type,&request,&slot_id,&error); |
lh | f81a46f | 2022-02-13 23:57:37 -0800 | [diff] [blame] | 921 | LYINFLOG("resp_type=%d,request=%d,slot_id=%d,error_code=%d",resp_type,request,slot_id,error); |
| 922 | return error; |
| 923 | } |
| 924 | */ |
| 925 | int getDataCallLists(lynq_data_call_response_v11_t dataCallList[LYNQ_APN_CHANNEL_MAX],int *realNum) |
| 926 | { |
| 927 | Parcel p; |
| 928 | lynq_client_t client; |
| 929 | int resp_type = -1; |
q.huang | 7de1d66 | 2022-09-13 14:19:24 +0800 | [diff] [blame] | 930 | int token; |
| 931 | int request = -1; |
lh | f81a46f | 2022-02-13 23:57:37 -0800 | [diff] [blame] | 932 | int slot_id = -1; |
| 933 | int error = -1; |
| 934 | int version =0; |
| 935 | int num = 0; |
lh | f81a46f | 2022-02-13 23:57:37 -0800 | [diff] [blame] | 936 | char *temp_char = NULL; |
| 937 | if(dataCallList==NULL) |
| 938 | { |
| 939 | LYERRLOG("dataCallList is null!!!"); |
| 940 | return -1; |
| 941 | } |
Hong_Liu | 7e1b85e | 2023-05-16 05:51:57 -0700 | [diff] [blame] | 942 | Global_uToken++; |
lh | f81a46f | 2022-02-13 23:57:37 -0800 | [diff] [blame] | 943 | client.uToken = Global_uToken; |
| 944 | client.request = 57;//RIL_REQUEST_DATA_CALL_LIST |
| 945 | client.paramLen = 0; |
| 946 | bzero(client.param,LYNQ_REQUEST_PARAM_BUF); |
| 947 | LYINFLOG("uToken=%d,request=%d,paralen=%d,param=%s",client.uToken,client.request,client.paramLen,client.param); |
rjw | ed00d04 | 2022-05-25 09:18:16 +0800 | [diff] [blame] | 948 | pthread_mutex_lock(&g_lynq_data_sendto_mutex); |
lh | f81a46f | 2022-02-13 23:57:37 -0800 | [diff] [blame] | 949 | if(send_request(lynq_client_sockfd,&client)==-1) |
| 950 | { |
| 951 | LYERRLOG("send request fail"); |
| 952 | perror("[LYNQ_DATA] send request fail:"); |
| 953 | return -1; |
| 954 | } |
| 955 | get_response(lynq_client_sockfd,p); |
rjw | ed00d04 | 2022-05-25 09:18:16 +0800 | [diff] [blame] | 956 | pthread_mutex_unlock(&g_lynq_data_sendto_mutex); |
rjw | fa53297 | 2022-09-16 13:39:41 +0800 | [diff] [blame] | 957 | if(p.dataAvail() > 0) |
| 958 | { |
rjw | 0fb4ccb | 2022-09-16 19:12:35 +0800 | [diff] [blame] | 959 | p.readInt32(&resp_type); |
| 960 | p.readInt32(&token); |
| 961 | p.readInt32(&request); |
| 962 | p.readInt32(&slot_id); |
| 963 | p.readInt32(&error); |
rjw | fa53297 | 2022-09-16 13:39:41 +0800 | [diff] [blame] | 964 | } |
| 965 | else |
| 966 | { |
| 967 | return -1; |
| 968 | } |
Hong_Liu | 7e1b85e | 2023-05-16 05:51:57 -0700 | [diff] [blame] | 969 | LYINFLOG("resp_type=%d,uToken=%d,request=%d,slot_id=%d,error_code=%d",resp_type,token,request,slot_id,error); |
lh | f81a46f | 2022-02-13 23:57:37 -0800 | [diff] [blame] | 970 | p.readInt32(&version); |
| 971 | if(version==11) |
| 972 | { |
| 973 | p.readInt32(&num); |
| 974 | *realNum = num; |
| 975 | for (int i = 0; i < num; i++) |
| 976 | { |
| 977 | p.readInt32(&dataCallList[i].status); |
| 978 | p.readInt32(&dataCallList[i].suggestedRetryTime); |
| 979 | p.readInt32(&dataCallList[i].cid); |
| 980 | p.readInt32(&dataCallList[i].active); |
| 981 | temp_char = strdupReadString(p); |
Hong_Liu | 6149f18 | 2023-05-12 02:15:14 -0700 | [diff] [blame] | 982 | LYINFLOG("[%s][%d]%s",__FUNCTION__,__LINE__,temp_char); |
| 983 | if(temp_char) |
| 984 | { |
| 985 | memcpy(dataCallList[i].type,temp_char,strlen(temp_char)+1); |
| 986 | free(temp_char); |
| 987 | } |
lh | f81a46f | 2022-02-13 23:57:37 -0800 | [diff] [blame] | 988 | temp_char = strdupReadString(p); |
Hong_Liu | 6149f18 | 2023-05-12 02:15:14 -0700 | [diff] [blame] | 989 | LYINFLOG("[%s][%d]%s",__FUNCTION__,__LINE__,temp_char); |
| 990 | if(temp_char) |
| 991 | { |
| 992 | memcpy(dataCallList[i].ifname,temp_char,strlen(temp_char)+1); |
| 993 | free(temp_char); |
| 994 | } |
lh | f81a46f | 2022-02-13 23:57:37 -0800 | [diff] [blame] | 995 | temp_char = strdupReadString(p); |
Hong_Liu | 6149f18 | 2023-05-12 02:15:14 -0700 | [diff] [blame] | 996 | LYINFLOG("[%s][%d]%s",__FUNCTION__,__LINE__,temp_char); |
| 997 | if(temp_char) |
| 998 | { |
| 999 | memcpy(dataCallList[i].addresses,temp_char,strlen(temp_char)+1); |
| 1000 | free(temp_char); |
| 1001 | } |
lh | f81a46f | 2022-02-13 23:57:37 -0800 | [diff] [blame] | 1002 | temp_char = strdupReadString(p); |
Hong_Liu | 6149f18 | 2023-05-12 02:15:14 -0700 | [diff] [blame] | 1003 | LYINFLOG("[%s][%d]%s",__FUNCTION__,__LINE__,temp_char); |
| 1004 | if(temp_char) |
| 1005 | { |
| 1006 | memcpy(dataCallList[i].dnses,temp_char,strlen(temp_char)+1); |
| 1007 | free(temp_char); |
| 1008 | } |
lh | f81a46f | 2022-02-13 23:57:37 -0800 | [diff] [blame] | 1009 | temp_char = strdupReadString(p); |
Hong_Liu | 6149f18 | 2023-05-12 02:15:14 -0700 | [diff] [blame] | 1010 | LYINFLOG("[%s][%d]%s",__FUNCTION__,__LINE__,temp_char); |
| 1011 | if(temp_char) |
| 1012 | { |
| 1013 | memcpy(dataCallList[i].gateways,temp_char,strlen(temp_char)+1); |
| 1014 | free(temp_char); |
| 1015 | } |
lh | f81a46f | 2022-02-13 23:57:37 -0800 | [diff] [blame] | 1016 | temp_char = strdupReadString(p); |
Hong_Liu | 6149f18 | 2023-05-12 02:15:14 -0700 | [diff] [blame] | 1017 | LYINFLOG("[%s][%d]%s",__FUNCTION__,__LINE__,temp_char); |
| 1018 | if(temp_char) |
| 1019 | { |
| 1020 | memcpy(dataCallList[i].pcscf,temp_char,strlen(temp_char)+1); |
| 1021 | free(temp_char); |
| 1022 | } |
lh | f81a46f | 2022-02-13 23:57:37 -0800 | [diff] [blame] | 1023 | p.readInt32(&dataCallList[i].mtu); |
| 1024 | } |
| 1025 | } |
| 1026 | return error; |
| 1027 | } |
| 1028 | int lynq_get_data_call_list(int *handle,lynq_data_call_response_v11_t *dataCallList) |
| 1029 | { |
| 1030 | lynq_data_call_response_v11_t interDataCallList[LYNQ_APN_CHANNEL_MAX]={}; |
| 1031 | int number = 0; |
| 1032 | int lynq_data_call_id = 0; |
| 1033 | int error = 0; |
| 1034 | lynq_data_call_id = *handle; |
| 1035 | if(handle==NULL) |
| 1036 | { |
| 1037 | LYERRLOG("handle is NULL"); |
| 1038 | return LYNQ_E_NULL_ANONALY; |
| 1039 | } |
rjw | 3938f26 | 2023-03-08 16:09:28 +0800 | [diff] [blame] | 1040 | if (*handle<0 && handle>8) |
| 1041 | { |
| 1042 | LYERRLOG("handle value error"); |
| 1043 | } |
| 1044 | LYINFLOG("incoming handle value: %d",*handle); |
lh | f81a46f | 2022-02-13 23:57:37 -0800 | [diff] [blame] | 1045 | memset(interDataCallList,0,sizeof(interDataCallList)); |
| 1046 | error = getDataCallLists(interDataCallList,&number); |
| 1047 | if(error == 0) |
| 1048 | { |
| 1049 | for(int i = 0;i < number;i++) |
| 1050 | { |
| 1051 | if(strcmp(interDataCallList[i].ifname,lynq_apn_table[lynq_data_call_id].ifaceName)==0) |
| 1052 | { |
| 1053 | dataCallList->active = interDataCallList[i].active; |
| 1054 | dataCallList->suggestedRetryTime = interDataCallList[i].suggestedRetryTime; |
| 1055 | dataCallList->cid = interDataCallList[i].cid; |
| 1056 | dataCallList->status = interDataCallList[i].status; |
| 1057 | dataCallList->mtu = interDataCallList[i].mtu; |
| 1058 | memcpy(dataCallList->addresses,interDataCallList[i].addresses,sizeof(interDataCallList[i].addresses)); |
| 1059 | memcpy(dataCallList->ifname,interDataCallList[i].ifname,sizeof(interDataCallList[i].ifname)); |
| 1060 | memcpy(dataCallList->dnses,interDataCallList[i].dnses,sizeof(interDataCallList[i].dnses)); |
| 1061 | memcpy(dataCallList->type,interDataCallList[i].type,sizeof(interDataCallList[i].type)); |
| 1062 | memcpy(dataCallList->gateways,interDataCallList[i].gateways,sizeof(interDataCallList[i].gateways)); |
| 1063 | memcpy(dataCallList->pcscf,interDataCallList[i].pcscf,sizeof(interDataCallList[i].pcscf)); |
| 1064 | LYDBGLOG("ifname:%s,addr:%s",dataCallList->ifname,dataCallList->addresses); |
| 1065 | } |
| 1066 | } |
| 1067 | } |
| 1068 | return error; |
| 1069 | } |
| 1070 | int lynq_wait_data_call_state_change(int *handle) |
| 1071 | { |
rjw | c3d6e58 | 2023-03-28 17:19:11 +0800 | [diff] [blame] | 1072 | if (data_waiting_status == 1) |
| 1073 | { |
| 1074 | LYDBGLOG("some thread is waiting"); |
| 1075 | return -3; |
| 1076 | } |
| 1077 | LYDBGLOG("is empty :%d",s_data_urc_wait_list.empty()); |
| 1078 | if (s_data_urc_wait_list.empty()) |
| 1079 | { |
| 1080 | LYDBGLOG("start wait"); |
| 1081 | data_waiting_status = 1; |
| 1082 | waitPdnChange(); |
| 1083 | } |
| 1084 | data_waiting_status = 0; |
rjw | 7ee7bb4 | 2023-01-18 11:34:28 +0800 | [diff] [blame] | 1085 | std::vector<int>::iterator iter; |
rjw | 7ee7bb4 | 2023-01-18 11:34:28 +0800 | [diff] [blame] | 1086 | |
| 1087 | pthread_mutex_lock(&s_lynq_urc_vector_mutex); |
| 1088 | iter = s_data_urc_wait_list.begin(); |
rjw | c3d6e58 | 2023-03-28 17:19:11 +0800 | [diff] [blame] | 1089 | if (iter != s_data_urc_wait_list.end()) |
| 1090 | { |
| 1091 | *handle = *iter; |
| 1092 | } |
rjw | 7ee7bb4 | 2023-01-18 11:34:28 +0800 | [diff] [blame] | 1093 | s_data_urc_wait_list.erase(iter); |
| 1094 | pthread_mutex_unlock(&s_lynq_urc_vector_mutex); |
| 1095 | |
rjw | 3938f26 | 2023-03-08 16:09:28 +0800 | [diff] [blame] | 1096 | LYINFLOG("lynq data call id:%d",*handle); |
lh | f81a46f | 2022-02-13 23:57:37 -0800 | [diff] [blame] | 1097 | return 0; |
| 1098 | } |
| 1099 | /*Warren add for T800 platform 2021/11/19 end*/ |
rjw | 20006d1 | 2022-04-21 16:29:04 +0800 | [diff] [blame] | 1100 | |
| 1101 | /*Typethree add for T800 platform 2022/04/21 start*/ |
rjw | 61fcae3 | 2022-08-18 14:03:39 +0800 | [diff] [blame] | 1102 | |
| 1103 | int insert_apn_char(char *agc, char *id,char *mcc, char *mnc, char *apn, char *apntype, char *user, char *password, char *normalprotocol, char *roamingprotocol, char *carrier) |
rjw | 20006d1 | 2022-04-21 16:29:04 +0800 | [diff] [blame] | 1104 | { |
| 1105 | char strtmp[10][32]; |
rjw | 61fcae3 | 2022-08-18 14:03:39 +0800 | [diff] [blame] | 1106 | if (id == NULL) |
rjw | 0cdacbc | 2022-06-22 10:51:07 +0800 | [diff] [blame] | 1107 | { |
rjw | 61fcae3 | 2022-08-18 14:03:39 +0800 | [diff] [blame] | 1108 | sprintf(strtmp[0], "id=;"); |
rjw | 0cdacbc | 2022-06-22 10:51:07 +0800 | [diff] [blame] | 1109 | } |
rjw | 61fcae3 | 2022-08-18 14:03:39 +0800 | [diff] [blame] | 1110 | else |
rjw | 0cdacbc | 2022-06-22 10:51:07 +0800 | [diff] [blame] | 1111 | { |
rjw | 61fcae3 | 2022-08-18 14:03:39 +0800 | [diff] [blame] | 1112 | sprintf(strtmp[0], "id=%s;", id); |
rjw | 0cdacbc | 2022-06-22 10:51:07 +0800 | [diff] [blame] | 1113 | } |
rjw | 20006d1 | 2022-04-21 16:29:04 +0800 | [diff] [blame] | 1114 | if (mcc == NULL) |
| 1115 | { |
| 1116 | sprintf(strtmp[1], "mcc=;"); |
| 1117 | } |
| 1118 | else |
| 1119 | { |
| 1120 | sprintf(strtmp[1], "mcc=%s;", mcc); |
| 1121 | } |
| 1122 | if (mnc == NULL) |
| 1123 | { |
rjw | 61fcae3 | 2022-08-18 14:03:39 +0800 | [diff] [blame] | 1124 | sprintf(strtmp[2], "mnc=;"); |
rjw | 20006d1 | 2022-04-21 16:29:04 +0800 | [diff] [blame] | 1125 | } |
| 1126 | else |
| 1127 | { |
| 1128 | sprintf(strtmp[2], "mnc=%s;", mnc); |
| 1129 | } |
| 1130 | if (apn == NULL) |
| 1131 | { |
| 1132 | sprintf(strtmp[3], "apn=;"); |
| 1133 | } |
| 1134 | else |
| 1135 | { |
| 1136 | sprintf(strtmp[3], "apn=%s;", apn); |
| 1137 | } |
| 1138 | if (apntype == NULL) |
| 1139 | { |
| 1140 | sprintf(strtmp[4], "apntype=;"); |
| 1141 | } |
| 1142 | else |
| 1143 | { |
| 1144 | sprintf(strtmp[4], "apntype=%s;", apntype); |
| 1145 | } |
| 1146 | if (user == NULL) |
| 1147 | { |
| 1148 | sprintf(strtmp[5], "user=;"); |
| 1149 | } |
| 1150 | else |
| 1151 | { |
| 1152 | sprintf(strtmp[5], "user=%s;", user); |
| 1153 | } |
| 1154 | if (password == NULL) |
| 1155 | { |
| 1156 | sprintf(strtmp[6], "password=;"); |
| 1157 | } |
| 1158 | else |
| 1159 | { |
| 1160 | sprintf(strtmp[6], "password=%s;", password); |
| 1161 | } |
| 1162 | if (normalprotocol == NULL) |
| 1163 | { |
| 1164 | sprintf(strtmp[7], "normalprotocol=;"); |
| 1165 | } |
| 1166 | else |
| 1167 | { |
| 1168 | sprintf(strtmp[7], "normalprotocol=%s;", normalprotocol); |
| 1169 | } |
| 1170 | if (roamingprotocol == NULL) |
| 1171 | { |
| 1172 | sprintf(strtmp[8], "roamingprotocol=;"); |
| 1173 | } |
| 1174 | else |
| 1175 | { |
| 1176 | sprintf(strtmp[8], "roamingprotocol=%s;", roamingprotocol); |
| 1177 | } |
| 1178 | if (carrier == NULL) |
| 1179 | { |
| 1180 | sprintf(strtmp[9], "carrier=;"); |
| 1181 | } |
| 1182 | else |
| 1183 | { |
| 1184 | sprintf(strtmp[9], "carrier=%s;", carrier); |
| 1185 | } |
rjw | 61fcae3 | 2022-08-18 14:03:39 +0800 | [diff] [blame] | 1186 | sprintf(agc, "%s%s%s%s%s%s%s%s%s%s",strtmp[0], strtmp[1], strtmp[2], strtmp[3], strtmp[4], strtmp[5], strtmp[6], strtmp[7], strtmp[8], strtmp[9]); |
rjw | 0cdacbc | 2022-06-22 10:51:07 +0800 | [diff] [blame] | 1187 | |
rjw | 20006d1 | 2022-04-21 16:29:04 +0800 | [diff] [blame] | 1188 | return 0; |
| 1189 | } |
| 1190 | |
| 1191 | int modify_apn_char(char *agc, char *id, char *mcc, char *mnc, char *apn, char *apntype, char *user, char *password, char *normalprotocol, char *roamingprotocol, char *carrier) |
| 1192 | { |
| 1193 | char strtmp[10][32]; |
| 1194 | if (id == NULL) |
| 1195 | { |
| 1196 | sprintf(strtmp[0], "id=;"); |
| 1197 | } |
| 1198 | else |
| 1199 | { |
| 1200 | sprintf(strtmp[0], "id=%s;", id); |
| 1201 | } |
| 1202 | if (mcc == NULL) |
| 1203 | { |
| 1204 | sprintf(strtmp[1], "mcc=;"); |
| 1205 | } |
| 1206 | else |
| 1207 | { |
| 1208 | sprintf(strtmp[1], "mcc=%s;", mcc); |
| 1209 | } |
| 1210 | if (mnc == NULL) |
| 1211 | { |
| 1212 | sprintf(strtmp[2], "mnc=;"); |
| 1213 | } |
| 1214 | else |
| 1215 | { |
| 1216 | sprintf(strtmp[2], "mnc=%s;", mnc); |
| 1217 | } |
| 1218 | if (apn == NULL) |
| 1219 | { |
| 1220 | sprintf(strtmp[3], "apn=;"); |
| 1221 | } |
| 1222 | else |
| 1223 | { |
| 1224 | sprintf(strtmp[3], "apn=%s;", apn); |
| 1225 | } |
| 1226 | if (apntype == NULL) |
| 1227 | { |
| 1228 | sprintf(strtmp[4], "apntype=;"); |
| 1229 | } |
| 1230 | else |
| 1231 | { |
| 1232 | sprintf(strtmp[4], "apntype=%s;", apntype); |
| 1233 | } |
| 1234 | if (user == NULL) |
| 1235 | { |
| 1236 | sprintf(strtmp[5], "user=;"); |
| 1237 | } |
| 1238 | else |
| 1239 | { |
| 1240 | sprintf(strtmp[5], "user=%s;", user); |
| 1241 | } |
| 1242 | if (password == NULL) |
| 1243 | { |
| 1244 | sprintf(strtmp[6], "password=;"); |
| 1245 | } |
| 1246 | else |
| 1247 | { |
| 1248 | sprintf(strtmp[6], "password=%s;", password); |
| 1249 | } |
| 1250 | if (normalprotocol == NULL) |
| 1251 | { |
| 1252 | sprintf(strtmp[7], "normalprotocol=;"); |
| 1253 | } |
| 1254 | else |
| 1255 | { |
| 1256 | sprintf(strtmp[7], "normalprotocol=%s;", normalprotocol); |
| 1257 | } |
| 1258 | if (roamingprotocol == NULL) |
| 1259 | { |
| 1260 | sprintf(strtmp[8], "roamingprotocol=;"); |
| 1261 | } |
| 1262 | else |
| 1263 | { |
| 1264 | sprintf(strtmp[8], "roamingprotocol=%s;", roamingprotocol); |
| 1265 | } |
| 1266 | if (carrier == NULL) |
| 1267 | { |
| 1268 | sprintf(strtmp[9], "carrier=;"); |
| 1269 | } |
| 1270 | else |
| 1271 | { |
| 1272 | sprintf(strtmp[9], "carrier=%s;", carrier); |
| 1273 | } |
| 1274 | sprintf(agc, "%s%s%s%s%s%s%s%s%s%s", strtmp[0], strtmp[1], strtmp[2], strtmp[3], strtmp[4], strtmp[5], strtmp[6], strtmp[7], strtmp[8], strtmp[9]); |
| 1275 | return 0; |
| 1276 | } |
| 1277 | |
rjw | af4b161 | 2022-06-13 17:26:01 +0800 | [diff] [blame] | 1278 | |
| 1279 | int query_apn_char(char *agc, char *id, char *mcc, char *mnc, char *apn, char *apntype, char *user, char *password, char *normalprotocol, char *roamingprotocol, char *carrier) |
| 1280 | { |
| 1281 | char strtmp[10][32]; |
| 1282 | if (id == NULL) |
| 1283 | { |
| 1284 | sprintf(strtmp[0], ""); |
| 1285 | } |
| 1286 | else |
| 1287 | { |
| 1288 | sprintf(strtmp[0], "id=%s;", id); |
| 1289 | } |
| 1290 | if (mcc == NULL) |
| 1291 | { |
| 1292 | sprintf(strtmp[1], ""); |
| 1293 | } |
| 1294 | else |
| 1295 | { |
| 1296 | sprintf(strtmp[1], "mcc=%s;", mcc); |
| 1297 | } |
| 1298 | if (mnc == NULL) |
| 1299 | { |
| 1300 | sprintf(strtmp[2], ""); |
| 1301 | } |
| 1302 | else |
| 1303 | { |
| 1304 | sprintf(strtmp[2], "mnc=%s;", mnc); |
| 1305 | } |
| 1306 | if (apn == NULL) |
| 1307 | { |
| 1308 | sprintf(strtmp[3], ""); |
| 1309 | } |
| 1310 | else |
| 1311 | { |
| 1312 | sprintf(strtmp[3], "apn=%s;", apn); |
| 1313 | } |
| 1314 | if (apntype == NULL) |
| 1315 | { |
| 1316 | sprintf(strtmp[4], ""); |
| 1317 | } |
| 1318 | else |
| 1319 | { |
| 1320 | sprintf(strtmp[4], "apntype=%s;", apntype); |
| 1321 | } |
| 1322 | if (user == NULL) |
| 1323 | { |
| 1324 | sprintf(strtmp[5], ""); |
| 1325 | } |
| 1326 | else |
| 1327 | { |
| 1328 | sprintf(strtmp[5], "user=%s;", user); |
| 1329 | } |
| 1330 | if (password == NULL) |
| 1331 | { |
| 1332 | sprintf(strtmp[6], ""); |
| 1333 | } |
| 1334 | else |
| 1335 | { |
| 1336 | sprintf(strtmp[6], "password=%s;", password); |
| 1337 | } |
| 1338 | if (normalprotocol == NULL) |
| 1339 | { |
| 1340 | sprintf(strtmp[7], ""); |
| 1341 | } |
| 1342 | else |
| 1343 | { |
| 1344 | sprintf(strtmp[7], "normalprotocol=%s;", normalprotocol); |
| 1345 | } |
| 1346 | if (roamingprotocol == NULL) |
| 1347 | { |
| 1348 | sprintf(strtmp[8], ""); |
| 1349 | } |
| 1350 | else |
| 1351 | { |
| 1352 | sprintf(strtmp[8], "roamingprotocol=%s;", roamingprotocol); |
| 1353 | } |
| 1354 | if (carrier == NULL) |
| 1355 | { |
| 1356 | sprintf(strtmp[9], ""); |
| 1357 | } |
| 1358 | else |
| 1359 | { |
| 1360 | sprintf(strtmp[9], "carrier=%s;", carrier); |
| 1361 | } |
| 1362 | sprintf(agc, "%s%s%s%s%s%s%s%s%s%s", strtmp[0], strtmp[1], strtmp[2], strtmp[3], strtmp[4], strtmp[5], strtmp[6], strtmp[7], strtmp[8], strtmp[9]); |
| 1363 | return 0; |
| 1364 | } |
| 1365 | |
rjw | 20006d1 | 2022-04-21 16:29:04 +0800 | [diff] [blame] | 1366 | static char *lynqStrdupReadString(Parcel &p) |
| 1367 | { |
| 1368 | size_t stringlen; |
| 1369 | const char16_t *s16; |
| 1370 | |
| 1371 | s16 = p.readString16Inplace(&stringlen); |
| 1372 | return strndup16to8(s16, stringlen); |
| 1373 | } |
| 1374 | |
| 1375 | int lynq_modify_apn_db(const int cmd, char *id, char *mcc, char *mnc, char *apn, char *apntype, char *user, char *password, char *normalprotocol, char *roamingprotocol, char *carrier, char *out) |
| 1376 | { |
| 1377 | if (NULL == id && NULL == mcc && NULL == mnc && NULL == apn && NULL == apntype && NULL == user && NULL == password && NULL == normalprotocol && NULL == roamingprotocol && NULL == carrier) |
| 1378 | { |
| 1379 | LYERRLOG("There are no valid parameters"); |
| 1380 | return -1; |
| 1381 | } |
| 1382 | lynq_client_t client; |
| 1383 | char argc[512]; |
rjw | 0cdacbc | 2022-06-22 10:51:07 +0800 | [diff] [blame] | 1384 | int res = 0; |
rjw | 20006d1 | 2022-04-21 16:29:04 +0800 | [diff] [blame] | 1385 | Parcel p; |
| 1386 | if (cmd == 0) // insert apn db |
| 1387 | { |
rjw | 61fcae3 | 2022-08-18 14:03:39 +0800 | [diff] [blame] | 1388 | res = insert_apn_char(argc, id, mcc, mnc, apn, apntype, user, password, normalprotocol, roamingprotocol, carrier); |
| 1389 | |
rjw | 20006d1 | 2022-04-21 16:29:04 +0800 | [diff] [blame] | 1390 | client.uToken = Global_uToken; |
| 1391 | client.request = 2000 + 193; // RIL_REQUEST_MODIFY_APN |
| 1392 | client.paramLen = 2; |
| 1393 | bzero(client.param, LYNQ_REQUEST_PARAM_BUF); |
| 1394 | sprintf(client.param, "%d %s", cmd, argc); |
| 1395 | } |
rjw | 61fcae3 | 2022-08-18 14:03:39 +0800 | [diff] [blame] | 1396 | else if (cmd == 1) //delete apn db |
rjw | 20006d1 | 2022-04-21 16:29:04 +0800 | [diff] [blame] | 1397 | { |
| 1398 | if (NULL == id) |
| 1399 | { |
| 1400 | LYERRLOG("id is NULL!!!please input id: "); |
| 1401 | } |
| 1402 | sprintf(argc, "id=%s", id); |
| 1403 | client.uToken = Global_uToken; |
| 1404 | client.request = 2000 + 193; // RIL_REQUEST_MODIFY_APN |
| 1405 | client.paramLen = 2; |
| 1406 | bzero(client.param, LYNQ_REQUEST_PARAM_BUF); |
| 1407 | sprintf(client.param, "%d %s", cmd, argc); |
| 1408 | } |
rjw | 61fcae3 | 2022-08-18 14:03:39 +0800 | [diff] [blame] | 1409 | else if (cmd == 2) //query apn db |
rjw | 20006d1 | 2022-04-21 16:29:04 +0800 | [diff] [blame] | 1410 | { |
rjw | af4b161 | 2022-06-13 17:26:01 +0800 | [diff] [blame] | 1411 | query_apn_char(argc, id, mcc, mnc, apn, apntype, user, password, normalprotocol, roamingprotocol, carrier); |
rjw | 20006d1 | 2022-04-21 16:29:04 +0800 | [diff] [blame] | 1412 | client.uToken = Global_uToken; |
| 1413 | client.request = 2000 + 193; // RIL_REQUEST_MODIFY_APN |
| 1414 | client.paramLen = 2; |
| 1415 | bzero(client.param, LYNQ_REQUEST_PARAM_BUF); |
| 1416 | sprintf(client.param, "%d %s", cmd, argc); |
| 1417 | } |
rjw | 61fcae3 | 2022-08-18 14:03:39 +0800 | [diff] [blame] | 1418 | else if (cmd == 3) //modify apn db |
rjw | 20006d1 | 2022-04-21 16:29:04 +0800 | [diff] [blame] | 1419 | { |
| 1420 | modify_apn_char(argc, id, mcc, mnc, apn, apntype, user, password, normalprotocol, roamingprotocol, carrier); |
| 1421 | client.uToken = Global_uToken; |
| 1422 | client.request = 2000 + 193; // RIL_REQUEST_MODIFY_APN |
| 1423 | client.paramLen = 2; |
| 1424 | bzero(client.param, LYNQ_REQUEST_PARAM_BUF); |
| 1425 | sprintf(client.param, "%d %s", cmd, argc); |
| 1426 | } |
| 1427 | else |
| 1428 | { |
| 1429 | LYERRLOG("incoming command is invalid"); |
| 1430 | return -1; |
| 1431 | } |
| 1432 | LYINFLOG("uToken=%d,request=%d,paralen=%d,param=%s",client.uToken,client.request,client.paramLen,client.param); |
rjw | ed00d04 | 2022-05-25 09:18:16 +0800 | [diff] [blame] | 1433 | pthread_mutex_lock(&g_lynq_data_sendto_mutex); |
rjw | 20006d1 | 2022-04-21 16:29:04 +0800 | [diff] [blame] | 1434 | if(send_request(lynq_client_sockfd,&client)==-1) |
| 1435 | { |
| 1436 | LYERRLOG("send request fail"); |
| 1437 | return -1; |
| 1438 | } |
rjw | ed00d04 | 2022-05-25 09:18:16 +0800 | [diff] [blame] | 1439 | pthread_mutex_unlock(&g_lynq_data_sendto_mutex); |
rjw | 20006d1 | 2022-04-21 16:29:04 +0800 | [diff] [blame] | 1440 | waitApnResult(); |
rjw | 3bcbbf1 | 2022-04-22 16:47:18 +0800 | [diff] [blame] | 1441 | strcpy(out, g_lynq_apn_result); |
rjw | 20006d1 | 2022-04-21 16:29:04 +0800 | [diff] [blame] | 1442 | LYINFLOG(">>>>>output info:%s",out); |
| 1443 | return 0; |
| 1444 | } |
| 1445 | |
| 1446 | int lynq_reset_apn(char *result) |
| 1447 | { |
| 1448 | Parcel p; |
| 1449 | lynq_client_t client; |
rjw | 3bcbbf1 | 2022-04-22 16:47:18 +0800 | [diff] [blame] | 1450 | if (NULL == result) |
| 1451 | { |
| 1452 | LYERRLOG("incoming paramters error"); |
| 1453 | } |
rjw | 20006d1 | 2022-04-21 16:29:04 +0800 | [diff] [blame] | 1454 | client.uToken = Global_uToken; |
| 1455 | client.request = 2000 + 194; |
| 1456 | client.paramLen = 0; |
| 1457 | bzero(client.param, LYNQ_REQUEST_PARAM_BUF); |
| 1458 | LYINFLOG("uToken=%d,request=%d,paralen=%d,param=%s", client.uToken, client.request, client.paramLen, client.param); |
rjw | ed00d04 | 2022-05-25 09:18:16 +0800 | [diff] [blame] | 1459 | pthread_mutex_lock(&g_lynq_data_sendto_mutex); |
rjw | 20006d1 | 2022-04-21 16:29:04 +0800 | [diff] [blame] | 1460 | if (send_request(lynq_client_sockfd, &client) == -1) |
| 1461 | { |
| 1462 | LYERRLOG("send request fail"); |
| 1463 | return -1; |
| 1464 | } |
rjw | ed00d04 | 2022-05-25 09:18:16 +0800 | [diff] [blame] | 1465 | pthread_mutex_unlock(&g_lynq_data_sendto_mutex); |
rjw | 20006d1 | 2022-04-21 16:29:04 +0800 | [diff] [blame] | 1466 | waitApnResult(); |
| 1467 | strcpy(result, g_lynq_apn_result); |
| 1468 | LYINFLOG(">>>>>result:%s",result); |
| 1469 | return 0; |
| 1470 | } |
| 1471 | |
rjw | 3bcbbf1 | 2022-04-22 16:47:18 +0800 | [diff] [blame] | 1472 | /*Typethree add for T800 platform 2022/04/21 end*/ |