comparison src/ui3/mfw/mfw_BtipsBmg.c @ 420:e8ddbb0837ed

src/ui3: initial import of TCS3/LoCosto BMI & MFW code
author Mychaela Falconia <falcon@freecalypso.org>
date Sun, 21 Jan 2018 03:09:00 +0000
parents
children
comparison
equal deleted inserted replaced
419:59143cd42ec7 420:e8ddbb0837ed
1 /* =========================================================
2 * Texas Instruments OMAP(TM) Platform Software
3 * (c) Copyright Texas Instruments, Incorporated. All Rights Reserved.
4 *
5 * Use of this software is controlled by the terms and conditions found
6 * in the license agreement under which this software has been supplied.
7 * ========================================================== */
8 /*
9 $Project name: Basic Bluetooth MMI
10 $Project code:
11 $Module: Bluetooth BMG MFW
12 $File: Mfw_Btips.c
13 $Revision: 1.0
14 $Author: Texas Instruments
15 $Date: 26/06/07
16
17 ********************************************************************************
18
19 Description:
20
21 This module provides the BTIPS BMG APPlication functionality.
22
23 ********************************************************************************
24 $History: Mfw_Btips.c
25
26 26/06/07 Sasken original version
27
28 $End
29
30 *******************************************************************************/
31
32
33
34
35 /*******************************************************************************
36
37 Include files
38
39 *******************************************************************************/
40
41 #define ENTITY_MFW
42 /* includes */
43
44 #include <string.h>
45 #ifdef FF_MMI_BTIPS_APP
46
47 /* BTIPS Includes */
48 #include "me.h"
49 #include "osapi.h"
50 #include "btl_common.h"
51 #include "bthal_btdrv.h"
52 #include "bthal_pm.h"
53 #include "bttypes.h"
54 #include "goep.h"
55 #include "bpp.h"
56 #include "Debug.h"
57
58 /* BTL includes */
59 #include "btl_bmg.h"
60
61 #endif
62 #if defined (NEW_FRAME)
63
64 #include "typedefs.h"
65 #include "vsi.h"
66 #include "pei.h"
67 #include "custom.h"
68 #include "gsm.h"
69 #include "prim.h"
70
71 #else
72
73 #include "STDDEFS.H"
74 #include "custom.h"
75 #include "gsm.h"
76 #include "vsi.h"
77
78 #endif
79
80 #include "mfw_mfw.h"
81 #include "mfw_win.h"
82 #include "mfw_icn.h" /* included for mfw_mnu.h */
83 #include "mfw_mnu.h"
84 #include "mfw_tim.h"
85 #include "mfw_kbd.h"
86 #include "mfw_sat.h" /* included for MmiDummy.h, included for MmiMenu.h */
87
88 #include "Mfw_Btips.h"
89 #include "Mfw_BtipsBmg.h"
90
91
92 #ifdef FF_MMI_BTIPS_APP
93
94 #define BTL_BMG_MAX_PIN_LEN 16
95 #define BTL_BMG_SEARCH_ALL 0
96 #define BTL_BMG_SEARCH_AUDIO_MAJOR 1
97 #define PME_APP_NAME "Locosto Phone"
98
99
100
101 //extern BtlA2dpContext *btlA2dpContext ;
102 //extern BtlFtpsContext *ftpsContext;
103 /* Internal functions prototypes */
104 void btips_bmgCallback (const BtlBmgEvent *);
105 extern UBYTE g_device_name[BT_MAX_REM_DEV_NAME];
106 extern BOOL g_Outgoing;
107
108 static BtlBmgContext *mfwBtipsBmgContext;
109
110 /*---------------------------------------------------------------------------
111 * mfw_btips_bmgGetDeviceName
112 *---------------------------------------------------------------------------
113 *
114 * Synopsis: Send PIN code.
115 *
116 * Return: TRUE if name is available. Else convert the BD_ADDR itself to a string.
117 *
118 */
119 BOOL mfw_btips_bmgGetDeviceName(const BD_ADDR *bdAddr, U8 *name)
120 {
121 BtStatus btStatus;
122 BtlBmgDeviceRecord record;
123 TRACE_FUNCTION("mfw_btips_bmgGetDeviceName");
124 btStatus = BTL_BMG_FindDeviceRecord(mfwBtipsBmgContext, bdAddr, &record);
125 if(BT_STATUS_SUCCESS == btStatus)
126 {
127
128 strcpy(name, record.name);
129 }
130 else
131 {
132 bdaddr_ntoa(bdAddr, name);
133 }
134 return TRUE;
135 }
136 //26-07-07
137 /*---------------------------------------------------------------------------
138 * mfw_btips_bmgSetDeviceRecord
139 *---------------------------------------------------------------------------
140 *
141 * Synopsis: Send PIN code.
142 *
143 * Return: TRUE if name is available. Else convert the BD_ADDR itself to a string.
144 *
145 */
146 BOOL mfw_btips_bmgSetDeviceNameInRecord(const BD_ADDR *bdAddr, UBYTE *name)
147 {
148 BtStatus btStatus;
149 BtlBmgDeviceRecord record;
150 TRACE_FUNCTION("mfw_btips_bmgGetDeviceName");
151 btStatus = BTL_BMG_FindDeviceRecord(mfwBtipsBmgContext, bdAddr, &record);
152 if(BT_STATUS_SUCCESS == btStatus)
153 {
154
155 OS_MemCopy(record.name, name, BT_MAX_REM_DEV_NAME);
156 BTL_BMG_SetDeviceRecord(mfwBtipsBmgContext, &record);
157
158 }
159 else
160 {
161 bdaddr_ntoa(bdAddr, name);
162 }
163 return TRUE;
164 }
165
166
167 BOOL mfw_btips_bmgGetDeviceState (const BD_ADDR *bdAddr, BtRemDevState *state)
168 {
169 TRACE_FUNCTION("mfw_btips_bmgGetDeviceState");
170 BTL_BMG_GetRemDevState (mfwBtipsBmgContext, bdAddr, state);
171 return TRUE;
172 }
173
174 /*---------------------------------------------------------------------------
175 * mfw_btips_bmgSendPin
176 *---------------------------------------------------------------------------
177 *
178 * Synopsis: Send PIN code.
179 *
180 * Return: TRUE if send PIN code is successful, FALSE otherwise.
181 *
182 */
183 BOOL mfw_btips_bmgSendPin (const BD_ADDR *bdAddr,
184 const U8 *pin,
185 const U8 len)
186 {
187 BtStatus btStatus;
188
189 btStatus = BTL_BMG_PinReply(mfwBtipsBmgContext, bdAddr, pin, len, BPT_SAVE_TRUSTED);
190 return mfw_btips_checkStatus(btStatus);
191 }
192
193 /*---------------------------------------------------------------------------
194 * mfw_btips_bmgSendHciCommand
195 *---------------------------------------------------------------------------
196 *
197 * Synopsis: Send an HCI Command.
198 *
199 * Return: TRUE if command was sent successfully, FALSE otherwise.
200 *
201 */
202 BOOL mfw_btips_bmgSendHciCommand (const U16 hciCommand,
203 const U8 parmsLen,
204 const U8 *parms,
205 const U8 event)
206 {
207 BtStatus btStatus;
208
209 TRACE_FUNCTION_P1("mfw_btips_bmgSendHciCommand %x", hciCommand);
210 btStatus = BTL_BMG_SendHciCommand(mfwBtipsBmgContext, hciCommand, parmsLen, parms, event);
211 return mfw_btips_checkStatus(btStatus);
212 }
213
214
215 BOOL mfw_btips_bmgBond(const BD_ADDR *bdAddr,
216 const U8 *pin,
217 const U8 len)
218 {
219 BtStatus btStatus;
220 btStatus = BTL_BMG_Bond(mfwBtipsBmgContext, bdAddr, pin, len, BPT_SAVE_TRUSTED);
221 return mfw_btips_checkStatus(btStatus);
222 }
223
224 BOOL mfw_btips_bmgCancelBond(const BD_ADDR *bdAddr)
225 {
226 BtStatus btStatus;
227 TRACE_FUNCTION("mfw_btips_bmgCancelBond");
228 btStatus = BTL_BMG_CancelBond(mfwBtipsBmgContext, bdAddr);
229 return mfw_btips_checkStatus(btStatus);
230
231 }
232 BOOL mfw_btips_bmgGetCodMajorValue(U8* CODMajorStr, U32 *CODMajor)
233 {
234 BOOL result;
235 #if 0
236 LINE_PARSER_ToLower(CODMajorStr);
237
238 *CODMajor = COD_MAJOR_MISCELLANEOUS;
239 result = TRUE;
240
241 if (strcmp((const char*)CODMajorStr, "comp") == 0)
242 {
243 *CODMajor = COD_MAJOR_COMPUTER;
244 }
245 else if (strcmp((const char*)CODMajorStr, "phone") == 0)
246 {
247 *CODMajor = COD_MAJOR_PHONE;
248 }
249 else if (strcmp((const char*)CODMajorStr, "lan") == 0)
250 {
251 *CODMajor = COD_MAJOR_LAN_ACCESS_POINT;
252 }
253 else if (strcmp((const char*)CODMajorStr, "audio") == 0)
254 {
255 *CODMajor = COD_MAJOR_AUDIO;
256 }
257 else if (strcmp((const char*)CODMajorStr, "periph") == 0)
258 {
259 *CODMajor = COD_MAJOR_PERIPHERAL;
260 }
261 else if (strcmp((const char*)CODMajorStr, "imaging") == 0)
262 {
263 *CODMajor = COD_MAJOR_IMAGING;
264 }
265 else if (strcmp((const char*)CODMajorStr, "none") == 0)
266 {
267 *CODMajor = COD_MAJOR_MISCELLANEOUS;
268 }
269 else
270 {
271 result = FALSE;
272 }
273 #endif
274 return result;
275 }
276
277 BOOL mfw_btips_bmgGetLAPValue(U8* lapStr, U32 *lap)
278 {
279 BOOL result;
280 #if 0
281 LINE_PARSER_ToLower(lapStr);
282
283 result = TRUE;
284
285 if (strcmp((const char*)lapStr, "giac") == 0)
286 {
287 *lap = BT_IAC_GIAC;
288 }
289 if (strcmp((const char*)lapStr, "liac") == 0)
290 {
291 *lap = BT_IAC_LIAC;
292 }
293 else
294 {
295 result = FALSE;
296 }
297 #endif
298 return result;
299 }
300
301 /*---------------------------------------------------------------------------
302 * mfw_btips_bmgSearch
303 *---------------------------------------------------------------------------
304 *
305 * Synopsis: Starts search process.
306 *
307 * Return: TRUE if search process is successfull, FALSE otherwise.
308 *
309 */
310 BOOL mfw_btips_bmgCancelSearch (void)
311 {
312 BtStatus btStatus = BT_STATUS_FAILED;
313
314 TRACE_FUNCTION ("mfw_btips_bmgCancelSearch()");
315
316 btStatus = BTL_BMG_CancelSearch(mfwBtipsBmgContext);
317 TRACE_FUNCTION_P1("MFW_BTIPS_BMG :BTL_BMG_CancelSearch returned btStatus: %s", pBT_Status(btStatus));
318
319 return mfw_btips_checkStatus(btStatus);
320 }
321
322 /*---------------------------------------------------------------------------
323 * mfw_btips_bmgSearch
324 *---------------------------------------------------------------------------
325 *
326 * Synopsis: Starts search process.
327 *
328 * Return: TRUE if search process is successfull, FALSE otherwise.
329 *
330 */
331 BOOL mfw_btips_bmgSearch (BOOL searchType)
332 {
333 BtStatus status = BT_STATUS_FAILED;
334 BtlBmgCodFilter CODFilter;
335 BtlBmgCodFilter *CODFilterPtr = 0;
336 // U8 lapStr[11];
337 BOOL performNameRequest = TRUE;
338 U8 maxResp = 0;
339 // U8 CODMajorStr[21];
340 // U32 CODMajor;
341
342 TRACE_FUNCTION_P1 ("mfw_btips_bmgSearch TYPE = %d", searchType);
343
344 switch(searchType)
345 {
346 case BTIPS_GENERIC_DEVICE_SEARCH:
347 status = BTL_BMG_SearchByCod(mfwBtipsBmgContext,
348 BTL_BMG_SEARCH_REGULAR,
349 BT_IAC_GIAC,
350 BT_INQ_TIME_GAP100,
351 MAX_RESPONSES,
352 0,
353 performNameRequest,
354 SDP_SERVICE_NONE);
355 break;
356 case BTIPS_A2DP_DEVICE_SEARCH:
357 CODFilter.codFilterMask = BTL_BMG_SEARCH_COD_FILTER_SERVICE_CLS|BTL_BMG_SEARCH_COD_FILTER_SERVICE_CLS;
358 CODFilter.serviceClass = COD_RENDERING|COD_AUDIO;
359 CODFilter.majorDeviceClass = COD_MAJOR_AUDIO;
360 status = BTL_BMG_SearchByCod(mfwBtipsBmgContext,
361 BTL_BMG_SEARCH_REGULAR,
362 BT_IAC_GIAC,
363 BT_INQ_TIME_GAP100,
364 MAX_RESPONSES,
365 &CODFilter,
366 performNameRequest,
367 SDP_SERVICE_NONE);
368 break;
369
370 case BTIPS_OPP_DEVICE_SEARCH:
371 CODFilter.codFilterMask = BTL_BMG_SEARCH_COD_FILTER_SERVICE_CLS;
372 CODFilter.serviceClass = COD_OBJECT_TRANSFER;
373 status = BTL_BMG_SearchByCod(mfwBtipsBmgContext,
374 BTL_BMG_SEARCH_REGULAR,
375 BT_IAC_GIAC,
376 BT_INQ_TIME_GAP100,
377 MAX_RESPONSES,
378 &CODFilter,
379 performNameRequest,
380 SDP_SERVICE_NONE);
381
382 break;
383 case BTIPS_HSHF_DEVICE_SEARCH:
384 CODFilter.codFilterMask = BTL_BMG_SEARCH_COD_FILTER_MAJOR_DEV_CLS;
385 CODFilter.majorDeviceClass = COD_MAJOR_AUDIO;
386 status = BTL_BMG_SearchByCod(mfwBtipsBmgContext,
387 BTL_BMG_SEARCH_REGULAR,
388 BT_IAC_GIAC,
389 BT_INQ_TIME_GAP100,
390 MAX_RESPONSES,
391 &CODFilter,
392 performNameRequest,
393 SDP_SERVICE_NONE);
394 break;
395
396 }
397
398
399 mfw_BtipsReport(("MFW_BTIPS_BMG :BTL_BMG_SearchByCod returned status: %s", pBT_Status(status)));
400 return mfw_btips_checkStatus(status);
401 }
402
403 /*---------------------------------------------------------------------------
404 * mfw_btips_bmgGetLocalDeviceName
405 *---------------------------------------------------------------------------
406 *
407 * Synopsis: Extract the currently set local name
408 *
409 * Return:
410 *
411 */
412 BOOL mfw_btips_bmgGetLocalDeviceName(U8 *name)
413 {
414 BtStatus btStatus;
415 U8 len = 0;
416 btStatus = BTL_BMG_GetLocalDeviceName(mfwBtipsBmgContext, name, &len);
417 return mfw_btips_checkStatus(btStatus);
418
419 }
420
421
422 /*---------------------------------------------------------------------------
423 * mfw_btips_bmgSetLocalDeviceName
424 *---------------------------------------------------------------------------
425 *
426 * Synopsis: Set local name (Send a null terminated string) of our device.
427 *
428 * Return: TRUE if setting local name is successfull, FALSE otherwise.
429 *
430 */
431 BOOL mfw_btips_bmgSetLocalDeviceName (U8 *name)
432 {
433 U8 len = 0;
434
435 BtStatus btStatus = BT_STATUS_FAILED;
436 len = (U8)(OS_StrLen((const char *)(name)));
437 name[len]=0;
438 btStatus = BTL_BMG_SetLocalDeviceName(mfwBtipsBmgContext, (U8 *)(name), len+1);
439 return mfw_btips_checkStatus(btStatus);
440 }
441
442 /*---------------------------------------------------------------------------
443 * mfw_btips_bmgSetPhoneVisibility
444 *---------------------------------------------------------------------------
445 *
446 * Synopsis: Set Accessibility of the BT device.
447 *
448 * Return: .
449 *
450 */
451 BOOL mfw_btips_bmgSetPhoneVisibility(BOOL status)
452 {
453 BtStatus btStatus;
454
455 BtAccessibleMode modeNC;
456 //BtAccessModeInfo infoNC;
457 BtAccessibleMode modeC;
458 //BtAccessModeInfo infoC;
459
460 TRACE_FUNCTION("mfw_btips_bmgSetPhoneVisibility");
461
462 btStatus = BTL_BMG_GetAccessibleMode(mfwBtipsBmgContext,
463 &modeNC,
464 0,
465 &modeC,
466 0);
467
468 TRACE_EVENT_P2("BTL_BMG_GetAccessibleMode %d, %d", modeNC, modeC);
469
470 if(TRUE == status)
471 {
472 modeNC = BAM_GENERAL_ACCESSIBLE;
473 modeC = BAM_GENERAL_ACCESSIBLE;
474 }
475 else
476 {
477 modeNC = BAM_CONNECTABLE_ONLY;
478 modeC = BAM_CONNECTABLE_ONLY;
479 }
480
481 btStatus = BTL_BMG_SetAccessibleMode(mfwBtipsBmgContext,
482 &modeNC,
483 0,
484 &modeC,
485 0);
486
487 TRACE_EVENT_P2("BTL_BMG_SetAccessibleMode %d, %d", modeNC, modeC);
488
489 return mfw_btips_checkStatus(btStatus);
490
491 }
492
493 /*---------------------------------------------------------------------------
494 * mfw_btips_bmgSetPhoneVisibility
495 *---------------------------------------------------------------------------
496 *
497 * Synopsis: Set Accessibility of the BT device.
498 *
499 * Return: .
500 *
501 */
502 BOOL mfw_btips_bmgGetPhoneVisibility(void)
503 {
504 BtStatus btStatus;
505
506 BtAccessibleMode modeNC;
507
508 BtAccessibleMode modeC;
509
510
511 TRACE_FUNCTION("mfw_btips_bmgSetPhoneVisibility");
512
513 btStatus = BTL_BMG_GetAccessibleMode(mfwBtipsBmgContext,
514 &modeNC,
515 0,
516 &modeC,
517 0);
518
519 if(modeNC == BAM_GENERAL_ACCESSIBLE)
520 return TRUE;
521
522 return FALSE;
523
524 }
525 /*---------------------------------------------------------------------------
526 * mfw_btips_bmgDeviceDelete
527 *---------------------------------------------------------------------------
528 *
529 * Synopsis: Delete a record with the given "bdAddr" from the device database.
530 *
531 * Return: .
532 *
533 */
534 BOOL mfw_btips_bmgDeviceDelete(const BD_ADDR *bdAddr)
535 {
536 BtStatus btStatus;
537
538 btStatus = BTL_BMG_DeleteDeviceRecord(mfwBtipsBmgContext, bdAddr);
539 mfw_BtipsReport(("BTL_BMG_GetNumberOfDeviceRecords() returned %s.\n", pBT_Status(btStatus)));
540 return mfw_btips_checkStatus(btStatus);
541 }
542
543 /*---------------------------------------------------------------------------
544 * mfw_btips_bmg_getPairedDevices
545 *---------------------------------------------------------------------------
546 *
547 * Synopsis: Enumerate the device database.
548 *
549 * Return: .
550 *
551 */
552 BOOL mfw_btips_bmg_getPairedDevices(Bmg_DeviceList *pairedDeviceList, U32 *count)
553 {
554 BtStatus btStatus;
555 U32 index, numOfDevicesDB;
556 BtlBmgDeviceRecord deviceRecord;
557 *count = 0;
558
559 TRACE_FUNCTION ("mfw_btips_bmg_getPairedDevices()");
560
561 /* Checks if the DB is empty or not*/
562 btStatus= BTL_BMG_GetNumberOfDeviceRecords(mfwBtipsBmgContext, &numOfDevicesDB);
563 mfw_BtipsReport(("BTL_BMG_GetNumberOfDeviceRecords() returned %s.\n", pBT_Status(btStatus)));
564 if(numOfDevicesDB!=0)
565 {
566 /*Current limitation is to have a display of only BT_MAX_DEVICE_LIST devices*/
567 for (index=0;index <numOfDevicesDB && index <= BT_MAX_DEVICE_LIST; index++)
568 {
569 btStatus=BTL_BMG_EnumDeviceRecords(mfwBtipsBmgContext, index, &deviceRecord);
570 mfw_BtipsReport(("BTL_BMG_EnumDeviceRecords() returned %s for %d: %s", pBT_Status(btStatus), index, deviceRecord.name));
571 if (btStatus == BT_STATUS_SUCCESS)
572 {
573 OS_MemCopy((U8*)&pairedDeviceList[index].bdAddr, (U8*)&deviceRecord.bdAddr, sizeof(BD_ADDR));
574 strcpy(pairedDeviceList[index].name, deviceRecord.name);
575 pairedDeviceList[index].myIndex = index;
576 }
577 }
578 *count = index;
579 return TRUE;
580 }
581 return mfw_btips_checkStatus(btStatus);
582 }
583
584
585
586 /*---------------------------------------------------------------------------
587 * mfw_btips_bmg_getConnectedDevices
588 *---------------------------------------------------------------------------
589 *
590 * Synopsis: Enumerate the device database.
591 *
592 * Return: .
593 *
594 */
595 BOOL mfw_btips_bmg_getConnectedDevices(Bmg_ConnectedDeviceList *ConnectedDeviceList, U32 *count)
596 {
597 BtStatus btStatus;
598 U32 index;//, numOfDevicesDB;
599 // BtlBmgDeviceRecord deviceRecord;
600 U32 profile_count=0;
601 BD_ADDR bdAddr;
602
603 char name[BT_MAX_REM_DEV_NAME];
604 U32 ServiceID;
605 *count = 0;
606
607 TRACE_FUNCTION ("mfw_btips_bmg_getConnectedDevices()");
608
609 for (index=0;index <BTIPS_MAX_PROFILE_COUNT; index++)
610 {
611 btStatus = mfw_btips_bmg_getConnectedDevicesForProfile(index,&bdAddr,name,&ServiceID);
612 if (btStatus)
613 {
614 memset(&ConnectedDeviceList[*count].name,0,BT_MAX_REM_DEV_NAME*sizeof(UBYTE));
615 memset(&ConnectedDeviceList[*count].bdAddr,0,sizeof(BD_ADDR));
616 OS_MemCopy((U8*)&ConnectedDeviceList[*count].bdAddr,(U8*)&bdAddr, sizeof(BD_ADDR));
617 strcpy(ConnectedDeviceList[*count].name, name);
618 ConnectedDeviceList[*count].myIndex = *count;
619 ConnectedDeviceList[*count].ServiceId= ServiceID;
620 ServiceID = 0;
621 (*count)++;
622 }
623
624 }
625
626 return mfw_btips_checkStatus(btStatus);
627 }
628
629 U32 mfw_btips_bmg_getConnectedDevicesCount(void)
630 {
631 BtStatus btStatus;
632 U32 index, count=0;
633 BD_ADDR bdAddr;
634
635 char name[BT_MAX_REM_DEV_NAME];
636 U32 ServiceID;
637
638
639 TRACE_FUNCTION ("mfw_btips_bmg_getConnectedDevicesCount()");
640
641 for (index=0;index <BTIPS_MAX_PROFILE_COUNT; index++)
642 {
643 btStatus = mfw_btips_bmg_getConnectedDevicesForProfile(index,&bdAddr,name,&ServiceID);
644
645 if (btStatus)
646 {
647 count++;
648 }
649 }
650 return count;
651 }
652
653 BOOL mfw_btips_bmg_getConnectedDevicesForProfile(U32 profile_num, BD_ADDR *bdAddr, U8 *name, U32 *ServiceID)
654 {
655
656
657 BOOL status;
658
659 switch(profile_num)
660 {
661
662 case BTIPS_SDP_SERVICE_A2DP:
663 status = mfw_btips_a2dpGetConnectedDevice(bdAddr, name);
664 if(TRUE ==status)
665 *ServiceID = BTIPS_SDP_SERVICE_A2DP;
666 TRACE_EVENT_P1("mfw_btips_bmg_getConnectedDevicesForProfile A2DP name =%s ",name);
667 break;
668
669
670 case BTIPS_SDP_SERVICE_VG:
671 status=mfw_btips_vgGetConnectedDevice(bdAddr, name);
672 if(TRUE ==status)
673 *ServiceID = BTIPS_SDP_SERVICE_VG;
674
675 TRACE_EVENT_P1("mfw_btips_bmg_getConnectedDevicesForProfile OPPC name =%s ",name);
676 break;
677
678
679
680 case BTIPS_SDP_SERVICE_OPPC:
681 status=mfw_btips_oppcGetConnectedDevice(bdAddr, name);
682 if(TRUE ==status)
683 *ServiceID = BTIPS_SDP_SERVICE_OPPC;
684
685 TRACE_EVENT_P1("mfw_btips_bmg_getConnectedDevicesForProfile OPPC name =%s ",name);
686 break;
687
688 case BTIPS_SDP_SERVICE_OPPS:
689
690 status=mfw_btips_oppsGetConnectedDevice(bdAddr, name);
691 if(TRUE ==status)
692 *ServiceID = BTIPS_SDP_SERVICE_OPPS;
693
694 TRACE_EVENT_P1("mfw_btips_bmg_getConnectedDevicesForProfile OPPS name =%s ",name);
695 break;
696
697
698 case BTIPS_SDP_SERVICE_FTPS:
699
700 status=mfw_btips_ftpsGetConnectedDevice(bdAddr, name);
701 if(TRUE ==status)
702 *ServiceID = BTIPS_SDP_SERVICE_FTPS;
703
704 TRACE_EVENT_P1("mfw_btips_bmg_getConnectedDevicesForProfile FTPS name =%s ",name);
705 break;
706
707
708 default:
709 break;
710 }
711 return status;
712 }
713
714 #if 0
715
716 /*---------------------------------------------------------------------------
717 * APP_BMG_SetSecurityMode
718 *---------------------------------------------------------------------------
719 *
720 * Synopsis: Set the security level of our device.
721 *
722 * Return: TRUE if setting the security level is successfull, FALSE otherwise.
723 *
724 */
725 BOOL APP_BMG_SetSecurityMode (void)
726 {
727 BtStatus status = BT_STATUS_FAILED;
728 U8 SecLevel;
729
730 LINE_PARSER_GetNextU8(&SecLevel, FALSE);
731 status = BTL_BMG_SetSecurityMode(mfwBtipsBmgContext, (SecLevel+1));
732 mfw_BtipsReport(("MFW_BTIPS_BMG :BTL_BMG_SetSecurityMode returned status: %s", pBT_Status(status)));
733 if (status == BT_STATUS_SUCCESS)
734 {
735 return TRUE;
736 }
737 return FALSE;
738 }
739
740
741 /*---------------------------------------------------------------------------
742 * APP_BMG_SetSecurityMode
743 *---------------------------------------------------------------------------
744 *
745 * Synopsis: Get the security level of our device.
746 *
747 * Return: TRUE if getting the security level is successfull, FALSE otherwise.
748 *
749 */
750 BOOL APP_BMG_GetSecurityMode (void)
751 {
752 BtStatus status = BT_STATUS_FAILED;
753 BtSecurityMode CurrentSecLevel;
754
755 status = BTL_BMG_GetSecurityMode(mfwBtipsBmgContext, &CurrentSecLevel);
756 mfw_BtipsReport(("MFW_BTIPS_BMG :APP_BMG_GetSecurityMode returned status: %s", pBT_Status(status)));
757 if (status == BT_STATUS_SUCCESS)
758 {
759 mfw_BtipsReport(("MFW_BTIPS_BMG : Current security mode is: %d", (CurrentSecLevel-1)));
760 return TRUE;
761 }
762 return FALSE;
763 }
764
765 #endif
766
767 /*---------------------------------------------------------------------------
768 * APP_BMG_AuthorizeDeviceReply
769 *---------------------------------------------------------------------------
770 *
771 * Synopsis: Reply for authorization request of another device.
772 *
773 * Return: TRUE if Autorization reply is successfull, FALSE otherwise.
774 *
775 */
776 BOOL mfw_btips_bmgAuthorizeDeviceReply (BOOL auth, BD_ADDR *BdAddr)
777 {
778 BtStatus btStatus = BT_STATUS_FAILED;
779 U8 AuthorizationType;//, BD_array[BDADDR_NTOA_SIZE];
780 AuthorizationType = auth? BTL_BMG_AUTHORIZED_NOT_TRUSTED: BTL_BMG_NOT_AUTHORIZED;
781 // btStatus = BTL_BMG_AuthorizeDeviceReply(mfwBtipsBmgContext, &BdAddr, (BtlBmgAuthorizationType) (AuthorizationType));
782 if (btStatus == BT_STATUS_SUCCESS)
783 {
784 return TRUE;
785 }
786 return FALSE;
787 }
788
789
790 /*---------------------------------------------------------------------------
791 * mfw_btips_bmgInit
792 *---------------------------------------------------------------------------
793 *
794 * Synopsis: BMG application initialization.
795 *
796 * Return: NONE.
797 *
798 */
799 void mfw_btips_bmgInit (void)
800 {
801 BtStatus btStatus = BT_STATUS_FAILED;
802
803 btStatus = BTL_BMG_Create(0, btips_bmgCallback, &mfwBtipsBmgContext);
804 Assert(btStatus == BT_STATUS_SUCCESS);
805
806 btStatus = BTL_BMG_SetEventForwardingMode(mfwBtipsBmgContext, BTL_BMG_EVENT_FORWARDING_ALL_EVENTS);
807 Assert(btStatus == BT_STATUS_SUCCESS);
808
809 #if 0
810 btStatus = BTL_BMG_SetClassOfDevice(mfwBtipsBmgContext, (COD_MAJOR_PHONE | COD_MINOR_PHONE_CELLULAR));
811 Assert(btStatus == BT_STATUS_SUCCESS);
812 #endif
813
814 mfw_BtipsReport(("BMGA_Init() complete.\n"));
815 }
816
817 /*---------------------------------------------------------------------------
818 * mfw_btips_bmgDeinit
819 *---------------------------------------------------------------------------
820 *
821 * Synopsis: BMG application deinitialization.
822 *
823 * Return: NONE.
824 *
825 */
826 void mfw_btips_bmgDeinit(void)
827 {
828 BtStatus btStatus = BT_STATUS_FAILED;
829
830 btStatus = BTL_BMG_Destroy(&mfwBtipsBmgContext);
831 Assert(btStatus == BT_STATUS_SUCCESS);
832
833 mfw_BtipsReport(("BMGA_Deinit() complete.\n"));
834 }
835
836 /*---------------------------------------------------------------------------
837 * btips_bmgCallback
838 *---------------------------------------------------------------------------
839 *
840 * Synopsis: Callback function to handle BMG profile events invoked in BTS context.
841 *
842 * Return: NONE.
843 *
844 */
845 void btips_bmgCallback (const BtlBmgEvent *bmgEvent)
846 {
847 const BtEvent *event = bmgEvent->event;
848 BtStatus btStatus = BT_STATUS_FAILED;
849 char bdAddr[BDADDR_NTOA_SIZE];
850 char *name;
851 T_BTIPS_MMI_IND btips_mmi_ind;
852
853 TRACE_FUNCTION_P1("btips_bmgCallback: %s", pME_Event(event->eType));
854 btips_mmi_ind.mfwBtipsEventType = MFW_BTIPS_BMG_EVENT;
855 btips_mmi_ind.data.bmgBtEvent.eventType = event->eType;
856 btips_mmi_ind.data.bmgBtEvent.errCode =event->errCode;
857
858 switch (event->eType)
859 {
860
861 case BTEVENT_LINK_CONNECT_IND:
862 btStatus = BTL_BMG_GetRemoteDeviceName(mfwBtipsBmgContext, &event->p.remDev->bdAddr);
863 break;
864 case BTEVENT_HCI_INITIALIZED:
865 btStatus = BTL_BMG_SetLocalDeviceName(mfwBtipsBmgContext, (U8 *)PME_APP_NAME, (U8)(sizeof(PME_APP_NAME)));
866 mfw_BtipsReport(("MFW_BTIPS_BMG :BTL_BMG_SetLocalDeviceName returned status: %s", pBT_Status(btStatus)));
867
868 btStatus = BTL_BMG_SetDefaultLinkPolicy(mfwBtipsBmgContext, ((BLP_MASTER_SLAVE_SWITCH|BLP_HOLD_MODE|BLP_SNIFF_MODE|BLP_PARK_MODE|BLP_SCATTER_MODE)&(~BLP_MASK)), ((BLP_MASTER_SLAVE_SWITCH|BLP_HOLD_MODE|BLP_SNIFF_MODE|BLP_PARK_MODE|BLP_SCATTER_MODE)&(~BLP_MASK)));
869 mfw_BtipsReport(("MFW_BTIPS_BMG :BTL_BMG_SetDefaultLinkPolicy returned status: %s", pBT_Status(btStatus)));
870
871 btStatus = BTL_BMG_SetSecurityMode(mfwBtipsBmgContext, BSM_SEC_LEVEL_2);
872 mfw_BtipsReport(("MFW_BTIPS_BMG :BTL_BMG_SetSecurityMode returned status: %s", pBT_Status(btStatus)));
873
874 btipsNotifyMFW(btips_mmi_ind);
875 break;
876
877 case BTEVENT_HCI_DEINITIALIZED:
878 btipsNotifyMFW(btips_mmi_ind);
879 break;
880
881
882 case BTEVENT_HCI_FAILED:
883 btipsNotifyMFW(&btips_mmi_ind);
884 break;
885
886 case BTEVENT_PAIRING_COMPLETE:
887 TRACE_EVENT_P2("Pairing with %s complete. status %s.\n", bdaddr_ntoa( &event->p.remDev->bdAddr, bdAddr), pHC_Status(event->errCode));
888 OS_MemCopy((U8*)&btips_mmi_ind.data.bmgBtEvent.bdAddr, (U8*)&event->p.remDev->bdAddr, sizeof(BD_ADDR));
889 btipsNotifyMFW(&btips_mmi_ind);
890 break;
891
892 case BTEVENT_BOND_RESULT:
893 if (event->errCode != BEC_NO_ERROR)
894 {
895 TRACE_EVENT_P2("Bond attempt to %s failed. Reason %s.", bdaddr_ntoa(&event->p.bdAddr, bdAddr), pHC_Status(event->errCode));
896 }
897 else
898 {
899 TRACE_EVENT_P1("Bond to %s ended successfully", bdaddr_ntoa(&event->p.bdAddr, bdAddr));
900 }
901
902 OS_MemCopy((U8*)&btips_mmi_ind.data.bmgBtEvent.bdAddr, (U8*)&event->p.bdAddr, sizeof(BD_ADDR));
903
904 btipsNotifyMFW(&btips_mmi_ind);
905 break;
906
907 case BTEVENT_BOND_CANCELLED:
908 btipsNotifyMFW(&btips_mmi_ind);
909 break;
910
911 case BTEVENT_PIN_REQ:
912 if (event->errCode == BT_STATUS_SUCCESS)
913 {
914 T_BTIPS_MMI_IND btipsMmiInd = {0};
915 BtlBmgDeviceRecord record;
916
917
918 btStatus=BTL_BMG_GetRemoteDeviceName(mfwBtipsBmgContext, &event->p.remDev->bdAddr);
919 TRACE_EVENT_P1("BTEVENT_PIN_REQ btStatus %d",btStatus);
920 /* Prompt the user for a PIN code */
921 mfw_BtipsReport(("Please Enter PIN Code for %s", bdaddr_ntoa(&event->p.remDev->bdAddr, bdAddr)));
922 }
923 else
924 {
925 /* Cancel the PIN code request */
926 mfw_BtipsReport ((("BMG: Pin code couldn't be displayed because of an error")));
927 }
928 OS_MemCopy((U8*)&btips_mmi_ind.data.bmgBtEvent.bdAddr, (U8*)&event->p.remDev->bdAddr, sizeof(BD_ADDR));
929 btipsNotifyMFW(&btips_mmi_ind);
930 break;
931
932 case BTEVENT_AUTHORIZATION_REQ:
933 TRACE_EVENT_P1("Authorization request received from %s",bdaddr_ntoa(&event->p.remDev->bdAddr, bdAddr));
934 break;
935
936 case BTEVENT_INQUIRY_RESULT:
937 mfw_BtipsReport(("Inquiry result arrived, BD address: %s", bdaddr_ntoa(&event->p.inqResult.bdAddr, bdAddr)));
938 break;
939
940 case BTEVENT_SEARCH_COMPLETE:
941 case BTEVENT_SEARCH_CANCELLED:
942 TRACE_EVENT_P1("Search %s ", ((event->eType == BTEVENT_SEARCH_COMPLETE) ? ("completed") : ("cancelled")));
943 btipsNotifyMFW(&btips_mmi_ind);
944 break;
945
946 case BTEVENT_INQUIRY_COMPLETE:
947 case BTEVENT_INQUIRY_CANCELED:
948 TRACE_EVENT_P1("Inquiry %s ", ((event->eType == BTEVENT_INQUIRY_COMPLETE) ? ("completed") : ("cancelled")));
949 //btipsNotifyMFW(&btips_mmi_ind);
950 break;
951
952 case BTEVENT_NAME_RESULT:
953
954 if (event->errCode == BEC_NO_ERROR)
955 {
956 OS_MemCopy((U8*)&btips_mmi_ind.data.bmgBtEvent.bdAddr, (U8*)&event->p.meToken->p.name.bdAddr, sizeof(BD_ADDR));
957 if (event->p.meToken->p.name.io.out.len == 0)
958 {
959 name = "Unknown";
960 strcpy(btips_mmi_ind.data.bmgBtEvent.p.deviceName, bdaddr_ntoa(&event->p.meToken->p.name.bdAddr, bdAddr));
961 }
962 else
963 {
964 name = (char *)(event->p.meToken->p.name.io.out.name);
965 if (name)
966 {
967 }
968 else
969 {
970 TRACE_EVENT("BTEVENT_NAME_RESULT Name = NULL");
971 }
972 strcpy(btips_mmi_ind.data.bmgBtEvent.p.deviceName, name);
973 }
974 TRACE_EVENT_P2("Received name %s for device %s", name, bdaddr_ntoa(&event->p.meToken->p.name.bdAddr, bdAddr));
975 btipsNotifyMFW(&btips_mmi_ind);
976 }
977 else
978 {
979 /* Record that the name request failed. Next time we'll skip it. */
980 mfw_BtipsReport(("BMG: Name request for %s failed, status %s.\n",
981 bdaddr_ntoa(&event->p.meToken->p.name.bdAddr, bdAddr),
982 pHC_Status(event->errCode)));
983 }
984 break;
985 case BTEVENT_DISCOVER_SERVICES_RESULT :
986 btips_mmi_ind.data.bmgBtEvent.p.discoveredServicesMask = event->p.discoveredServices.discoveredServicesMask;
987 bdaddr_ntoa(&event->p.discoveredServices.bdAddr, bdAddr);
988 OS_MemCopy((U8*)&btips_mmi_ind.data.bmgBtEvent.bdAddr , (U8*)&event->p.discoveredServices.bdAddr, sizeof(BD_ADDR));
989 btips_mmi_ind.data.bmgBtEvent.p.discoveredServicesMask = event->p.discoveredServices.discoveredServicesMask;
990 TRACE_EVENT_P2("Discover Services %x for %s",event->p.discoveredServices.discoveredServicesMask, bdAddr);
991 btipsNotifyMFW(&btips_mmi_ind);
992 break;
993 default:
994 break;
995 }
996 }
997
998
999 /************************************************************************
1000 BMG in ACI Context Module Start
1001 ************************************************************************/
1002 void mfw_btips_bmgCallback( T_BTIPS_MMI_IND * para)
1003 {
1004 MfwBtBmgEvent bmgBtEvent = para->data.bmgBtEvent;
1005
1006 TRACE_FUNCTION_P1("mfw_btips_bmgCallback - %s", pME_Event(bmgBtEvent.eventType));
1007
1008 switch(bmgBtEvent.eventType)
1009 {
1010 case BTEVENT_HCI_DEINITIALIZED:
1011 break;
1012
1013 case BTEVENT_HCI_INITIALIZED:
1014 mfw_btips_bmgSetPhoneVisibility(TRUE);
1015 break;
1016
1017 case BTEVENT_HCI_FAILED:
1018 mfw_btips_signal(E_BTIPS_POWERON_FAILURE, NULL);
1019 break;
1020
1021 case BTEVENT_PAIRING_COMPLETE:
1022 mfw_btips_signal(E_BTIPS_BMG_PAIRING_COMPLETE, para);
1023 break;
1024
1025 case BTEVENT_BOND_RESULT:
1026 mfw_btips_signal(E_BTIPS_BMG_BOND_COMPLETE, para);
1027 break;
1028
1029 case BTEVENT_BOND_CANCELLED:
1030 mfw_btips_signal(E_BTIPS_BMG_BOND_CANCELLED, NULL);
1031 break;
1032
1033 case BTEVENT_PIN_REQ:
1034 if (bmgBtEvent.errCode == BT_STATUS_SUCCESS)
1035 {
1036 mfw_btips_signal(E_BTIPS_INCOMING_PIN_REQ, para);
1037 }
1038 break;
1039
1040 case BTEVENT_NAME_RESULT:
1041
1042 TRACE_EVENT_P1("Received name for device %s", bmgBtEvent.p.deviceName);
1043 mfw_btips_signal(E_BTIPS_BMG_NAME_RESULT, para);
1044 break;
1045
1046 case BTEVENT_SEARCH_COMPLETE:
1047 mfw_btips_signal(E_BTIPS_BMG_SEARCH_COMPLETE, NULL);
1048 break;
1049 case BTEVENT_SEARCH_CANCELLED:
1050 mfw_btips_signal(E_BTIPS_BMG_SEARCH_CANCELLED, NULL);
1051 break;
1052
1053 case BTEVENT_INQUIRY_COMPLETE:
1054 break;
1055
1056 case BTEVENT_INQUIRY_CANCELED:
1057 break;
1058 case BTEVENT_DISCOVER_SERVICES_RESULT:
1059 TRACE_FUNCTION("mfw_btips_bmgCallback BTEVENT_DISCOVER_SERVICES_RESULT");
1060 mfw_btips_signal(E_BTIPS_BMG_DEVICE_SERVICES, para);
1061 break;
1062
1063 default:
1064 break;
1065 }
1066 }
1067 BOOL mfw_btips_bmgDeviceSetConnectPermissionAllow(const BD_ADDR *bdAddr,BOOL permission )
1068 {
1069
1070 BtlBmgDeviceRecord record;
1071
1072 BtStatus btStatus = BT_STATUS_FAILED;
1073
1074 TRACE_FUNCTION("mfw_btips_bmgDeviceSetConnectPermissionAllow()");
1075
1076 btStatus = BTL_BMG_FindDeviceRecord(mfwBtipsBmgContext, bdAddr, &record);
1077 TRACE_EVENT_P1("BTL_BMG_FindDeviceRecord in mfw_btips_bmgDeviceSetConnectPermissionAllow returned - %d", btStatus);
1078
1079 if(BT_STATUS_SUCCESS == btStatus)
1080 {
1081 record.trusted = TRUE;
1082 record.trustedPerService= SDP_SERVICE_OPP|SDP_SERVICE_DUN|SDP_SERVICE_FTP|SDP_SERVICE_A2DP|SDP_SERVICE_HFP; //Not sure if this is the way to set the bits in the mask field
1083
1084 btStatus = BTL_BMG_SetDeviceRecord(mfwBtipsBmgContext, &record);
1085
1086 TRACE_EVENT_P1("BTL_BMG_SetDeviceRecord in mfw_btips_bmgDeviceSetConnectPermissionAllow returned - %d", btStatus);
1087 }
1088
1089 return mfw_btips_checkStatus(btStatus);
1090
1091
1092
1093 }
1094
1095 BOOL mfw_btips_bmgDeviceSetConnectPermissionAsk(const BD_ADDR *bdAddr,BOOL permission)
1096 {
1097
1098 BtlBmgDeviceRecord record;
1099
1100 BtStatus btStatus = BT_STATUS_FAILED;
1101
1102 TRACE_FUNCTION("mfw_btips_bmgDeviceSetConnectPermissionAsk()");
1103
1104
1105 btStatus = BTL_BMG_FindDeviceRecord(mfwBtipsBmgContext, bdAddr,&record);
1106
1107 TRACE_EVENT_P1("BTL_BMG_FindDeviceRecord in mfw_btips_bmgDeviceSetConnectPermissionAsk returned - %d", btStatus);
1108
1109
1110 if(BT_STATUS_SUCCESS == btStatus)
1111 {
1112 record.trusted = FALSE;
1113
1114 record.trustedPerService= 0; //Not sure if this is the way to set the bits in the mask field
1115
1116 btStatus = BTL_BMG_SetDeviceRecord(mfwBtipsBmgContext, &record);
1117
1118 TRACE_EVENT_P1("BTL_BMG_SetDeviceRecord in mfw_btips_bmgDeviceSetConnectPermissionAsk returned - %d", btStatus);
1119
1120 }
1121
1122 return mfw_btips_checkStatus(btStatus);
1123
1124
1125 }
1126
1127
1128 BOOL mfw_btips_bmgSetRemoteDeviceName( const BD_ADDR *bdAddr, U8 *name)
1129 {
1130
1131 BtStatus btStatus = BT_STATUS_FAILED;
1132
1133 BtlBmgDeviceRecord record;
1134
1135 TRACE_FUNCTION("mfw_btips_bmgSetRemoteDeviceName()");
1136
1137 btStatus = BTL_BMG_FindDeviceRecord(mfwBtipsBmgContext, bdAddr,&record);
1138
1139 if(BT_STATUS_SUCCESS == btStatus)
1140 {
1141 strcpy(record.name, name);
1142 btStatus = BTL_BMG_SetDeviceRecord(mfwBtipsBmgContext, &record);
1143 }
1144 return mfw_btips_checkStatus(btStatus);
1145 }
1146
1147 //vamsee
1148 /* Get the Services Supported by the Remote Device*/
1149 U32 mfw_btips_bmgDeviceGetServices(const BD_ADDR *bdAddr)
1150 {
1151
1152 BtlBmgDeviceRecord record;
1153 BtStatus btStatus = BT_STATUS_FAILED;
1154 TRACE_FUNCTION("mfw_btips_bmgDeviceGetServices()");
1155 btStatus = BTL_BMG_FindDeviceRecord(mfwBtipsBmgContext, bdAddr, &record);
1156 TRACE_EVENT_P1("Record Services %x",record.services);
1157 return record.services;
1158 }
1159
1160 BOOL mfw_btips_bmg_DiscoverServices(const BD_ADDR *bdAddr, SdpServicesMask sdpServicesMask)
1161 {
1162 BtStatus btStatus;
1163
1164 TRACE_EVENT_P1("mfw_btips_bmg_DiscoverServices Discover %x",sdpServicesMask);
1165
1166 btStatus = BTL_BMG_DiscoverServices(mfwBtipsBmgContext, bdAddr, sdpServicesMask);
1167 return mfw_btips_checkStatus(btStatus);
1168 }
1169
1170 BOOL mfw_btips_bmgSetDeviceRecord( const BD_ADDR *bdAddr, U32 sdpSericesMask)
1171 {
1172
1173
1174 BtStatus btStatus = BT_STATUS_FAILED;
1175
1176 BtlBmgDeviceRecord record;
1177
1178 TRACE_FUNCTION("mfw_btips_bmgSetDeviceRecord()");
1179
1180 btStatus = BTL_BMG_FindDeviceRecord(mfwBtipsBmgContext, bdAddr,&record);
1181
1182 if(BT_STATUS_SUCCESS == btStatus)
1183 {
1184 TRACE_EVENT_P1("mfw_btips_bmgSetDeviceRecord() %x",sdpSericesMask);
1185
1186 record.services = sdpSericesMask;
1187
1188 TRACE_EVENT_P1("Record Services %x",record.services);
1189
1190 btStatus = BTL_BMG_SetDeviceRecord(mfwBtipsBmgContext, &record);
1191 }
1192 return mfw_btips_checkStatus(btStatus);
1193 }
1194
1195 /************************************************************************
1196 BMG in ACI Context Module End
1197 ************************************************************************/
1198
1199
1200
1201
1202 #endif
1203