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