lh | 7b0674a | 2022-01-10 00:34:35 -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_call.h"
|
| 12 | #include <cutils/jstring.h>
|
| 13 | #include <pthread.h>
|
| 14 | #include "liblog/lynq_deflog.h"
|
lh | 2afc773 | 2022-01-10 02:24:31 -0800 | [diff] [blame] | 15 | #include <sys/time.h>
|
lh | 21502f5 | 2022-01-27 00:27:12 -0800 | [diff] [blame] | 16 | #include <string.h>
|
lh | 7b0674a | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 17 | #define LYNQ_SERVICE_PORT 8088
|
rjw | 5d2a50e | 2022-02-28 15:01:49 +0800 | [diff] [blame] | 18 | #define DSET_IP_ADDRESS "127.0.0.1"
|
lh | 7b0674a | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 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_CALL"
|
| 24 |
|
| 25 | using ::android::Parcel;
|
| 26 | typedef enum {
|
| 27 | LYNQ_CALL_ACTIVE = 0,
|
| 28 | LYNQ_CALL_HOLDING = 1,
|
| 29 | LYNQ_CALL_DIALING = 2, /* MO call only */
|
| 30 | LYNQ_CALL_ALERTING = 3, /* MO call only */
|
| 31 | LYNQ_CALL_INCOMING = 4, /* MT call only */
|
| 32 | LYNQ_CALL_WAITING = 5 ,/* MT call only */
|
| 33 | }lynq_call_state_t;
|
| 34 |
|
| 35 | typedef struct{
|
| 36 | int uToken;
|
| 37 | int request;
|
| 38 | int paramLen;
|
| 39 | char param[LYNQ_REQUEST_PARAM_BUF];
|
| 40 | }lynq_client_t;
|
| 41 | typedef struct
|
| 42 | {
|
| 43 | int used;
|
| 44 | int call_id;
|
| 45 | int call_state;
|
| 46 | int toa;
|
| 47 | int direction;/*0: MO call,1:MT call*/
|
| 48 | char addr[LYNQ_PHONE_NUMBER_MAX];
|
| 49 | int hasTimeout;
|
| 50 | }lynq_call_list_e_t;
|
| 51 | typedef struct
|
| 52 | {
|
| 53 | int call_id;
|
| 54 | int call_state;
|
| 55 | int toa;
|
| 56 | int direction;/*0: MO call,1:MT call*/
|
| 57 | char addr[LYNQ_PHONE_NUMBER_MAX];
|
| 58 | }lynq_call_list_t;
|
| 59 |
|
| 60 | lynq_call_list_e_t lynq_call_lists[LYNQ_CALL_MAX]={};
|
| 61 | static pthread_mutex_t call_state_change_mutex = PTHREAD_MUTEX_INITIALIZER;
|
| 62 | static pthread_cond_t call_state_change_cond = PTHREAD_COND_INITIALIZER;
|
ll | 04ae414 | 2022-01-27 05:54:38 +0000 | [diff] [blame] | 63 | static pthread_mutex_t s_urc_call_state_change_mutex = PTHREAD_MUTEX_INITIALIZER;
|
lh | 7b0674a | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 64 | static pthread_cond_t s_urc_call_state_change_cond = PTHREAD_COND_INITIALIZER;
|
| 65 | static pthread_mutex_t s_incoming_call_mutex = PTHREAD_MUTEX_INITIALIZER;
|
| 66 | static pthread_cond_t s_incoming_call_cond = PTHREAD_COND_INITIALIZER;
|
ll | a8c25a8 | 2022-03-17 05:31:33 +0000 | [diff] [blame] | 67 | pthread_t lynq_call_urc_tid = -1;
|
| 68 | pthread_t lynq_call_list_loop_tid = -1;
|
lh | ec17b0a | 2022-02-13 23:56:05 -0800 | [diff] [blame] | 69 |
|
rjw | 5d2a50e | 2022-02-28 15:01:49 +0800 | [diff] [blame] | 70 | /*lei add*/
|
| 71 | /* socket文件描述符 */
|
| 72 | int len_addr_serv;
|
| 73 | struct sockaddr_in addr_serv;
|
| 74 | lynq_client_t client_t;
|
| 75 | int client_size = 0;
|
| 76 | /*lei add*/
|
lh | 7b0674a | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 77 |
|
lh | 42c1e57 | 2022-01-25 18:47:39 -0800 | [diff] [blame] | 78 | int s_call_urc_event_complete = 1;
|
lh | 7b0674a | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 79 |
|
| 80 | enum{
|
| 81 | CALL_OFF=0,
|
| 82 | CALL_ON=1
|
| 83 | }call_state;
|
ll | 04ae414 | 2022-01-27 05:54:38 +0000 | [diff] [blame] | 84 | typedef enum{
|
| 85 | LYNQ_E_CARDSTATE_ERROR=8000,
|
| 86 | /* The voice service state is out of service*/
|
| 87 | LYNQ_E_STATE_OUT_OF_SERVICE=8001,
|
| 88 | /* The voice service state is EMERGENCY_ONLY*/
|
| 89 | LYNQ_E_STATE_EMERGENCY_ONLY=8002,
|
| 90 | /* The radio power is power off*/
|
| 91 | LYNQ_E_STATE_POWER_OFF=8003,
|
| 92 | LYNQ_E_TIME_OUT=8004,
|
| 93 | /*create or open sms DB fail */
|
| 94 | LYNQ_E_SMS_DB_FAIL=8005,
|
| 95 | /*Failed to execute sql statement*/
|
| 96 | LYNQ_E_SMS_SQL_FAIL = 8006,
|
| 97 | LYNQ_E_SMS_NOT_FIND = 8007,
|
| 98 | /* The logic conflict*/
|
| 99 | LYNQ_E_CONFLICT=9000,
|
| 100 | /*Null anomaly*/
|
| 101 | LYNQ_E_NULL_ANONALY=9001
|
lh | 7b0674a | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 102 | }LYNQ_E;
|
q.huang | ec88da9 | 2022-03-29 04:17:32 -0400 | [diff] [blame] | 103 | typedef enum{
|
| 104 | LYNQ_E_VOLUMN_SET_DTMF,
|
| 105 | LYNQ_E_VOLUMN_SET_SPEECH
|
| 106 | }LYNQ_E_VOLUMN_SET;
|
lh | 7b0674a | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 107 |
|
| 108 | int lynq_call_state =CALL_OFF;
|
lh | 42c1e57 | 2022-01-25 18:47:39 -0800 | [diff] [blame] | 109 | int lynq_call_client_sockfd = 0;
|
| 110 | int Global_uToken_call = 0;
|
lh | 7b0674a | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 111 | int global_call_count =0;
|
| 112 | int global_call_auto_answer = 0;
|
lh | 42c1e57 | 2022-01-25 18:47:39 -0800 | [diff] [blame] | 113 | bool urc_call_recive_status = 1;
|
lh | 7b0674a | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 114 | bool call_list_loop = 1;
|
| 115 | int isDial = 0;
|
| 116 | int lynqIncomingCallId = 0;
|
ll | a8c25a8 | 2022-03-17 05:31:33 +0000 | [diff] [blame] | 117 | /**
|
| 118 | * @brief mark call initialization state
|
| 119 | * 0: deinit state
|
| 120 | * 1: init state
|
| 121 | */
|
| 122 | int g_lynq_call_init_flag = 0;
|
lh | 7b0674a | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 123 |
|
| 124 | int JumpHeader(Parcel &p,int *resp_type,int *request,int *slot_id,int *error)
|
| 125 | {
|
| 126 | if(p.dataAvail() > 0)
|
| 127 | {
|
| 128 | p.readInt32(resp_type);
|
| 129 | p.readInt32(request);
|
| 130 | p.readInt32(slot_id);
|
| 131 | p.readInt32(error);
|
| 132 | return 0;
|
| 133 | }
|
| 134 | else
|
| 135 | {
|
| 136 | return -1;
|
| 137 | }
|
| 138 | }
|
| 139 | int send_request(int sockfd,lynq_client_t *client_tmp)
|
| 140 | {
|
| 141 | int ret=0;
|
rjw | 5d2a50e | 2022-02-28 15:01:49 +0800 | [diff] [blame] | 142 | ret = sendto(sockfd, client_tmp, client_size, 0, (struct sockaddr *)&addr_serv, len_addr_serv);
|
lh | 7b0674a | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 143 | if(ret==-1)
|
| 144 | {
|
ll | 3fe0346 | 2022-03-01 09:18:53 +0000 | [diff] [blame] | 145 | LYERRLOG("sendto error\n");
|
lh | 7b0674a | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 146 | return -1;
|
| 147 | }
|
| 148 | return 0;
|
| 149 | }
|
| 150 |
|
| 151 | int get_response(int sockfd,Parcel &p)
|
| 152 | {
|
| 153 | int len = 0;
|
| 154 | char recvline[LYNQ_REC_BUF];
|
| 155 | bzero(recvline,LYNQ_REC_BUF);
|
| 156 | /* receive data from server */
|
rjw | 5d2a50e | 2022-02-28 15:01:49 +0800 | [diff] [blame] | 157 | len = recvfrom(sockfd,recvline,LYNQ_REC_BUF, 0, (struct sockaddr *)&addr_serv,(socklen_t*)&len_addr_serv);
|
lh | 7b0674a | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 158 | if(len == -1)
|
| 159 | {
|
ll | 3fe0346 | 2022-03-01 09:18:53 +0000 | [diff] [blame] | 160 | LYERRLOG("recvfrom error\n");
|
lh | 7b0674a | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 161 | return -1;
|
| 162 | }
|
lh | 7b0674a | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 163 | if (recvline != NULL) {
|
| 164 | p.setData((uint8_t *)recvline,len); // p.setData((uint8_t *) buffer, buflen);
|
| 165 | p.setDataPosition(0);
|
| 166 | }
|
| 167 | return 0;
|
| 168 | }
|
| 169 | static char *strdupReadString(Parcel &p) {
|
ll | 04ae414 | 2022-01-27 05:54:38 +0000 | [diff] [blame] | 170 | size_t stringlen;
|
lh | 7b0674a | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 171 | const char16_t *s16;
|
| 172 | s16 = p.readString16Inplace(&stringlen);
|
ll | 04ae414 | 2022-01-27 05:54:38 +0000 | [diff] [blame] | 173 | return strndup16to8(s16, stringlen);
|
lh | 7b0674a | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 174 | }
|
| 175 |
|
| 176 | int lynq_get_current_call_list(lynq_call_list_t call_list[LYNQ_CALL_MAX])
|
| 177 | {
|
| 178 | Parcel p;
|
| 179 | lynq_client_t client;
|
| 180 | int resp_type = -1;
|
| 181 | int request = -1;
|
| 182 | int slot_id = -1;
|
| 183 | int error = -1;
|
| 184 | int call_num = 0;
|
| 185 | int temp = 0;
|
| 186 | char *remote_phoneNum = NULL;
|
| 187 | char *remote_name= NULL;
|
| 188 | char *uusData = NULL;
|
lh | 42c1e57 | 2022-01-25 18:47:39 -0800 | [diff] [blame] | 189 | client.uToken = Global_uToken_call;
|
lh | 7b0674a | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 190 | client.request = 9;//RIL_REQUEST_GET_CURRENT_CALLS
|
| 191 | client.paramLen = 0;
|
| 192 | bzero(client.param,LYNQ_REQUEST_PARAM_BUF);
|
| 193 | LYDBGLOG("uToken=%d,request=%d,paralen=%d,param=%s\n",client.uToken,client.request,client.paramLen,client.param);
|
lh | 42c1e57 | 2022-01-25 18:47:39 -0800 | [diff] [blame] | 194 | if(send_request(lynq_call_client_sockfd,&client)==-1)
|
lh | 7b0674a | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 195 | {
|
| 196 | LYERRLOG("send request fail");
|
lh | 7b0674a | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 197 | return -1;
|
| 198 | }
|
lh | 42c1e57 | 2022-01-25 18:47:39 -0800 | [diff] [blame] | 199 | get_response(lynq_call_client_sockfd,p);
|
lh | 7b0674a | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 200 | JumpHeader(p,&resp_type,&request,&slot_id,&error);
|
| 201 | LYINFLOG("resp_type=%d,request=%d,slot_id=%d,error_code=%d",resp_type,request,slot_id,error);
|
| 202 | if(error == 0)
|
| 203 | {
|
| 204 | p.readInt32(&call_num);
|
| 205 | global_call_count = call_num;
|
| 206 | if(call_num<=0)
|
| 207 | {
|
| 208 | lynq_call_state = CALL_OFF;
|
lh | ec17b0a | 2022-02-13 23:56:05 -0800 | [diff] [blame] | 209 | LYINFLOG("lynq_call_state:%d",lynq_call_state);
|
lh | 7b0674a | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 210 | return 0;
|
| 211 | }
|
lh | ec17b0a | 2022-02-13 23:56:05 -0800 | [diff] [blame] | 212 | lynq_call_state = CALL_ON;
|
| 213 | LYINFLOG("lynq_call_state:%d",lynq_call_state);
|
lh | 7b0674a | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 214 | for(int i = 0;i < call_num;i++)
|
| 215 | {
|
| 216 | p.readInt32(&temp);
|
| 217 | call_list[i].call_state = temp;
|
| 218 | p.readInt32(&call_list[i].call_id);
|
| 219 | p.readInt32(&call_list[i].toa);
|
| 220 | p.readInt32(&temp);
|
| 221 | p.readInt32(&temp);
|
| 222 | call_list[i].direction = temp;
|
| 223 | p.readInt32(&temp);
|
| 224 | p.readInt32(&temp);
|
| 225 | p.readInt32(&temp);
|
| 226 | remote_phoneNum = strdupReadString(p);
|
| 227 | memcpy(call_list[i].addr,remote_phoneNum,strlen(remote_phoneNum));
|
| 228 | LYINFLOG("call_id=%d,call_state=%d,direction=%d,addr=%s,toa=%d",call_list[i].call_id,call_list[i].call_state,
|
| 229 | call_list[i].direction,call_list[i].addr,call_list[i].toa);
|
| 230 | p.readInt32(&temp);
|
| 231 | remote_name = strdupReadString(p);
|
| 232 | p.readInt32(&temp);
|
| 233 | p.readInt32(&temp);
|
| 234 | if(temp==0)
|
| 235 | {
|
| 236 | continue;
|
| 237 | }
|
| 238 | p.readInt32(&temp); /* UUS Information is present */
|
| 239 | p.readInt32(&temp);
|
| 240 | p.readInt32(&temp);
|
| 241 | p.read(uusData,temp);
|
| 242 | }
|
| 243 | }
|
| 244 | return 0;
|
| 245 | }
|
| 246 |
|
| 247 | void cleanCallList(int lynq_call_id)
|
| 248 | {
|
| 249 | lynq_call_lists[lynq_call_id].call_id = 0;
|
| 250 | lynq_call_lists[lynq_call_id].call_state = 0;
|
| 251 | lynq_call_lists[lynq_call_id].toa = 0;
|
| 252 | lynq_call_lists[lynq_call_id].direction = 0;
|
| 253 | lynq_call_lists[lynq_call_id].used = 0;
|
| 254 | lynq_call_lists[lynq_call_id].hasTimeout = 0;
|
| 255 | memset(lynq_call_lists[lynq_call_id].addr,0,sizeof(lynq_call_lists[lynq_call_id].addr));
|
| 256 | }
|
| 257 | int getUnusedElement()
|
| 258 | {
|
| 259 | for(int i=0;i < LYNQ_CALL_MAX; i++)
|
| 260 | {
|
| 261 | if(lynq_call_lists[i].used!=1)
|
| 262 | {
|
| 263 | return i;
|
| 264 | }
|
| 265 | }
|
| 266 | return -1;
|
| 267 | }
|
| 268 | int updateAddr(char addr[])
|
| 269 | {
|
| 270 | int ret = 0;
|
| 271 | ret = getUnusedElement();
|
| 272 | memcpy(lynq_call_lists[ret].addr,addr,strlen(addr)+1);
|
| 273 | lynq_call_lists[ret].used = 1;
|
| 274 | return ret;
|
| 275 | }
|
| 276 | void updateCallList(lynq_call_list_e_t *callList, int call_id,int call_state,int toa,int direction)
|
| 277 | {
|
| 278 | callList->call_id = call_id;
|
| 279 | callList->call_state = call_state;
|
| 280 | callList->toa = toa;
|
| 281 | callList->direction = direction;
|
| 282 | callList->used = 1;
|
| 283 | callList->hasTimeout = 0;
|
| 284 | return;
|
| 285 | }
|
| 286 | int waitCallstateChange(int mtime)
|
| 287 | {
|
| 288 | int ret = 0;
|
| 289 | int sec = 0;
|
| 290 | int usec = 0;
|
lh | 2afc773 | 2022-01-10 02:24:31 -0800 | [diff] [blame] | 291 | struct timeval now;
|
| 292 | struct timespec timeout;
|
| 293 | gettimeofday(&now,NULL);
|
lh | 7b0674a | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 294 | sec = mtime/1000;
|
| 295 | usec = mtime%1000;
|
lh | 2afc773 | 2022-01-10 02:24:31 -0800 | [diff] [blame] | 296 | timeout.tv_sec = now.tv_sec+sec;
|
| 297 | timeout.tv_nsec = now.tv_usec*1000+usec*1000000;
|
lh | 7b0674a | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 298 | pthread_mutex_lock(&call_state_change_mutex);
|
lh | 2afc773 | 2022-01-10 02:24:31 -0800 | [diff] [blame] | 299 | ret = pthread_cond_timedwait(&call_state_change_cond,&call_state_change_mutex,&timeout);
|
lh | 7b0674a | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 300 | pthread_mutex_unlock(&call_state_change_mutex);
|
| 301 | return ret;
|
| 302 | }
|
| 303 | int waitIncomingCall()
|
| 304 | {
|
| 305 | int ret = 0;
|
| 306 | pthread_mutex_lock(&s_incoming_call_mutex);
|
| 307 | ret = pthread_cond_wait(&s_incoming_call_cond,&s_incoming_call_mutex);
|
| 308 | pthread_mutex_unlock(&s_incoming_call_mutex);
|
| 309 | return ret;
|
| 310 | }
|
| 311 | int checkHasCall(char addr[])
|
| 312 | {
|
| 313 | for(int i = 0;i<LYNQ_CALL_MAX;i++)
|
| 314 | {
|
| 315 | if(strcmp(lynq_call_lists[i].addr,addr)==0)
|
| 316 | {
|
| 317 | return 1;
|
| 318 | }
|
| 319 | }
|
| 320 | return 0;
|
| 321 | }
|
| 322 | void sendSignalToWaitCallStateChange()
|
| 323 | {
|
| 324 | pthread_mutex_lock(&call_state_change_mutex);
|
| 325 | pthread_cond_signal(&call_state_change_cond);
|
| 326 | pthread_mutex_unlock(&call_state_change_mutex);
|
| 327 | }
|
| 328 | void sendSignalIncomingCall()
|
| 329 | {
|
| 330 | pthread_mutex_lock(&s_incoming_call_mutex);
|
| 331 | pthread_cond_signal(&s_incoming_call_cond);
|
| 332 | pthread_mutex_unlock(&s_incoming_call_mutex);
|
| 333 | }
|
| 334 |
|
| 335 | void addCallListToLynqCallList(lynq_call_list_e_t *callList, int call_id,int call_state,int toa,int direction,char addr[LYNQ_PHONE_NUMBER_MAX])
|
| 336 | {
|
| 337 | callList->call_id = call_id;
|
| 338 | callList->call_state = call_state;
|
| 339 | callList->toa = toa;
|
| 340 | callList->direction = direction;
|
| 341 | memcpy(callList->addr,addr,strlen(addr)+1);
|
| 342 | callList->used = 1;
|
| 343 | callList->hasTimeout = 0;
|
| 344 | return;
|
| 345 | }
|
| 346 |
|
| 347 | void *triggerGetCallList(void *parg)
|
ll | 04ae414 | 2022-01-27 05:54:38 +0000 | [diff] [blame] | 348 | {
|
| 349 | int ret=0;
|
| 350 | lynq_call_list_t call_list[LYNQ_CALL_MAX];
|
lh | 7b0674a | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 351 | while(call_list_loop)
|
ll | 04ae414 | 2022-01-27 05:54:38 +0000 | [diff] [blame] | 352 | {
|
| 353 | pthread_mutex_lock(&s_urc_call_state_change_mutex);
|
| 354 | pthread_cond_wait(&s_urc_call_state_change_cond, &s_urc_call_state_change_mutex);
|
lh | 7b0674a | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 355 | LYDBGLOG("triggerGetCallList event!!!\n");
|
ll | 04ae414 | 2022-01-27 05:54:38 +0000 | [diff] [blame] | 356 | memset(call_list,0,sizeof(call_list));
|
| 357 | ret = lynq_get_current_call_list(call_list);
|
| 358 | if(ret != 0)
|
| 359 | {
|
| 360 | printf("get current call list failure!!!\n");
|
| 361 | break;
|
| 362 | }
|
lh | 7b0674a | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 363 | for(int i = 0;i < LYNQ_CALL_MAX;i++)
|
| 364 | {
|
| 365 | if(call_list[i].direction == 1)//MT call
|
| 366 | {
|
| 367 | if(call_list[i].call_state ==4)//LYNQ_CALL_INCOMING = 4, /* MT call only */
|
| 368 | {
|
ll | 72bf6c1 | 2022-03-24 10:22:25 +0800 | [diff] [blame] | 369 | /*you call me, and i call you,One party failed to dial*/
|
lh | 7b0674a | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 370 | if(!checkHasCall(call_list[i].addr))
|
| 371 | {
|
| 372 | lynqIncomingCallId = getUnusedElement();
|
| 373 | addCallListToLynqCallList(&lynq_call_lists[lynqIncomingCallId],call_list[i].call_id,call_list[i].call_state,call_list[i].toa,call_list[i].direction,call_list[i].addr);
|
| 374 | sendSignalIncomingCall();
|
| 375 | }
|
| 376 | }
|
ll | 72bf6c1 | 2022-03-24 10:22:25 +0800 | [diff] [blame] | 377 | /*if state changed*/
|
| 378 | else
|
| 379 | {
|
| 380 | /*update call state*/
|
| 381 | for(int n = 0 ; n < LYNQ_CALL_MAX; n++)
|
| 382 | {
|
| 383 | if(strcmp(call_list[i].addr,lynq_call_lists[n].addr)==0)
|
| 384 | {
|
| 385 | updateCallList(&lynq_call_lists[n],call_list[i].call_id,call_list[i].call_state,call_list[i].toa,call_list[i].direction);
|
ll | 90a255c | 2022-04-07 09:09:55 +0000 | [diff] [blame] | 386 | break;
|
ll | 72bf6c1 | 2022-03-24 10:22:25 +0800 | [diff] [blame] | 387 | }
|
| 388 | }
|
| 389 | }
|
lh | 7b0674a | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 390 | }
|
| 391 | else
|
| 392 | {
|
| 393 | if(call_list[i].call_id==0)
|
| 394 | {
|
| 395 | break;
|
| 396 | }
|
| 397 | for(int n = 0 ; n < LYNQ_CALL_MAX; n++)
|
| 398 | {
|
| 399 | if(lynq_call_lists[n].hasTimeout==1)
|
| 400 | {
|
| 401 | /*hangup call with id*/
|
| 402 | lynq_call_hungup(&n);
|
| 403 | lynq_call_lists[n].hasTimeout==0;
|
| 404 | continue;
|
| 405 | }
|
| 406 | if(strcmp(call_list[i].addr,lynq_call_lists[n].addr)==0)
|
| 407 | {
|
| 408 | updateCallList(&lynq_call_lists[n],call_list[i].call_id,call_list[i].call_state,call_list[i].toa,call_list[i].direction);
|
| 409 | }
|
| 410 | }
|
| 411 | LYDBGLOG("[count:%d]call_id=%d,call_state=%d,direction=%d,addr=%s,toa=%d",i,call_list[i].call_id,call_list[i].call_state,
|
| 412 | call_list[i].direction,call_list[i].addr,call_list[i].toa);
|
| 413 | }
|
ll | 04ae414 | 2022-01-27 05:54:38 +0000 | [diff] [blame] | 414 | }
|
lh | 42c1e57 | 2022-01-25 18:47:39 -0800 | [diff] [blame] | 415 | s_call_urc_event_complete = 1;
|
lh | 7b0674a | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 416 | if(isDial==1)
|
| 417 | {
|
| 418 | sendSignalToWaitCallStateChange();
|
| 419 | isDial = 0;
|
| 420 | }
|
ll | 04ae414 | 2022-01-27 05:54:38 +0000 | [diff] [blame] | 421 | pthread_mutex_unlock(&s_urc_call_state_change_mutex);
|
| 422 | }
|
| 423 | return NULL;
|
lh | 7b0674a | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 424 | }
|
| 425 |
|
| 426 | void lynqRespWatingEvent()
|
ll | 04ae414 | 2022-01-27 05:54:38 +0000 | [diff] [blame] | 427 | {
|
| 428 | if(s_call_urc_event_complete==1)
|
| 429 | {
|
| 430 | pthread_mutex_lock(&s_urc_call_state_change_mutex);
|
| 431 | pthread_cond_signal(&s_urc_call_state_change_cond);
|
| 432 | s_call_urc_event_complete = 0;
|
| 433 | pthread_mutex_unlock(&s_urc_call_state_change_mutex);
|
lh | 7b0674a | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 434 | }
|
ll | 04ae414 | 2022-01-27 05:54:38 +0000 | [diff] [blame] | 435 | return;
|
lh | 7b0674a | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 436 | }
|
| 437 |
|
| 438 | /*Warren add for T800 platform 2021/11/19 start*/
|
| 439 | int lynq_socket_client_start()
|
rjw | 5d2a50e | 2022-02-28 15:01:49 +0800 | [diff] [blame] | 440 | {
|
| 441 | #if 0
|
lh | 7b0674a | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 442 | struct sockaddr_in lynq_socket_server_addr;
|
| 443 | /* init lynq_socket_server_addr */
|
| 444 | bzero(&lynq_socket_server_addr, sizeof(lynq_socket_server_addr));
|
| 445 | lynq_socket_server_addr.sin_family = AF_INET;
|
| 446 | lynq_socket_server_addr.sin_port = htons(LYNQ_SERVICE_PORT);
|
| 447 | lynq_socket_server_addr.sin_addr.s_addr = htons(INADDR_ANY);
|
rjw | 5d2a50e | 2022-02-28 15:01:49 +0800 | [diff] [blame] | 448 |
|
lh | 7b0674a | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 449 | /*
|
| 450 | if(inet_pton(AF_INET,"127.0.0.1", &lynq_socket_server_addr.sin_addr) <= 0)
|
| 451 | {
|
| 452 | printf("[%s] is not a valid IPaddress\n", argv[1]);
|
| 453 | exit(1);
|
| 454 | }
|
| 455 | */
|
lh | 42c1e57 | 2022-01-25 18:47:39 -0800 | [diff] [blame] | 456 | lynq_call_client_sockfd = socket(AF_INET, SOCK_DGRAM, 0);
|
| 457 | if(connect(lynq_call_client_sockfd, (struct sockaddr *)&lynq_socket_server_addr, sizeof(lynq_socket_server_addr)) == -1)
|
lh | 7b0674a | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 458 | {
|
ll | 3fe0346 | 2022-03-01 09:18:53 +0000 | [diff] [blame] | 459 | LYERRLOG("connect error\n");
|
lh | 7b0674a | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 460 | return -1;
|
| 461 | }
|
rjw | 5d2a50e | 2022-02-28 15:01:49 +0800 | [diff] [blame] | 462 | #endif
|
| 463 | lynq_call_client_sockfd = socket(AF_INET, SOCK_DGRAM, 0);
|
| 464 | if (-1 == lynq_call_client_sockfd)
|
| 465 | {
|
| 466 | return lynq_call_client_sockfd;
|
| 467 | }
|
| 468 | /* 设置address */
|
| 469 | memset(&addr_serv, 0, sizeof(addr_serv));
|
| 470 | addr_serv.sin_family = AF_INET;
|
| 471 | addr_serv.sin_addr.s_addr = inet_addr(DSET_IP_ADDRESS);
|
| 472 | addr_serv.sin_port = htons(LYNQ_SERVICE_PORT);
|
| 473 | len_addr_serv = sizeof(addr_serv);
|
lh | 7b0674a | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 474 | return 0;
|
| 475 | }
|
| 476 | int lynq_update_call_list_loop()
|
| 477 | {
|
| 478 | int ret = 0;
|
lh | 7b0674a | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 479 | pthread_attr_t attr;
|
| 480 | pthread_attr_init(&attr);
|
| 481 | pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED);
|
lh | ec17b0a | 2022-02-13 23:56:05 -0800 | [diff] [blame] | 482 | ret = pthread_create(&lynq_call_list_loop_tid,&attr,triggerGetCallList,NULL);
|
lh | 7b0674a | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 483 | if(ret < 0)
|
| 484 | {
|
| 485 | LYERRLOG("lynq_update_call_list_loop fail!!!");
|
| 486 | return -1;
|
| 487 | }
|
| 488 | LYDBGLOG("lynq_update_call_list_loop success!!!\n");
|
| 489 | return 0;
|
| 490 |
|
| 491 | }
|
| 492 | void *thread_urc_recv(void *parg)
|
ll | 04ae414 | 2022-01-27 05:54:38 +0000 | [diff] [blame] | 493 | {
|
lh | 7b0674a | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 494 | int socket_fd = (int64_t)parg;
|
| 495 | int len=0;
|
| 496 | socklen_t addr_len=0;
|
| 497 | uint8_t *dataLength = NULL;
|
| 498 | char urc_data[LYNQ_REC_BUF];
|
| 499 | int slot_id = -1;
|
| 500 | int resp_type = -1;
|
| 501 | int urcid = -1;
|
| 502 | Parcel *p = NULL;
|
| 503 | struct sockaddr_in dest_addr;
|
| 504 | LYINFLOG("thread_urc_recv in running....\n");
|
lh | 42c1e57 | 2022-01-25 18:47:39 -0800 | [diff] [blame] | 505 | while(urc_call_recive_status)
|
lh | 7b0674a | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 506 | {
|
| 507 | bzero(urc_data,LYNQ_REC_BUF);
|
| 508 | //get data msg
|
| 509 | len = recvfrom(socket_fd,urc_data,LYNQ_REC_BUF,0,(struct sockaddr *)&dest_addr,&addr_len);
|
| 510 | if(len <= 0)
|
ll | 04ae414 | 2022-01-27 05:54:38 +0000 | [diff] [blame] | 511 | {
|
ll | 3fe0346 | 2022-03-01 09:18:53 +0000 | [diff] [blame] | 512 | LYERRLOG("thread_urc_recv step2 fail\n");
|
ll | 04ae414 | 2022-01-27 05:54:38 +0000 | [diff] [blame] | 513 | break;
|
lh | 7b0674a | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 514 | }
|
| 515 | LYDBGLOG("=====>urc data len<=====:%d\n",len);
|
| 516 | p = new Parcel();
|
| 517 | if(p==NULL)
|
| 518 | {
|
lh | 21502f5 | 2022-01-27 00:27:12 -0800 | [diff] [blame] | 519 | LYERRLOG("new parcel failure!!!");
|
lh | 7b0674a | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 520 | break;
|
| 521 | }
|
| 522 | p->setData((uint8_t *)urc_data,len); // p.setData((uint8_t *) buffer, buflen);
|
| 523 | p->setDataPosition(0);
|
| 524 | if(p->dataAvail() > 0)
|
| 525 | {
|
| 526 | p->readInt32(&resp_type);
|
| 527 | p->readInt32(&urcid);
|
| 528 | p->readInt32(&slot_id);
|
| 529 | //LYDBGLOG("*******Warren test*******:resp_type=%d,urcid=%d,slot_id=%d\n",resp_type,urcid,slot_id);
|
| 530 | switch (urcid)
|
| 531 | {
|
| 532 | case 1001://RIL_UNSOL_RESPONSE_CALL_STATE_CHANGED
|
| 533 | {
|
| 534 | LYINFLOG("**************:resp_type=%d,urcid=%d,slot_id=%d\n",resp_type,urcid,slot_id);
|
| 535 | lynqRespWatingEvent();
|
| 536 | break;
|
| 537 | }
|
| 538 | case 1018://RIL_UNSOL_CALL_RING
|
| 539 | {
|
| 540 | if(global_call_auto_answer==1)
|
| 541 | {
|
| 542 | lynq_call_answer();
|
| 543 | }
|
| 544 | break;
|
| 545 | }
|
| 546 | case 1029://RIL_UNSOL_RINGBACK_TONE
|
| 547 | case 3049://RIL_UNSOL_CALL_INFO_INDICATION
|
| 548 | {
|
| 549 | LYINFLOG("**************:resp_type=%d,urcid=%d,slot_id=%d\n",resp_type,urcid,slot_id);
|
| 550 | break;
|
| 551 | }
|
| 552 | default:
|
| 553 | break;
|
| 554 | }
|
| 555 | }
|
| 556 | delete p;
|
| 557 | p = NULL;
|
| 558 | }
|
| 559 | close(socket_fd);
|
| 560 | }
|
| 561 | int lynq_socket_urc_start()
|
| 562 | {
|
| 563 | int socket_fd=0;
|
| 564 | int rt=0;
|
| 565 | int len=0;
|
| 566 | int on=1;
|
| 567 | struct sockaddr_in urc_local_addr;
|
lh | 7b0674a | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 568 | pthread_attr_t attr;
|
ll | 04ae414 | 2022-01-27 05:54:38 +0000 | [diff] [blame] | 569 | socket_fd = socket(AF_INET,SOCK_DGRAM,0);
|
ll | 04ae414 | 2022-01-27 05:54:38 +0000 | [diff] [blame] | 570 | if(socket_fd < 0)
|
| 571 | {
|
ll | 3fe0346 | 2022-03-01 09:18:53 +0000 | [diff] [blame] | 572 | LYERRLOG("creaet socket for udp fail\n");
|
ll | 04ae414 | 2022-01-27 05:54:38 +0000 | [diff] [blame] | 573 | return -1;
|
lh | 7b0674a | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 574 | }
|
| 575 | urc_local_addr.sin_family = AF_INET;
|
| 576 | urc_local_addr.sin_port = htons(LYNQ_URC_SERVICE_PORT);
|
| 577 | urc_local_addr.sin_addr.s_addr = htons(INADDR_ANY);
|
| 578 | /* Set socket to allow reuse of address and port, SO_REUSEADDR value is 2*/
|
ll | 04ae414 | 2022-01-27 05:54:38 +0000 | [diff] [blame] | 579 | rt = setsockopt(socket_fd,SOL_SOCKET,SO_REUSEADDR,&on,sizeof on);
|
| 580 | if(rt<0)
|
| 581 | {
|
ll | 3fe0346 | 2022-03-01 09:18:53 +0000 | [diff] [blame] | 582 | LYERRLOG("SO_REUSEADDR fail\n");
|
lh | 7b0674a | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 583 | return -1;
|
| 584 | }
|
| 585 | rt = bind(socket_fd ,(struct sockaddr*)&urc_local_addr, sizeof(urc_local_addr));
|
ll | 04ae414 | 2022-01-27 05:54:38 +0000 | [diff] [blame] | 586 | if (rt == -1)
|
| 587 | {
|
lh | 21502f5 | 2022-01-27 00:27:12 -0800 | [diff] [blame] | 588 | LYERRLOG("bind failed");
|
ll | 04ae414 | 2022-01-27 05:54:38 +0000 | [diff] [blame] | 589 | return -1;
|
lh | 7b0674a | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 590 | }
|
| 591 | pthread_attr_init(&attr);
|
| 592 | pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED);
|
lh | ec17b0a | 2022-02-13 23:56:05 -0800 | [diff] [blame] | 593 | rt = pthread_create(&lynq_call_urc_tid,&attr,thread_urc_recv,(void *)socket_fd);
|
lh | 7b0674a | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 594 | if(rt < 0)
|
| 595 | {
|
lh | 21502f5 | 2022-01-27 00:27:12 -0800 | [diff] [blame] | 596 | LYERRLOG("urc loop failure!!!\n");
|
lh | 7b0674a | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 597 | return -1;
|
| 598 | }
|
lh | 21502f5 | 2022-01-27 00:27:12 -0800 | [diff] [blame] | 599 | LYDBGLOG("urc loop success!!!\n");
|
lh | 7b0674a | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 600 | return 0;
|
| 601 | }
|
| 602 | int getSelfElement(char addr[])
|
| 603 | {
|
| 604 | for(int i=0;i < LYNQ_CALL_MAX; i++)
|
| 605 | {
|
| 606 | if(lynq_call_lists[i].used==1)
|
| 607 | {
|
| 608 | if(strcmp(lynq_call_lists[i].addr,addr)==0)
|
| 609 | {
|
| 610 | return i;
|
| 611 | }
|
| 612 |
|
| 613 | }
|
| 614 | }
|
| 615 | return -1;
|
| 616 | }
|
| 617 |
|
| 618 | void lynq_call_state_change_test(int soc_id)
|
| 619 | {
|
| 620 | printf("call state change,sim:%d\n",soc_id);
|
| 621 | }
|
| 622 | int lynq_init_call(int uToken)
|
ll | a8c25a8 | 2022-03-17 05:31:33 +0000 | [diff] [blame] | 623 | {
|
| 624 | if(g_lynq_call_init_flag == 1){
|
| 625 | LYDBGLOG("lynq init call failed!!!");
|
| 626 | return -1;
|
| 627 | }
|
| 628 | g_lynq_call_init_flag = 1;
|
lh | 7b0674a | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 629 | int result = 0;
|
lh | 42c1e57 | 2022-01-25 18:47:39 -0800 | [diff] [blame] | 630 | Global_uToken_call = uToken;
|
lh | 21502f5 | 2022-01-27 00:27:12 -0800 | [diff] [blame] | 631 | urc_call_recive_status = 1;
|
rjw | 5d2a50e | 2022-02-28 15:01:49 +0800 | [diff] [blame] | 632 | client_size = sizeof(client_t);
|
lh | 7b0674a | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 633 | LYLOGSET(LOG_INFO);
|
| 634 | LYLOGEINIT(USER_LOG_TAG);
|
| 635 | result = lynq_socket_client_start();
|
| 636 | if(result!=0)
|
| 637 | {
|
| 638 | return -1;
|
| 639 | }
|
| 640 | result = lynq_socket_urc_start();
|
| 641 | if(result!=0)
|
| 642 | {
|
| 643 | return -1;
|
| 644 | }
|
| 645 | result = lynq_update_call_list_loop();
|
| 646 | if(result!=0)
|
| 647 | {
|
| 648 | return -1;
|
| 649 | }
|
| 650 | memset(lynq_call_lists,0,sizeof(lynq_call_lists));
|
| 651 | LYDBGLOG("lynq init call success!!!");
|
| 652 | return 0;
|
| 653 | }
|
| 654 | int lynq_deinit_call()
|
| 655 | {
|
ll | a8c25a8 | 2022-03-17 05:31:33 +0000 | [diff] [blame] | 656 | if(g_lynq_call_init_flag == 0)
|
lh | ec17b0a | 2022-02-13 23:56:05 -0800 | [diff] [blame] | 657 | {
|
ll | a8c25a8 | 2022-03-17 05:31:33 +0000 | [diff] [blame] | 658 | LYDBGLOG("lynq_deinit_call failed!!!");
|
| 659 | return -1;
|
lh | ec17b0a | 2022-02-13 23:56:05 -0800 | [diff] [blame] | 660 | }
|
ll | a8c25a8 | 2022-03-17 05:31:33 +0000 | [diff] [blame] | 661 | else
|
| 662 | {
|
| 663 | g_lynq_call_init_flag = 0;
|
| 664 | int ret = -1;
|
| 665 | if(lynq_call_client_sockfd>0)
|
| 666 | {
|
| 667 | close(lynq_call_client_sockfd);
|
| 668 | }
|
| 669 | urc_call_recive_status = 0;
|
| 670 | call_list_loop = 0;
|
| 671 | if(lynq_call_urc_tid == -1 || lynq_call_list_loop_tid == -1)
|
| 672 | {
|
| 673 | return -1;
|
| 674 | }
|
| 675 | ret = pthread_cancel(lynq_call_urc_tid);
|
| 676 | LYDBGLOG("pthread cancel ret = %d",ret);
|
| 677 | ret = pthread_cancel(lynq_call_list_loop_tid);
|
| 678 | LYDBGLOG("pthread cancel ret = %d",ret);
|
| 679 | ret = pthread_join(lynq_call_urc_tid,NULL);
|
| 680 | LYDBGLOG("pthread join ret = %d",ret);
|
| 681 | ret = pthread_join(lynq_call_list_loop_tid,NULL);
|
| 682 | LYDBGLOG("pthread join ret = %d",ret);
|
| 683 | return 0;
|
| 684 | }
|
rita | 98e2e9c | 2022-04-07 06:08:13 -0400 | [diff] [blame^] | 685 | }
|
rita | 089527e | 2022-04-07 01:55:39 -0400 | [diff] [blame] | 686 | #ifdef ECALL_SUPPORT
|
| 687 | int lynq_fast_ecall(int* handle, int ecall_cat, int ecall_variant, char *addr, unsigned char *msd_data)
|
| 688 | {
|
| 689 | Parcel p;
|
| 690 | lynq_client_t client;
|
| 691 | int resp_type = -1;
|
| 692 | int request = -1;
|
| 693 | int slot_id = -1;
|
| 694 | int error = -1;
|
| 695 | int lynq_call_id = -1;
|
| 696 |
|
| 697 | if(addr==NULL)
|
| 698 | {
|
| 699 | LYERRLOG("Phone num is null!!!");
|
| 700 | return -1;
|
| 701 | }
|
| 702 | client.uToken = Global_uToken_call;
|
| 703 | client.request = 9010;
|
| 704 | client.paramLen = 5;
|
| 705 | bzero(client.param,LYNQ_REQUEST_PARAM_BUF);
|
| 706 | sprintf(client.param,"%d %d %s %s", ecall_cat, ecall_variant, addr, msd_data);
|
| 707 | printf("[%s-%d] uToken=%d, request=%d, paralen=%d, param=%s\n", __FUNCTION__, __LINE__, client.uToken, client.request, client.paramLen, client.param);
|
| 708 |
|
| 709 | if(send_request(lynq_call_client_sockfd, &client)==-1)
|
| 710 | {
|
| 711 | LYERRLOG("send request fail");
|
| 712 | return -1;
|
| 713 | }
|
| 714 |
|
| 715 | get_response(lynq_call_client_sockfd, p);
|
| 716 | JumpHeader(p,&resp_type,&request,&slot_id,&error);
|
| 717 | printf("[%s-%d] resp_type=%d,request=%d,slot_id=%d,error_code=%d", __FUNCTION__, __LINE__, resp_type, request, slot_id, error);
|
| 718 |
|
| 719 | lynq_call_id = updateAddr(addr);
|
| 720 | if(error==0)
|
| 721 | {
|
| 722 | isDial = 1;
|
| 723 | if(waitCallstateChange(3000)==ETIMEDOUT)//3000ms
|
| 724 | {
|
| 725 | error = LYNQ_E_TIME_OUT;
|
| 726 | LYERRLOG("timeout:wait Call state fail!!!");
|
| 727 | lynq_call_lists[lynq_call_id].hasTimeout = 1;
|
| 728 | return error;
|
| 729 | }
|
| 730 |
|
| 731 | *handle = lynq_call_id;
|
| 732 | }
|
| 733 |
|
| 734 | return error;
|
lh | 7b0674a | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 735 | }
|
rita | 089527e | 2022-04-07 01:55:39 -0400 | [diff] [blame] | 736 |
|
| 737 | int lynq_set_psap(int enable)
|
| 738 | {
|
| 739 | Parcel p;
|
| 740 | lynq_client_t client;
|
| 741 | int resp_type = -1;
|
| 742 | int request = -1;
|
| 743 | int slot_id = -1;
|
| 744 | int error = -1;
|
| 745 |
|
| 746 |
|
| 747 | client.uToken = Global_uToken_call;
|
| 748 | client.request = 9005;
|
| 749 | client.paramLen = 2;
|
| 750 | bzero(client.param,LYNQ_REQUEST_PARAM_BUF);
|
| 751 | sprintf(client.param, "%d", enable);
|
| 752 | printf("[%s-%d] uToken=%d, request=%d, paralen=%d, param=%s\n", __FUNCTION__, __LINE__, client.uToken, client.request, client.paramLen, client.param);
|
| 753 |
|
| 754 | if(send_request(lynq_call_client_sockfd,&client)==-1)
|
| 755 | {
|
| 756 | LYERRLOG("send request fail");
|
| 757 | return -1;
|
| 758 | }
|
| 759 |
|
| 760 | get_response(lynq_call_client_sockfd,p);
|
| 761 | JumpHeader(p,&resp_type,&request,&slot_id,&error);
|
| 762 | printf("[%s-%d] resp_type=%d,request=%d,slot_id=%d,error_code=%d", __FUNCTION__, __LINE__, resp_type, request, slot_id, error);
|
| 763 |
|
| 764 | return error;
|
| 765 | }
|
| 766 |
|
| 767 |
|
| 768 | int lynq_psap_pull_msd()
|
| 769 | {
|
| 770 | Parcel p;
|
| 771 | lynq_client_t client;
|
| 772 | int resp_type = -1;
|
| 773 | int request = -1;
|
| 774 | int slot_id = -1;
|
| 775 | int error = -1;
|
| 776 | int lynq_call_id = -1;
|
| 777 |
|
| 778 |
|
| 779 | client.uToken = Global_uToken_call;
|
| 780 | client.request = 9008;
|
| 781 | client.paramLen = 1;
|
| 782 | bzero(client.param,LYNQ_REQUEST_PARAM_BUF);
|
| 783 | printf("[%s-%d] uToken=%d, request=%d, paralen=%d, param=%s\n", __FUNCTION__, __LINE__, client.uToken, client.request, client.paramLen, client.param);
|
| 784 |
|
| 785 | if(send_request(lynq_call_client_sockfd,&client)==-1)
|
| 786 | {
|
| 787 | LYERRLOG("send request fail");
|
| 788 | return -1;
|
| 789 | }
|
| 790 |
|
| 791 | get_response(lynq_call_client_sockfd,p);
|
| 792 | JumpHeader(p,&resp_type,&request,&slot_id,&error);
|
| 793 | printf("[%s-%d] resp_type=%d,request=%d,slot_id=%d,error_code=%d", __FUNCTION__, __LINE__, resp_type, request, slot_id, error);
|
| 794 |
|
| 795 | return error;
|
| 796 | }
|
| 797 | int lynq_make_ecall(int* handle, int type)
|
| 798 | {
|
| 799 | Parcel p;
|
| 800 | lynq_client_t client;
|
| 801 | int resp_type = -1;
|
| 802 | int request = -1;
|
| 803 | int slot_id = -1;
|
| 804 | int error = -1;
|
| 805 | int lynq_call_id = -1;
|
| 806 |
|
| 807 |
|
| 808 | client.uToken = Global_uToken_call;
|
| 809 | client.request = 9006;
|
| 810 | client.paramLen = 2;
|
| 811 | bzero(client.param,LYNQ_REQUEST_PARAM_BUF);
|
| 812 | sprintf(client.param, "%d", type);
|
| 813 | printf("[%s-%d] uToken=%d, request=%d, paralen=%d, param=%s\n", __FUNCTION__, __LINE__, client.uToken, client.request, client.paramLen, client.param);
|
| 814 |
|
| 815 | if(send_request(lynq_call_client_sockfd,&client)==-1)
|
| 816 | {
|
| 817 | LYERRLOG("send request fail");
|
| 818 | return -1;
|
| 819 | }
|
| 820 |
|
| 821 | get_response(lynq_call_client_sockfd,p);
|
| 822 | JumpHeader(p,&resp_type,&request,&slot_id,&error);
|
| 823 | printf("[%s-%d] resp_type=%d,request=%d,slot_id=%d,error_code=%d", __FUNCTION__, __LINE__, resp_type, request, slot_id, error);
|
| 824 |
|
| 825 | return error;
|
| 826 | }
|
| 827 |
|
| 828 |
|
| 829 | int lynq_set_msd(int call_id, char *msd_data)
|
| 830 | {
|
| 831 | Parcel p;
|
| 832 | lynq_client_t client;
|
| 833 | int resp_type = -1;
|
| 834 | int request = -1;
|
| 835 | int slot_id = -1;
|
| 836 | int error = -1;
|
| 837 | int lynq_call_id = -1;
|
| 838 |
|
| 839 |
|
| 840 | client.uToken = Global_uToken_call;
|
| 841 | client.request = 9004;
|
| 842 | client.paramLen = 3;
|
| 843 | bzero(client.param,LYNQ_REQUEST_PARAM_BUF);
|
| 844 | sprintf(client.param, "%d %s", call_id, msd_data);
|
| 845 | printf("[%s-%d] uToken=%d, request=%d, paralen=%d, param=%s\n", __FUNCTION__, __LINE__, client.uToken, client.request, client.paramLen, client.param);
|
| 846 |
|
| 847 | if(send_request(lynq_call_client_sockfd,&client)==-1)
|
| 848 | {
|
| 849 | LYERRLOG("send request fail");
|
| 850 | return -1;
|
| 851 | }
|
| 852 |
|
| 853 | get_response(lynq_call_client_sockfd,p);
|
| 854 | JumpHeader(p,&resp_type,&request,&slot_id,&error);
|
| 855 | printf("[%s-%d] resp_type=%d,request=%d,slot_id=%d,error_code=%d", __FUNCTION__, __LINE__, resp_type, request, slot_id, error);
|
| 856 |
|
| 857 | return error;
|
| 858 | }
|
| 859 |
|
| 860 | int lynq_set_ivs(int enable)
|
| 861 | {
|
| 862 | Parcel p;
|
| 863 | lynq_client_t client;
|
| 864 | int resp_type = -1;
|
| 865 | int request = -1;
|
| 866 | int slot_id = -1;
|
| 867 | int error = -1;
|
| 868 | int lynq_call_id = -1;
|
| 869 |
|
| 870 |
|
| 871 | client.uToken = Global_uToken_call;
|
| 872 | client.request = 9004;
|
| 873 | client.paramLen = 2;
|
| 874 | bzero(client.param,LYNQ_REQUEST_PARAM_BUF);
|
| 875 | sprintf(client.param, "%d", enable);
|
| 876 | printf("[%s-%d] uToken=%d, request=%d, paralen=%d, param=%s\n", __FUNCTION__, __LINE__, client.uToken, client.request, client.paramLen, client.param);
|
| 877 |
|
| 878 | if(send_request(lynq_call_client_sockfd,&client)==-1)
|
| 879 | {
|
| 880 | LYERRLOG("send request fail");
|
| 881 | return -1;
|
| 882 | }
|
| 883 |
|
| 884 | get_response(lynq_call_client_sockfd,p);
|
| 885 | JumpHeader(p,&resp_type,&request,&slot_id,&error);
|
| 886 | printf("[%s-%d] resp_type=%d,request=%d,slot_id=%d,error_code=%d", __FUNCTION__, __LINE__, resp_type, request, slot_id, error);
|
| 887 |
|
| 888 | return error;
|
| 889 | }
|
| 890 |
|
| 891 | int lynq_reset_ivs()
|
| 892 | {
|
| 893 | Parcel p;
|
| 894 | lynq_client_t client;
|
| 895 | int resp_type = -1;
|
| 896 | int request = -1;
|
| 897 | int slot_id = -1;
|
| 898 | int error = -1;
|
| 899 | int lynq_call_id = -1;
|
| 900 |
|
| 901 |
|
| 902 | client.uToken = Global_uToken_call;
|
| 903 | client.request = 9012;
|
| 904 | client.paramLen = 1;
|
| 905 | bzero(client.param,LYNQ_REQUEST_PARAM_BUF);
|
| 906 | printf("[%s-%d] uToken=%d, request=%d, paralen=%d, param=%s\n", __FUNCTION__, __LINE__, client.uToken, client.request, client.paramLen, client.param);
|
| 907 |
|
| 908 | if(send_request(lynq_call_client_sockfd,&client)==-1)
|
| 909 | {
|
| 910 | LYERRLOG("send request fail");
|
| 911 | return -1;
|
| 912 | }
|
| 913 |
|
| 914 | get_response(lynq_call_client_sockfd,p);
|
| 915 | JumpHeader(p,&resp_type,&request,&slot_id,&error);
|
| 916 | printf("[%s-%d] resp_type=%d,request=%d,slot_id=%d,error_code=%d", __FUNCTION__, __LINE__, resp_type, request, slot_id, error);
|
| 917 |
|
| 918 | return error;
|
| 919 | }
|
| 920 |
|
| 921 | int lynq_ivs_push_msd()
|
| 922 | {
|
| 923 | Parcel p;
|
| 924 | lynq_client_t client;
|
| 925 | int resp_type = -1;
|
| 926 | int request = -1;
|
| 927 | int slot_id = -1;
|
| 928 | int error = -1;
|
| 929 | int lynq_call_id = -1;
|
| 930 |
|
| 931 |
|
| 932 | client.uToken = Global_uToken_call;
|
| 933 | client.request = 9007;
|
| 934 | client.paramLen = 1;
|
| 935 | bzero(client.param,LYNQ_REQUEST_PARAM_BUF);
|
| 936 | // sprintf(client.param, "%d", enable);
|
| 937 | printf("[%s-%d] uToken=%d, request=%d, paralen=%d, param=%s\n", __FUNCTION__, __LINE__, client.uToken, client.request, client.paramLen, client.param);
|
| 938 |
|
| 939 | if(send_request(lynq_call_client_sockfd,&client)==-1)
|
| 940 | {
|
| 941 | LYERRLOG("send request fail");
|
| 942 | return -1;
|
| 943 | }
|
| 944 |
|
| 945 | get_response(lynq_call_client_sockfd,p);
|
| 946 | JumpHeader(p,&resp_type,&request,&slot_id,&error);
|
| 947 | printf("[%s-%d] resp_type=%d,request=%d,slot_id=%d,error_code=%d", __FUNCTION__, __LINE__, resp_type, request, slot_id, error);
|
| 948 |
|
| 949 | return error;
|
| 950 | }
|
| 951 | #endif
|
lh | 7b0674a | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 952 | int lynq_call(int* handle,char addr[])
|
| 953 | {
|
| 954 | Parcel p;
|
| 955 | lynq_client_t client;
|
| 956 | int resp_type = -1;
|
| 957 | int request = -1;
|
| 958 | int slot_id = -1;
|
| 959 | int error = -1;
|
| 960 | int lynq_call_id = -1;
|
| 961 | if(addr==NULL)
|
| 962 | {
|
| 963 | LYERRLOG("Phone num is null!!!");
|
| 964 | return -1;
|
| 965 | }
|
lh | 42c1e57 | 2022-01-25 18:47:39 -0800 | [diff] [blame] | 966 | client.uToken = Global_uToken_call;
|
lh | 7b0674a | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 967 | client.request = 10;//RIL_REQUEST_DIAL
|
| 968 | client.paramLen = 2;
|
| 969 | bzero(client.param,LYNQ_REQUEST_PARAM_BUF);
|
| 970 | memcpy(client.param,addr,strlen(addr)+1);
|
| 971 | strcat(client.param," 0");
|
| 972 | LYERRLOG("uToken=%d,request=%d,paralen=%d,param=%s",client.uToken,client.request,client.paramLen,client.param);
|
lh | 42c1e57 | 2022-01-25 18:47:39 -0800 | [diff] [blame] | 973 | if(send_request(lynq_call_client_sockfd,&client)==-1)
|
lh | 7b0674a | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 974 | {
|
| 975 | LYERRLOG("send request fail");
|
lh | 7b0674a | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 976 | return -1;
|
| 977 | }
|
lh | 42c1e57 | 2022-01-25 18:47:39 -0800 | [diff] [blame] | 978 | get_response(lynq_call_client_sockfd,p);
|
lh | 7b0674a | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 979 | JumpHeader(p,&resp_type,&request,&slot_id,&error);
|
| 980 | LYINFLOG("resp_type=%d,request=%d,slot_id=%d,error_code=%d",resp_type,request,slot_id,error);
|
| 981 | lynq_call_id = updateAddr(addr);
|
| 982 | if(error==0)
|
| 983 | {
|
| 984 | isDial = 1;
|
ll | 72bf6c1 | 2022-03-24 10:22:25 +0800 | [diff] [blame] | 985 | if(waitCallstateChange(6000)==ETIMEDOUT)//6000ms
|
lh | 7b0674a | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 986 | {
|
| 987 | error = LYNQ_E_TIME_OUT;
|
| 988 | LYERRLOG("timeout:wait Call state fail!!!");
|
| 989 | lynq_call_lists[lynq_call_id].hasTimeout = 1;
|
| 990 | return error;
|
| 991 | }
|
| 992 | *handle = lynq_call_id;
|
| 993 | }
|
| 994 | return error;
|
| 995 | }
|
| 996 | int lynq_call_answer()
|
| 997 | {
|
| 998 | Parcel p;
|
| 999 | lynq_client_t client;
|
| 1000 | int resp_type = -1;
|
| 1001 | int request = -1;
|
| 1002 | int slot_id = -1;
|
| 1003 | int error = -1;
|
lh | 42c1e57 | 2022-01-25 18:47:39 -0800 | [diff] [blame] | 1004 | client.uToken = Global_uToken_call;
|
lh | 7b0674a | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 1005 | client.request = 40;//RIL_REQUEST_DIAL
|
| 1006 | client.paramLen = 0;
|
| 1007 | bzero(client.param,LYNQ_REQUEST_PARAM_BUF);
|
| 1008 | LYDBGLOG("uToken=%d,request=%d,paralen=%d,param=%s\n",client.uToken,client.request,client.paramLen,client.param);
|
lh | 42c1e57 | 2022-01-25 18:47:39 -0800 | [diff] [blame] | 1009 | if(send_request(lynq_call_client_sockfd,&client)==-1)
|
lh | 7b0674a | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 1010 | {
|
| 1011 | LYERRLOG("send request fail");
|
lh | 7b0674a | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 1012 | return -1;
|
| 1013 | }
|
lh | 42c1e57 | 2022-01-25 18:47:39 -0800 | [diff] [blame] | 1014 | get_response(lynq_call_client_sockfd,p);
|
lh | 7b0674a | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 1015 | JumpHeader(p,&resp_type,&request,&slot_id,&error);
|
| 1016 | LYINFLOG("resp_type=%d,request=%d,slot_id=%d,error_code=%d",resp_type,request,slot_id,error);
|
| 1017 | return error;
|
| 1018 | }
|
| 1019 | int lynq_call_hungup(int* handle)
|
| 1020 | {
|
| 1021 | Parcel p;
|
| 1022 | lynq_client_t client;
|
| 1023 | int resp_type = -1;
|
| 1024 | int request = -1;
|
| 1025 | int slot_id = -1;
|
| 1026 | int error = -1;
|
| 1027 | int call_id = 0;
|
| 1028 | int lynq_call_id = 0;
|
lh | 42c1e57 | 2022-01-25 18:47:39 -0800 | [diff] [blame] | 1029 | if(handle==NULL||!((*handle>=0)&&(*handle<10)))
|
| 1030 | {
|
| 1031 | LYERRLOG("[%s] illegal input!!!!",__FUNCTION__);
|
| 1032 | return LYNQ_E_CONFLICT;
|
| 1033 | }
|
| 1034 | client.uToken = Global_uToken_call;
|
lh | 7b0674a | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 1035 | client.request = 12;//RIL_REQUEST_HUNGUP
|
| 1036 | client.paramLen = 1;
|
| 1037 | bzero(client.param,LYNQ_REQUEST_PARAM_BUF);
|
| 1038 | lynq_call_id = *handle;
|
| 1039 | call_id = lynq_call_lists[lynq_call_id].call_id;
|
| 1040 | sprintf(client.param,"%d",call_id);
|
| 1041 | LYDBGLOG("uToken=%d,request=%d,paralen=%d,param=%s\n",client.uToken,client.request,client.paramLen,client.param);
|
lh | 42c1e57 | 2022-01-25 18:47:39 -0800 | [diff] [blame] | 1042 | if(send_request(lynq_call_client_sockfd,&client)==-1)
|
lh | 7b0674a | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 1043 | {
|
| 1044 | LYERRLOG("send request fail");
|
lh | 7b0674a | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 1045 | return -1;
|
| 1046 | }
|
lh | 42c1e57 | 2022-01-25 18:47:39 -0800 | [diff] [blame] | 1047 | get_response(lynq_call_client_sockfd,p);
|
lh | 7b0674a | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 1048 | JumpHeader(p,&resp_type,&request,&slot_id,&error);
|
| 1049 | LYINFLOG("resp_type=%d,request=%d,slot_id=%d,error_code=%d",resp_type,request,slot_id,error);
|
| 1050 | if(error==0)
|
| 1051 | {
|
| 1052 | cleanCallList(lynq_call_id);
|
| 1053 | }
|
| 1054 | return error;
|
| 1055 | }
|
| 1056 | int lynq_call_hungup_all()
|
| 1057 | {
|
| 1058 | Parcel p;
|
| 1059 | lynq_client_t client;
|
| 1060 | int resp_type = -1;
|
| 1061 | int request = -1;
|
| 1062 | int slot_id = -1;
|
| 1063 | int error = -1;
|
lh | 42c1e57 | 2022-01-25 18:47:39 -0800 | [diff] [blame] | 1064 | client.uToken = Global_uToken_call;
|
lh | 7b0674a | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 1065 | client.request = 17;//RIL_REQUEST_UDUB
|
| 1066 | client.paramLen = 0;
|
| 1067 | bzero(client.param,LYNQ_REQUEST_PARAM_BUF);
|
| 1068 | LYDBGLOG("uToken=%d,request=%d,paralen=%d,param=%s\n",client.uToken,client.request,client.paramLen,client.param);
|
lh | 42c1e57 | 2022-01-25 18:47:39 -0800 | [diff] [blame] | 1069 | if(send_request(lynq_call_client_sockfd,&client)==-1)
|
lh | 7b0674a | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 1070 | {
|
| 1071 | LYERRLOG("send request fail");
|
lh | 7b0674a | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 1072 | return -1;
|
| 1073 | }
|
lh | 42c1e57 | 2022-01-25 18:47:39 -0800 | [diff] [blame] | 1074 | get_response(lynq_call_client_sockfd,p);
|
lh | 7b0674a | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 1075 | JumpHeader(p,&resp_type,&request,&slot_id,&error);
|
| 1076 | LYINFLOG("resp_type=%d,request=%d,slot_id=%d,error_code=%d",resp_type,request,slot_id,error);
|
| 1077 | return error;
|
| 1078 | }
|
| 1079 | int lynq_wait_incoming_call(int *handle)
|
| 1080 | {
|
| 1081 | waitIncomingCall();
|
| 1082 | *handle = lynqIncomingCallId;
|
| 1083 | LYINFLOG("lynq incoming call id:%d",lynqIncomingCallId);
|
| 1084 | return 0;
|
| 1085 | }
|
| 1086 |
|
| 1087 | int lynq_set_auto_answercall(const int mode)
|
| 1088 | {
|
| 1089 | global_call_auto_answer = mode;
|
| 1090 | LYINFLOG("auto answer call mode =%d",mode);
|
| 1091 | return 0;
|
| 1092 | }
|
q.huang | ec88da9 | 2022-03-29 04:17:32 -0400 | [diff] [blame] | 1093 | int lynq_get_current_call_state(int *handle, int *call_state,int *toa,int *direction,char addr[])
|
| 1094 | {
|
| 1095 | int lynq_call_id = 0;
|
| 1096 | if(handle==NULL)
|
| 1097 | {
|
| 1098 | return LYNQ_E_NULL_ANONALY;
|
| 1099 | }
|
| 1100 | lynq_call_id = *handle;
|
| 1101 | *call_state = lynq_call_lists[lynq_call_id].call_state;
|
| 1102 | *toa = lynq_call_lists[lynq_call_id].toa;
|
| 1103 | *direction = lynq_call_lists[lynq_call_id].direction;
|
| 1104 | memcpy(addr,lynq_call_lists[lynq_call_id].addr,strlen(lynq_call_lists[lynq_call_id].addr)+1);
|
| 1105 | return 0;
|
| 1106 | }
|
| 1107 |
|
| 1108 | /*audio begin*/
|
| 1109 | int lynq_set_common_request(int request_id, int argc, const char* format,...)
|
| 1110 | {
|
| 1111 | Parcel p;
|
| 1112 | lynq_client_t client;
|
| 1113 | int resp_type = -1;
|
| 1114 | int request = -1;
|
| 1115 | int slot_id = -1;
|
| 1116 | int error = -1;
|
| 1117 | //if(!lynq_call_state)
|
| 1118 | //{
|
| 1119 | // LYERRLOG("LYNQ_E_CONFLICT");
|
| 1120 | // return LYNQ_E_CONFLICT;
|
| 1121 | //}
|
| 1122 | client.uToken = Global_uToken_call;
|
| 1123 | client.request = request_id;
|
| 1124 | client.paramLen = argc;
|
| 1125 | bzero(client.param,LYNQ_REQUEST_PARAM_BUF);
|
| 1126 | va_list args;
|
| 1127 | va_start(args, format);
|
| 1128 | vsnprintf(client.param, LYNQ_REQUEST_PARAM_BUF, format, args);
|
| 1129 | va_end(args);
|
| 1130 | LYDBGLOG("uToken=%d,request=%d,paralen=%d,param=%s\n",client.uToken,client.request,client.paramLen,client.param);
|
| 1131 | if(send_request(lynq_call_client_sockfd,&client)==-1)
|
| 1132 | {
|
| 1133 | LYERRLOG("send request fail");
|
| 1134 | return -1;
|
| 1135 | }
|
| 1136 | if(get_response(lynq_call_client_sockfd,p)==0)
|
| 1137 | {
|
| 1138 | JumpHeader(p,&resp_type,&request,&slot_id,&error);
|
| 1139 | LYINFLOG("resp_type=%d,request=%d,slot_id=%d,error_code=%d",resp_type,request,slot_id,error);
|
| 1140 | }
|
| 1141 | return error;
|
| 1142 | }
|
| 1143 |
|
| 1144 | int lynq_get_common_request(int request_id, int* status)
|
lh | 7b0674a | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 1145 | {
|
| 1146 | Parcel p;
|
| 1147 | lynq_client_t client;
|
| 1148 | int resp_type = -1;
|
| 1149 | int request = -1;
|
| 1150 | int slot_id = -1;
|
| 1151 | int error = -1;
|
| 1152 | if(status==NULL)
|
| 1153 | {
|
| 1154 | LYERRLOG("status is null");
|
| 1155 | return -1;
|
| 1156 | }
|
lh | 42c1e57 | 2022-01-25 18:47:39 -0800 | [diff] [blame] | 1157 | client.uToken = Global_uToken_call;
|
q.huang | ec88da9 | 2022-03-29 04:17:32 -0400 | [diff] [blame] | 1158 | client.request = request_id;
|
lh | 7b0674a | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 1159 | client.paramLen = 0;
|
| 1160 | bzero(client.param,LYNQ_REQUEST_PARAM_BUF);
|
| 1161 | LYDBGLOG("uToken=%d,request=%d,paralen=%d,param=%s\n",client.uToken,client.request,client.paramLen,client.param);
|
lh | 42c1e57 | 2022-01-25 18:47:39 -0800 | [diff] [blame] | 1162 | if(send_request(lynq_call_client_sockfd,&client)==-1)
|
lh | 7b0674a | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 1163 | {
|
| 1164 | LYERRLOG("send request fail");
|
lh | 7b0674a | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 1165 | return -1;
|
| 1166 | }
|
q.huang | ec88da9 | 2022-03-29 04:17:32 -0400 | [diff] [blame] | 1167 | if(get_response(lynq_call_client_sockfd,p)==0)
|
| 1168 | {
|
| 1169 | JumpHeader(p,&resp_type,&request,&slot_id,&error);
|
| 1170 | p.readInt32(status);
|
| 1171 | LYINFLOG("resp_type=%d,request=%d,slot_id=%d,error_code=%d",resp_type,request,slot_id,error);
|
| 1172 | }
|
lh | 7b0674a | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 1173 | return error;
|
| 1174 | }
|
ll | dc99c9b | 2022-01-24 12:16:22 +0000 | [diff] [blame] | 1175 |
|
| 1176 | static int judge_mic(const int enable){
|
ll | f512fa3 | 2022-02-14 08:58:16 +0000 | [diff] [blame] | 1177 | switch(enable){
|
| 1178 | case 0:
|
| 1179 | return 1;
|
| 1180 | case 1:
|
| 1181 | return 1;
|
| 1182 | default:
|
| 1183 | return 0;
|
ll | dc99c9b | 2022-01-24 12:16:22 +0000 | [diff] [blame] | 1184 | }
|
| 1185 | }
|
| 1186 |
|
lh | 7b0674a | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 1187 | int lynq_set_mute_mic(const int enable)
|
ll | dc99c9b | 2022-01-24 12:16:22 +0000 | [diff] [blame] | 1188 | {
|
| 1189 | if(!judge_mic(enable)){
|
| 1190 | return LYNQ_E_CONFLICT;
|
| 1191 | }
|
q.huang | ec88da9 | 2022-03-29 04:17:32 -0400 | [diff] [blame] | 1192 | return lynq_set_common_request(53,1,"%d",enable); //RIL_REQUEST_SET_MUTE
|
| 1193 | }
|
| 1194 | int lynq_get_mute_mic(int *status)
|
| 1195 | {
|
| 1196 | return lynq_get_common_request(54,status);//RIL_REQUEST_GET_MUTE
|
lh | 7b0674a | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 1197 | }
|
ll | 72bf6c1 | 2022-03-24 10:22:25 +0800 | [diff] [blame] | 1198 |
|
| 1199 | /**
|
| 1200 | * @brief Check whether DTMF is valid
|
| 1201 | *
|
| 1202 | * @param callnum dtmf eg:0-9 * #
|
| 1203 | * @return int
|
| 1204 | */
|
| 1205 | static int judge_dtmf(const char callnum)
|
| 1206 | {
|
| 1207 | if(callnum == '#')
|
| 1208 | {
|
| 1209 | return 1;
|
| 1210 | }
|
| 1211 | if(callnum == '*')
|
| 1212 | {
|
| 1213 | return 1;
|
| 1214 | }
|
| 1215 | if(callnum >= '0'&& callnum <= '9')
|
| 1216 | {
|
| 1217 | return 1;
|
| 1218 | }
|
| 1219 | return 0;
|
| 1220 | }
|
| 1221 |
|
lh | 7b0674a | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 1222 | int lynq_set_DTMF(const char callnum)
|
| 1223 | {
|
ll | 72bf6c1 | 2022-03-24 10:22:25 +0800 | [diff] [blame] | 1224 | if(!judge_dtmf(callnum))
|
| 1225 | {
|
| 1226 | return LYNQ_E_CONFLICT;
|
| 1227 | }
|
lh | 7b0674a | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 1228 | if(!lynq_call_state)
|
| 1229 | {
|
| 1230 | LYERRLOG("LYNQ_E_CONFLICT");
|
| 1231 | return LYNQ_E_CONFLICT;
|
| 1232 | }
|
q.huang | ec88da9 | 2022-03-29 04:17:32 -0400 | [diff] [blame] | 1233 | return lynq_set_common_request(24,1,"%c",callnum); //RIL_REQUEST_DTMF
|
lh | 7b0674a | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 1234 | }
|
q.huang | ec88da9 | 2022-03-29 04:17:32 -0400 | [diff] [blame] | 1235 | static int judge_volume(LYNQ_E_VOLUMN_SET set,const int volume){
|
| 1236 | if(set==LYNQ_E_VOLUMN_SET_DTMF){
|
| 1237 | if(volume < 0 ||volume >36){
|
| 1238 | return 0;
|
| 1239 | }
|
| 1240 | }
|
| 1241 | else if (set==LYNQ_E_VOLUMN_SET_SPEECH)
|
| 1242 | {
|
| 1243 | if(volume < 1 ||volume >7){
|
| 1244 | return 0;
|
| 1245 | }
|
ll | dc99c9b | 2022-01-24 12:16:22 +0000 | [diff] [blame] | 1246 | }
|
ll | 04ae414 | 2022-01-27 05:54:38 +0000 | [diff] [blame] | 1247 | return 1;
|
ll | dc99c9b | 2022-01-24 12:16:22 +0000 | [diff] [blame] | 1248 | }
|
lh | 7b0674a | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 1249 | int lynq_set_DTMF_volume(const int volume)
|
ll | dc99c9b | 2022-01-24 12:16:22 +0000 | [diff] [blame] | 1250 | {
|
q.huang | ec88da9 | 2022-03-29 04:17:32 -0400 | [diff] [blame] | 1251 | if(!judge_volume(LYNQ_E_VOLUMN_SET_DTMF,volume)){
|
ll | dc99c9b | 2022-01-24 12:16:22 +0000 | [diff] [blame] | 1252 | return LYNQ_E_CONFLICT;
|
| 1253 | }
|
q.huang | ec88da9 | 2022-03-29 04:17:32 -0400 | [diff] [blame] | 1254 | return lynq_set_common_request(8003,1,"%d",volume);//LYNQ_REQUEST_SET_DTMF_VOLUME
|
lh | 7b0674a | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 1255 | }
|
q.huang | b212fde | 2022-04-05 23:11:02 -0400 | [diff] [blame] | 1256 | int lynq_set_speech_volume(const int volume)//mixer_set_volume
|
lh | 7b0674a | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 1257 | {
|
q.huang | ec88da9 | 2022-03-29 04:17:32 -0400 | [diff] [blame] | 1258 | if(!judge_volume(LYNQ_E_VOLUMN_SET_SPEECH,volume))
|
lh | 7b0674a | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 1259 | {
|
q.huang | ec88da9 | 2022-03-29 04:17:32 -0400 | [diff] [blame] | 1260 | return LYNQ_E_CONFLICT;
|
lh | 7b0674a | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 1261 | }
|
q.huang | ec88da9 | 2022-03-29 04:17:32 -0400 | [diff] [blame] | 1262 | return lynq_set_common_request(8009,1,"%d",volume); //LYNQ_REQUEST_SET_SPEECH_VOLUME
|
lh | 7b0674a | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 1263 | }
|
q.huang | ec88da9 | 2022-03-29 04:17:32 -0400 | [diff] [blame] | 1264 | int lynq_get_speech_volume(int* volumn)//mixer_get_volume
|
| 1265 | {
|
| 1266 | return lynq_get_common_request(8010,volumn);//LYNQ_REQUEST_GET_SPEECH_VOLUME
|
| 1267 | }
|
q.huang | b212fde | 2022-04-05 23:11:02 -0400 | [diff] [blame] | 1268 | int lynq_incall_record_start(const char* file_path)
|
q.huang | ec88da9 | 2022-03-29 04:17:32 -0400 | [diff] [blame] | 1269 | {
|
q.huang | b212fde | 2022-04-05 23:11:02 -0400 | [diff] [blame] | 1270 | return lynq_set_common_request(8011,2,"%s %s","1",file_path); //LYNQ_REQUEST_RECORD
|
q.huang | ec88da9 | 2022-03-29 04:17:32 -0400 | [diff] [blame] | 1271 | }
|
| 1272 | int lynq_incall_record_stop()
|
| 1273 | {
|
q.huang | b212fde | 2022-04-05 23:11:02 -0400 | [diff] [blame] | 1274 | const char* unused_file="just_ocuupy_paramter_postion";
|
| 1275 | return lynq_set_common_request(8011,2,"%s %s","0",unused_file); //LYNQ_REQUEST_RECORD
|
q.huang | ec88da9 | 2022-03-29 04:17:32 -0400 | [diff] [blame] | 1276 | }
|
| 1277 | /*audio end*/
|
lh | 7b0674a | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 1278 | #if 0
|
| 1279 | int main(int argc,char **argv)
|
| 1280 | {
|
| 1281 | int n = 0;
|
| 1282 | n = lynq_init_call(lynq_call_state_change_test,2222);
|
| 1283 | if(n<0)
|
| 1284 | {
|
| 1285 | printf("lynq init call fail!!!\n");
|
| 1286 | return -1;
|
| 1287 | }
|
| 1288 | printf("lynq call init success!!!\n");
|
| 1289 | char phoneNum[LYNQ_PHONE_NUMBER_MAX];
|
| 1290 | sprintf(phoneNum,"18180053406 0",strlen("18180053406 0")+1);
|
| 1291 | lynq_call(phoneNum);
|
| 1292 | while(1)
|
| 1293 | {
|
| 1294 | sleep(1);
|
| 1295 | }
|
| 1296 | return 0;
|
| 1297 | }
|
| 1298 | #endif
|
| 1299 | /*Warren add for T800 platform 2021/11/19 end*/
|