lh | 2582795 | 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>
|
lh | 2582795 | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 11 | #include <cutils/jstring.h>
|
| 12 | #include <pthread.h>
|
| 13 | #include "liblog/lynq_deflog.h"
|
lh | 228a7b8 | 2022-01-10 02:24:31 -0800 | [diff] [blame] | 14 | #include <sys/time.h>
|
lh | 59e0d00 | 2022-01-27 00:27:12 -0800 | [diff] [blame] | 15 | #include <string.h>
|
q.huang | fe1b405 | 2022-04-18 00:09:50 -0400 | [diff] [blame] | 16 | #include <vendor-ril/telephony/ril.h>
|
| 17 | #include <vendor-ril/telephony/mtk_ril_sp.h>
|
| 18 | #include <vendor-ril/telephony/mtk_ril_ivt.h>
|
| 19 | #include "lynq_call.h"
|
| 20 |
|
| 21 |
|
lh | 2582795 | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 22 | #define LYNQ_SERVICE_PORT 8088
|
rjw | 8bdc56b | 2022-02-28 15:01:49 +0800 | [diff] [blame] | 23 | #define DSET_IP_ADDRESS "127.0.0.1"
|
lh | 2582795 | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 24 | #define LYNQ_URC_SERVICE_PORT 8086
|
| 25 | #define LYNQ_REC_BUF 8192
|
| 26 | #define LYNQ_REQUEST_PARAM_BUF 8192
|
| 27 | #define LYQN_SEDN_BUF 1024*8+sizeof(int)*3
|
q.huang | 783ed5d | 2022-06-02 14:49:02 +0800 | [diff] [blame] | 28 | #define INVALID_ID (-1)
|
lh | 2582795 | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 29 | #define USER_LOG_TAG "LYNQ_CALL"
|
| 30 |
|
| 31 | using ::android::Parcel;
|
| 32 | typedef enum {
|
| 33 | LYNQ_CALL_ACTIVE = 0,
|
| 34 | LYNQ_CALL_HOLDING = 1,
|
| 35 | LYNQ_CALL_DIALING = 2, /* MO call only */
|
| 36 | LYNQ_CALL_ALERTING = 3, /* MO call only */
|
| 37 | LYNQ_CALL_INCOMING = 4, /* MT call only */
|
lh | 8657e74 | 2022-04-26 00:45:44 -0700 | [diff] [blame] | 38 | LYNQ_CALL_WAITING = 5, /* MT call only */
|
| 39 | /*warren add for T800 platform 2022/04/26 start*/
|
| 40 | LYNQ_CALL_END = 6, /*CALL END*/
|
| 41 | /*warren add for T800 platform 2022/04/26 end*/
|
lh | 2582795 | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 42 | }lynq_call_state_t;
|
| 43 |
|
| 44 | typedef struct{
|
| 45 | int uToken;
|
| 46 | int request;
|
| 47 | int paramLen;
|
| 48 | char param[LYNQ_REQUEST_PARAM_BUF];
|
| 49 | }lynq_client_t;
|
| 50 | typedef struct
|
| 51 | {
|
| 52 | int used;
|
| 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];
|
lh | 2582795 | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 58 | }lynq_call_list_e_t;
|
| 59 | typedef struct
|
| 60 | {
|
| 61 | int call_id;
|
| 62 | int call_state;
|
| 63 | int toa;
|
| 64 | int direction;/*0: MO call,1:MT call*/
|
| 65 | char addr[LYNQ_PHONE_NUMBER_MAX];
|
| 66 | }lynq_call_list_t;
|
| 67 |
|
| 68 | lynq_call_list_e_t lynq_call_lists[LYNQ_CALL_MAX]={};
|
| 69 | static pthread_mutex_t call_state_change_mutex = PTHREAD_MUTEX_INITIALIZER;
|
| 70 | static pthread_cond_t call_state_change_cond = PTHREAD_COND_INITIALIZER;
|
ll | 375c94d | 2022-01-27 05:54:38 +0000 | [diff] [blame] | 71 | static pthread_mutex_t s_urc_call_state_change_mutex = PTHREAD_MUTEX_INITIALIZER;
|
lh | 2582795 | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 72 | static pthread_cond_t s_urc_call_state_change_cond = PTHREAD_COND_INITIALIZER;
|
| 73 | static pthread_mutex_t s_incoming_call_mutex = PTHREAD_MUTEX_INITIALIZER;
|
| 74 | static pthread_cond_t s_incoming_call_cond = PTHREAD_COND_INITIALIZER;
|
ll | 1343a5b | 2022-03-17 05:31:33 +0000 | [diff] [blame] | 75 | pthread_t lynq_call_urc_tid = -1;
|
| 76 | pthread_t lynq_call_list_loop_tid = -1;
|
lh | cdf816a | 2022-02-13 23:56:05 -0800 | [diff] [blame] | 77 |
|
rjw | 8bdc56b | 2022-02-28 15:01:49 +0800 | [diff] [blame] | 78 | /*lei add*/
|
| 79 | /* socket文件描述符 */
|
| 80 | int len_addr_serv;
|
| 81 | struct sockaddr_in addr_serv;
|
| 82 | lynq_client_t client_t;
|
| 83 | int client_size = 0;
|
| 84 | /*lei add*/
|
lh | 2582795 | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 85 |
|
lh | a35d4ee | 2022-01-25 18:47:39 -0800 | [diff] [blame] | 86 | int s_call_urc_event_complete = 1;
|
lh | 2582795 | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 87 |
|
| 88 | enum{
|
| 89 | CALL_OFF=0,
|
| 90 | CALL_ON=1
|
| 91 | }call_state;
|
ll | 375c94d | 2022-01-27 05:54:38 +0000 | [diff] [blame] | 92 | typedef enum{
|
| 93 | LYNQ_E_CARDSTATE_ERROR=8000,
|
| 94 | /* The voice service state is out of service*/
|
| 95 | LYNQ_E_STATE_OUT_OF_SERVICE=8001,
|
| 96 | /* The voice service state is EMERGENCY_ONLY*/
|
| 97 | LYNQ_E_STATE_EMERGENCY_ONLY=8002,
|
| 98 | /* The radio power is power off*/
|
| 99 | LYNQ_E_STATE_POWER_OFF=8003,
|
| 100 | LYNQ_E_TIME_OUT=8004,
|
| 101 | /*create or open sms DB fail */
|
| 102 | LYNQ_E_SMS_DB_FAIL=8005,
|
| 103 | /*Failed to execute sql statement*/
|
| 104 | LYNQ_E_SMS_SQL_FAIL = 8006,
|
| 105 | LYNQ_E_SMS_NOT_FIND = 8007,
|
| 106 | /* The logic conflict*/
|
| 107 | LYNQ_E_CONFLICT=9000,
|
| 108 | /*Null anomaly*/
|
q.huang | 783ed5d | 2022-06-02 14:49:02 +0800 | [diff] [blame] | 109 | LYNQ_E_NULL_ANONALY=9001,
|
| 110 | /*Invalid id anomaly*/
|
| 111 | LYNQ_E_INVALID_ID_ANONALY=9002,
|
| 112 | #ifdef ECALL_SUPPORT
|
| 113 | LYNQ_E_ECALL_BEING_RUNNING =9003,
|
| 114 | LYNQ_E_ECALL_MSD_LENGTH_ERROR =9004,
|
| 115 | #endif
|
lh | 2582795 | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 116 | }LYNQ_E;
|
q.huang | b0eb7b0 | 2022-03-29 04:17:32 -0400 | [diff] [blame] | 117 | typedef enum{
|
| 118 | LYNQ_E_VOLUMN_SET_DTMF,
|
| 119 | LYNQ_E_VOLUMN_SET_SPEECH
|
| 120 | }LYNQ_E_VOLUMN_SET;
|
lh | 2582795 | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 121 |
|
| 122 | int lynq_call_state =CALL_OFF;
|
lh | a35d4ee | 2022-01-25 18:47:39 -0800 | [diff] [blame] | 123 | int lynq_call_client_sockfd = 0;
|
| 124 | int Global_uToken_call = 0;
|
lh | 2582795 | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 125 | int global_call_count =0;
|
| 126 | int global_call_auto_answer = 0;
|
lh | a35d4ee | 2022-01-25 18:47:39 -0800 | [diff] [blame] | 127 | bool urc_call_recive_status = 1;
|
lh | 2582795 | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 128 | bool call_list_loop = 1;
|
| 129 | int isDial = 0;
|
| 130 | int lynqIncomingCallId = 0;
|
q.huang | 18d08bf | 2022-04-19 20:27:44 -0400 | [diff] [blame] | 131 |
|
| 132 | #ifdef ECALL_SUPPORT
|
q.huang | 783ed5d | 2022-06-02 14:49:02 +0800 | [diff] [blame] | 133 | int lynq_set_common_request(int request_id, int argc, const char* format,...);
|
| 134 | int is_ecall_dial = 0;
|
| 135 | int g_ecallId = INVALID_ID;
|
q.huang | 18d08bf | 2022-04-19 20:27:44 -0400 | [diff] [blame] | 136 | typedef enum{
|
| 137 | LYNQ_ECALL_TYPE_TEST = 0, /* Test eCall */
|
| 138 | LYNQ_ECALL_TYPE_RECONFIG = 1, /* Reconfiguration eCall */
|
q.huang | fe1b405 | 2022-04-18 00:09:50 -0400 | [diff] [blame] | 139 | LYNQ_ECALL_MANUAL_EMERGENCY = 2, /*Manual Emergency eCall */
|
| 140 | LYNQ_ECALL_TYPE_AUTO_EMERGENCY = 3, /* Automatic Emergency eCall */\
|
| 141 | }LYNQ_ECall_Type;
|
| 142 |
|
q.huang | 783ed5d | 2022-06-02 14:49:02 +0800 | [diff] [blame] | 143 | char e_call_addr[LYNQ_ECALL_VAR_MAX][LYNQ_PHONE_NUMBER_MAX]={"test_ecall","emergency_ecall","reconf_ecall"};
|
q.huang | 18d08bf | 2022-04-19 20:27:44 -0400 | [diff] [blame] | 144 |
|
| 145 | static pthread_mutex_t s_incoming_e_call_mutex = PTHREAD_MUTEX_INITIALIZER;
|
| 146 | static pthread_cond_t s_incoming_e_call_cond = PTHREAD_COND_INITIALIZER;
|
| 147 |
|
q.huang | 783ed5d | 2022-06-02 14:49:02 +0800 | [diff] [blame] | 148 | LYNQ_ECall_Indication g_lynqIncomingEcallIndication;
|
q.huang | 18d08bf | 2022-04-19 20:27:44 -0400 | [diff] [blame] | 149 |
|
| 150 | void sendSignalIncomingECallEvent()
|
| 151 | {
|
q.huang | 783ed5d | 2022-06-02 14:49:02 +0800 | [diff] [blame] | 152 | LYINFLOG("send incoming ecall event signal");;
|
q.huang | 18d08bf | 2022-04-19 20:27:44 -0400 | [diff] [blame] | 153 | pthread_mutex_lock(&s_incoming_e_call_mutex);
|
| 154 | pthread_cond_signal(&s_incoming_e_call_cond);
|
| 155 | pthread_mutex_unlock(&s_incoming_e_call_mutex);
|
| 156 | }
|
q.huang | 783ed5d | 2022-06-02 14:49:02 +0800 | [diff] [blame] | 157 |
|
| 158 | int lynq_is_msd_suc(LYNQ_ECall_Indication lynqIncomingEcallIndication)
|
| 159 | {
|
| 160 | if(LYNQ_ECALL_LLACK_RECEIVED == lynqIncomingEcallIndication ||
|
| 161 | LYNQ_ECALL_ALACK_POSITIVE_RECEIVED == lynqIncomingEcallIndication ||
|
| 162 | LYNQ_ECALL_ALACK_CLEARDOWN_RECEIVED == lynqIncomingEcallIndication ||
|
| 163 | LYNQ_ECALL_T5_TIMER_OUT == lynqIncomingEcallIndication ||
|
| 164 | LYNQ_ECALL_T6_TIMER_OUT == lynqIncomingEcallIndication ||
|
| 165 | LYNQ_ECALL_T7_TIMER_OUT == lynqIncomingEcallIndication)
|
| 166 | {
|
| 167 | return 1;
|
| 168 | }
|
| 169 |
|
| 170 | return 0;
|
| 171 | }
|
| 172 |
|
| 173 | int lynq_ecall_is_running()
|
| 174 | {
|
| 175 | return (is_ecall_dial!=0) || (g_ecallId !=INVALID_ID);
|
| 176 | }
|
| 177 |
|
q.huang | 18d08bf | 2022-04-19 20:27:44 -0400 | [diff] [blame] | 178 | #endif
|
q.huang | fe1b405 | 2022-04-18 00:09:50 -0400 | [diff] [blame] | 179 |
|
ll | 1343a5b | 2022-03-17 05:31:33 +0000 | [diff] [blame] | 180 | /**
|
| 181 | * @brief mark call initialization state
|
| 182 | * 0: deinit state
|
| 183 | * 1: init state
|
| 184 | */
|
| 185 | int g_lynq_call_init_flag = 0;
|
lh | 2582795 | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 186 |
|
| 187 | int JumpHeader(Parcel &p,int *resp_type,int *request,int *slot_id,int *error)
|
| 188 | {
|
| 189 | if(p.dataAvail() > 0)
|
| 190 | {
|
| 191 | p.readInt32(resp_type);
|
| 192 | p.readInt32(request);
|
| 193 | p.readInt32(slot_id);
|
| 194 | p.readInt32(error);
|
| 195 | return 0;
|
| 196 | }
|
| 197 | else
|
| 198 | {
|
| 199 | return -1;
|
| 200 | }
|
| 201 | }
|
| 202 | int send_request(int sockfd,lynq_client_t *client_tmp)
|
| 203 | {
|
| 204 | int ret=0;
|
rjw | 8bdc56b | 2022-02-28 15:01:49 +0800 | [diff] [blame] | 205 | ret = sendto(sockfd, client_tmp, client_size, 0, (struct sockaddr *)&addr_serv, len_addr_serv);
|
lh | 2582795 | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 206 | if(ret==-1)
|
| 207 | {
|
q.huang | 783ed5d | 2022-06-02 14:49:02 +0800 | [diff] [blame] | 208 | LYERRLOG("sendto error");
|
lh | 2582795 | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 209 | return -1;
|
| 210 | }
|
| 211 | return 0;
|
| 212 | }
|
| 213 |
|
| 214 | int get_response(int sockfd,Parcel &p)
|
| 215 | {
|
| 216 | int len = 0;
|
| 217 | char recvline[LYNQ_REC_BUF];
|
| 218 | bzero(recvline,LYNQ_REC_BUF);
|
| 219 | /* receive data from server */
|
rjw | 8bdc56b | 2022-02-28 15:01:49 +0800 | [diff] [blame] | 220 | len = recvfrom(sockfd,recvline,LYNQ_REC_BUF, 0, (struct sockaddr *)&addr_serv,(socklen_t*)&len_addr_serv);
|
lh | 2582795 | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 221 | if(len == -1)
|
| 222 | {
|
q.huang | 783ed5d | 2022-06-02 14:49:02 +0800 | [diff] [blame] | 223 | LYERRLOG("recvfrom error");
|
lh | 2582795 | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 224 | return -1;
|
| 225 | }
|
lh | 2582795 | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 226 | if (recvline != NULL) {
|
| 227 | p.setData((uint8_t *)recvline,len); // p.setData((uint8_t *) buffer, buflen);
|
| 228 | p.setDataPosition(0);
|
| 229 | }
|
| 230 | return 0;
|
| 231 | }
|
| 232 | static char *strdupReadString(Parcel &p) {
|
ll | 375c94d | 2022-01-27 05:54:38 +0000 | [diff] [blame] | 233 | size_t stringlen;
|
lh | 2582795 | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 234 | const char16_t *s16;
|
| 235 | s16 = p.readString16Inplace(&stringlen);
|
ll | 375c94d | 2022-01-27 05:54:38 +0000 | [diff] [blame] | 236 | return strndup16to8(s16, stringlen);
|
lh | 2582795 | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 237 | }
|
| 238 |
|
| 239 | int lynq_get_current_call_list(lynq_call_list_t call_list[LYNQ_CALL_MAX])
|
| 240 | {
|
| 241 | Parcel p;
|
| 242 | lynq_client_t client;
|
| 243 | int resp_type = -1;
|
| 244 | int request = -1;
|
| 245 | int slot_id = -1;
|
| 246 | int error = -1;
|
| 247 | int call_num = 0;
|
| 248 | int temp = 0;
|
| 249 | char *remote_phoneNum = NULL;
|
| 250 | char *remote_name= NULL;
|
| 251 | char *uusData = NULL;
|
lh | a35d4ee | 2022-01-25 18:47:39 -0800 | [diff] [blame] | 252 | client.uToken = Global_uToken_call;
|
lh | 2582795 | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 253 | client.request = 9;//RIL_REQUEST_GET_CURRENT_CALLS
|
| 254 | client.paramLen = 0;
|
| 255 | bzero(client.param,LYNQ_REQUEST_PARAM_BUF);
|
q.huang | 783ed5d | 2022-06-02 14:49:02 +0800 | [diff] [blame] | 256 | LYINFLOG("uToken=%d,request=%d,paralen=%d,param=%s",client.uToken,client.request,client.paramLen,client.param);
|
lh | a35d4ee | 2022-01-25 18:47:39 -0800 | [diff] [blame] | 257 | if(send_request(lynq_call_client_sockfd,&client)==-1)
|
lh | 2582795 | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 258 | {
|
| 259 | LYERRLOG("send request fail");
|
lh | 2582795 | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 260 | return -1;
|
| 261 | }
|
lh | a35d4ee | 2022-01-25 18:47:39 -0800 | [diff] [blame] | 262 | get_response(lynq_call_client_sockfd,p);
|
lh | 2582795 | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 263 | JumpHeader(p,&resp_type,&request,&slot_id,&error);
|
| 264 | LYINFLOG("resp_type=%d,request=%d,slot_id=%d,error_code=%d",resp_type,request,slot_id,error);
|
| 265 | if(error == 0)
|
| 266 | {
|
| 267 | p.readInt32(&call_num);
|
| 268 | global_call_count = call_num;
|
| 269 | if(call_num<=0)
|
| 270 | {
|
| 271 | lynq_call_state = CALL_OFF;
|
lh | cdf816a | 2022-02-13 23:56:05 -0800 | [diff] [blame] | 272 | LYINFLOG("lynq_call_state:%d",lynq_call_state);
|
lh | 2582795 | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 273 | return 0;
|
| 274 | }
|
lh | cdf816a | 2022-02-13 23:56:05 -0800 | [diff] [blame] | 275 | lynq_call_state = CALL_ON;
|
q.huang | 783ed5d | 2022-06-02 14:49:02 +0800 | [diff] [blame] | 276 | LYINFLOG("lynq_call_state:%d, call num is %d ",lynq_call_state,call_num);
|
lh | 2582795 | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 277 | for(int i = 0;i < call_num;i++)
|
| 278 | {
|
| 279 | p.readInt32(&temp);
|
| 280 | call_list[i].call_state = temp;
|
| 281 | p.readInt32(&call_list[i].call_id);
|
| 282 | p.readInt32(&call_list[i].toa);
|
| 283 | p.readInt32(&temp);
|
| 284 | p.readInt32(&temp);
|
| 285 | call_list[i].direction = temp;
|
| 286 | p.readInt32(&temp);
|
| 287 | p.readInt32(&temp);
|
| 288 | p.readInt32(&temp);
|
| 289 | remote_phoneNum = strdupReadString(p);
|
| 290 | memcpy(call_list[i].addr,remote_phoneNum,strlen(remote_phoneNum));
|
| 291 | LYINFLOG("call_id=%d,call_state=%d,direction=%d,addr=%s,toa=%d",call_list[i].call_id,call_list[i].call_state,
|
| 292 | call_list[i].direction,call_list[i].addr,call_list[i].toa);
|
| 293 | p.readInt32(&temp);
|
| 294 | remote_name = strdupReadString(p);
|
| 295 | p.readInt32(&temp);
|
| 296 | p.readInt32(&temp);
|
| 297 | if(temp==0)
|
| 298 | {
|
| 299 | continue;
|
| 300 | }
|
| 301 | p.readInt32(&temp); /* UUS Information is present */
|
| 302 | p.readInt32(&temp);
|
| 303 | p.readInt32(&temp);
|
| 304 | p.read(uusData,temp);
|
| 305 | }
|
| 306 | }
|
| 307 | return 0;
|
| 308 | }
|
| 309 |
|
| 310 | void cleanCallList(int lynq_call_id)
|
| 311 | {
|
q.huang | 783ed5d | 2022-06-02 14:49:02 +0800 | [diff] [blame] | 312 | LYINFLOG("cleanCall local idx is %d, id is %d",lynq_call_id,lynq_call_lists[lynq_call_id].call_id);
|
lh | 2582795 | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 313 | lynq_call_lists[lynq_call_id].call_id = 0;
|
lh | 8657e74 | 2022-04-26 00:45:44 -0700 | [diff] [blame] | 314 | lynq_call_lists[lynq_call_id].call_state = (int)LYNQ_CALL_END;
|
lh | 2582795 | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 315 | lynq_call_lists[lynq_call_id].toa = 0;
|
| 316 | lynq_call_lists[lynq_call_id].direction = 0;
|
| 317 | lynq_call_lists[lynq_call_id].used = 0;
|
lh | 2582795 | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 318 | memset(lynq_call_lists[lynq_call_id].addr,0,sizeof(lynq_call_lists[lynq_call_id].addr));
|
| 319 | }
|
| 320 | int getUnusedElement()
|
| 321 | {
|
| 322 | for(int i=0;i < LYNQ_CALL_MAX; i++)
|
| 323 | {
|
| 324 | if(lynq_call_lists[i].used!=1)
|
| 325 | {
|
| 326 | return i;
|
| 327 | }
|
| 328 | }
|
| 329 | return -1;
|
| 330 | }
|
q.huang | 783ed5d | 2022-06-02 14:49:02 +0800 | [diff] [blame] | 331 | int addAddr(char addr[])
|
lh | 2582795 | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 332 | {
|
| 333 | int ret = 0;
|
| 334 | ret = getUnusedElement();
|
| 335 | memcpy(lynq_call_lists[ret].addr,addr,strlen(addr)+1);
|
| 336 | lynq_call_lists[ret].used = 1;
|
q.huang | 783ed5d | 2022-06-02 14:49:02 +0800 | [diff] [blame] | 337 | LYINFLOG("add local idx is %d addr is %s",ret,addr);
|
lh | 2582795 | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 338 | return ret;
|
| 339 | }
|
| 340 | void updateCallList(lynq_call_list_e_t *callList, int call_id,int call_state,int toa,int direction)
|
| 341 | {
|
q.huang | 783ed5d | 2022-06-02 14:49:02 +0800 | [diff] [blame] | 342 | LYINFLOG("Update original local id is %d, new local id is %d",callList->call_id,call_id);
|
lh | 2582795 | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 343 | callList->call_id = call_id;
|
| 344 | callList->call_state = call_state;
|
| 345 | callList->toa = toa;
|
q.huang | 783ed5d | 2022-06-02 14:49:02 +0800 | [diff] [blame] | 346 | callList->direction = direction;
|
lh | 2582795 | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 347 | return;
|
| 348 | }
|
| 349 | int waitCallstateChange(int mtime)
|
| 350 | {
|
lh | be92dd1 | 2022-04-19 06:01:25 -0700 | [diff] [blame] | 351 | LYINFLOG("wait Call state Change");
|
lh | 2582795 | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 352 | int ret = 0;
|
| 353 | int sec = 0;
|
| 354 | int usec = 0;
|
lh | 228a7b8 | 2022-01-10 02:24:31 -0800 | [diff] [blame] | 355 | struct timeval now;
|
| 356 | struct timespec timeout;
|
| 357 | gettimeofday(&now,NULL);
|
lh | 2582795 | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 358 | sec = mtime/1000;
|
| 359 | usec = mtime%1000;
|
lh | 228a7b8 | 2022-01-10 02:24:31 -0800 | [diff] [blame] | 360 | timeout.tv_sec = now.tv_sec+sec;
|
| 361 | timeout.tv_nsec = now.tv_usec*1000+usec*1000000;
|
lh | 2582795 | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 362 | pthread_mutex_lock(&call_state_change_mutex);
|
lh | 228a7b8 | 2022-01-10 02:24:31 -0800 | [diff] [blame] | 363 | ret = pthread_cond_timedwait(&call_state_change_cond,&call_state_change_mutex,&timeout);
|
lh | 2582795 | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 364 | pthread_mutex_unlock(&call_state_change_mutex);
|
| 365 | return ret;
|
| 366 | }
|
| 367 | int waitIncomingCall()
|
| 368 | {
|
lh | be92dd1 | 2022-04-19 06:01:25 -0700 | [diff] [blame] | 369 | LYINFLOG("wait incming call");
|
lh | 2582795 | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 370 | int ret = 0;
|
| 371 | pthread_mutex_lock(&s_incoming_call_mutex);
|
| 372 | ret = pthread_cond_wait(&s_incoming_call_cond,&s_incoming_call_mutex);
|
| 373 | pthread_mutex_unlock(&s_incoming_call_mutex);
|
| 374 | return ret;
|
| 375 | }
|
| 376 | int checkHasCall(char addr[])
|
| 377 | {
|
| 378 | for(int i = 0;i<LYNQ_CALL_MAX;i++)
|
| 379 | {
|
| 380 | if(strcmp(lynq_call_lists[i].addr,addr)==0)
|
| 381 | {
|
q.huang | 783ed5d | 2022-06-02 14:49:02 +0800 | [diff] [blame] | 382 | LYINFLOG("checkHasCall addr is %s idx is %d id is %d",addr,i,lynq_call_lists[i].call_id);
|
lh | 2582795 | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 383 | return 1;
|
| 384 | }
|
| 385 | }
|
q.huang | 783ed5d | 2022-06-02 14:49:02 +0800 | [diff] [blame] | 386 | LYINFLOG("checkHasCall addr is %s , no idx is found",addr);
|
lh | 2582795 | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 387 | return 0;
|
| 388 | }
|
lh | be92dd1 | 2022-04-19 06:01:25 -0700 | [diff] [blame] | 389 | int find_call_id_with_addr(char *addr)
|
| 390 | {
|
lh | be92dd1 | 2022-04-19 06:01:25 -0700 | [diff] [blame] | 391 | for(int id = 0; id < LYNQ_CALL_MAX; id++)
|
| 392 | {
|
q.huang | 783ed5d | 2022-06-02 14:49:02 +0800 | [diff] [blame] | 393 | if(lynq_call_lists[id].used && (strcmp(lynq_call_lists[id].addr,addr) == 0))
|
lh | be92dd1 | 2022-04-19 06:01:25 -0700 | [diff] [blame] | 394 | {
|
q.huang | 783ed5d | 2022-06-02 14:49:02 +0800 | [diff] [blame] | 395 | LYINFLOG("find addr %s in local list, local idx is %d id is %d",addr,id,lynq_call_lists[id].call_id);
|
lh | be92dd1 | 2022-04-19 06:01:25 -0700 | [diff] [blame] | 396 | return id;
|
| 397 | }
|
| 398 | }
|
q.huang | 783ed5d | 2022-06-02 14:49:02 +0800 | [diff] [blame] | 399 | LYINFLOG("find addr %s in local list , not found",addr);
|
lh | be92dd1 | 2022-04-19 06:01:25 -0700 | [diff] [blame] | 400 | return -1;
|
| 401 | }
|
q.huang | 783ed5d | 2022-06-02 14:49:02 +0800 | [diff] [blame] | 402 | int find_call_id_with_call_id(int call_id)
|
| 403 | {
|
| 404 | for(int id = 0; id < LYNQ_CALL_MAX; id++)
|
| 405 | {
|
| 406 | if(lynq_call_lists[id].used && (lynq_call_lists[id].call_id == call_id))
|
| 407 | {
|
| 408 | LYINFLOG("find id %d in local list, local idx is %d, addr is %s",call_id,id,lynq_call_lists[id].addr);
|
| 409 | return id;
|
| 410 | }
|
| 411 | }
|
| 412 | LYINFLOG("find id %d in local list , not found",call_id);
|
| 413 | return INVALID_ID;
|
| 414 | }
|
lh | 2582795 | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 415 | void sendSignalToWaitCallStateChange()
|
| 416 | {
|
lh | be92dd1 | 2022-04-19 06:01:25 -0700 | [diff] [blame] | 417 | LYINFLOG("send Signal To Wait Call State Change");
|
lh | 2582795 | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 418 | pthread_mutex_lock(&call_state_change_mutex);
|
| 419 | pthread_cond_signal(&call_state_change_cond);
|
| 420 | pthread_mutex_unlock(&call_state_change_mutex);
|
| 421 | }
|
| 422 | void sendSignalIncomingCall()
|
| 423 | {
|
lh | be92dd1 | 2022-04-19 06:01:25 -0700 | [diff] [blame] | 424 | LYINFLOG("send incoming call signal");
|
lh | 2582795 | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 425 | pthread_mutex_lock(&s_incoming_call_mutex);
|
| 426 | pthread_cond_signal(&s_incoming_call_cond);
|
| 427 | pthread_mutex_unlock(&s_incoming_call_mutex);
|
| 428 | }
|
| 429 |
|
| 430 | void addCallListToLynqCallList(lynq_call_list_e_t *callList, int call_id,int call_state,int toa,int direction,char addr[LYNQ_PHONE_NUMBER_MAX])
|
| 431 | {
|
| 432 | callList->call_id = call_id;
|
| 433 | callList->call_state = call_state;
|
| 434 | callList->toa = toa;
|
| 435 | callList->direction = direction;
|
| 436 | memcpy(callList->addr,addr,strlen(addr)+1);
|
| 437 | callList->used = 1;
|
lh | 2582795 | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 438 | return;
|
| 439 | }
|
| 440 |
|
| 441 | void *triggerGetCallList(void *parg)
|
ll | 375c94d | 2022-01-27 05:54:38 +0000 | [diff] [blame] | 442 | {
|
| 443 | int ret=0;
|
lh | be92dd1 | 2022-04-19 06:01:25 -0700 | [diff] [blame] | 444 | bool call_end;
|
ll | 375c94d | 2022-01-27 05:54:38 +0000 | [diff] [blame] | 445 | lynq_call_list_t call_list[LYNQ_CALL_MAX];
|
q.huang | 18d08bf | 2022-04-19 20:27:44 -0400 | [diff] [blame] | 446 | int update=0;
|
q.huang | 783ed5d | 2022-06-02 14:49:02 +0800 | [diff] [blame] | 447 | int cnt;
|
| 448 | int i,n;
|
| 449 |
|
lh | 2582795 | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 450 | while(call_list_loop)
|
ll | 375c94d | 2022-01-27 05:54:38 +0000 | [diff] [blame] | 451 | {
|
q.huang | 18d08bf | 2022-04-19 20:27:44 -0400 | [diff] [blame] | 452 | update=0;
|
ll | 375c94d | 2022-01-27 05:54:38 +0000 | [diff] [blame] | 453 | pthread_mutex_lock(&s_urc_call_state_change_mutex);
|
| 454 | pthread_cond_wait(&s_urc_call_state_change_cond, &s_urc_call_state_change_mutex);
|
q.huang | 783ed5d | 2022-06-02 14:49:02 +0800 | [diff] [blame] | 455 | LYDBGLOG("triggerGetCallList event!!!");
|
ll | 375c94d | 2022-01-27 05:54:38 +0000 | [diff] [blame] | 456 | memset(call_list,0,sizeof(call_list));
|
| 457 | ret = lynq_get_current_call_list(call_list);
|
| 458 | if(ret != 0)
|
| 459 | {
|
q.huang | 783ed5d | 2022-06-02 14:49:02 +0800 | [diff] [blame] | 460 | LYDBGLOG("get current call list failure!!!");
|
ll | 2210140 | 2022-04-11 05:49:51 +0000 | [diff] [blame] | 461 | continue;
|
ll | 375c94d | 2022-01-27 05:54:38 +0000 | [diff] [blame] | 462 | }
|
lh | be92dd1 | 2022-04-19 06:01:25 -0700 | [diff] [blame] | 463 | LYINFLOG("++++++++++++++triggerGetCallList++++++++++++++");
|
q.huang | 783ed5d | 2022-06-02 14:49:02 +0800 | [diff] [blame] | 464 | LYINFLOG("clear local index begin");
|
| 465 | cnt=0;
|
| 466 | for(i = 0;i < LYNQ_CALL_MAX;i++)
|
lh | 2582795 | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 467 | {
|
q.huang | 783ed5d | 2022-06-02 14:49:02 +0800 | [diff] [blame] | 468 | if(lynq_call_lists[i].used ==0)
|
| 469 | {
|
| 470 | continue;
|
| 471 | }
|
| 472 | cnt++;
|
| 473 | LYINFLOG("local idx is %d id is %d addr is %s state is %d direction is %d",i,lynq_call_lists[i].call_id,lynq_call_lists[i].addr,lynq_call_lists[i].call_state,lynq_call_lists[i].direction);
|
| 474 |
|
| 475 | if(lynq_call_lists[i].call_id > 0)
|
lh | be92dd1 | 2022-04-19 06:01:25 -0700 | [diff] [blame] | 476 | {
|
| 477 | call_end = 0;
|
q.huang | 783ed5d | 2022-06-02 14:49:02 +0800 | [diff] [blame] | 478 | for(n = 0; n < LYNQ_CALL_MAX; n++)
|
lh | be92dd1 | 2022-04-19 06:01:25 -0700 | [diff] [blame] | 479 | {
|
q.huang | 783ed5d | 2022-06-02 14:49:02 +0800 | [diff] [blame] | 480 | if(call_list[n].call_id == lynq_call_lists[i].call_id)
|
lh | be92dd1 | 2022-04-19 06:01:25 -0700 | [diff] [blame] | 481 | {
|
| 482 | call_end = 1;
|
q.huang | 783ed5d | 2022-06-02 14:49:02 +0800 | [diff] [blame] | 483 | LYINFLOG("find lynq call local idx %d, service idx %d id is %d!!!",i,n,lynq_call_lists[i].call_id);
|
| 484 | break;
|
lh | be92dd1 | 2022-04-19 06:01:25 -0700 | [diff] [blame] | 485 | }
|
| 486 | }
|
| 487 | if(call_end == 0)
|
| 488 | {
|
q.huang | 783ed5d | 2022-06-02 14:49:02 +0800 | [diff] [blame] | 489 | LYINFLOG("MT hungup,then clean call info local idx is %d id is %d",i, lynq_call_lists[i].call_id);
|
| 490 | cleanCallList(i);
|
lh | be92dd1 | 2022-04-19 06:01:25 -0700 | [diff] [blame] | 491 | }
|
| 492 | } //fix bug API-54
|
q.huang | 783ed5d | 2022-06-02 14:49:02 +0800 | [diff] [blame] | 493 | else
|
| 494 | {
|
| 495 | LYINFLOG("local id is 0");
|
| 496 | }
|
| 497 | }
|
| 498 | LYINFLOG("clear local index end, local used cnt is %d", cnt);
|
| 499 |
|
| 500 | LYINFLOG("add or update local index begin ");
|
| 501 | for (i = 0;i < LYNQ_CALL_MAX;i++)
|
| 502 | {
|
| 503 | if(call_list[i].call_id==0)
|
| 504 | {
|
| 505 | break;
|
| 506 | }
|
| 507 |
|
| 508 | LYINFLOG("servie idx %d begin: call_id=%d, call_state=%d, direction=%d, addr=%s, toa=%d",i,call_list[i].call_id, call_list[i].call_state,
|
| 509 | call_list[i].direction,call_list[i].addr,call_list[i].toa);
|
| 510 |
|
lh | 2582795 | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 511 | if(call_list[i].direction == 1)//MT call
|
| 512 | {
|
q.huang | 783ed5d | 2022-06-02 14:49:02 +0800 | [diff] [blame] | 513 | LYINFLOG("This is a MT CALL");
|
lh | 4256e1b | 2022-05-13 03:02:19 -0700 | [diff] [blame] | 514 | /*MT CALL state code
|
| 515 | **LYNQ_CALL_INCOMING = 4,
|
| 516 | **LYNQ_CALL_WAITING = 5,
|
| 517 | */
|
| 518 | if((call_list[i].call_state ==4) || (call_list[i].call_state ==5))
|
lh | 2582795 | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 519 | {
|
q.huang | 783ed5d | 2022-06-02 14:49:02 +0800 | [diff] [blame] | 520 | #ifdef ECALL_SUPPORT
|
| 521 | if(lynq_ecall_is_running())
|
lh | 2582795 | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 522 | {
|
q.huang | 783ed5d | 2022-06-02 14:49:02 +0800 | [diff] [blame] | 523 | lynq_call_hungup(&(call_list[i].call_id));
|
| 524 | continue;
|
lh | 2582795 | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 525 | }
|
q.huang | 783ed5d | 2022-06-02 14:49:02 +0800 | [diff] [blame] | 526 | #endif
|
| 527 | }
|
| 528 | /*you call me, and i call you,One party failed to dial*/
|
| 529 | n = find_call_id_with_addr(call_list[i].addr);
|
| 530 | if(n ==INVALID_ID)
|
| 531 | {
|
| 532 | n = addAddr(call_list[i].addr);
|
| 533 | updateCallList(&lynq_call_lists[n],call_list[i].call_id,call_list[i].call_state,call_list[i].toa,call_list[i].direction);
|
| 534 | lynqIncomingCallId = call_list[i].call_id;
|
| 535 | sendSignalIncomingCall();
|
| 536 | }
|
| 537 | else if(lynq_call_lists[n].call_state == call_list[i].call_state)
|
| 538 | {
|
| 539 | LYINFLOG("state not changed, state is %d ",call_list[i].call_state);
|
| 540 | if(call_list[i].call_state ==4 || call_list[i].call_state ==5)
|
lh | be92dd1 | 2022-04-19 06:01:25 -0700 | [diff] [blame] | 541 | {
|
lh | be92dd1 | 2022-04-19 06:01:25 -0700 | [diff] [blame] | 542 | /*if call state not change,Maybe this call was ignored, so we need to continue to inform the user of
|
| 543 | **an incoming call until the status changes.
|
| 544 | **fix bug API-54
|
| 545 | */
|
q.huang | 783ed5d | 2022-06-02 14:49:02 +0800 | [diff] [blame] | 546 | LYINFLOG("resend incoming call signal");
|
| 547 | sendSignalIncomingCall();
|
lh | be92dd1 | 2022-04-19 06:01:25 -0700 | [diff] [blame] | 548 | }
|
lh | 2582795 | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 549 | }
|
q.huang | 783ed5d | 2022-06-02 14:49:02 +0800 | [diff] [blame] | 550 | else
|
ll | 45d3ea9 | 2022-03-24 10:22:25 +0800 | [diff] [blame] | 551 | {
|
q.huang | 783ed5d | 2022-06-02 14:49:02 +0800 | [diff] [blame] | 552 | LYINFLOG("state changed from %d to %d",lynq_call_lists[n].call_state,call_list[i].call_state);
|
| 553 |
|
| 554 | updateCallList(&lynq_call_lists[n],call_list[i].call_id,call_list[i].call_state,call_list[i].toa,call_list[i].direction);
|
| 555 | }
|
lh | 2582795 | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 556 | }
|
| 557 | else
|
q.huang | 783ed5d | 2022-06-02 14:49:02 +0800 | [diff] [blame] | 558 | {
|
| 559 | LYINFLOG("This is a MO CALL");
|
| 560 | call_end = 0;
|
| 561 | for(n = 0 ; n < LYNQ_CALL_MAX; n++)
|
lh | 2582795 | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 562 | {
|
q.huang | 783ed5d | 2022-06-02 14:49:02 +0800 | [diff] [blame] | 563 | if(lynq_call_lists[n].used && ((strcmp(call_list[i].addr,lynq_call_lists[n].addr)==0)||(call_list[i].call_id==lynq_call_lists[n].call_id)))
|
lh | 2582795 | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 564 | {
|
q.huang | 783ed5d | 2022-06-02 14:49:02 +0800 | [diff] [blame] | 565 | if(lynq_call_lists[n].call_id==0)
|
| 566 | {
|
| 567 | LYINFLOG("add a call id");
|
| 568 | update=1;
|
| 569 | }
|
| 570 | LYINFLOG("local idx %d updated, original call id is %d origial addr is %s original state is %d",n,lynq_call_lists[n].call_id,lynq_call_lists[n].addr,lynq_call_lists[n].call_state);
|
| 571 | updateCallList(&lynq_call_lists[n],call_list[i].call_id,call_list[i].call_state,call_list[i].toa,call_list[i].direction);
|
| 572 | call_end = 1;
|
| 573 | break;
|
| 574 | }
|
| 575 | }
|
| 576 |
|
| 577 | if(call_end == 0)
|
| 578 | {
|
| 579 | LYINFLOG("need to hangup id %d", call_list[i].call_id);
|
| 580 | #ifdef ECALL_SUPPORT
|
| 581 | if(is_ecall_dial==1)
|
| 582 | {
|
| 583 | LYINFLOG("ecall is dialing, for the timebeing, don't huangup");
|
lh | 2582795 | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 584 | continue;
|
| 585 | }
|
q.huang | 783ed5d | 2022-06-02 14:49:02 +0800 | [diff] [blame] | 586 | #endif
|
| 587 | LYINFLOG("hang up service call id %d",call_list[i].call_id);
|
| 588 | lynq_call_hungup(&(call_list[i].call_id));
|
lh | 2582795 | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 589 | }
|
lh | 2582795 | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 590 | }
|
q.huang | 783ed5d | 2022-06-02 14:49:02 +0800 | [diff] [blame] | 591 | LYDBGLOG("servie idx %d end",i);
|
ll | 375c94d | 2022-01-27 05:54:38 +0000 | [diff] [blame] | 592 | }
|
q.huang | 783ed5d | 2022-06-02 14:49:02 +0800 | [diff] [blame] | 593 | LYINFLOG("add or update local index end ");
|
lh | a35d4ee | 2022-01-25 18:47:39 -0800 | [diff] [blame] | 594 | s_call_urc_event_complete = 1;
|
q.huang | 783ed5d | 2022-06-02 14:49:02 +0800 | [diff] [blame] | 595 | if(isDial==1)
|
lh | 2582795 | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 596 | {
|
q.huang | 783ed5d | 2022-06-02 14:49:02 +0800 | [diff] [blame] | 597 | LYINFLOG("now is dialing");
|
| 598 | if(update==1)
|
| 599 | {
|
| 600 | LYINFLOG("find added call");
|
| 601 | sendSignalToWaitCallStateChange();
|
| 602 | isDial = 0;
|
| 603 | }
|
| 604 | else
|
| 605 | {
|
| 606 | LYINFLOG("not find added call");
|
| 607 | }
|
| 608 | }
|
| 609 | else
|
| 610 | {
|
| 611 | LYINFLOG("now is not dialing");
|
lh | 2582795 | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 612 | }
|
ll | 375c94d | 2022-01-27 05:54:38 +0000 | [diff] [blame] | 613 | pthread_mutex_unlock(&s_urc_call_state_change_mutex);
|
| 614 | }
|
| 615 | return NULL;
|
lh | 2582795 | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 616 | }
|
| 617 |
|
| 618 | void lynqRespWatingEvent()
|
ll | 375c94d | 2022-01-27 05:54:38 +0000 | [diff] [blame] | 619 | {
|
| 620 | if(s_call_urc_event_complete==1)
|
| 621 | {
|
| 622 | pthread_mutex_lock(&s_urc_call_state_change_mutex);
|
| 623 | pthread_cond_signal(&s_urc_call_state_change_cond);
|
| 624 | s_call_urc_event_complete = 0;
|
| 625 | pthread_mutex_unlock(&s_urc_call_state_change_mutex);
|
lh | 2582795 | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 626 | }
|
ll | 375c94d | 2022-01-27 05:54:38 +0000 | [diff] [blame] | 627 | return;
|
lh | 2582795 | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 628 | }
|
| 629 |
|
| 630 | /*Warren add for T800 platform 2021/11/19 start*/
|
| 631 | int lynq_socket_client_start()
|
rjw | 8bdc56b | 2022-02-28 15:01:49 +0800 | [diff] [blame] | 632 | {
|
| 633 | #if 0
|
lh | 2582795 | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 634 | struct sockaddr_in lynq_socket_server_addr;
|
| 635 | /* init lynq_socket_server_addr */
|
| 636 | bzero(&lynq_socket_server_addr, sizeof(lynq_socket_server_addr));
|
| 637 | lynq_socket_server_addr.sin_family = AF_INET;
|
| 638 | lynq_socket_server_addr.sin_port = htons(LYNQ_SERVICE_PORT);
|
| 639 | lynq_socket_server_addr.sin_addr.s_addr = htons(INADDR_ANY);
|
rjw | 8bdc56b | 2022-02-28 15:01:49 +0800 | [diff] [blame] | 640 |
|
lh | 2582795 | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 641 | /*
|
| 642 | if(inet_pton(AF_INET,"127.0.0.1", &lynq_socket_server_addr.sin_addr) <= 0)
|
| 643 | {
|
q.huang | 783ed5d | 2022-06-02 14:49:02 +0800 | [diff] [blame] | 644 | LYDBGLOG("[%s] is not a valid IPaddress", argv[1]);
|
lh | 2582795 | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 645 | exit(1);
|
| 646 | }
|
| 647 | */
|
lh | a35d4ee | 2022-01-25 18:47:39 -0800 | [diff] [blame] | 648 | lynq_call_client_sockfd = socket(AF_INET, SOCK_DGRAM, 0);
|
| 649 | if(connect(lynq_call_client_sockfd, (struct sockaddr *)&lynq_socket_server_addr, sizeof(lynq_socket_server_addr)) == -1)
|
lh | 2582795 | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 650 | {
|
q.huang | 783ed5d | 2022-06-02 14:49:02 +0800 | [diff] [blame] | 651 | LYERRLOG("connect error");
|
lh | 2582795 | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 652 | return -1;
|
| 653 | }
|
rjw | 8bdc56b | 2022-02-28 15:01:49 +0800 | [diff] [blame] | 654 | #endif
|
| 655 | lynq_call_client_sockfd = socket(AF_INET, SOCK_DGRAM, 0);
|
| 656 | if (-1 == lynq_call_client_sockfd)
|
| 657 | {
|
| 658 | return lynq_call_client_sockfd;
|
| 659 | }
|
| 660 | /* 设置address */
|
| 661 | memset(&addr_serv, 0, sizeof(addr_serv));
|
| 662 | addr_serv.sin_family = AF_INET;
|
| 663 | addr_serv.sin_addr.s_addr = inet_addr(DSET_IP_ADDRESS);
|
| 664 | addr_serv.sin_port = htons(LYNQ_SERVICE_PORT);
|
| 665 | len_addr_serv = sizeof(addr_serv);
|
lh | 2582795 | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 666 | return 0;
|
| 667 | }
|
| 668 | int lynq_update_call_list_loop()
|
| 669 | {
|
| 670 | int ret = 0;
|
lh | 2582795 | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 671 | pthread_attr_t attr;
|
| 672 | pthread_attr_init(&attr);
|
| 673 | pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED);
|
lh | cdf816a | 2022-02-13 23:56:05 -0800 | [diff] [blame] | 674 | ret = pthread_create(&lynq_call_list_loop_tid,&attr,triggerGetCallList,NULL);
|
lh | 2582795 | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 675 | if(ret < 0)
|
| 676 | {
|
| 677 | LYERRLOG("lynq_update_call_list_loop fail!!!");
|
| 678 | return -1;
|
| 679 | }
|
q.huang | 783ed5d | 2022-06-02 14:49:02 +0800 | [diff] [blame] | 680 | LYDBGLOG("lynq_update_call_list_loop success!!!");
|
lh | 2582795 | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 681 | return 0;
|
| 682 |
|
| 683 | }
|
q.huang | 783ed5d | 2022-06-02 14:49:02 +0800 | [diff] [blame] | 684 |
|
lh | 2582795 | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 685 | void *thread_urc_recv(void *parg)
|
ll | 375c94d | 2022-01-27 05:54:38 +0000 | [diff] [blame] | 686 | {
|
lh | 2582795 | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 687 | int socket_fd = (int64_t)parg;
|
| 688 | int len=0;
|
| 689 | socklen_t addr_len=0;
|
| 690 | uint8_t *dataLength = NULL;
|
| 691 | char urc_data[LYNQ_REC_BUF];
|
| 692 | int slot_id = -1;
|
| 693 | int resp_type = -1;
|
| 694 | int urcid = -1;
|
| 695 | Parcel *p = NULL;
|
| 696 | struct sockaddr_in dest_addr;
|
q.huang | 18d08bf | 2022-04-19 20:27:44 -0400 | [diff] [blame] | 697 | #ifdef ECALL_SUPPORT
|
q.huang | 783ed5d | 2022-06-02 14:49:02 +0800 | [diff] [blame] | 698 | int ecall_ind;
|
| 699 | int ecallId;
|
| 700 | int unused_callid;
|
q.huang | 18d08bf | 2022-04-19 20:27:44 -0400 | [diff] [blame] | 701 | #endif
|
| 702 |
|
q.huang | 783ed5d | 2022-06-02 14:49:02 +0800 | [diff] [blame] | 703 | LYINFLOG("thread_urc_recv in running....");
|
lh | a35d4ee | 2022-01-25 18:47:39 -0800 | [diff] [blame] | 704 | while(urc_call_recive_status)
|
lh | 2582795 | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 705 | {
|
| 706 | bzero(urc_data,LYNQ_REC_BUF);
|
| 707 | //get data msg
|
| 708 | len = recvfrom(socket_fd,urc_data,LYNQ_REC_BUF,0,(struct sockaddr *)&dest_addr,&addr_len);
|
| 709 | if(len <= 0)
|
ll | 375c94d | 2022-01-27 05:54:38 +0000 | [diff] [blame] | 710 | {
|
q.huang | 783ed5d | 2022-06-02 14:49:02 +0800 | [diff] [blame] | 711 | LYERRLOG("thread_urc_recv step2 fail");
|
ll | 375c94d | 2022-01-27 05:54:38 +0000 | [diff] [blame] | 712 | break;
|
lh | 2582795 | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 713 | }
|
q.huang | 783ed5d | 2022-06-02 14:49:02 +0800 | [diff] [blame] | 714 | LYDBGLOG("=====>urc data len<=====:%d",len);
|
lh | 2582795 | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 715 | p = new Parcel();
|
| 716 | if(p==NULL)
|
| 717 | {
|
lh | 59e0d00 | 2022-01-27 00:27:12 -0800 | [diff] [blame] | 718 | LYERRLOG("new parcel failure!!!");
|
lh | 2582795 | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 719 | break;
|
| 720 | }
|
| 721 | p->setData((uint8_t *)urc_data,len); // p.setData((uint8_t *) buffer, buflen);
|
| 722 | p->setDataPosition(0);
|
| 723 | if(p->dataAvail() > 0)
|
| 724 | {
|
| 725 | p->readInt32(&resp_type);
|
| 726 | p->readInt32(&urcid);
|
| 727 | p->readInt32(&slot_id);
|
q.huang | 783ed5d | 2022-06-02 14:49:02 +0800 | [diff] [blame] | 728 | //LYDBGLOG("*******Warren test*******:resp_type=%d,urcid=%d,slot_id=%d",resp_type,urcid,slot_id);
|
lh | 2582795 | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 729 | switch (urcid)
|
| 730 | {
|
| 731 | case 1001://RIL_UNSOL_RESPONSE_CALL_STATE_CHANGED
|
| 732 | {
|
q.huang | 783ed5d | 2022-06-02 14:49:02 +0800 | [diff] [blame] | 733 | LYINFLOG("**************:resp_type=%d,urcid=%d,slot_id=%d",resp_type,urcid,slot_id);
|
lh | 2582795 | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 734 | lynqRespWatingEvent();
|
| 735 | break;
|
| 736 | }
|
| 737 | case 1018://RIL_UNSOL_CALL_RING
|
| 738 | {
|
| 739 | if(global_call_auto_answer==1)
|
| 740 | {
|
| 741 | lynq_call_answer();
|
| 742 | }
|
| 743 | break;
|
| 744 | }
|
| 745 | case 1029://RIL_UNSOL_RINGBACK_TONE
|
| 746 | case 3049://RIL_UNSOL_CALL_INFO_INDICATION
|
| 747 | {
|
q.huang | 783ed5d | 2022-06-02 14:49:02 +0800 | [diff] [blame] | 748 | LYINFLOG("**************:resp_type=%d,urcid=%d,slot_id=%d",resp_type,urcid,slot_id);
|
lh | 2582795 | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 749 | break;
|
| 750 | }
|
q.huang | 18d08bf | 2022-04-19 20:27:44 -0400 | [diff] [blame] | 751 | #ifdef ECALL_SUPPORT
|
| 752 | case RIL_UNSOL_ECALL_INDICATIONS:
|
| 753 | {
|
q.huang | 783ed5d | 2022-06-02 14:49:02 +0800 | [diff] [blame] | 754 | p->readInt32(&ecall_ind);
|
| 755 | g_lynqIncomingEcallIndication = ecall_ind;
|
| 756 | p->readInt32(&ecallId);
|
| 757 | LYINFLOG("**************:RIL_UNSOL_ECALL_INDICATIONS ,Id %d, ind %d, ecall dialing is %d, normal dialing is %d, local ecall id is %d",ecallId,ecall_ind,is_ecall_dial,isDial,g_ecallId);
|
| 758 | if(lynq_is_msd_suc(g_lynqIncomingEcallIndication))
|
| 759 | {
|
| 760 | if(is_ecall_dial)
|
| 761 | {
|
| 762 | LYINFLOG("ecall is dialing, recv suc indication");
|
| 763 | is_ecall_dial=0;
|
| 764 | if(ecallId >0 && find_call_id_with_call_id(ecallId)==INVALID_ID)
|
| 765 | {
|
| 766 | LYINFLOG("add ecall in loacl list");
|
| 767 | g_ecallId = ecallId;
|
| 768 | unused_callid=addAddr("ecall");
|
| 769 | lynq_call_lists[unused_callid].call_id=g_ecallId;
|
| 770 | }
|
q.huang | 18d08bf | 2022-04-19 20:27:44 -0400 | [diff] [blame] | 771 | sendSignalToWaitCallStateChange();
|
q.huang | 783ed5d | 2022-06-02 14:49:02 +0800 | [diff] [blame] | 772 | }
|
| 773 | else if(ecallId >0 && (find_call_id_with_call_id(ecallId)==INVALID_ID)){
|
| 774 | LYERRLOG("ecall is not in dialing and first recv suc indication, hangup");
|
| 775 | lynq_call_hungup(&ecallId);
|
| 776 | }
|
| 777 | else
|
| 778 | {
|
| 779 | LYERRLOG("ecall is not in dialing and not first recv suc indication");
|
| 780 | }
|
| 781 | }
|
| 782 | else if (LYNQ_ECALL_PSAP_CALLBACK_START == g_lynqIncomingEcallIndication)
|
| 783 | {
|
| 784 | if(lynq_ecall_is_running()==0)
|
| 785 | {
|
| 786 | LYINFLOG("ecall is not running, recv psap call back msd start, set ecall in dialing");
|
q.huang | 755b325 | 2022-06-06 16:52:13 +0800 | [diff] [blame] | 787 | if(find_call_id_with_call_id(ecallId)!=INVALID_ID)
|
q.huang | 783ed5d | 2022-06-02 14:49:02 +0800 | [diff] [blame] | 788 | {
|
q.huang | 755b325 | 2022-06-06 16:52:13 +0800 | [diff] [blame] | 789 | g_ecallId = ecallId;
|
| 790 | if(isDial)
|
| 791 | {
|
| 792 | LYINFLOG("stop normal dial");
|
| 793 | sendSignalToWaitCallStateChange();
|
| 794 | }
|
| 795 | else
|
| 796 | {
|
| 797 | LYINFLOG("no normal dial");
|
| 798 | }
|
q.huang | 783ed5d | 2022-06-02 14:49:02 +0800 | [diff] [blame] | 799 | }
|
| 800 | else
|
| 801 | {
|
q.huang | 755b325 | 2022-06-06 16:52:13 +0800 | [diff] [blame] | 802 | LYERRLOG("can't find ecall id in local list");
|
q.huang | 783ed5d | 2022-06-02 14:49:02 +0800 | [diff] [blame] | 803 | }
|
| 804 | }
|
| 805 | else
|
| 806 | {
|
| 807 | LYERRLOG("ecall is running, recv psap call back msd start");
|
| 808 | }
|
| 809 | }
|
| 810 | else if (LYNQ_ECALL_ABNORMAL_HANGUP == g_lynqIncomingEcallIndication)
|
| 811 | {
|
| 812 | if(is_ecall_dial==0)
|
| 813 | {
|
| 814 | LYERRLOG("ecall is not in dialing, recv abnormal hangup");
|
| 815 | g_ecallId = INVALID_ID;
|
| 816 | }
|
| 817 | else
|
| 818 | {
|
| 819 | LYINFLOG("ecall is in dialing, recv abnormal hangup");
|
| 820 | }
|
| 821 | }
|
| 822 | else if (LYNQ_ECALL_DISCONNECTED == g_lynqIncomingEcallIndication ||
|
| 823 | LYNQ_ECALL_REDIAL_TIMER_OUT == g_lynqIncomingEcallIndication ||
|
| 824 | LYNQ_ECALL_T2_TIMER_OUT == g_lynqIncomingEcallIndication)
|
| 825 | {
|
| 826 | g_ecallId = INVALID_ID;
|
| 827 | if(is_ecall_dial)
|
| 828 | {
|
| 829 | LYERRLOG("ecall is in dialing, recv like disconnect indication");
|
| 830 | is_ecall_dial=0;
|
| 831 | sendSignalToWaitCallStateChange();
|
| 832 | }
|
| 833 | else
|
| 834 | {
|
| 835 | LYINFLOG("ecall is not in dialing, recv like disconnect indication");
|
| 836 | }
|
| 837 | }
|
| 838 | else
|
| 839 | {
|
| 840 | LYINFLOG("not special indication");
|
| 841 | }
|
q.huang | 18d08bf | 2022-04-19 20:27:44 -0400 | [diff] [blame] | 842 | sendSignalIncomingECallEvent();
|
q.huang | 783ed5d | 2022-06-02 14:49:02 +0800 | [diff] [blame] | 843 | LYINFLOG("**************:RIL_UNSOL_ECALL_INDICATIONS, local ecall id is %d", g_ecallId);
|
q.huang | 18d08bf | 2022-04-19 20:27:44 -0400 | [diff] [blame] | 844 | break;
|
| 845 | }
|
| 846 | #endif
|
lh | 2582795 | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 847 | default:
|
| 848 | break;
|
| 849 | }
|
| 850 | }
|
| 851 | delete p;
|
| 852 | p = NULL;
|
| 853 | }
|
| 854 | close(socket_fd);
|
| 855 | }
|
| 856 | int lynq_socket_urc_start()
|
| 857 | {
|
| 858 | int socket_fd=0;
|
| 859 | int rt=0;
|
| 860 | int len=0;
|
| 861 | int on=1;
|
| 862 | struct sockaddr_in urc_local_addr;
|
lh | 2582795 | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 863 | pthread_attr_t attr;
|
ll | 375c94d | 2022-01-27 05:54:38 +0000 | [diff] [blame] | 864 | socket_fd = socket(AF_INET,SOCK_DGRAM,0);
|
ll | 375c94d | 2022-01-27 05:54:38 +0000 | [diff] [blame] | 865 | if(socket_fd < 0)
|
| 866 | {
|
q.huang | 783ed5d | 2022-06-02 14:49:02 +0800 | [diff] [blame] | 867 | LYERRLOG("creaet socket for udp fail");
|
ll | 375c94d | 2022-01-27 05:54:38 +0000 | [diff] [blame] | 868 | return -1;
|
lh | 2582795 | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 869 | }
|
| 870 | urc_local_addr.sin_family = AF_INET;
|
| 871 | urc_local_addr.sin_port = htons(LYNQ_URC_SERVICE_PORT);
|
| 872 | urc_local_addr.sin_addr.s_addr = htons(INADDR_ANY);
|
| 873 | /* Set socket to allow reuse of address and port, SO_REUSEADDR value is 2*/
|
ll | 375c94d | 2022-01-27 05:54:38 +0000 | [diff] [blame] | 874 | rt = setsockopt(socket_fd,SOL_SOCKET,SO_REUSEADDR,&on,sizeof on);
|
| 875 | if(rt<0)
|
| 876 | {
|
q.huang | 783ed5d | 2022-06-02 14:49:02 +0800 | [diff] [blame] | 877 | LYERRLOG("SO_REUSEADDR fail");
|
lh | 2582795 | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 878 | return -1;
|
| 879 | }
|
| 880 | rt = bind(socket_fd ,(struct sockaddr*)&urc_local_addr, sizeof(urc_local_addr));
|
ll | 375c94d | 2022-01-27 05:54:38 +0000 | [diff] [blame] | 881 | if (rt == -1)
|
| 882 | {
|
lh | 59e0d00 | 2022-01-27 00:27:12 -0800 | [diff] [blame] | 883 | LYERRLOG("bind failed");
|
ll | 375c94d | 2022-01-27 05:54:38 +0000 | [diff] [blame] | 884 | return -1;
|
lh | 2582795 | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 885 | }
|
| 886 | pthread_attr_init(&attr);
|
| 887 | pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED);
|
lh | cdf816a | 2022-02-13 23:56:05 -0800 | [diff] [blame] | 888 | rt = pthread_create(&lynq_call_urc_tid,&attr,thread_urc_recv,(void *)socket_fd);
|
lh | 2582795 | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 889 | if(rt < 0)
|
| 890 | {
|
q.huang | 783ed5d | 2022-06-02 14:49:02 +0800 | [diff] [blame] | 891 | LYERRLOG("urc loop failure!!!");
|
lh | 2582795 | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 892 | return -1;
|
| 893 | }
|
q.huang | 783ed5d | 2022-06-02 14:49:02 +0800 | [diff] [blame] | 894 | LYDBGLOG("urc loop success!!!");
|
lh | 2582795 | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 895 | return 0;
|
| 896 | }
|
| 897 | int getSelfElement(char addr[])
|
| 898 | {
|
| 899 | for(int i=0;i < LYNQ_CALL_MAX; i++)
|
| 900 | {
|
| 901 | if(lynq_call_lists[i].used==1)
|
| 902 | {
|
| 903 | if(strcmp(lynq_call_lists[i].addr,addr)==0)
|
| 904 | {
|
| 905 | return i;
|
| 906 | }
|
| 907 |
|
| 908 | }
|
| 909 | }
|
| 910 | return -1;
|
| 911 | }
|
| 912 |
|
| 913 | void lynq_call_state_change_test(int soc_id)
|
| 914 | {
|
q.huang | 783ed5d | 2022-06-02 14:49:02 +0800 | [diff] [blame] | 915 | LYDBGLOG("call state change,sim:%d",soc_id);
|
lh | 2582795 | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 916 | }
|
| 917 | int lynq_init_call(int uToken)
|
ll | 1343a5b | 2022-03-17 05:31:33 +0000 | [diff] [blame] | 918 | {
|
| 919 | if(g_lynq_call_init_flag == 1){
|
| 920 | LYDBGLOG("lynq init call failed!!!");
|
| 921 | return -1;
|
| 922 | }
|
| 923 | g_lynq_call_init_flag = 1;
|
lh | 2582795 | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 924 | int result = 0;
|
lh | a35d4ee | 2022-01-25 18:47:39 -0800 | [diff] [blame] | 925 | Global_uToken_call = uToken;
|
lh | 59e0d00 | 2022-01-27 00:27:12 -0800 | [diff] [blame] | 926 | urc_call_recive_status = 1;
|
rjw | 8bdc56b | 2022-02-28 15:01:49 +0800 | [diff] [blame] | 927 | client_size = sizeof(client_t);
|
lh | 2582795 | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 928 | LYLOGSET(LOG_INFO);
|
| 929 | LYLOGEINIT(USER_LOG_TAG);
|
| 930 | result = lynq_socket_client_start();
|
| 931 | if(result!=0)
|
| 932 | {
|
| 933 | return -1;
|
| 934 | }
|
| 935 | result = lynq_socket_urc_start();
|
| 936 | if(result!=0)
|
| 937 | {
|
| 938 | return -1;
|
| 939 | }
|
| 940 | result = lynq_update_call_list_loop();
|
| 941 | if(result!=0)
|
| 942 | {
|
| 943 | return -1;
|
| 944 | }
|
| 945 | memset(lynq_call_lists,0,sizeof(lynq_call_lists));
|
| 946 | LYDBGLOG("lynq init call success!!!");
|
| 947 | return 0;
|
| 948 | }
|
| 949 | int lynq_deinit_call()
|
| 950 | {
|
q.huang | 783ed5d | 2022-06-02 14:49:02 +0800 | [diff] [blame] | 951 | int ret;
|
ll | 1343a5b | 2022-03-17 05:31:33 +0000 | [diff] [blame] | 952 | if(g_lynq_call_init_flag == 0)
|
lh | cdf816a | 2022-02-13 23:56:05 -0800 | [diff] [blame] | 953 | {
|
ll | 1343a5b | 2022-03-17 05:31:33 +0000 | [diff] [blame] | 954 | LYDBGLOG("lynq_deinit_call failed!!!");
|
| 955 | return -1;
|
lh | cdf816a | 2022-02-13 23:56:05 -0800 | [diff] [blame] | 956 | }
|
ll | 1343a5b | 2022-03-17 05:31:33 +0000 | [diff] [blame] | 957 | else
|
| 958 | {
|
| 959 | g_lynq_call_init_flag = 0;
|
q.huang | 783ed5d | 2022-06-02 14:49:02 +0800 | [diff] [blame] | 960 | lynq_call_hungup_all();
|
ll | 1343a5b | 2022-03-17 05:31:33 +0000 | [diff] [blame] | 961 | if(lynq_call_client_sockfd>0)
|
| 962 | {
|
| 963 | close(lynq_call_client_sockfd);
|
| 964 | }
|
| 965 | urc_call_recive_status = 0;
|
| 966 | call_list_loop = 0;
|
| 967 | if(lynq_call_urc_tid == -1 || lynq_call_list_loop_tid == -1)
|
| 968 | {
|
| 969 | return -1;
|
| 970 | }
|
| 971 | ret = pthread_cancel(lynq_call_urc_tid);
|
| 972 | LYDBGLOG("pthread cancel ret = %d",ret);
|
| 973 | ret = pthread_cancel(lynq_call_list_loop_tid);
|
| 974 | LYDBGLOG("pthread cancel ret = %d",ret);
|
| 975 | ret = pthread_join(lynq_call_urc_tid,NULL);
|
| 976 | LYDBGLOG("pthread join ret = %d",ret);
|
| 977 | ret = pthread_join(lynq_call_list_loop_tid,NULL);
|
| 978 | LYDBGLOG("pthread join ret = %d",ret);
|
| 979 | return 0;
|
| 980 | }
|
rita | 47debb9 | 2022-04-07 06:08:13 -0400 | [diff] [blame] | 981 | }
|
q.huang | fe1b405 | 2022-04-18 00:09:50 -0400 | [diff] [blame] | 982 |
|
| 983 | int lynq_set_common_request(int request_id, int argc, const char* format,...)
|
rita | 9b436d8 | 2022-04-07 01:55:39 -0400 | [diff] [blame] | 984 | {
|
| 985 | Parcel p;
|
| 986 | lynq_client_t client;
|
| 987 | int resp_type = -1;
|
| 988 | int request = -1;
|
| 989 | int slot_id = -1;
|
| 990 | int error = -1;
|
rita | 9b436d8 | 2022-04-07 01:55:39 -0400 | [diff] [blame] | 991 |
|
| 992 | client.uToken = Global_uToken_call;
|
q.huang | fe1b405 | 2022-04-18 00:09:50 -0400 | [diff] [blame] | 993 | client.request = request_id;
|
| 994 | client.paramLen = argc;
|
rita | 9b436d8 | 2022-04-07 01:55:39 -0400 | [diff] [blame] | 995 | bzero(client.param,LYNQ_REQUEST_PARAM_BUF);
|
q.huang | fe1b405 | 2022-04-18 00:09:50 -0400 | [diff] [blame] | 996 | if(argc!=0)
|
| 997 | {
|
| 998 | va_list args;
|
| 999 | va_start(args, format);
|
| 1000 | vsnprintf(client.param, LYNQ_REQUEST_PARAM_BUF, format, args);
|
| 1001 | va_end(args);
|
| 1002 | }
|
q.huang | 783ed5d | 2022-06-02 14:49:02 +0800 | [diff] [blame] | 1003 | LYINFLOG("uToken=%d,request=%d,paralen=%d,param=%s",client.uToken,client.request,client.paramLen,client.param);
|
rita | 9b436d8 | 2022-04-07 01:55:39 -0400 | [diff] [blame] | 1004 | if(send_request(lynq_call_client_sockfd,&client)==-1)
|
| 1005 | {
|
| 1006 | LYERRLOG("send request fail");
|
| 1007 | return -1;
|
| 1008 | }
|
q.huang | fe1b405 | 2022-04-18 00:09:50 -0400 | [diff] [blame] | 1009 | if(get_response(lynq_call_client_sockfd,p)==0)
|
| 1010 | {
|
| 1011 | JumpHeader(p,&resp_type,&request,&slot_id,&error);
|
| 1012 | LYINFLOG("resp_type=%d,request=%d,slot_id=%d,error_code=%d",resp_type,request,slot_id,error);
|
| 1013 | }
|
rita | 9b436d8 | 2022-04-07 01:55:39 -0400 | [diff] [blame] | 1014 | return error;
|
| 1015 | }
|
| 1016 |
|
q.huang | fe1b405 | 2022-04-18 00:09:50 -0400 | [diff] [blame] | 1017 | int lynq_get_common_request(int request_id, int* status)
|
rita | 9b436d8 | 2022-04-07 01:55:39 -0400 | [diff] [blame] | 1018 | {
|
| 1019 | Parcel p;
|
| 1020 | lynq_client_t client;
|
| 1021 | int resp_type = -1;
|
| 1022 | int request = -1;
|
| 1023 | int slot_id = -1;
|
| 1024 | int error = -1;
|
q.huang | fe1b405 | 2022-04-18 00:09:50 -0400 | [diff] [blame] | 1025 | if(status==NULL)
|
| 1026 | {
|
| 1027 | LYERRLOG("status is null");
|
| 1028 | return -1;
|
| 1029 | }
|
rita | 9b436d8 | 2022-04-07 01:55:39 -0400 | [diff] [blame] | 1030 | client.uToken = Global_uToken_call;
|
q.huang | fe1b405 | 2022-04-18 00:09:50 -0400 | [diff] [blame] | 1031 | client.request = request_id;
|
| 1032 | client.paramLen = 0;
|
rita | 9b436d8 | 2022-04-07 01:55:39 -0400 | [diff] [blame] | 1033 | bzero(client.param,LYNQ_REQUEST_PARAM_BUF);
|
q.huang | 783ed5d | 2022-06-02 14:49:02 +0800 | [diff] [blame] | 1034 | LYINFLOG("uToken=%d,request=%d,paralen=%d,param=%s",client.uToken,client.request,client.paramLen,client.param);
|
rita | 9b436d8 | 2022-04-07 01:55:39 -0400 | [diff] [blame] | 1035 | if(send_request(lynq_call_client_sockfd,&client)==-1)
|
| 1036 | {
|
| 1037 | LYERRLOG("send request fail");
|
| 1038 | return -1;
|
| 1039 | }
|
q.huang | fe1b405 | 2022-04-18 00:09:50 -0400 | [diff] [blame] | 1040 | if(get_response(lynq_call_client_sockfd,p)==0)
|
rita | 9b436d8 | 2022-04-07 01:55:39 -0400 | [diff] [blame] | 1041 | {
|
q.huang | fe1b405 | 2022-04-18 00:09:50 -0400 | [diff] [blame] | 1042 | JumpHeader(p,&resp_type,&request,&slot_id,&error);
|
| 1043 | p.readInt32(status);
|
| 1044 | LYINFLOG("resp_type=%d,request=%d,slot_id=%d,error_code=%d",resp_type,request,slot_id,error);
|
rita | 9b436d8 | 2022-04-07 01:55:39 -0400 | [diff] [blame] | 1045 | }
|
rita | 9b436d8 | 2022-04-07 01:55:39 -0400 | [diff] [blame] | 1046 | return error;
|
| 1047 | }
|
| 1048 |
|
lh | 2582795 | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 1049 | int lynq_call(int* handle,char addr[])
|
| 1050 | {
|
| 1051 | Parcel p;
|
| 1052 | lynq_client_t client;
|
| 1053 | int resp_type = -1;
|
| 1054 | int request = -1;
|
| 1055 | int slot_id = -1;
|
| 1056 | int error = -1;
|
| 1057 | int lynq_call_id = -1;
|
q.huang | 783ed5d | 2022-06-02 14:49:02 +0800 | [diff] [blame] | 1058 |
|
| 1059 | LYINFLOG("lynq_call begin addr %s",addr);
|
lh | 2582795 | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 1060 | if(addr==NULL)
|
| 1061 | {
|
| 1062 | LYERRLOG("Phone num is null!!!");
|
| 1063 | return -1;
|
| 1064 | }
|
q.huang | 783ed5d | 2022-06-02 14:49:02 +0800 | [diff] [blame] | 1065 |
|
| 1066 | if(find_call_id_with_addr(addr)!=INVALID_ID)
|
| 1067 | {
|
| 1068 | LYERRLOG("addr %s exists",addr);
|
| 1069 | return LYNQ_E_CONFLICT;
|
| 1070 | }
|
| 1071 |
|
| 1072 | #ifdef ECALL_SUPPORT
|
| 1073 | if(lynq_ecall_is_running())
|
| 1074 | {
|
| 1075 | LYERRLOG("lynq_fast_ecall ecall is running");
|
| 1076 | return LYNQ_E_ECALL_BEING_RUNNING;
|
| 1077 | }
|
| 1078 | #endif
|
| 1079 |
|
lh | a35d4ee | 2022-01-25 18:47:39 -0800 | [diff] [blame] | 1080 | client.uToken = Global_uToken_call;
|
lh | 2582795 | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 1081 | client.request = 10;//RIL_REQUEST_DIAL
|
| 1082 | client.paramLen = 2;
|
| 1083 | bzero(client.param,LYNQ_REQUEST_PARAM_BUF);
|
| 1084 | memcpy(client.param,addr,strlen(addr)+1);
|
| 1085 | strcat(client.param," 0");
|
q.huang | 783ed5d | 2022-06-02 14:49:02 +0800 | [diff] [blame] | 1086 | lynq_call_id = addAddr(addr);
|
| 1087 | LYINFLOG("uToken=%d,request=%d,paralen=%d,param=%s",client.uToken,client.request,client.paramLen,client.param);
|
lh | a35d4ee | 2022-01-25 18:47:39 -0800 | [diff] [blame] | 1088 | if(send_request(lynq_call_client_sockfd,&client)==-1)
|
lh | 2582795 | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 1089 | {
|
| 1090 | LYERRLOG("send request fail");
|
q.huang | 783ed5d | 2022-06-02 14:49:02 +0800 | [diff] [blame] | 1091 | cleanCallList(lynq_call_id);
|
lh | 2582795 | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 1092 | return -1;
|
| 1093 | }
|
lh | a35d4ee | 2022-01-25 18:47:39 -0800 | [diff] [blame] | 1094 | get_response(lynq_call_client_sockfd,p);
|
lh | 2582795 | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 1095 | JumpHeader(p,&resp_type,&request,&slot_id,&error);
|
| 1096 | LYINFLOG("resp_type=%d,request=%d,slot_id=%d,error_code=%d",resp_type,request,slot_id,error);
|
lh | 2582795 | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 1097 | if(error==0)
|
| 1098 | {
|
| 1099 | isDial = 1;
|
ll | 45d3ea9 | 2022-03-24 10:22:25 +0800 | [diff] [blame] | 1100 | if(waitCallstateChange(6000)==ETIMEDOUT)//6000ms
|
lh | 2582795 | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 1101 | {
|
lh | be92dd1 | 2022-04-19 06:01:25 -0700 | [diff] [blame] | 1102 | //if timeout,this call need destroy.
|
| 1103 | isDial = 0;
|
lh | 2582795 | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 1104 | error = LYNQ_E_TIME_OUT;
|
q.huang | 783ed5d | 2022-06-02 14:49:02 +0800 | [diff] [blame] | 1105 | LYERRLOG("lynq_call timeout:wait Call state fail!!! clear local idx %d",lynq_call_id);
|
| 1106 | cleanCallList(lynq_call_id);
|
lh | 2582795 | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 1107 | return error;
|
| 1108 | }
|
q.huang | 783ed5d | 2022-06-02 14:49:02 +0800 | [diff] [blame] | 1109 | isDial = 0;
|
| 1110 | *handle = lynq_call_lists[lynq_call_id].call_id;
|
| 1111 | if(*handle > 0)
|
| 1112 | {
|
| 1113 | LYINFLOG("lynq_call dial addr %s suc, id is %d",addr,*handle);
|
| 1114 | return 0;
|
| 1115 | }
|
| 1116 | else
|
| 1117 | {
|
| 1118 | LYERRLOG("lynq_call dial addr %s fail, invalid id",addr);
|
| 1119 | cleanCallList(lynq_call_id);
|
| 1120 | return LYNQ_E_INVALID_ID_ANONALY;
|
| 1121 | }
|
| 1122 |
|
lh | 2582795 | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 1123 | }
|
q.huang | 783ed5d | 2022-06-02 14:49:02 +0800 | [diff] [blame] | 1124 | LYERRLOG("lynq_call dial addr %s fail, service error %d",addr, error);
|
| 1125 | cleanCallList(lynq_call_id);
|
lh | 2582795 | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 1126 | return error;
|
| 1127 | }
|
| 1128 | int lynq_call_answer()
|
| 1129 | {
|
| 1130 | Parcel p;
|
| 1131 | lynq_client_t client;
|
| 1132 | int resp_type = -1;
|
| 1133 | int request = -1;
|
| 1134 | int slot_id = -1;
|
| 1135 | int error = -1;
|
lh | a35d4ee | 2022-01-25 18:47:39 -0800 | [diff] [blame] | 1136 | client.uToken = Global_uToken_call;
|
lh | 2582795 | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 1137 | client.request = 40;//RIL_REQUEST_DIAL
|
| 1138 | client.paramLen = 0;
|
| 1139 | bzero(client.param,LYNQ_REQUEST_PARAM_BUF);
|
q.huang | 783ed5d | 2022-06-02 14:49:02 +0800 | [diff] [blame] | 1140 | LYINFLOG("uToken=%d,request=%d,paralen=%d,param=%s",client.uToken,client.request,client.paramLen,client.param);
|
lh | a35d4ee | 2022-01-25 18:47:39 -0800 | [diff] [blame] | 1141 | if(send_request(lynq_call_client_sockfd,&client)==-1)
|
lh | 2582795 | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 1142 | {
|
| 1143 | LYERRLOG("send request fail");
|
lh | 2582795 | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 1144 | return -1;
|
| 1145 | }
|
lh | a35d4ee | 2022-01-25 18:47:39 -0800 | [diff] [blame] | 1146 | get_response(lynq_call_client_sockfd,p);
|
lh | 2582795 | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 1147 | JumpHeader(p,&resp_type,&request,&slot_id,&error);
|
| 1148 | LYINFLOG("resp_type=%d,request=%d,slot_id=%d,error_code=%d",resp_type,request,slot_id,error);
|
| 1149 | return error;
|
| 1150 | }
|
| 1151 | int lynq_call_hungup(int* handle)
|
| 1152 | {
|
| 1153 | Parcel p;
|
| 1154 | lynq_client_t client;
|
| 1155 | int resp_type = -1;
|
| 1156 | int request = -1;
|
| 1157 | int slot_id = -1;
|
| 1158 | int error = -1;
|
| 1159 | int call_id = 0;
|
q.huang | 783ed5d | 2022-06-02 14:49:02 +0800 | [diff] [blame] | 1160 | int lynq_call_id;
|
lh | a35d4ee | 2022-01-25 18:47:39 -0800 | [diff] [blame] | 1161 | if(handle==NULL||!((*handle>=0)&&(*handle<10)))
|
| 1162 | {
|
| 1163 | LYERRLOG("[%s] illegal input!!!!",__FUNCTION__);
|
| 1164 | return LYNQ_E_CONFLICT;
|
| 1165 | }
|
| 1166 | client.uToken = Global_uToken_call;
|
lh | 2582795 | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 1167 | client.request = 12;//RIL_REQUEST_HUNGUP
|
| 1168 | client.paramLen = 1;
|
| 1169 | bzero(client.param,LYNQ_REQUEST_PARAM_BUF);
|
q.huang | 783ed5d | 2022-06-02 14:49:02 +0800 | [diff] [blame] | 1170 | call_id = *handle;
|
lh | 2582795 | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 1171 | sprintf(client.param,"%d",call_id);
|
q.huang | 783ed5d | 2022-06-02 14:49:02 +0800 | [diff] [blame] | 1172 | LYINFLOG("uToken=%d,request=%d,paralen=%d,param=%s",client.uToken,client.request,client.paramLen,client.param);
|
lh | a35d4ee | 2022-01-25 18:47:39 -0800 | [diff] [blame] | 1173 | if(send_request(lynq_call_client_sockfd,&client)==-1)
|
lh | 2582795 | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 1174 | {
|
| 1175 | LYERRLOG("send request fail");
|
lh | 2582795 | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 1176 | return -1;
|
| 1177 | }
|
lh | a35d4ee | 2022-01-25 18:47:39 -0800 | [diff] [blame] | 1178 | get_response(lynq_call_client_sockfd,p);
|
lh | 2582795 | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 1179 | JumpHeader(p,&resp_type,&request,&slot_id,&error);
|
| 1180 | LYINFLOG("resp_type=%d,request=%d,slot_id=%d,error_code=%d",resp_type,request,slot_id,error);
|
| 1181 | if(error==0)
|
| 1182 | {
|
q.huang | 783ed5d | 2022-06-02 14:49:02 +0800 | [diff] [blame] | 1183 | lynq_call_id=find_call_id_with_call_id(call_id);
|
| 1184 | if(lynq_call_id!=INVALID_ID)
|
| 1185 | {
|
| 1186 | cleanCallList(lynq_call_id);
|
| 1187 | }
|
lh | 2582795 | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 1188 | }
|
| 1189 | return error;
|
| 1190 | }
|
| 1191 | int lynq_call_hungup_all()
|
| 1192 | {
|
| 1193 | Parcel p;
|
| 1194 | lynq_client_t client;
|
| 1195 | int resp_type = -1;
|
| 1196 | int request = -1;
|
| 1197 | int slot_id = -1;
|
| 1198 | int error = -1;
|
lh | a35d4ee | 2022-01-25 18:47:39 -0800 | [diff] [blame] | 1199 | client.uToken = Global_uToken_call;
|
lh | 2582795 | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 1200 | client.request = 17;//RIL_REQUEST_UDUB
|
| 1201 | client.paramLen = 0;
|
| 1202 | bzero(client.param,LYNQ_REQUEST_PARAM_BUF);
|
q.huang | 783ed5d | 2022-06-02 14:49:02 +0800 | [diff] [blame] | 1203 | LYDBGLOG("uToken=%d,request=%d,paralen=%d,param=%s",client.uToken,client.request,client.paramLen,client.param);
|
lh | a35d4ee | 2022-01-25 18:47:39 -0800 | [diff] [blame] | 1204 | if(send_request(lynq_call_client_sockfd,&client)==-1)
|
lh | 2582795 | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 1205 | {
|
| 1206 | LYERRLOG("send request fail");
|
lh | 2582795 | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 1207 | return -1;
|
| 1208 | }
|
lh | a35d4ee | 2022-01-25 18:47:39 -0800 | [diff] [blame] | 1209 | get_response(lynq_call_client_sockfd,p);
|
lh | 2582795 | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 1210 | JumpHeader(p,&resp_type,&request,&slot_id,&error);
|
| 1211 | LYINFLOG("resp_type=%d,request=%d,slot_id=%d,error_code=%d",resp_type,request,slot_id,error);
|
| 1212 | return error;
|
| 1213 | }
|
| 1214 | int lynq_wait_incoming_call(int *handle)
|
| 1215 | {
|
| 1216 | waitIncomingCall();
|
| 1217 | *handle = lynqIncomingCallId;
|
| 1218 | LYINFLOG("lynq incoming call id:%d",lynqIncomingCallId);
|
| 1219 | return 0;
|
| 1220 | }
|
| 1221 |
|
| 1222 | int lynq_set_auto_answercall(const int mode)
|
| 1223 | {
|
| 1224 | global_call_auto_answer = mode;
|
| 1225 | LYINFLOG("auto answer call mode =%d",mode);
|
| 1226 | return 0;
|
| 1227 | }
|
q.huang | b0eb7b0 | 2022-03-29 04:17:32 -0400 | [diff] [blame] | 1228 | int lynq_get_current_call_state(int *handle, int *call_state,int *toa,int *direction,char addr[])
|
| 1229 | {
|
| 1230 | int lynq_call_id = 0;
|
q.huang | 783ed5d | 2022-06-02 14:49:02 +0800 | [diff] [blame] | 1231 | LYINFLOG("lynq_get_current_call_state begin ");
|
q.huang | b0eb7b0 | 2022-03-29 04:17:32 -0400 | [diff] [blame] | 1232 | if(handle==NULL)
|
| 1233 | {
|
q.huang | 783ed5d | 2022-06-02 14:49:02 +0800 | [diff] [blame] | 1234 | LYERRLOG("handle is NULL");
|
q.huang | b0eb7b0 | 2022-03-29 04:17:32 -0400 | [diff] [blame] | 1235 | return LYNQ_E_NULL_ANONALY;
|
| 1236 | }
|
q.huang | 783ed5d | 2022-06-02 14:49:02 +0800 | [diff] [blame] | 1237 | lynq_call_id = find_call_id_with_call_id(*handle);
|
| 1238 | if(lynq_call_id==INVALID_ID)
|
| 1239 | {
|
| 1240 | return LYNQ_E_INVALID_ID_ANONALY;
|
| 1241 | }
|
q.huang | b0eb7b0 | 2022-03-29 04:17:32 -0400 | [diff] [blame] | 1242 | *call_state = lynq_call_lists[lynq_call_id].call_state;
|
| 1243 | *toa = lynq_call_lists[lynq_call_id].toa;
|
| 1244 | *direction = lynq_call_lists[lynq_call_id].direction;
|
| 1245 | memcpy(addr,lynq_call_lists[lynq_call_id].addr,strlen(lynq_call_lists[lynq_call_id].addr)+1);
|
| 1246 | return 0;
|
| 1247 | }
|
| 1248 |
|
| 1249 | /*audio begin*/
|
ll | 7e055f2 | 2022-01-24 12:16:22 +0000 | [diff] [blame] | 1250 | static int judge_mic(const int enable){
|
ll | c603006 | 2022-02-14 08:58:16 +0000 | [diff] [blame] | 1251 | switch(enable){
|
| 1252 | case 0:
|
| 1253 | return 1;
|
| 1254 | case 1:
|
| 1255 | return 1;
|
| 1256 | default:
|
| 1257 | return 0;
|
ll | 7e055f2 | 2022-01-24 12:16:22 +0000 | [diff] [blame] | 1258 | }
|
| 1259 | }
|
| 1260 |
|
lh | 2582795 | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 1261 | int lynq_set_mute_mic(const int enable)
|
ll | 7e055f2 | 2022-01-24 12:16:22 +0000 | [diff] [blame] | 1262 | {
|
| 1263 | if(!judge_mic(enable)){
|
| 1264 | return LYNQ_E_CONFLICT;
|
| 1265 | }
|
q.huang | b0eb7b0 | 2022-03-29 04:17:32 -0400 | [diff] [blame] | 1266 | return lynq_set_common_request(53,1,"%d",enable); //RIL_REQUEST_SET_MUTE
|
| 1267 | }
|
| 1268 | int lynq_get_mute_mic(int *status)
|
| 1269 | {
|
| 1270 | return lynq_get_common_request(54,status);//RIL_REQUEST_GET_MUTE
|
lh | 2582795 | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 1271 | }
|
ll | 45d3ea9 | 2022-03-24 10:22:25 +0800 | [diff] [blame] | 1272 |
|
| 1273 | /**
|
| 1274 | * @brief Check whether DTMF is valid
|
| 1275 | *
|
| 1276 | * @param callnum dtmf eg:0-9 * #
|
| 1277 | * @return int
|
| 1278 | */
|
| 1279 | static int judge_dtmf(const char callnum)
|
| 1280 | {
|
| 1281 | if(callnum == '#')
|
| 1282 | {
|
| 1283 | return 1;
|
| 1284 | }
|
| 1285 | if(callnum == '*')
|
| 1286 | {
|
| 1287 | return 1;
|
| 1288 | }
|
| 1289 | if(callnum >= '0'&& callnum <= '9')
|
| 1290 | {
|
| 1291 | return 1;
|
| 1292 | }
|
| 1293 | return 0;
|
| 1294 | }
|
| 1295 |
|
lh | 2582795 | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 1296 | int lynq_set_DTMF(const char callnum)
|
| 1297 | {
|
ll | 45d3ea9 | 2022-03-24 10:22:25 +0800 | [diff] [blame] | 1298 | if(!judge_dtmf(callnum))
|
| 1299 | {
|
| 1300 | return LYNQ_E_CONFLICT;
|
| 1301 | }
|
lh | 2582795 | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 1302 | if(!lynq_call_state)
|
| 1303 | {
|
| 1304 | LYERRLOG("LYNQ_E_CONFLICT");
|
| 1305 | return LYNQ_E_CONFLICT;
|
| 1306 | }
|
q.huang | b0eb7b0 | 2022-03-29 04:17:32 -0400 | [diff] [blame] | 1307 | return lynq_set_common_request(24,1,"%c",callnum); //RIL_REQUEST_DTMF
|
lh | 2582795 | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 1308 | }
|
q.huang | b0eb7b0 | 2022-03-29 04:17:32 -0400 | [diff] [blame] | 1309 | static int judge_volume(LYNQ_E_VOLUMN_SET set,const int volume){
|
| 1310 | if(set==LYNQ_E_VOLUMN_SET_DTMF){
|
| 1311 | if(volume < 0 ||volume >36){
|
| 1312 | return 0;
|
| 1313 | }
|
| 1314 | }
|
| 1315 | else if (set==LYNQ_E_VOLUMN_SET_SPEECH)
|
| 1316 | {
|
| 1317 | if(volume < 1 ||volume >7){
|
| 1318 | return 0;
|
| 1319 | }
|
ll | 7e055f2 | 2022-01-24 12:16:22 +0000 | [diff] [blame] | 1320 | }
|
ll | 375c94d | 2022-01-27 05:54:38 +0000 | [diff] [blame] | 1321 | return 1;
|
ll | 7e055f2 | 2022-01-24 12:16:22 +0000 | [diff] [blame] | 1322 | }
|
lh | 2582795 | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 1323 | int lynq_set_DTMF_volume(const int volume)
|
ll | 7e055f2 | 2022-01-24 12:16:22 +0000 | [diff] [blame] | 1324 | {
|
q.huang | b0eb7b0 | 2022-03-29 04:17:32 -0400 | [diff] [blame] | 1325 | if(!judge_volume(LYNQ_E_VOLUMN_SET_DTMF,volume)){
|
ll | 7e055f2 | 2022-01-24 12:16:22 +0000 | [diff] [blame] | 1326 | return LYNQ_E_CONFLICT;
|
| 1327 | }
|
q.huang | b0eb7b0 | 2022-03-29 04:17:32 -0400 | [diff] [blame] | 1328 | return lynq_set_common_request(8003,1,"%d",volume);//LYNQ_REQUEST_SET_DTMF_VOLUME
|
lh | 2582795 | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 1329 | }
|
q.huang | 9ee6d5b | 2022-04-05 23:11:02 -0400 | [diff] [blame] | 1330 | int lynq_set_speech_volume(const int volume)//mixer_set_volume
|
lh | 2582795 | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 1331 | {
|
q.huang | b0eb7b0 | 2022-03-29 04:17:32 -0400 | [diff] [blame] | 1332 | if(!judge_volume(LYNQ_E_VOLUMN_SET_SPEECH,volume))
|
lh | 2582795 | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 1333 | {
|
q.huang | b0eb7b0 | 2022-03-29 04:17:32 -0400 | [diff] [blame] | 1334 | return LYNQ_E_CONFLICT;
|
lh | 2582795 | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 1335 | }
|
q.huang | b0eb7b0 | 2022-03-29 04:17:32 -0400 | [diff] [blame] | 1336 | return lynq_set_common_request(8009,1,"%d",volume); //LYNQ_REQUEST_SET_SPEECH_VOLUME
|
lh | 2582795 | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 1337 | }
|
q.huang | b0eb7b0 | 2022-03-29 04:17:32 -0400 | [diff] [blame] | 1338 | int lynq_get_speech_volume(int* volumn)//mixer_get_volume
|
| 1339 | {
|
| 1340 | return lynq_get_common_request(8010,volumn);//LYNQ_REQUEST_GET_SPEECH_VOLUME
|
| 1341 | }
|
q.huang | 9ee6d5b | 2022-04-05 23:11:02 -0400 | [diff] [blame] | 1342 | int lynq_incall_record_start(const char* file_path)
|
q.huang | b0eb7b0 | 2022-03-29 04:17:32 -0400 | [diff] [blame] | 1343 | {
|
q.huang | 783ed5d | 2022-06-02 14:49:02 +0800 | [diff] [blame] | 1344 | return lynq_set_common_request(8011,2,"%s %s","1",file_path); //LYNQ_REQUEST_RECORD
|
q.huang | b0eb7b0 | 2022-03-29 04:17:32 -0400 | [diff] [blame] | 1345 | }
|
| 1346 | int lynq_incall_record_stop()
|
| 1347 | {
|
q.huang | 9ee6d5b | 2022-04-05 23:11:02 -0400 | [diff] [blame] | 1348 | const char* unused_file="just_ocuupy_paramter_postion";
|
| 1349 | return lynq_set_common_request(8011,2,"%s %s","0",unused_file); //LYNQ_REQUEST_RECORD
|
q.huang | b0eb7b0 | 2022-03-29 04:17:32 -0400 | [diff] [blame] | 1350 | }
|
| 1351 | /*audio end*/
|
q.huang | fe1b405 | 2022-04-18 00:09:50 -0400 | [diff] [blame] | 1352 |
|
| 1353 | #ifdef ECALL_SUPPORT
|
| 1354 | LYNQ_ECall_Variant lynq_get_lynq_ecall_variant_from_lynq_type(LYNQ_ECall_Type type)
|
| 1355 | {
|
| 1356 | switch(type)
|
| 1357 | {
|
| 1358 | case LYNQ_ECALL_TYPE_TEST:
|
| 1359 | return LYNQ_ECALL_TEST;
|
| 1360 | case LYNQ_ECALL_TYPE_RECONFIG:
|
| 1361 | return LYNQ_ECALL_RECONFIG;
|
| 1362 | default:
|
| 1363 | return LYNQ_ECALL_EMERGENCY;
|
| 1364 | }
|
| 1365 | }
|
| 1366 |
|
| 1367 | RIL_ECall_Variant lynq_get_ril_ecall_variant_from_lynq_variant(LYNQ_ECall_Variant type)
|
| 1368 | {
|
| 1369 | switch(type)
|
| 1370 | {
|
| 1371 | case LYNQ_ECALL_TEST:
|
| 1372 | return ECALL_TEST;
|
| 1373 | case LYNQ_ECALL_RECONFIG:
|
| 1374 | return ECALL_RECONFIG;
|
| 1375 | default:
|
| 1376 | return ECALL_EMERGENCY;
|
| 1377 | }
|
| 1378 | }
|
| 1379 |
|
| 1380 | RIL_ECall_Category lynq_get_ril_ecall_cat_from_lynq_cat(LYNQ_ECall_Category cat)
|
| 1381 | {
|
| 1382 | switch(cat)
|
| 1383 | {
|
| 1384 | case LYNQ_EMER_CAT_MANUAL_ECALL:
|
| 1385 | return EMER_CAT_MANUAL_ECALL;
|
| 1386 | default:
|
| 1387 | return EMER_CAT_AUTO_ECALL;
|
| 1388 | }
|
| 1389 | }
|
| 1390 |
|
| 1391 |
|
| 1392 | int lynq_set_test_num(LYNQ_ECall_Set_Type type, const char *test_num, int test_num_length)
|
| 1393 | {
|
| 1394 | int error;
|
| 1395 |
|
| 1396 | if(test_num==NULL || test_num_length > LYNQ_PHONE_NUMBER_MAX )
|
| 1397 | {
|
q.huang | 783ed5d | 2022-06-02 14:49:02 +0800 | [diff] [blame] | 1398 | LYERRLOG("test_num is null or test_num_length %d s greater than %d ",test_num_length,LYNQ_PHONE_NUMBER_MAX);
|
q.huang | fe1b405 | 2022-04-18 00:09:50 -0400 | [diff] [blame] | 1399 | return -1;
|
| 1400 | }
|
| 1401 |
|
| 1402 | error=lynq_set_common_request(RIL_REQUEST_ECALL_SET_TEST_NUM,2,"%d %s",type,test_num);
|
| 1403 |
|
| 1404 | if(error==0)
|
| 1405 | {
|
| 1406 | snprintf(e_call_addr[LYNQ_ECALL_TEST],LYNQ_PHONE_NUMBER_MAX,"%s",test_num);
|
| 1407 | }
|
| 1408 |
|
| 1409 | return error;
|
| 1410 | }
|
| 1411 |
|
q.huang | 892722f | 2022-05-10 20:37:21 +0800 | [diff] [blame] | 1412 | int lynq_fast_ecall(int* handle, LYNQ_ECall_Category lynq_ecall_cat, LYNQ_ECall_Variant lynq_ecall_variant, const char *addr, int addr_length, const unsigned char *msd_data,int msd_length)
|
q.huang | fe1b405 | 2022-04-18 00:09:50 -0400 | [diff] [blame] | 1413 | {
|
q.huang | 783ed5d | 2022-06-02 14:49:02 +0800 | [diff] [blame] | 1414 | int error;
|
q.huang | fe1b405 | 2022-04-18 00:09:50 -0400 | [diff] [blame] | 1415 | RIL_ECall_Variant ril_ecall_variant = lynq_get_ril_ecall_variant_from_lynq_variant (lynq_ecall_variant);
|
q.huang | 9a9b876 | 2022-04-19 05:20:12 -0400 | [diff] [blame] | 1416 | RIL_ECall_Category ril_ecall_cat = lynq_get_ril_ecall_cat_from_lynq_cat(lynq_ecall_cat);
|
q.huang | 6a11976 | 2022-05-11 20:10:38 +0800 | [diff] [blame] | 1417 | char lynq_msd_data[MSD_MAX_LENGTH*2+1]={0};
|
| 1418 | unsigned int i;
|
q.huang | 783ed5d | 2022-06-02 14:49:02 +0800 | [diff] [blame] | 1419 | if(lynq_ecall_is_running())
|
q.huang | 892722f | 2022-05-10 20:37:21 +0800 | [diff] [blame] | 1420 | {
|
q.huang | 783ed5d | 2022-06-02 14:49:02 +0800 | [diff] [blame] | 1421 | LYERRLOG("lynq_fast_ecall ecall is running");
|
| 1422 | return LYNQ_E_ECALL_BEING_RUNNING;
|
| 1423 | }
|
| 1424 |
|
| 1425 | if(msd_length > MSD_MAX_LENGTH || msd_length <=0)
|
| 1426 | {
|
| 1427 | LYERRLOG("lynq_fast_ecall msd_length %d is greater than %d or <= 0, parameter error",msd_length,MSD_MAX_LENGTH);
|
| 1428 | return LYNQ_E_ECALL_MSD_LENGTH_ERROR;
|
q.huang | 892722f | 2022-05-10 20:37:21 +0800 | [diff] [blame] | 1429 | }
|
q.huang | 892722f | 2022-05-10 20:37:21 +0800 | [diff] [blame] | 1430 |
|
q.huang | 6a11976 | 2022-05-11 20:10:38 +0800 | [diff] [blame] | 1431 | for(i =0; i<msd_length;i++)
|
q.huang | 892722f | 2022-05-10 20:37:21 +0800 | [diff] [blame] | 1432 | {
|
q.huang | 6a11976 | 2022-05-11 20:10:38 +0800 | [diff] [blame] | 1433 | sprintf(&(lynq_msd_data[i<<1]),"%02x",msd_data[i]);
|
q.huang | 892722f | 2022-05-10 20:37:21 +0800 | [diff] [blame] | 1434 | }
|
| 1435 |
|
q.huang | 18d08bf | 2022-04-19 20:27:44 -0400 | [diff] [blame] | 1436 |
|
q.huang | 783ed5d | 2022-06-02 14:49:02 +0800 | [diff] [blame] | 1437 | LYINFLOG("lynq_fast_ecall addr is %s",e_call_addr[lynq_ecall_variant]);
|
q.huang | 18d08bf | 2022-04-19 20:27:44 -0400 | [diff] [blame] | 1438 |
|
q.huang | 892722f | 2022-05-10 20:37:21 +0800 | [diff] [blame] | 1439 | error=lynq_set_common_request(RIL_REQUEST_ECALL_FAST_MAKE_ECALL,4,"%d %d %s %s",ril_ecall_cat, ril_ecall_variant, "null", lynq_msd_data);
|
q.huang | fe1b405 | 2022-04-18 00:09:50 -0400 | [diff] [blame] | 1440 |
|
| 1441 | if(error==0)
|
q.huang | 783ed5d | 2022-06-02 14:49:02 +0800 | [diff] [blame] | 1442 | {
|
| 1443 | is_ecall_dial = 1;
|
| 1444 | if(waitCallstateChange(180000)==ETIMEDOUT)//180000ms
|
q.huang | fe1b405 | 2022-04-18 00:09:50 -0400 | [diff] [blame] | 1445 | {
|
q.huang | 783ed5d | 2022-06-02 14:49:02 +0800 | [diff] [blame] | 1446 | LYERRLOG("lynq_fast_ecall timeout:wait Call state time out!!!");
|
| 1447 | is_ecall_dial = 0;
|
| 1448 | lynqRespWatingEvent();
|
| 1449 | return LYNQ_E_TIME_OUT;
|
q.huang | fe1b405 | 2022-04-18 00:09:50 -0400 | [diff] [blame] | 1450 | }
|
q.huang | 783ed5d | 2022-06-02 14:49:02 +0800 | [diff] [blame] | 1451 | is_ecall_dial = 0;
|
| 1452 | lynqRespWatingEvent();
|
q.huang | 18d08bf | 2022-04-19 20:27:44 -0400 | [diff] [blame] | 1453 |
|
q.huang | 783ed5d | 2022-06-02 14:49:02 +0800 | [diff] [blame] | 1454 | if(g_ecallId != INVALID_ID)
|
| 1455 | {
|
| 1456 | *handle=g_ecallId;
|
| 1457 | LYINFLOG("lynq_fast_ecall id is %d",g_ecallId);
|
| 1458 | return 0;
|
| 1459 | }
|
| 1460 | else
|
| 1461 | {
|
| 1462 | LYERRLOG("lynq_fast_ecall service return fail");
|
| 1463 | return LYNQ_E_INVALID_ID_ANONALY;
|
| 1464 | }
|
q.huang | fe1b405 | 2022-04-18 00:09:50 -0400 | [diff] [blame] | 1465 | }
|
| 1466 |
|
| 1467 | return error;
|
| 1468 | }
|
| 1469 |
|
| 1470 | int lynq_set_psap(int enable)
|
| 1471 | {
|
| 1472 | return lynq_set_common_request(RIL_REQUEST_ECALL_SET_PSAP,1,"%d",enable);
|
| 1473 | }
|
| 1474 |
|
| 1475 | int lynq_psap_pull_msd()
|
| 1476 | {
|
| 1477 | return lynq_set_common_request(RIL_REQUEST_ECALL_PSAP_PULL_MSD,0,"");
|
| 1478 | }
|
| 1479 |
|
| 1480 | int lynq_make_ecall(int* handle, LYNQ_ECall_Type type)
|
| 1481 | {
|
| 1482 | LYNQ_ECall_Variant lynq_ecall_variant;
|
| 1483 | int error = -1;
|
| 1484 | int lynq_call_id = -1;
|
| 1485 |
|
| 1486 | if(handle==NULL)
|
| 1487 | {
|
q.huang | 783ed5d | 2022-06-02 14:49:02 +0800 | [diff] [blame] | 1488 | LYERRLOG("handle is NULL, parameter error ");
|
q.huang | fe1b405 | 2022-04-18 00:09:50 -0400 | [diff] [blame] | 1489 | return -1;
|
| 1490 | }
|
| 1491 |
|
| 1492 | error=lynq_set_common_request(RIL_REQUEST_ECALL_MAKE_ECALL,1,"%d",type);
|
| 1493 |
|
| 1494 | if(error==0)
|
| 1495 | {
|
| 1496 | lynq_ecall_variant=lynq_get_lynq_ecall_variant_from_lynq_type(type);
|
| 1497 |
|
q.huang | 783ed5d | 2022-06-02 14:49:02 +0800 | [diff] [blame] | 1498 | lynq_call_id = addAddr(e_call_addr[lynq_ecall_variant]);
|
q.huang | fe1b405 | 2022-04-18 00:09:50 -0400 | [diff] [blame] | 1499 | isDial = 1;
|
| 1500 | if(waitCallstateChange(10000)==ETIMEDOUT)//10000ms
|
| 1501 | {
|
| 1502 | error = LYNQ_E_TIME_OUT;
|
| 1503 | LYERRLOG("timeout:wait Call state fail!!!");
|
q.huang | fe1b405 | 2022-04-18 00:09:50 -0400 | [diff] [blame] | 1504 | return error;
|
| 1505 | }
|
| 1506 |
|
| 1507 | *handle = lynq_call_id;
|
| 1508 | }
|
| 1509 |
|
| 1510 | return error;
|
| 1511 | }
|
| 1512 |
|
| 1513 |
|
q.huang | bd6a306 | 2022-05-10 20:49:46 +0800 | [diff] [blame] | 1514 | int lynq_set_msd(int* handle, const unsigned char *msd_data, int msd_length)
|
q.huang | fe1b405 | 2022-04-18 00:09:50 -0400 | [diff] [blame] | 1515 | {
|
q.huang | 6a11976 | 2022-05-11 20:10:38 +0800 | [diff] [blame] | 1516 | char lynq_msd_data[MSD_MAX_LENGTH*2+1]={0};
|
| 1517 | unsigned int i;
|
| 1518 |
|
q.huang | 783ed5d | 2022-06-02 14:49:02 +0800 | [diff] [blame] | 1519 | if(handle==NULL || ((*handle) >= LYNQ_CALL_MAX) || msd_length > MSD_MAX_LENGTH || msd_length == 0 || msd_data ==NULL)
|
q.huang | fe1b405 | 2022-04-18 00:09:50 -0400 | [diff] [blame] | 1520 | {
|
q.huang | 783ed5d | 2022-06-02 14:49:02 +0800 | [diff] [blame] | 1521 | LYERRLOG("lynq_set_msd handle is NULL or *handle %d is greater or equeal to %d or msd_length %d is greater than %d or msd_data %s is NULL, parameter error",*handle,LYNQ_CALL_MAX,msd_length,MSD_MAX_LENGTH, msd_data);
|
q.huang | bd6a306 | 2022-05-10 20:49:46 +0800 | [diff] [blame] | 1522 | return -1;
|
| 1523 | }
|
q.huang | bd6a306 | 2022-05-10 20:49:46 +0800 | [diff] [blame] | 1524 |
|
q.huang | 6a11976 | 2022-05-11 20:10:38 +0800 | [diff] [blame] | 1525 | for(i=0; i<msd_length;i++)
|
q.huang | bd6a306 | 2022-05-10 20:49:46 +0800 | [diff] [blame] | 1526 | {
|
q.huang | 6a11976 | 2022-05-11 20:10:38 +0800 | [diff] [blame] | 1527 | sprintf(&(lynq_msd_data[i<<1]),"%02x",msd_data[i]);
|
q.huang | 783ed5d | 2022-06-02 14:49:02 +0800 | [diff] [blame] | 1528 | }
|
| 1529 |
|
| 1530 | LYINFLOG("lynq_set_msd ");
|
q.huang | fe1b405 | 2022-04-18 00:09:50 -0400 | [diff] [blame] | 1531 |
|
q.huang | bd6a306 | 2022-05-10 20:49:46 +0800 | [diff] [blame] | 1532 | return lynq_set_common_request(RIL_REQUEST_ECALL_SET_MSD,2,"%d %s",lynq_call_lists[(*handle)].call_id,lynq_msd_data);
|
q.huang | fe1b405 | 2022-04-18 00:09:50 -0400 | [diff] [blame] | 1533 | }
|
| 1534 |
|
| 1535 | int lynq_set_ivs(int enable)
|
| 1536 | {
|
q.huang | 783ed5d | 2022-06-02 14:49:02 +0800 | [diff] [blame] | 1537 | if(enable<0)
|
| 1538 | {
|
| 1539 | lynq_set_common_request(RIL_REQUEST_ECALL_SET_IVS,1,"%d",enable);
|
| 1540 | return 0;
|
| 1541 | }
|
| 1542 |
|
| 1543 | return lynq_set_common_request(RIL_REQUEST_ECALL_SET_IVS,1,"%d",enable);
|
q.huang | fe1b405 | 2022-04-18 00:09:50 -0400 | [diff] [blame] | 1544 | }
|
| 1545 |
|
| 1546 | int lynq_reset_ivs()
|
| 1547 | {
|
| 1548 | return lynq_set_common_request(RIL_REQUEST_ECALL_RESET_IVS,0,"");
|
| 1549 | }
|
| 1550 |
|
| 1551 | int lynq_ivs_push_msd()
|
| 1552 | {
|
| 1553 | return lynq_set_common_request(RIL_REQUEST_ECALL_IVS_PUSH_MSD,0,"");
|
| 1554 | }
|
q.huang | 18d08bf | 2022-04-19 20:27:44 -0400 | [diff] [blame] | 1555 |
|
| 1556 | int wait_ecall_event()
|
| 1557 | {
|
| 1558 | int ret = 0;
|
| 1559 | pthread_mutex_lock(&s_incoming_e_call_mutex);
|
| 1560 | ret = pthread_cond_wait(&s_incoming_e_call_cond,&s_incoming_e_call_mutex);
|
q.huang | 783ed5d | 2022-06-02 14:49:02 +0800 | [diff] [blame] | 1561 | pthread_mutex_unlock(&s_incoming_e_call_mutex);
|
q.huang | 18d08bf | 2022-04-19 20:27:44 -0400 | [diff] [blame] | 1562 | return ret;
|
| 1563 | }
|
| 1564 |
|
| 1565 | int lynq_wait_ecall_indication(LYNQ_ECall_Indication *eCall_Indication)
|
| 1566 | {
|
| 1567 | wait_ecall_event();
|
q.huang | 783ed5d | 2022-06-02 14:49:02 +0800 | [diff] [blame] | 1568 | *eCall_Indication = g_lynqIncomingEcallIndication;
|
| 1569 | LYINFLOG("lynq_wait_ecall_indication id: %d",g_lynqIncomingEcallIndication);
|
q.huang | 18d08bf | 2022-04-19 20:27:44 -0400 | [diff] [blame] | 1570 | return 0;
|
| 1571 | }
|
| 1572 |
|
q.huang | fe1b405 | 2022-04-18 00:09:50 -0400 | [diff] [blame] | 1573 | #endif
|
| 1574 |
|
q.huang | 877d6b3 | 2022-06-06 16:15:31 +0800 | [diff] [blame] | 1575 | /*Audio Path setting begin*/
|
| 1576 | /*set*/
|
| 1577 | int lynq_set_voice_audio_mode(const LYNQ_Audio_Mode audio_mode)
|
| 1578 | {
|
| 1579 | return 0;
|
| 1580 | }
|
q.huang | 65033cb | 2022-06-06 20:23:15 +0800 | [diff] [blame^] | 1581 | int lynq_set_rtp_ip(const LYNQ_Rtp_Mode rtp_mode, const char* ip, const int ip_length)
|
q.huang | 877d6b3 | 2022-06-06 16:15:31 +0800 | [diff] [blame] | 1582 | {
|
| 1583 | return 0;
|
| 1584 | }
|
q.huang | 65033cb | 2022-06-06 20:23:15 +0800 | [diff] [blame^] | 1585 | int lynq_set_rtp_port(const LYNQ_Rtp_Mode rtp_mode, const int port)
|
q.huang | 877d6b3 | 2022-06-06 16:15:31 +0800 | [diff] [blame] | 1586 | {
|
| 1587 | return 0;
|
| 1588 | }
|
| 1589 | int lynq_set_rtp_param(const int clock_rate,const int channels,const int latency) //only for client mode
|
| 1590 | {
|
| 1591 | return 0;
|
| 1592 | }
|
| 1593 | /*get*/
|
| 1594 | LYNQ_Audio_Mode lynq_get_voice_audio_mode()
|
| 1595 | {
|
| 1596 | return AUDIO_MODE_CODEC;
|
| 1597 | }
|
| 1598 | int lynq_get_rtp_ip(const LYNQ_Rtp_Mode rtp_mode, char* ip, const int ip_length)
|
| 1599 | {
|
| 1600 | if(ip==NULL)
|
| 1601 | {
|
| 1602 | return 1;
|
| 1603 | }
|
| 1604 | return 0;
|
| 1605 | }
|
| 1606 | int lynq_get_rtp_port(const LYNQ_Rtp_Mode rtp_mode, int* port)
|
| 1607 | {
|
| 1608 | if(port==NULL)
|
| 1609 | {
|
| 1610 | return 1;
|
| 1611 | }
|
| 1612 | return 0;
|
| 1613 | }
|
| 1614 | int lynq_get_rtp_param(int* clock_rate, int* channels, int* latency)//only for client mode
|
| 1615 | {
|
| 1616 | if(clock_rate == NULL || channels ==NULL || latency ==NULL)
|
| 1617 | {
|
| 1618 | return 1;
|
| 1619 | }
|
| 1620 |
|
| 1621 | return 0;
|
| 1622 | }
|
| 1623 | /*Audio Path setting end*/
|
| 1624 |
|
lh | 2582795 | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 1625 | #if 0
|
| 1626 | int main(int argc,char **argv)
|
| 1627 | {
|
| 1628 | int n = 0;
|
| 1629 | n = lynq_init_call(lynq_call_state_change_test,2222);
|
| 1630 | if(n<0)
|
| 1631 | {
|
q.huang | 783ed5d | 2022-06-02 14:49:02 +0800 | [diff] [blame] | 1632 | LYDBGLOG("lynq init call fail!!!");
|
lh | 2582795 | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 1633 | return -1;
|
| 1634 | }
|
q.huang | 783ed5d | 2022-06-02 14:49:02 +0800 | [diff] [blame] | 1635 | LYDBGLOG("lynq call init success!!!");
|
lh | 2582795 | 2022-01-10 00:34:35 -0800 | [diff] [blame] | 1636 | char phoneNum[LYNQ_PHONE_NUMBER_MAX];
|
| 1637 | sprintf(phoneNum,"18180053406 0",strlen("18180053406 0")+1);
|
| 1638 | lynq_call(phoneNum);
|
| 1639 | while(1)
|
| 1640 | {
|
| 1641 | sleep(1);
|
| 1642 | }
|
| 1643 | return 0;
|
| 1644 | }
|
| 1645 | #endif
|
| 1646 | /*Warren add for T800 platform 2021/11/19 end*/
|