comparison src/ui3/mfw/mfw_Btips.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
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_fs.h"
53 #include "bthal_pm.h"
54 #include "bthal_config.h"
55 #include "bttypes.h"
56 #include "goep.h"
57 #include "bpp.h"
58 #include "Debug.h"
59
60 /* BTL includes */
61 #include "btl_bppsnd.h"
62 #include "btl_bmg.h"
63
64 #if FM_STACK == XA_ENABLED
65
66 #include "fms_api.h"
67 #endif
68
69 #if defined (NEW_FRAME)
70
71 #include "typedefs.h"
72 #include "vsi.h"
73 #include "pei.h"
74 #include "custom.h"
75 #include "gsm.h"
76 #include "prim.h"
77
78 #else
79
80 #include "STDDEFS.H"
81 #include "custom.h"
82 #include "gsm.h"
83 #include "vsi.h"
84
85 #endif
86 #include "mfw_mfw.h"
87 #include "mfw_win.h"
88 #include "mfw_icn.h" /* included for mfw_mnu.h */
89 #include "mfw_mnu.h"
90 #include "mfw_tim.h"
91 #include "mfw_kbd.h"
92 #include "mfw_sat.h" /* included for MmiDummy.h, included for MmiMenu.h */
93
94 #include "Mfw_Btips.h"
95 #include "ffs/ffs_api.h"
96 /*------------------------------------------------------------------------
97 *
98 * Default BT Demo folder fsPath (i.e. \MfwBtDemo)
99 */
100 U8 Bt_DefaultDemoDir[BT_FS_MAX_PATH_LENGTH];
101
102 #define hCommACI _ENTITY_PREFIXED(hCommACI)
103
104
105 #define MFW_BTIPS_RADIO_OFF 0
106 #define MFW_BTIPS_RADIO_ON 1
107 #define MFW_BTIPS_RADIO_IN_PROGRESS -1
108
109 EXTERN MfwHdr * current_mfw_elem;
110
111
112 /* Declaration of static variables */
113 static BOOL isBtRadioEnabled = MFW_BTIPS_RADIO_OFF; /* To check at start-up */
114
115 static void btips_btlCallBack(const BtlEvent *event);
116 static void mfw_btips_btlCallBack(T_BTIPS_MMI_IND *btips_mmi_ind);
117 static void mfw_btips_callBack(T_BTIPS_MMI_IND *btips_mmi_ind );
118 static BOOL mfw_btips_createDemoRootDir(const BTHAL_U8 *fsPath);
119 BOOL mfw_btips_checkStatus(BtStatus btStatus);
120
121 void Btips_ffs_log_clear(void)
122 {
123 ffs_remove((const char*)"/ffslog");
124 }
125 void Btips_ffs_log_message(char *LogMsg,...)
126 {
127 #ifdef FFSLOG
128 fd_t fd= -1;
129 char log_ffs_buf[256];
130 va_list varpars;
131
132 va_start (varpars, LogMsg);
133 vsprintf(log_ffs_buf,LogMsg,varpars);
134 va_end (varpars);
135 fd = ffs_open((const char*)"/ffslog", FFS_O_APPEND | FFS_O_WRONLY );
136 if(fd < 0)
137 fd=ffs_open((const char*)"/ffslog", FFS_O_CREATE |FFS_O_WRONLY );
138 if(fd >= 0)
139 {
140 strcat(log_ffs_buf," \n ");
141 ffs_write(fd, log_ffs_buf, strlen(log_ffs_buf));
142 ffs_close(fd);
143 }
144 #endif
145 }
146 #ifdef FF_MMI_BTIPS_APP
147
148 /************************************************************************
149 MFW - ACI Communication Module Start
150 ************************************************************************/
151
152 /*******************************************************************************
153
154 $Function: mfw_btips_sign_exec
155
156 $Description: This function sends the Mfw BTIPS events from the Mfw to the BMI.
157
158 $Returns: None
159
160 $Arguments: None
161
162 *******************************************************************************/
163 BOOL mfw_btips_sign_exec (T_MFW_HDR * cur_elem, T_MFW_EVENT event, T_MFW_BTIPS_PARA * para)
164 {
165 TRACE_FUNCTION("mfw_btips_sign_exec()");
166
167 while (cur_elem)
168 {
169 /*
170 * event handler is available
171 */
172 TRACE_FUNCTION_P1("mfw_btips_sign_exec - %x", event);
173 if (cur_elem->type EQ MfwTyBtipsBmg)
174 {
175 T_MFW_BTIPS * btips_data;
176
177 TRACE_FUNCTION("mfw_btips_sign_exec() cur_elem->type EQ MfwTyBtipsBmg");
178 /*
179 * handler is CM management handler
180 */
181 btips_data = (T_MFW_BTIPS *)cur_elem->data;
182 if (btips_data->emask & event)
183 {
184 /*
185 * event is expected by the call back function
186 */
187 btips_data->event = event;
188 switch (event)
189 {
190 /*
191 ** BTIPS BMG Events
192 */
193 case E_BTIPS_BMG_NAME_RESULT:
194 case E_BTIPS_BMG_SEARCH_COMPLETE:
195 case E_BTIPS_BMG_SEARCH_CANCELLED:
196 case E_BTIPS_BMG_BOND_COMPLETE:
197 case E_BTIPS_BMG_BOND_CANCELLED:
198 case E_BTIPS_BMG_DEVICE_SERVICES:
199 if(para!=NULL)
200 memcpy (&btips_data->para, para, sizeof (T_MFW_BTIPS_PARA));
201 break;
202 default:
203 return FALSE;
204
205 }
206
207 /*
208 * if call back defined, call it
209 */
210 if (btips_data->handler)
211 {
212 current_mfw_elem = cur_elem;
213
214 if ((*(btips_data->handler)) (btips_data->event, (void *)&btips_data->para))
215 return TRUE;
216 }
217 }
218 }
219 else if (cur_elem->type EQ MfwTyBtips)
220 {
221 T_MFW_BTIPS * btips_data;
222
223 TRACE_FUNCTION("mfw_btips_sign_exec() cur_elem->type EQ MfwTyBtips");
224 /*
225 * handler is CM management handler
226 */
227 btips_data = (T_MFW_BTIPS *)cur_elem->data;
228 if (btips_data->emask & event)
229 {
230 /*
231 * event is expected by the call back function
232 */
233 btips_data->event = event;
234 switch (event)
235 {
236 /*
237 ** BTIPS generic Events
238 */
239 case E_BTIPS_POWERON_SUCCESS:
240 case E_BTIPS_POWERON_FAILURE:
241 case E_BTIPS_POWEROFF_SUCCESS:
242 case E_BTIPS_BT_NOT_ON:
243 case E_BTIPS_FATAL_ERROR:
244 case E_BTIPS_INCOMING_PIN_REQ:
245 case E_BTIPS_BMG_PAIRING_COMPLETE:
246 case E_BTIPS_OPPS_PUSH_EVENT:
247 case E_BTIPS_OPPS_PULL_EVENT:
248 case E_BTIPS_FTPS_PUT_EVENT:
249 case E_BTIPS_FTPS_GET_EVENT:
250 case E_BTIPS_FTPS_DELETE_EVENT:
251 case E_BTIPS_FTPS_COMPLETE_EVENT: //sundeep
252 case E_BTIPS_FTPS_ABORTED_EVENT:
253 case E_BTIPS_FTPS_PUT_COMP_EVENT:
254 // case E_BTIPS_FTPS_GET_COMP_EVENT:
255 case E_BTIPS_FTPS_CONNECT_EVENT:
256 case E_BTIPS_FTPS_DISCONNECT_EVENT:
257 case E_BTIPS_FTPS_DELETE_COMP_EVENT:
258 case E_BTIPS_VG_CONNECT_EVENT:
259 case E_BTIPS_VG_DISCONNECT_EVENT:
260 case E_BTIPS_VG_AUDIO_CONNECT_EVENT:
261 case E_BTIPS_VG_AUDIO_DISCONNECT_EVENT:
262 case E_BTIPS_BMG_NAME_RESULT:
263 case E_BTIPS_OPPS_PULL_COMP_EVENT:
264 case E_BTIPS_OPPS_PUSH_COMP_EVENT:
265 if(para!=NULL)
266 memcpy (&btips_data->para, para, sizeof (T_MFW_BTIPS_PARA));
267
268 break;
269 default:
270 return FALSE;
271 }
272
273 /*
274 * if call back defined, call it
275 */
276 if (btips_data->handler)
277 {
278 current_mfw_elem = cur_elem;
279
280 if ((*(btips_data->handler)) (btips_data->event, (void *)&btips_data->para))
281 return TRUE;
282 }
283 }
284 }
285
286
287 cur_elem = cur_elem->next;
288 }
289 return FALSE;
290 }
291
292 /*******************************************************************************
293
294 $Function: mfw_btips_signal
295
296 $Description: This function sends the Mfw btipsnts from the Mfw to the BMI.
297
298 $Returns: None
299
300 $Arguments: T_MFW_EVENT : The event to be sent to the BMI
301 T_BTIPS_MMI_IND * : Pointer to the Event data
302
303 *******************************************************************************/
304 void mfw_btips_signal(T_MFW_EVENT event, T_BTIPS_MMI_IND * para)
305 {
306 UBYTE temp;
307 temp = dspl_Enable(0);
308
309 TRACE_FUNCTION("mfw_btips_signal()");
310
311 if (mfwSignallingMethod EQ 0)
312 {
313 /*
314 * focus is on a window
315 */
316 if (mfwFocus)
317 {
318 /*
319 * send event to sim management
320 * handler if available
321 */
322 if (mfw_btips_sign_exec (mfwFocus, event, para))
323 {
324 dspl_Enable(temp);
325 return;
326 }
327 }
328
329 /*
330 * actual focussed window is not available
331 * or has no network management registration
332 * handler, then search all nodes from the root.
333 */
334 if (mfwRoot)
335 mfw_btips_sign_exec (mfwRoot, event, para);
336 }
337 else
338 {
339 MfwHdr * h = 0;
340
341 /*
342 * Focus set, then start here
343 */
344 if (mfwFocus)
345 h = mfwFocus;
346
347 /*
348 * Focus not set, then start root
349 */
350 if (!h)
351 h = mfwRoot;
352
353 /*
354 * No elements available, return
355 */
356 while (h)
357 {
358 /*
359 * Signal consumed, then return
360 */
361 if (mfw_btips_sign_exec (h, event, para))
362 {
363 dspl_Enable(temp);
364 return;
365 }
366
367 /*
368 * All windows tried inclusive root
369 */
370 if (h == mfwRoot)
371 {
372 dspl_Enable(temp);
373 return;
374 }
375
376 /*
377 * get parent window
378 */
379 h = mfwParent(mfwParent(h));
380
381 if (h)
382 h = ((MfwWin * )(h->data))->elems;
383 }
384
385 mfw_btips_sign_exec (mfwRoot, event, para);
386
387 }
388
389 dspl_Enable(temp);
390
391 return;
392 }
393
394
395 /*******************************************************************************
396
397 $Function: mfw_btips_create
398
399 $Description: This function initialises an Mfw BTIPS entity and adds it to the Window Stack
400
401 $Returns: T_MFW_HND : A handle for the entity
402
403 $Arguments: T_MFW_HND : Parent Window Handle
404 T_MFW_EVENT : Event Mask of the events to be handled
405 T_MFW_CB : Callback function to handle the events
406
407 *******************************************************************************/
408 T_MFW_HND mfw_btips_create(T_MFW_HND hWin, T_MFW_EVENT event, MfwTyp type, T_MFW_CB cbfunc)
409 {
410 T_MFW_HDR *hdr;
411 T_MFW_BTIPS *btips_para;
412
413 TRACE_FUNCTION_P1("mfw_btips_create TYPE = %x", type);
414
415 hdr = (T_MFW_HDR *) mfwAlloc(sizeof (T_MFW_HDR));
416 btips_para = (T_MFW_BTIPS *) mfwAlloc(sizeof (T_MFW_BTIPS));
417
418 if (!hdr OR !btips_para)
419 return FALSE;
420
421 /*
422 * initialisation of the handler
423 */
424 btips_para->emask = event;
425 btips_para->handler = cbfunc;
426
427 hdr->data = btips_para;
428 hdr->type = type;
429
430 /*
431 * installation of the handler
432 */
433 return mfwInsert((T_MFW_HDR *)hWin, hdr);
434 }
435
436
437 /*******************************************************************************
438
439 $Function: mfw_btips_delete
440
441 $Description: This function clears down an Mfw BTIPS entity and removes it from the
442 Window Stack
443
444 $Returns: T_MFW_RES : The result of the function
445
446 $Arguments: T_MFW_HND : The Handle of the entity to be removed
447
448 *******************************************************************************/
449 T_MFW_RES mfw_btips_delete(T_MFW_HND hnd)
450 {
451 TRACE_FUNCTION("mfw_btips_delete()");
452
453 if (!hnd OR !((T_MFW_HDR *)hnd)->data)
454 return MFW_RES_ILL_HND;
455
456 if (!mfwRemove((T_MFW_HDR *)hnd))
457 return MFW_RES_ILL_HND;
458
459 mfwFree((U8 *)(((T_MFW_HDR *) hnd)->data),sizeof(T_MFW_BTIPS));
460 mfwFree((U8 *)hnd,sizeof(T_MFW_HDR));
461
462 return MFW_RES_OK;
463 }
464
465
466
467 /*
468 +------------------------------------------------------------------------------
469 | Function : btipsNotifyMFW
470 +------------------------------------------------------------------------------
471 | Description : Posts the FM Radio events to the MMI task
472 |
473 | Parameters : T_FMRADIO_EVENT fmradioevent
474 | void context - not used now
475 |
476 | Return : TRUE/FALSE
477 +------------------------------------------------------------------------------
478 */
479 void btipsNotifyMFW (T_BTIPS_MMI_IND * event)
480 {
481 #if defined (NEW_FRAME)
482 EXTERN T_HANDLE hCommACI;
483 #else
484 EXTERN T_VSI_CHANDLE hCommACI;
485 #endif
486
487 PALLOC(btips_mmi_ind,BTIPS_MMI_IND);
488 TRACE_FUNCTION_P1 ("btipsNotifyMFW %x", event->mfwBtipsEventType);
489 /*Copy required data to btips_mmi_ind*/
490 btips_mmi_ind->mfwBtipsEventType = event->mfwBtipsEventType;
491 btips_mmi_ind->data = event->data;
492
493 #if defined (NEW_FRAME)
494 PSENDX(ACI,btips_mmi_ind);
495 #else
496 #if defined (_TMS470)
497 vsi_c_send("",hCommACI,D2P(btips_mmi_ind),
498 sizeof(T_PRIM_HEADER)+sizeof(T_BTIPS_MMI_IND));
499 #else
500 PSEND(ACI,btips_mmi_ind);
501 #endif
502 #endif
503 return;
504 }
505 /*
506 +------------------------------------------------------------------------------
507 | Function : btipsPrimHandler
508 +------------------------------------------------------------------------------
509 | Description : This fn is the primitive handler for BTIPS MFW application
510 |
511 | Parameters : opc-opc code
512 | data - data
513 |
514 |
515 | Return : TRUE/FALSE
516 +------------------------------------------------------------------------------
517 */
518 GLOBAL BOOL btipsPrimHandler (USHORT opc, void * data)
519 {
520 TRACE_FUNCTION_P1 ("btipsPrimHandler %x", opc);
521
522 if (opc EQ BTIPS_MMI_IND)
523 {
524 T_BTIPS_MMI_IND *btips_mmi_ind = (T_BTIPS_MMI_IND *)data;
525 mfw_btips_callBack(btips_mmi_ind);
526 PFREE(btips_mmi_ind);
527 return TRUE;
528 }
529 return FALSE;
530 }
531
532 /*This function will be invoked in the ACI context and from here the signals will be
533 passed on to the respective mfw_btips_xxxx_callback()*/
534 static void mfw_btips_callBack(T_BTIPS_MMI_IND *btips_mmi_ind )
535 {
536 /*Todo: implement function pointer callback*/
537 switch(btips_mmi_ind->mfwBtipsEventType)
538 {
539 case MFW_BTIPS_MAIN_EVENT:
540 mfw_btips_btlCallBack(btips_mmi_ind);
541 break;
542 case MFW_BTIPS_BMG_EVENT:
543 mfw_btips_bmgCallback(btips_mmi_ind);
544 break;
545
546 case MFW_BTIPS_OPPS_EVENT:
547 mfw_btips_oppsCallback(btips_mmi_ind);
548 break;
549
550 case MFW_BTIPS_FTPS_EVENT:
551 mfw_btips_ftpsCallback(btips_mmi_ind);
552 break;
553
554 case MFW_BTIPS_VG_EVENT:
555 mfw_btips_vgCallback(btips_mmi_ind);
556 break;
557
558 case MFW_BTIPS_OPPC_EVENT:
559 mfw_btips_oppcCallback(btips_mmi_ind);
560 break;
561
562 case MFW_BTIPS_MDG_EVENT:
563 mfw_btips_mdgCallback(btips_mmi_ind);
564 break;
565
566 default:
567 break;
568 }
569 }
570 /************************************************************************
571 MFW - ACI Communication Module End
572 ************************************************************************/
573
574 /*---------------------------------------------------------------------------
575 * mfw_btips_init
576 *---------------------------------------------------------------------------
577 *
578 * Synopsis: To return the current status of BT radio.
579 *
580 * Return: TRUE if send PIN code is successful, FALSE otherwise.
581 *
582 */
583 void mfw_btips_init(void)
584 {
585
586 // BTHAL_OS_Sleep(100);
587 /* Initialize BTIPS basic components: BT stack, BTL layer... */
588 TRACE_FUNCTION(("mfw_btips_init: Starting BTL_Init"));
589 OS_StrCpy(Bt_DefaultDemoDir, BT_DEMO_FOLDER_PATH);
590 if (TRUE != mfw_btips_createDemoRootDir(Bt_DefaultDemoDir))
591 {
592 Report(("Fatal Error: Could not create BT root folder\n"));;
593 }
594 if (BT_STATUS_SUCCESS != BTL_Init(btips_btlCallBack))
595 {
596 mfw_BtipsReport(("Fatal Error: Could not initialize the BTIPS basic components\n"));
597 }
598
599 /* Initialize application modules */
600 mfw_btips_bmgInit();
601 mfw_btips_a2dpInit();
602 mfw_btips_ftpsInit();
603 mfw_btips_vgInit();
604 mfw_btips_oppsInit();
605 mfw_btips_oppcInit();
606 mfw_btips_mdgInit();
607
608 #if FM_STACK == XA_ENABLED
609 Assert(FM_STATUS_SUCCESS == FM_Init());
610 #endif
611
612
613 }
614
615 /*---------------------------------------------------------------------------
616 * mfw_btips_getRadioStatus
617 *---------------------------------------------------------------------------
618 *
619 * Synopsis: To return the current status of BT radio.
620 *
621 * Return: TRUE if send PIN code is successful, FALSE otherwise.
622 *
623 */
624 BOOL mfw_btips_getRadioStatus (void)
625 {
626 return isBtRadioEnabled;
627 }
628
629
630 /*---------------------------------------------------------------------------
631 * mfw_btips_radioOn
632 *---------------------------------------------------------------------------
633 *
634 * Synopsis: Enable BT radio.
635 *
636 * Return: TRUE if Enabling BT radio is successful, FALSE otherwise.
637 *
638 */
639 BOOL mfw_btips_radioOn (void)
640 {
641 BtStatus btStatus;
642
643 TRACE_FUNCTION("mfw_btips_radioOn()");
644
645 Btips_ffs_log_clear();
646
647 if (MFW_BTIPS_RADIO_OFF == isBtRadioEnabled)
648 {
649 isBtRadioEnabled = MFW_BTIPS_RADIO_IN_PROGRESS;
650 btStatus = BTL_RadioOn();
651 Assert(MFW_BTIPS_SUCCESS == mfw_btips_checkStatus(btStatus));
652 }
653 else
654 {
655 TRACE_EVENT_P1("mfw_btips_radioOn -BT radio is already enabled %d", isBtRadioEnabled);
656 }
657 }
658
659
660 /*---------------------------------------------------------------------------
661 * mfw_btips_radioOff
662 *---------------------------------------------------------------------------
663 *
664 * Synopsis: Disable BT radio.
665 *
666 * Return: TRUE if Disabling BT radio is successful, FALSE otherwise.
667 *
668 */
669 BOOL mfw_btips_radioOff (void)
670 {
671 BtStatus btStatus;
672
673 TRACE_FUNCTION("mfw_btips_radioOff()");
674
675 if (MFW_BTIPS_RADIO_ON == isBtRadioEnabled)
676 {
677 isBtRadioEnabled = MFW_BTIPS_RADIO_IN_PROGRESS;
678 btStatus = BTL_RadioOff();
679 Assert(MFW_BTIPS_SUCCESS == mfw_btips_checkStatus(btStatus));
680 }
681 else
682 {
683 mfw_BtipsReport(("APP MAIN: BT radio is already disabled"));
684 }
685 }
686
687 /*---------------------------------------------------------------------------
688 * btips_btlCallBack
689 *---------------------------------------------------------------------------
690 *
691 * Synopsis: BTL Main application callback in BTS Context
692 *
693 * Return:
694 *
695 */
696 static void btips_btlCallBack(const BtlEvent *event)
697 {
698 T_BTIPS_MMI_IND btips_mmi_ind;
699
700 TRACE_FUNCTION_P1("btips_btlCallBack %d", event->type);
701 btips_mmi_ind.mfwBtipsEventType = MFW_BTIPS_MAIN_EVENT;
702 switch (event->type)
703 {
704 case BTL_EVENT_RADIO_OFF_COMPLETE:
705 isBtRadioEnabled = MFW_BTIPS_RADIO_OFF;
706 btips_mmi_ind.data.btlBtEvent = BTL_EVENT_RADIO_OFF_COMPLETE;
707 btipsNotifyMFW(&btips_mmi_ind);
708 break;
709
710 case BTL_EVENT_RADIO_ON_COMPLETE:
711 // Display Bluetooth Icon on the opening/default main window
712 isBtRadioEnabled = MFW_BTIPS_RADIO_ON;
713 btips_mmi_ind.data.btlBtEvent = BTL_EVENT_RADIO_ON_COMPLETE;
714 btipsNotifyMFW(&btips_mmi_ind);
715 break;
716 }
717 }
718
719 /*---------------------------------------------------------------------------
720 * mfw_btips_radioOff
721 *---------------------------------------------------------------------------
722 *
723 * Synopsis: Disable BT radio.
724 *
725 * Return: TRUE if Disabling BT radio is successful, FALSE otherwise.
726 *
727 */
728
729 static void mfw_btips_btlCallBack(T_BTIPS_MMI_IND * para)
730 {
731 MfwBtMainEvent event = para->data.btlBtEvent;
732
733 TRACE_FUNCTION_P1("mfw_btips_btlCallBack %d", event);
734
735 switch (event)
736 {
737 case BTL_EVENT_RADIO_OFF_COMPLETE:
738 mfw_btips_signal(E_BTIPS_POWEROFF_SUCCESS, NULL);
739 break;
740
741 case BTL_EVENT_RADIO_ON_COMPLETE:
742 // Display Bluetooth Icon on the opening/default main window
743 mfw_btips_signal(E_BTIPS_POWERON_SUCCESS, NULL);
744 break;
745
746 };
747 }
748
749 BOOL mfw_btips_checkStatus(BtStatus btStatus)
750 {
751 BOOL mfwBtStatus = 0;
752 TRACE_EVENT_P1("mfw_btips_checkStatus : %s", pBT_Status(btStatus));
753 switch(btStatus)
754 {
755 case BT_STATUS_SUCCESS:
756 case BT_STATUS_PENDING:
757 case BT_STATUS_IN_PROGRESS:
758 mfwBtStatus = MFW_BTIPS_SUCCESS;
759 break;
760
761 case BTEVENT_HCI_FATAL_ERROR:
762 mfwBtStatus = MFW_BTIPS_FAILED;
763 TRACE_ERROR("mfw_btips_checkStatus - Fatal Error");
764 mfw_btips_signal(E_BTIPS_FATAL_ERROR, NULL);
765 break;
766
767 case BT_STATUS_INVALID_PARM:
768 mfwBtStatus = MFW_BTIPS_FAILED;
769 TRACE_ERROR("mfw_btips_checkStatus - Invalid Params");
770 break;
771
772 case BT_STATUS_DEVICE_NOT_FOUND:
773 mfwBtStatus = MFW_BTIPS_FAILED;
774 TRACE_ERROR("mfw_btips_checkStatus - BT_STATUS_DEVICE_NOT_FOUND");
775 break;
776
777 case BT_STATUS_HCI_INIT_ERR:
778 mfwBtStatus = MFW_BTIPS_FAILED;
779 TRACE_ERROR("mfw_btips_checkStatus - BT_STATUS_HCI_INIT_ERR");
780 mfw_btips_signal(E_BTIPS_FATAL_ERROR, NULL);
781 break;
782
783 default:
784 mfwBtStatus = MFW_BTIPS_SUCCESS; //For the time being
785 break;
786 }
787 return mfwBtStatus;
788 }
789
790 static BOOL mfw_btips_createDemoRootDir(const BTHAL_U8 *fsPath)
791 {
792 static char path[BTHAL_FS_MAX_PATH_LENGTH] = {'\0'};
793
794 BtFsStatus status;
795 BthalFsStat fileStat;
796
797 if (BT_STATUS_HAL_FS_SUCCESS != BTHAL_FS_Stat((const BTHAL_U8 *)fsPath, &fileStat))
798 {
799 /* First, create the root directory */
800 status = BTHAL_FS_Mkdir((const BTHAL_U8 *)fsPath);
801 if ((status != BT_STATUS_HAL_FS_ERROR_EXISTS) && (status != BT_STATUS_HAL_FS_SUCCESS))
802 {
803 Report(("Error: Unable to create Demo root dir %s\n", path));
804 return FALSE;
805 }
806
807
808 }
809
810 return TRUE;
811 }
812
813 #endif
814