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