-
Notifications
You must be signed in to change notification settings - Fork 0
/
TcBtPhone.cpp
1330 lines (1136 loc) · 37.8 KB
/
TcBtPhone.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/****************************************************************************
* FileName : TcBtApp.cpp
* Description :
****************************************************************************
*
* TCC Version 1.0
* Copyright (c) Telechips Inc.
* All rights reserved
This source code contains confidential information of Telechips.
Any unauthorized use without a written permission of Telechips including not limited to re-
distribution in source or binary form is strictly prohibited.
This source code is provided "AS IS" and nothing contained in this source code shall
constitute any express or implied warranty of any kind, including without limitation, any warranty
of merchantability, fitness for a particular purpose or non-infringement of any patent, copyright
or other third party intellectual property right. No warranty is made, express or implied,
regarding the information's accuracy, completeness, or performance.
In no event shall Telechips be liable for any claim, damages or other liability arising from, out of
or in connection with this source code or the use in the source code.
This source code is provided subject to the terms of a Mutual Non-Disclosure Agreement
between Telechips and Company.
*
****************************************************************************/
/******************************************************************************
* Description : This file contains functions and variables for a UI body
*******************************************************************************
*
* yy/mm/dd ver descriptions Author
* --------- -------- ----------------- -----------------
* 13/12/22 0.1 created Kwon Sunhong
*******************************************************************************/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
#include <QDebug>
#include "BtApp_Gap.h"
#include "TcBtPhone.h"
#include "TcBtEvt.h"
#include "TcBtHFEvt.h"
#include "BT_CFG.h"
#include "TC_BT.h"
#include "BtApp_Av.h"
#include "BTAPP.h"
#include "BtPhoneBookCmd.h"
#include "TC_BT/inc/TC_BT_SC_EVT.h"
#include "TC_BT/inc/TC_BT_SD_EVT.h"
#include "TC_BT/inc/TC_BT_CM_EVT.h"
#include"TC_BT/inc/BtPlatform.h"
#ifdef BT_HANDSFREE_UNIT
#endif
extern unsigned char gKorUtf8CharacterTable[BT_PB_SEARCH_KOR_COUNT][BT_PB_SEARCH_CHAR_SIZE];
static bool bStart = FALSE;
//TcBtapp global instance
#if defined(__arm__) && !defined(BT_NO_LACUCHER)
int g_appID = -1;
#endif
#define BT_CONTACTS_MAX 9
static void Tc_Bt_StartBTAudio(void);
static void Tc_Bt_StoptBTAudio(void);
static INT32U GetData4Bytes(const INT8U *pBufData)
{
INT32U lIntData;
INT32U lTmpData;
lTmpData = pBufData[1];
lIntData = pBufData[0] | (lTmpData << 8);
lTmpData = pBufData[2];
lIntData |= (lTmpData << 16);
lTmpData = pBufData[3];
lIntData |= (lTmpData << 24);
return lIntData;
}
TcBtPhone::TcBtPhone(QObject *parent) :
QObject(parent)
{
qRegisterMetaType<unsigned short int >("unsigned short int ");
pMsgForClose = NULL;
m_DBSignal = new TcBtAppDBSignal;
callFromPhone = false;
callIncoming = false;
outgoingAudioOpened = false;
callTime =0;
connect(m_DBSignal, SIGNAL(SYS_Event(int)), this, SLOT(OnSYSHandler(int)), Qt::QueuedConnection);
connect(m_DBSignal, SIGNAL(HF_Event(int , void *)), this, SLOT(OnHFHandler(int , void *)), Qt::QueuedConnection);
connect(m_DBSignal, SIGNAL(DM_Event(int,void *)), this, SLOT(OnDMHandler(int, void *)), Qt::QueuedConnection);
connect(m_DBSignal, SIGNAL(PB_Event(int , void *)), this, SLOT(OnPBHandler(int , void *)), Qt::QueuedConnection);
connect(m_DBSignal, SIGNAL(MAP_Event(int, void *)), this, SLOT(OnMAPHandler(int, void *)), Qt::QueuedConnection);
}
TcBtPhone::~TcBtPhone()
{
}
TcBtPhone *TcBtPhone::getInstance()
{
static TcBtPhone tcapp;
return &tcapp;
}
bool TcBtPhone::sysActivate(void)
{
G_BtThread->Initilaize();
G_BtThread->start();
G_BtSys->BtApp_SYS_Init();
}
void BtApp_SYS_DeinitTimer2(unsigned char id, unsigned char loc)
{
G_BtSys->BtApp_SYS_Deinit();
}
void BtApp_SYS_DeinitTimer(unsigned char id, unsigned char loc)
{
if(BtApp_GAP_DisconnectAllAtBTDeactivate() != 0)
{
TCCAPI_Timer_SetTime(50, TIMER_BT_DISCONNECT_AT_BTOFF, BtApp_SYS_DeinitTimer2);
}
else
{
(void)G_BtSys->BtApp_SYS_Deinit(); // request delete all tasks.
}
}
bool TcBtPhone::sysDeactivate(void)
{
unsigned char ucDevNo=0;
int iIdx;
int iBTStatus;
iBTStatus = TC_BT_SYS_GetBTStatus();
#if 1
if((iBTStatus == TC_BT_SYS_Idle)
|| (iBTStatus == TC_BT_SYS_Deactivating))
#else
if (Bluetooth_GetTaskStatus()!=BT_TASK_ACTIVE/* active */
|| !UI_API_GetBluetoothStatus(BTAPP_STATUS_MASK_TASK_INIT) )
#endif
{
return 0;
}
#ifdef BT_AUDIO_SINK
if (G_BtSys->BtApp_SYS_GetBasicMode() == B_BT_A2DP_SINK)
{
BtApp_AV_SNK_AudioEnd();
}
#endif
#ifdef BT_HANDSFREE_UNIT
ucDevNo=BtApp_HF_GetSelectedDevNum();
BtApp_HF_SetCurrDevNum(ucDevNo);
/* handsfree */
#ifdef BT_HFP_RING_FOR_NO_IN_BAND
if (G_BtSys->BtApp_SYS_GetBasicMode() == B_BT_HFP_RING)
{
//BtApp_HF_RejectCall();
BtApp_HF_SetIRingEnd();
//BtApp_HF_EvtPowerOff(ucDevNo);
}
#endif
if (G_BtSys->BtApp_SYS_GetBasicMode() == B_BT_HFP_CALL)
{
//BtApp_HF_TerminateCall();
BtApp_HF_SetCallEnd();
BtApp_HF_SetOutgoingEnd();
//BtApp_HF_EvtPowerOff(ucDevNo);
}
if(BtApp_HF_VoiceRecognitionLearning() != 0)
{
BtApp_HF_VoiceRecognitionLearningToggle();
//BtApp_HF_TerminateVoiceRecognition();
BtApp_HF_Close_Call();
//BtApp_HF_EvtPowerOff(ucDevNo);
}
if(BtApp_HF_VoiceRecognition() != 0)
{
BtApp_HF_VoiceRecognitionInd(FALSE);
//BtApp_HF_TerminateVoiceRecognition();
BtApp_HF_Close_Call();
//BtApp_HF_EvtPowerOff(ucDevNo);
}
/* headset */
#endif
BtApp_GAP_SetAuthoriseFlag(FALSE);
if(BtApp_GAP_DisconnectAllAtBTDeactivate() != 0)
{
TCCAPI_Timer_SetTime(50, TIMER_BT_DISCONNECT_AT_BTOFF, BtApp_SYS_DeinitTimer);
}
else
{
G_BtSys->BtApp_SYS_Deinit(); // request delete all tasks.
}
}
bool TcBtPhone::deviceSearchStart(int totalSearchTime, int maxDevices, short update)
{
G_BtDm->StartSearchDevice(totalSearchTime,maxDevices,update);
}
bool TcBtPhone::deviceSearchCancel(void)
{
G_BtDm->CancelSearchDevice();
}
bool TcBtPhone::deviceConnect(int DeviceNum)
{
G_BtDm->ConnectDevice(DeviceNum);
}
bool TcBtPhone::deviceDisconnect(int DeviceNum)
{
G_BtDm->DisConnectDevice(DeviceNum);
}
bool TcBtPhone::deviceDelete(int DeviceNum)
{
G_BtDm->DeleteDevice(DeviceNum);
}
bool TcBtPhone::deviceAllDelete(void)
{
G_BtDm->DeleteAll();
}
bool TcBtPhone::deviceCompare(bool bAccept)
{
G_BtDm->SC_SSP_NumericCompare(bAccept);
}
bool TcBtPhone::getContactInfo(void)
{
unsigned char searchKeyword[BT_PB_SEARCH_CHAR_SIZE];
memcpy(searchKeyword, &gEngCharacterTable[0], BT_PB_SEARCH_CHAR_SIZE);
getContactCount = 0;
//G_BtPB->BtApp_PB_CmdGetContactsList(0,9,searchKeyword);
G_BtPB->BtApp_PB_CmdGetContactsListInfo(getContactCount,searchKeyword);
getContactCount ++;
}
bool TcBtPhone::getHistoryCalInfo(void)
{
G_BtPB->BtApp_PB_CmdPACPullCallHistory(BTAPP_PB_SELECT_CCH);
}
bool TcBtPhone::cmdReDial( void)
{
G_BtHf->BtApp_HF_CmdDialRedial(0);
}
bool TcBtPhone::cmdDialByNum( unsigned char * contactPhNum,short numSize)
{
G_BtPB->BtApp_PB_CmdDialPlaceByNumber(0,numSize,contactPhNum);
}
bool TcBtPhone::cmdDialByName(const unsigned char * contactName,short nameSize)
{
}
bool TcBtPhone::cmdIncomingAnswer(void)
{
G_BtHf->BtApp_HF_CmdIncomingAnswer(0);
}
bool TcBtPhone::cmdIncomingReject(void)
{
G_BtHf->BtApp_HF_CmdIncomingReject(0);
}
bool TcBtPhone::cmdEndCal(void)
{
G_BtHf->BtApp_HF_CmdCallTerminate(0);
}
bool TcBtPhone::cmdHangUp(void)
{
G_BtHf->BtApp_HF_CmdIncomingResponseAndHold(0,0);
}
bool TcBtPhone::cmdChangeVoiceMode(void)
{
G_BtHf->BtApp_HF_CmdCallAudioOnOff(0);
}
bool TcBtPhone::cmdSetVoiceMute(void)
{
G_BtHf->BtApp_HF_CmdCallMicMute(0);
}
void TcBtPhone::cmdVoiceRecognition(void)
{
G_BtHf->BtApp_HF_CmdVoiceRecognition(0);
}
bool TcBtPhone::cmdNumBtnClicked(int Num)
{
unsigned char data=0;
const U8 aucDtmf[]="123456789*0#ABCD";
data=aucDtmf[Num-BT_HF_MAIN_BTN_DIAL_1]; /* Set data as start enum 0 */
G_BtHf->BtApp_HF_CmdCallDTMF(0, data);
}
void TcBtPhone::cmdOpenPhoneAudio()
{
// G_BtHf->BtApp_HF_CmdOpenAudio();
}
void TcBtPhone::cmdStartOutgoingCall()
{
fprintf(stderr,"come to here %s %d\n",__FUNCTION__,__LINE__);
G_BtHf->BtApp_HF_CmdOutgoingStart(0);
}
void TcBtPhone::cmdStartIncomingCall()
{
fprintf(stderr,"come to here %s %d %d,\n",__FUNCTION__,__LINE__);
if (outgoingAudioOpened == false)
{
G_BtHf->BtApp_HF_CmdIncomingStart(0);
outgoingAudioOpened = true;
}
}
void TcBtPhone::OnSYSHandler(int result)
{
switch (result)
{
case BT_SYS_EVT_INIT_SVR_ERR:
{
// BtappSenddeviceDBusToUI(1,(unsigned char *)"Could not execute to BSA server.");
emit btinitBtappFaile();
}
break;
case BT_SYS_EVT_INIT_ERR:
{
//char *err="Could not connect to BSA server";
emit btinitBtappFaile();
}
break;
case BT_SYS_EVT_INIT_CFM:
{
}
break;
case BT_SYS_EVT_DEINIT_CFM:
{
emit btdeInitBtappSuccess();
}
break;
default:
break;
}
}
void TcBtPhone::OnDMHandler(int type,void *pTcBtEvt)
{
printf("===========OnDMHandler===result = %d=============\n",type);
switch (type)
{
case BT_DM_EVT_BOND_SUCCESS:
{
//If top widow is DM widow, we need to refresh device list.
TcBtEvt_DMEvt(BT_DM_EVT_REFRESH,NULL);
}
break;
case BT_DM_EVT_BOND_ERR:
{
}
break;
case BT_DM_EVT_PINCODE_IND:
{
}
break;
case BT_DM_EVT_SSP_NUMERIC_COMPARISON_IND:
{
//G_BtDm->SC_SSP_NumericCompare(1);
TcBtScPairingSSPSendEvt *pTcBtSCEvt = (TcBtScPairingSSPSendEvt *)pTcBtEvt;
char npassword[24];
char naddr[64];
sprintf(npassword,"%d",pTcBtSCEvt->numericValue);
sprintf(naddr,"%02x:%06x:%x",pTcBtSCEvt->deviceAddr.nap,pTcBtSCEvt->deviceAddr.lap,pTcBtSCEvt->deviceAddr.uap);
//QString name((char*)pTcBtSCEvt->deviceName);
//const QChar *data =(const QChar *)(pTcBtSCEvt->deviceName);
QString name((char *)pTcBtSCEvt->deviceName);
QString password((char*)npassword);
QString addr((char*)naddr);
emit btdeviceCompare(name,password,addr);
if(pTcBtSCEvt->deviceName != NULL)
{
TC_BT_Pfree(pTcBtSCEvt->deviceName);
}
}
break;
case BT_DM_EVT_SSP_PASSKEY_NOTIFICATION_IND:
{
TcBtScPairingSSPSendEvt *pTcBtSCEvt = (TcBtScPairingSSPSendEvt *)pTcBtEvt;
}
break;
case BT_DM_EVT_SSP_JUST_WORKS_IND:
{
TcBtScPairingSendEvt *pTcBtSCEvt = (TcBtScPairingSendEvt *)pTcBtEvt;
}
break;
case BT_DM_EVT_CONNECTED:
{
TcBtScPairingSendEvt *pTcBtSCEvt = (TcBtScPairingSendEvt *)pTcBtEvt;
// memcpy(deviceName ,pTcBtSCEvt->deviceName,sizeof(pTcBtSCEvt->deviceName));
char naddr[64];
// sprintf(npassword,"%d",pTcBtSCEvt->numericValue);
sprintf(naddr,"%02x:%06x:%x",pTcBtSCEvt->deviceAddr.nap,pTcBtSCEvt->deviceAddr.lap,pTcBtSCEvt->deviceAddr.uap);
// QString name((char*)pTcBtSCEvt->deviceName);
//const QChar *data =(const QChar *)(pTcBtSCEvt->deviceName);
QString name((char *)pTcBtSCEvt->deviceName);
QString addr((char*)naddr);
emit btdeviceConnectSuccess(name,addr);
}break;
case BT_DM_EVT_SEARCH_RESULT:
{
TcBtSdSearchResultInd *pTcBtSDEvt = (TcBtSdSearchResultInd *)pTcBtEvt;
G_BtDm->AddSearchList(pTcBtSDEvt->deviceAddr, pTcBtSDEvt->deviceClass, pTcBtSDEvt->rssi, (char*)pTcBtSDEvt->deviceName);
//QString s((char*)pTcBtSDEvt->deviceName);
//const QChar *data =(const QChar *)(pTcBtSDEvt->deviceName);
QString s(( char*)pTcBtSDEvt->deviceName);
//qDebug() <<s;
emit btdeviceSearchSuccess(s);
if(pTcBtSDEvt->deviceName != NULL)
{
TC_BT_Pfree(pTcBtSDEvt->deviceName);
}
printf("==========AddSearchList====Line %d=====\n",__LINE__);
}break;
case BT_DM_EVT_SEARCH_CLOSE:
{
emit btdeviceSearchClosed();
}break;
case BT_DM_EVT_REFRESH:
{
G_BtDm->Handler(type,pTcBtEvt);
}break;
case BT_DM_EVT_READLOCALDEVICE:
{
char naddr[64];
TcBtInt8 LocalDevName[TC_BT_MAX_FRIENDLY_NAME_LEN+1] = {NULL, };
TcBtCmReadLocalBdAddrCfm *pTcBtCMEvt = (TcBtCmReadLocalBdAddrCfm *)pTcBtEvt;
(void)sprintf(LocalDevName, "BR_LIN_%06x", pTcBtCMEvt->deviceAddr.lap);
sprintf(naddr,"%02x:%06x:%x",pTcBtCMEvt->deviceAddr.nap,pTcBtCMEvt->deviceAddr.lap,pTcBtCMEvt->deviceAddr.uap);
QString name(LocalDevName);
QString addr((char*)naddr);
emit btinitBtappSuccess(name,addr);
}break;
default:
break;
}
// if(pTcBtEvt != NULL)
// {
// TC_BT_Pfree(pTcBtEvt);
// }
}
#if 1
void TcBtPhone::setState(State state)
{
m_state = state;
}
int TcBtPhone::EventProcess(unsigned int event_type, int param1, const char* param2)
{
UI_EVENT_TYPE *pstEvent = (UI_EVENT_TYPE *)event_type;
unsigned char src;
unsigned char ucDevNo,ucTmpDevNo;
unsigned char ucValue;
unsigned char loc;
const unsigned char *data;
unsigned short id;
static char tmp[16];
int uniStrlength = 0;
static unsigned char strUniTemp[256];
unsigned short dataLength = 0;
int totalLength = 0;
BT_HF_STATUS status=BT_HF_STATUS_DEACTIVATED;
#ifdef BT_HFP_WIDEBAND_SPEECH
unsigned char boCodecUpdated=FALSE;
#endif
src = MSG_SRC_BT_HF;
if(G_BtSys->BtApp_SYS_GetStatus(BTAPP_STATUS_HW_AVAILABLE) == TRUE)
{
//location = TccUISys_GetDiskLocation(MSG_SRC_BT_SYS);
/* All events must be delivered, as if HF is activated */
loc = BT_HF_WINDOW_ACTIVATED;
}
id = pstEvent->id;
totalLength = param1;
data = (unsigned char *)param2;
if(*data == 0xFF && totalLength > 2)
{
data++;
dataLength = (unsigned short)(*data);
data++;
dataLength |= ((unsigned short)(*data)) << 8;
data++;
totalLength -= 2;
}
else
{
dataLength = (unsigned short)(*data);
data++;
totalLength--;
}
if(totalLength < dataLength)
{
return -1; /* Message Error */
}
ucDevNo=0;
if(id!=BT_HF_EVT_UPDATE_STATUS)
{
ucDevNo=*data; /* device no */
data+=4;
//qDebug() << "ucDevNo" << ucDevNo;
}
#ifdef BT_AUDIO_SINK
/* for mode change between BT AUDIO */
if(G_BtSys->BtApp_SYS_GetBasicMode() == B_BT_A2DP_SINK)
{
if((id == BT_HF_EVT_INCOMING_IND)
|| (id == BT_HF_EVT_CIEV_CALL_ONE_IND)
|| (id == BT_HF_EVT_OUTGOING_START_IND)
|| (id == BT_HF_EVT_VOICE_RECOGNITION_START_IND)
|| (id == BT_HF_EVT_VOICE_RECOGNITION_LEARN_START_IND))
{
}
}
#endif
if ((id != 58) && (id !=1)&& (id !=47))
{
printf("=======================1==come to here %s %d id =%d ==================== \n",__FUNCTION__,__LINE__,id);
}
switch (id)
{
case BT_HF_EVT_UPDATE_STATUS :
break;
case BT_HF_EVT_POWEROFF :
break;
case BT_HF_EVT_NOT_ACTIVATED :
break;
case BT_HF_EVT_ALREADY_ACTIVATED :
break;
case BT_HF_EVT_ACTIVATE_CFM :
break;
case BT_HF_EVT_ACTIVATE_ERR :
break;
case BT_HF_EVT_DEACTIVATE_CFM :
break;
case BT_HF_EVT_DEACTIVATE_ERR :
break;
case BT_HF_EVT_SERVICE_CONNECT_IND :
break;
case BT_HF_EVT_SERVICE_CONNECT_NOTIFICATION_IND:
break;
case BT_HF_EVT_SERVICE_CONNECT_ERR :
break;
case BT_HF_EVT_ALREADY_CONNECTED :
break;
case BT_HF_EVT_NOT_CONNECTED :
break;
case BT_HF_EVT_DISCONNECT_BY_REMOTE :
break;
case BT_HF_EVT_DISCONNECT_IND :
break;
case BT_HF_EVT_DISCONNECT_ERR :
break;
case BT_HF_EVT_DISCONNECT_LINK_LOSS :
break;
case BT_HF_EVT_AUDIO_IND :
if(m_state == IncomingCall)
//setState(ConnectCall);
break;
case BT_HF_EVT_AUDIO_ACCEPT_IND :
G_BtHf->BtApp_HF_CmdCallAudioAccept(0, TRUE);
break;
case BT_HF_EVT_UPDATE_SUPPORTED_CODEC_CFM :
break;
#ifdef BT_HFP_WIDEBAND_SPEECH
/* Need to update icon here *
* 1. connect -> first incoming -> answer to update HD voice icon *
* 2. Call -> disconnect -> connect */
case BT_HF_EVT_SELECTED_CODEC_IND :
break;
#endif
case BT_HF_EVT_INCOMING_IND :
{
if (m_state != IncomingCall)
{
emit btRequestBtPhoneAudioSource();
emit btStartIncomingCall();
}
setState(IncomingCall);
INT8U boUnicodeOrNot;
char strUniTemp[256];
int uniStrlength = 0;
INT8U aucCallNumber[BTAPP_HF_CALLNUM_MAX_LEN];
boUnicodeOrNot = data[3];
memcpy(&aucCallNumber[0],&data[4],BTAPP_HF_CALLNUM_MAX_LEN);
if (boUnicodeOrNot!=0)
{
memset(&strUniTemp, 0x00, 256);
uniStrlength = str_len16(aucCallNumber)*2;
strUniTemp[0] = 0x00;
strUniTemp[1] = 0x80;
memcpy(&(strUniTemp[2]), aucCallNumber, uniStrlength);
const QChar *data=(const QChar *)(aucCallNumber);
QString callName(data);
qDebug()<<callName.size();
if(callName.size() != 0)
{
emit btincomingCall(callName);
}
}
else
{
QString callNum((char *)aucCallNumber);
qDebug()<<callNum.size();
if (callNum.size() != 0)
{
emit btincomingCall(callNum);
}
}
}
break;
case BT_HF_EVT_INCOMING_TIMEOUT_IND:
G_BtHf->BtApp_HF_CmdIncomingEnd(0);
break;
case BT_HF_EVT_INCOMING_END_IND:
emit btendingCall();
emit btReleaseBtPhoneAudioSource();
G_BtHf->BtApp_HF_CmdIncomingEnd(0);
break;
case BT_HF_EVT_CIEV_CALL_ZERO_IND:
unsigned char cmd[3];
unsigned char pCmd[4];
cmd[0] = 2;
cmd[1] = 0 & 0xFF ; /* data 1 */
cmd[2] = loc;
G_BtHf->BtApp_HF_CmdPwrOff(cmd[1]);
pCmd[0] = 1;
pCmd[1] = 0 & 0xFF ;
G_BtHf->BtApp_HF_CmdCallEnd(pCmd[1]);
//G_BtHf->BtApp_HF_CmdCloseAudio();
outgoingAudioOpened = false;
emit btendingCall();
emit btReleaseBtPhoneAudioSource();
setState(Unknow);
break;
case BT_HF_EVT_CIEV_CALL_ONE_IND:
{
emit btconnectCall();
if(m_state == IncomingCall)
{
emit btAnswerCall();
G_BtHf->BtApp_HF_CmdCallDTMF(0, 0);
G_BtHf->BtApp_HF_CmdCallStart(0);
}
callTime = 0;
emit btchangeCallTime("");
}
break;
case BT_HF_EVT_CIEV_CALLSETUP_IND:
{
if(m_state == ConnectCall)
{
}
if(m_state == IncomingCall)
{
//emit btendingCall();
return 1;
}
INT8U boUnicodeOrNot;
char strUniTemp[256];
int uniStrlength = 0;
INT8U aucCallNumber[BTAPP_HF_CALLNUM_MAX_LEN];
boUnicodeOrNot = data[9];
memcpy(&aucCallNumber[0],&data[10],BTAPP_HF_CALLNUM_MAX_LEN);
if (boUnicodeOrNot!=0)
{
memset(&strUniTemp, 0x00, 256);
uniStrlength = str_len16(aucCallNumber)*2;
strUniTemp[0] = 0x00;
strUniTemp[1] = 0x80;
memcpy(&(strUniTemp[2]), aucCallNumber, uniStrlength);
const QChar *data=(const QChar *)(aucCallNumber);
QString callName(data);
// qDebug()<<callName.size();
if((callName.size() != 0) )
{
emit btoutgoingCall(callName);
}
}
else
{
QString callNum((char *)aucCallNumber);
qDebug()<<callNum.size();
if ((callNum.size() != 0))
{
emit btoutgoingCall(callNum);
}
}
}
break;
case BT_HF_EVT_CIEV_CALLHELD_IND:
break;
case BT_HF_EVT_CIEV_SERVICE_IND :
break;
case BT_HF_EVT_CIEV_ROAM_IND :
break;
case BT_HF_EVT_CIEV_SIGNAL_IND:
break;
case BT_HF_EVT_CIEV_BATTCHG_IND:
break;
case BT_HF_EVT_CIEV_MESSAGE_IND:
break;
case BT_HF_EVT_ANSWER_REQ:
break;
case BT_HF_EVT_REJECT_REQ:
break;
case BT_HF_EVT_REJECT_ERR:
break;
case BT_HF_EVT_TERMINATE_REQ:
break;
case BT_HF_EVT_PLACE_REQ:
break;
case BT_HF_EVT_CALL_ALREADY_EXIST:
break;
case BT_HF_EVT_CLIP_IND:
{
}
break;
case BT_HF_EVT_OUTGOING_NUMBER_IND:
{
}
break;
case BT_HF_EVT_OUTGOING_FROM_HFG_IND:
setState(OutCall);
emit btRequestBtPhoneAudioSource();
break;
case BT_HF_EVT_OUTGOING_START_IND:
{
emit btStartOutgoingCall();
}
break;
case BT_HF_EVT_OUTGOING_END_IND:
break;
case BT_HF_EVT_OUTGOING_RETRY :
break;
case BT_HF_EVT_OUTGOING_DIAL_INF :
break;
case BT_HF_EVT_CALL_TIMESTAMP_COUNT_ID:
{
static unsigned char cCallTime[12];
INT32U uiCallSec= GetData4Bytes(data);
if((uiCallSec != 0) && ((uiCallSec%300) == 0))////FOR TIME CHANGE
{
//display hour
cCallTime[0] = ((unsigned char)((callTime/3600)/10))+0x30;
cCallTime[1] = ((unsigned char)((callTime/3600)%10))+0x30;
cCallTime[2] = ':';
//display minute
cCallTime[3] = ((unsigned char)(((callTime%3600)/60)/10))+0x30;
cCallTime[4] = ((unsigned char)(((callTime%3600)/60)%10))+0x30;
cCallTime[5] = ':';
//display sec
cCallTime[6] = ((unsigned char)((callTime%60)/10))+0x30;
cCallTime[7] = ((unsigned char)((callTime%60)%10))+0x30;
cCallTime[8] = 0;
emit btchangeCallTime(QString((char *)cCallTime));
callTime ++;
}
else
{
//emit btchangeCallTime("");
}
}
break;
case BT_HF_EVT_CALL_TIMESTAMP_CLEAR_ID:
//emit btendingCall();
callTime = 0;
emit btchangeCallTime("");
break;
case BT_HF_EVT_SET_SPEAKER_VOLUME_IND:
{
G_BtHf->BtApp_HF_CmdSetVol(0);
}
break;
case BT_HF_EVT_SET_MIC_GAIN_IND:
break;
#ifdef BT_HFP_LOOPBACK_TEST
case BT_HF_EVT_LOOPBACK_TEST_START_IND:
break;
case BT_HF_EVT_LOOPBACK_TEST_END_IND:
break;
#endif
case BT_HF_EVT_SUPPORT_VOICE_RECOGNITION_IND :
break;
case BT_HF_EVT_VOICE_RECOGNITION_START_IND:
{
G_BtHf->BtApp_HF_CmdVoiceRecognitionStart(0);
G_BtHf->BtApp_HF_CmdCallDTMF(0,0);
G_BtHf->BtApp_HF_CmdCallStart(0);
}
break;
case BT_HF_EVT_VOICE_RECOGNITION_END_IND:
{
G_BtHf->BtApp_HF_CmdVoiceRecognitionLearnEnd(0);
}
break;
case BT_HF_EVT_VOICE_RECOGNITION_LEARN_START_IND:
break;
case BT_HF_EVT_VOICE_RECOGNITION_LEARN_END_IND:
break;
#if 1 /* Telechips' 2008.12 QA - 3.6 (a), (b) */
case BT_HF_EVT_CLCC_IND:
{
}
break;
#endif
case BT_HF_EVT_CCWA_IND:
break;
case BT_HF_EVT_CMEE_IND:
break;
case BT_HF_EVT_OUTGOING_BUSY_LINE_IND:
break;
case BT_HF_EVT_GET_INFORMATION_INF: /* Get remote device information */
break;
case BT_HS_EVT_SERVICE_CONNECT_IND:
break;
case BT_HS_EVT_SERVICE_CONNECT_ERR:
break;
case BT_HS_EVT_ALREADY_CONNECTED:
break;
case BT_HS_EVT_NOT_CONNECTED:
break;
case BT_HS_EVT_DISCONNECT_BY_REMOTE:
break;
case BT_HS_EVT_DISCONNECT_IND:
break;
case BT_HS_EVT_DISCONNECT_ERR:
break;
case BT_HS_EVT_DISCONNECT_LINK_LOSS:
break;
case BT_HS_EVT_RING_IND:
break;
case BT_HS_EVT_RING_START_IND:
break;
case BT_HS_EVT_RING_TIMEOUT_IND:
break;
case BT_HS_EVT_RING_END_IND:
break;
case BT_HS_EVT_AUDIO_ON_IND:
break;
case BT_HS_EVT_AUDIO_OFF_IND:
break;
case BT_HS_EVT_SET_SPEAKER_VOLUME_IND:
break;
case BT_HS_EVT_SET_MIC_GAIN_IND:
break;
/* PC Tool Use Home screen */
case BT_HF_EVT_OPTIONS_AUTOANSWER_INF:
break;
case BT_HF_EVT_OPTIONS_MICGAIN_INF:
break;
case BT_HF_EVT_OPTIONS_SMSALARM_INF:
break;
case BT_HF_EVT_OPTIONS_RING_INF:
break;
case BT_HF_EVT_OPTIONS_BUILTIN_INF:
break;
case BT_HF_EVT_OPTIONS_NREC_INF:
break;
case BT_HF_EVT_DTMF_INF:
break;
case BT_HF_EVT_SET_MIC_MUTE_INF:
break;
case BT_HF_EVT_OPTIONS_CLCC_INF:
break;
case BT_HF_EVT_OPTIONS_BIA_INF:
break;
default:
break;
}
}
#endif
void TcBtPhone::UIBTHFMsgProcessor(BT_HF_MSG_t *uiMessage)
{
if (uiMessage != NULL)
{
if (uiMessage->type == MSG_EVENT_TYPE)
{
UI_EVENT_TYPE event_type;
event_type.group = 0;
event_type.id = uiMessage->id;
event_type.src = MSG_SRC_BT_HF;
event_type.type = uiMessage->type;
EventProcess((unsigned int)&event_type,uiMessage->totalLength, (const char *)uiMessage->data);
}
else if (uiMessage->type == MSG_INFO_TYPE)
{
//objHF.BT_HF_InfoParser(uiMessage);