FreeCalypso > hg > fc-tourmaline
changeset 183:83c6933e8f90
rm src/ui/mfw/mfw_Btips*
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Tue, 19 Jan 2021 05:29:26 +0000 |
parents | e41c934ecd97 |
children | 73fd75652066 |
files | src/ui/mfw/mfw_Btips.c src/ui/mfw/mfw_Btips.h src/ui/mfw/mfw_BtipsA2dp.c src/ui/mfw/mfw_BtipsA2dp.h src/ui/mfw/mfw_BtipsBmg.c src/ui/mfw/mfw_BtipsBmg.h src/ui/mfw/mfw_BtipsFtps.c src/ui/mfw/mfw_BtipsMdg.c src/ui/mfw/mfw_BtipsOppc.c src/ui/mfw/mfw_BtipsOppc.h src/ui/mfw/mfw_BtipsOpps.c src/ui/mfw/mfw_BtipsVg.c src/ui/mfw/mfw_BtipsVg.h |
diffstat | 13 files changed, 0 insertions(+), 7211 deletions(-) [+] |
line wrap: on
line diff
--- a/src/ui/mfw/mfw_Btips.c Tue Jan 19 05:23:24 2021 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,814 +0,0 @@ -/* ========================================================= -* Texas Instruments OMAP(TM) Platform Software -* (c) Copyright Texas Instruments, Incorporated. All Rights Reserved. -* -* Use of this software is controlled by the terms and conditions found -* in the license agreement under which this software has been supplied. -* ========================================================== */ -/* - $Project name: Basic Bluetooth MMI - $Project code: - $Module: Bluetooth BMG MFW - $File: Mfw_Btips.c - $Revision: 1.0 - $Author: Texas Instruments - $Date: 26/06/07 - -******************************************************************************** - - Description: - - This module provides the BTIPS BMG APPlication functionality. - -******************************************************************************** - $History: Mfw_Btips.c - - 26/06/07 Sasken original version - - $End - -*******************************************************************************/ - - - - -/******************************************************************************* - - Include files - -*******************************************************************************/ - -#define ENTITY_MFW -/* includes */ - -#include <string.h> - - -/* BTIPS Includes */ -#include "me.h" -#include "osapi.h" -#include "btl_common.h" -#include "bthal_btdrv.h" -#include "bthal_fs.h" -#include "bthal_pm.h" -#include "bthal_config.h" -#include "bttypes.h" -#include "goep.h" -#include "bpp.h" -#include "Debug.h" - -/* BTL includes */ -#include "btl_bppsnd.h" -#include "btl_bmg.h" - -#if FM_STACK == XA_ENABLED - -#include "fms_api.h" -#endif - -#if defined (NEW_FRAME) - -#include "typedefs.h" -#include "vsi.h" -#include "pei.h" -#include "custom.h" -#include "gsm.h" -#include "prim.h" - -#else - -#include "STDDEFS.H" -#include "custom.h" -#include "gsm.h" -#include "vsi.h" - -#endif -#include "mfw_mfw.h" -#include "mfw_win.h" -#include "mfw_icn.h" /* included for mfw_mnu.h */ -#include "mfw_mnu.h" -#include "mfw_tim.h" -#include "mfw_kbd.h" -#include "mfw_sat.h" /* included for MmiDummy.h, included for MmiMenu.h */ - -#include "Mfw_Btips.h" -#include "ffs/ffs_api.h" -/*------------------------------------------------------------------------ - * - * Default BT Demo folder fsPath (i.e. \MfwBtDemo) - */ -U8 Bt_DefaultDemoDir[BT_FS_MAX_PATH_LENGTH]; - -#define hCommACI _ENTITY_PREFIXED(hCommACI) - - -#define MFW_BTIPS_RADIO_OFF 0 -#define MFW_BTIPS_RADIO_ON 1 -#define MFW_BTIPS_RADIO_IN_PROGRESS -1 - -EXTERN MfwHdr * current_mfw_elem; - - -/* Declaration of static variables */ -static BOOL isBtRadioEnabled = MFW_BTIPS_RADIO_OFF; /* To check at start-up */ - -static void btips_btlCallBack(const BtlEvent *event); -static void mfw_btips_btlCallBack(T_BTIPS_MMI_IND *btips_mmi_ind); -static void mfw_btips_callBack(T_BTIPS_MMI_IND *btips_mmi_ind ); -static BOOL mfw_btips_createDemoRootDir(const BTHAL_U8 *fsPath); -BOOL mfw_btips_checkStatus(BtStatus btStatus); - -void Btips_ffs_log_clear(void) -{ - ffs_remove((const char*)"/ffslog"); -} -void Btips_ffs_log_message(char *LogMsg,...) -{ -#ifdef FFSLOG - fd_t fd= -1; - char log_ffs_buf[256]; - va_list varpars; - - va_start (varpars, LogMsg); - vsprintf(log_ffs_buf,LogMsg,varpars); - va_end (varpars); - fd = ffs_open((const char*)"/ffslog", FFS_O_APPEND | FFS_O_WRONLY ); - if(fd < 0) - fd=ffs_open((const char*)"/ffslog", FFS_O_CREATE |FFS_O_WRONLY ); - if(fd >= 0) - { - strcat(log_ffs_buf," \n "); - ffs_write(fd, log_ffs_buf, strlen(log_ffs_buf)); - ffs_close(fd); - } -#endif -} -#ifdef FF_MMI_BTIPS_APP - -/************************************************************************ - MFW - ACI Communication Module Start -************************************************************************/ - -/******************************************************************************* - - $Function: mfw_btips_sign_exec - - $Description: This function sends the Mfw BTIPS events from the Mfw to the BMI. - - $Returns: None - - $Arguments: None - -*******************************************************************************/ -BOOL mfw_btips_sign_exec (T_MFW_HDR * cur_elem, T_MFW_EVENT event, T_MFW_BTIPS_PARA * para) -{ - TRACE_FUNCTION("mfw_btips_sign_exec()"); - - while (cur_elem) - { - /* - * event handler is available - */ - TRACE_FUNCTION_P1("mfw_btips_sign_exec - %x", event); - if (cur_elem->type EQ MfwTyBtipsBmg) - { - T_MFW_BTIPS * btips_data; - - TRACE_FUNCTION("mfw_btips_sign_exec() cur_elem->type EQ MfwTyBtipsBmg"); - /* - * handler is CM management handler - */ - btips_data = (T_MFW_BTIPS *)cur_elem->data; - if (btips_data->emask & event) - { - /* - * event is expected by the call back function - */ - btips_data->event = event; - switch (event) - { - /* - ** BTIPS BMG Events - */ - case E_BTIPS_BMG_NAME_RESULT: - case E_BTIPS_BMG_SEARCH_COMPLETE: - case E_BTIPS_BMG_SEARCH_CANCELLED: - case E_BTIPS_BMG_BOND_COMPLETE: - case E_BTIPS_BMG_BOND_CANCELLED: - case E_BTIPS_BMG_DEVICE_SERVICES: - if(para!=NULL) - memcpy (&btips_data->para, para, sizeof (T_MFW_BTIPS_PARA)); - break; - default: - return FALSE; - - } - - /* - * if call back defined, call it - */ - if (btips_data->handler) - { - current_mfw_elem = cur_elem; - - if ((*(btips_data->handler)) (btips_data->event, (void *)&btips_data->para)) - return TRUE; - } - } - } - else if (cur_elem->type EQ MfwTyBtips) - { - T_MFW_BTIPS * btips_data; - - TRACE_FUNCTION("mfw_btips_sign_exec() cur_elem->type EQ MfwTyBtips"); - /* - * handler is CM management handler - */ - btips_data = (T_MFW_BTIPS *)cur_elem->data; - if (btips_data->emask & event) - { - /* - * event is expected by the call back function - */ - btips_data->event = event; - switch (event) - { - /* - ** BTIPS generic Events - */ - case E_BTIPS_POWERON_SUCCESS: - case E_BTIPS_POWERON_FAILURE: - case E_BTIPS_POWEROFF_SUCCESS: - case E_BTIPS_BT_NOT_ON: - case E_BTIPS_FATAL_ERROR: - case E_BTIPS_INCOMING_PIN_REQ: - case E_BTIPS_BMG_PAIRING_COMPLETE: - case E_BTIPS_OPPS_PUSH_EVENT: - case E_BTIPS_OPPS_PULL_EVENT: - case E_BTIPS_FTPS_PUT_EVENT: - case E_BTIPS_FTPS_GET_EVENT: - case E_BTIPS_FTPS_DELETE_EVENT: - case E_BTIPS_FTPS_COMPLETE_EVENT: //sundeep - case E_BTIPS_FTPS_ABORTED_EVENT: - case E_BTIPS_FTPS_PUT_COMP_EVENT: - // case E_BTIPS_FTPS_GET_COMP_EVENT: - case E_BTIPS_FTPS_CONNECT_EVENT: - case E_BTIPS_FTPS_DISCONNECT_EVENT: - case E_BTIPS_FTPS_DELETE_COMP_EVENT: - case E_BTIPS_VG_CONNECT_EVENT: - case E_BTIPS_VG_DISCONNECT_EVENT: - case E_BTIPS_VG_AUDIO_CONNECT_EVENT: - case E_BTIPS_VG_AUDIO_DISCONNECT_EVENT: - case E_BTIPS_BMG_NAME_RESULT: - case E_BTIPS_OPPS_PULL_COMP_EVENT: - case E_BTIPS_OPPS_PUSH_COMP_EVENT: - if(para!=NULL) - memcpy (&btips_data->para, para, sizeof (T_MFW_BTIPS_PARA)); - - break; - default: - return FALSE; - } - - /* - * if call back defined, call it - */ - if (btips_data->handler) - { - current_mfw_elem = cur_elem; - - if ((*(btips_data->handler)) (btips_data->event, (void *)&btips_data->para)) - return TRUE; - } - } - } - - - cur_elem = cur_elem->next; - } - return FALSE; -} - -/******************************************************************************* - - $Function: mfw_btips_signal - - $Description: This function sends the Mfw btipsnts from the Mfw to the BMI. - - $Returns: None - - $Arguments: T_MFW_EVENT : The event to be sent to the BMI - T_BTIPS_MMI_IND * : Pointer to the Event data - -*******************************************************************************/ -void mfw_btips_signal(T_MFW_EVENT event, T_BTIPS_MMI_IND * para) -{ - UBYTE temp; - temp = dspl_Enable(0); - - TRACE_FUNCTION("mfw_btips_signal()"); - - if (mfwSignallingMethod EQ 0) - { - /* - * focus is on a window - */ - if (mfwFocus) - { - /* - * send event to sim management - * handler if available - */ - if (mfw_btips_sign_exec (mfwFocus, event, para)) - { - dspl_Enable(temp); - return; - } - } - - /* - * actual focussed window is not available - * or has no network management registration - * handler, then search all nodes from the root. - */ - if (mfwRoot) - mfw_btips_sign_exec (mfwRoot, event, para); - } - else - { - MfwHdr * h = 0; - - /* - * Focus set, then start here - */ - if (mfwFocus) - h = mfwFocus; - - /* - * Focus not set, then start root - */ - if (!h) - h = mfwRoot; - - /* - * No elements available, return - */ - while (h) - { - /* - * Signal consumed, then return - */ - if (mfw_btips_sign_exec (h, event, para)) - { - dspl_Enable(temp); - return; - } - - /* - * All windows tried inclusive root - */ - if (h == mfwRoot) - { - dspl_Enable(temp); - return; - } - - /* - * get parent window - */ - h = mfwParent(mfwParent(h)); - - if (h) - h = ((MfwWin * )(h->data))->elems; - } - - mfw_btips_sign_exec (mfwRoot, event, para); - - } - - dspl_Enable(temp); - - return; -} - - -/******************************************************************************* - - $Function: mfw_btips_create - - $Description: This function initialises an Mfw BTIPS entity and adds it to the Window Stack - - $Returns: T_MFW_HND : A handle for the entity - - $Arguments: T_MFW_HND : Parent Window Handle - T_MFW_EVENT : Event Mask of the events to be handled - T_MFW_CB : Callback function to handle the events - -*******************************************************************************/ -T_MFW_HND mfw_btips_create(T_MFW_HND hWin, T_MFW_EVENT event, MfwTyp type, T_MFW_CB cbfunc) -{ - T_MFW_HDR *hdr; - T_MFW_BTIPS *btips_para; - - TRACE_FUNCTION_P1("mfw_btips_create TYPE = %x", type); - - hdr = (T_MFW_HDR *) mfwAlloc(sizeof (T_MFW_HDR)); - btips_para = (T_MFW_BTIPS *) mfwAlloc(sizeof (T_MFW_BTIPS)); - - if (!hdr OR !btips_para) - return FALSE; - - /* - * initialisation of the handler - */ - btips_para->emask = event; - btips_para->handler = cbfunc; - - hdr->data = btips_para; - hdr->type = type; - - /* - * installation of the handler - */ - return mfwInsert((T_MFW_HDR *)hWin, hdr); -} - - -/******************************************************************************* - - $Function: mfw_btips_delete - - $Description: This function clears down an Mfw BTIPS entity and removes it from the - Window Stack - - $Returns: T_MFW_RES : The result of the function - - $Arguments: T_MFW_HND : The Handle of the entity to be removed - -*******************************************************************************/ -T_MFW_RES mfw_btips_delete(T_MFW_HND hnd) -{ - TRACE_FUNCTION("mfw_btips_delete()"); - - if (!hnd OR !((T_MFW_HDR *)hnd)->data) - return MFW_RES_ILL_HND; - - if (!mfwRemove((T_MFW_HDR *)hnd)) - return MFW_RES_ILL_HND; - - mfwFree((U8 *)(((T_MFW_HDR *) hnd)->data),sizeof(T_MFW_BTIPS)); - mfwFree((U8 *)hnd,sizeof(T_MFW_HDR)); - - return MFW_RES_OK; -} - - - -/* -+------------------------------------------------------------------------------ -| Function : btipsNotifyMFW -+------------------------------------------------------------------------------ -| Description : Posts the FM Radio events to the MMI task -| -| Parameters : T_FMRADIO_EVENT fmradioevent -| void context - not used now -| -| Return : TRUE/FALSE -+------------------------------------------------------------------------------ -*/ -void btipsNotifyMFW (T_BTIPS_MMI_IND * event) -{ -#if defined (NEW_FRAME) - EXTERN T_HANDLE hCommACI; -#else - EXTERN T_VSI_CHANDLE hCommACI; -#endif - - PALLOC(btips_mmi_ind,BTIPS_MMI_IND); - TRACE_FUNCTION_P1 ("btipsNotifyMFW %x", event->mfwBtipsEventType); - /*Copy required data to btips_mmi_ind*/ - btips_mmi_ind->mfwBtipsEventType = event->mfwBtipsEventType; - btips_mmi_ind->data = event->data; - -#if defined (NEW_FRAME) - PSENDX(ACI,btips_mmi_ind); -#else -#if defined (_TMS470) - vsi_c_send("",hCommACI,D2P(btips_mmi_ind), - sizeof(T_PRIM_HEADER)+sizeof(T_BTIPS_MMI_IND)); -#else - PSEND(ACI,btips_mmi_ind); -#endif -#endif - return; - } -/* -+------------------------------------------------------------------------------ -| Function : btipsPrimHandler -+------------------------------------------------------------------------------ -| Description : This fn is the primitive handler for BTIPS MFW application -| -| Parameters : opc-opc code -| data - data -| -| -| Return : TRUE/FALSE -+------------------------------------------------------------------------------ -*/ -GLOBAL BOOL btipsPrimHandler (USHORT opc, void * data) -{ - TRACE_FUNCTION_P1 ("btipsPrimHandler %x", opc); - - if (opc EQ BTIPS_MMI_IND) - { - T_BTIPS_MMI_IND *btips_mmi_ind = (T_BTIPS_MMI_IND *)data; - mfw_btips_callBack(btips_mmi_ind); - PFREE(btips_mmi_ind); - return TRUE; - } - return FALSE; -} - -/*This function will be invoked in the ACI context and from here the signals will be -passed on to the respective mfw_btips_xxxx_callback()*/ -static void mfw_btips_callBack(T_BTIPS_MMI_IND *btips_mmi_ind ) -{ -/*Todo: implement function pointer callback*/ - switch(btips_mmi_ind->mfwBtipsEventType) - { - case MFW_BTIPS_MAIN_EVENT: - mfw_btips_btlCallBack(btips_mmi_ind); - break; - case MFW_BTIPS_BMG_EVENT: - mfw_btips_bmgCallback(btips_mmi_ind); - break; - - case MFW_BTIPS_OPPS_EVENT: - mfw_btips_oppsCallback(btips_mmi_ind); - break; - - case MFW_BTIPS_FTPS_EVENT: - mfw_btips_ftpsCallback(btips_mmi_ind); - break; - - case MFW_BTIPS_VG_EVENT: - mfw_btips_vgCallback(btips_mmi_ind); - break; - - case MFW_BTIPS_OPPC_EVENT: - mfw_btips_oppcCallback(btips_mmi_ind); - break; - - case MFW_BTIPS_MDG_EVENT: - mfw_btips_mdgCallback(btips_mmi_ind); - break; - - default: - break; - } -} -/************************************************************************ - MFW - ACI Communication Module End -************************************************************************/ - -/*--------------------------------------------------------------------------- - * mfw_btips_init - *--------------------------------------------------------------------------- - * - * Synopsis: To return the current status of BT radio. - * - * Return: TRUE if send PIN code is successful, FALSE otherwise. - * - */ -void mfw_btips_init(void) -{ - -// BTHAL_OS_Sleep(100); - /* Initialize BTIPS basic components: BT stack, BTL layer... */ - TRACE_FUNCTION(("mfw_btips_init: Starting BTL_Init")); - OS_StrCpy(Bt_DefaultDemoDir, BT_DEMO_FOLDER_PATH); - if (TRUE != mfw_btips_createDemoRootDir(Bt_DefaultDemoDir)) - { - Report(("Fatal Error: Could not create BT root folder\n"));; - } - if (BT_STATUS_SUCCESS != BTL_Init(btips_btlCallBack)) - { - mfw_BtipsReport(("Fatal Error: Could not initialize the BTIPS basic components\n")); - } - - /* Initialize application modules */ - mfw_btips_bmgInit(); - mfw_btips_a2dpInit(); - mfw_btips_ftpsInit(); - mfw_btips_vgInit(); - mfw_btips_oppsInit(); - mfw_btips_oppcInit(); -mfw_btips_mdgInit(); - - #if FM_STACK == XA_ENABLED - Assert(FM_STATUS_SUCCESS == FM_Init()); - #endif - - -} - -/*--------------------------------------------------------------------------- - * mfw_btips_getRadioStatus - *--------------------------------------------------------------------------- - * - * Synopsis: To return the current status of BT radio. - * - * Return: TRUE if send PIN code is successful, FALSE otherwise. - * - */ -BOOL mfw_btips_getRadioStatus (void) -{ - return isBtRadioEnabled; -} - - -/*--------------------------------------------------------------------------- - * mfw_btips_radioOn - *--------------------------------------------------------------------------- - * - * Synopsis: Enable BT radio. - * - * Return: TRUE if Enabling BT radio is successful, FALSE otherwise. - * - */ -BOOL mfw_btips_radioOn (void) -{ - BtStatus btStatus; - - TRACE_FUNCTION("mfw_btips_radioOn()"); - - Btips_ffs_log_clear(); - - if (MFW_BTIPS_RADIO_OFF == isBtRadioEnabled) - { - isBtRadioEnabled = MFW_BTIPS_RADIO_IN_PROGRESS; - btStatus = BTL_RadioOn(); - Assert(MFW_BTIPS_SUCCESS == mfw_btips_checkStatus(btStatus)); - } - else - { - TRACE_EVENT_P1("mfw_btips_radioOn -BT radio is already enabled %d", isBtRadioEnabled); - } -} - - -/*--------------------------------------------------------------------------- - * mfw_btips_radioOff - *--------------------------------------------------------------------------- - * - * Synopsis: Disable BT radio. - * - * Return: TRUE if Disabling BT radio is successful, FALSE otherwise. - * - */ -BOOL mfw_btips_radioOff (void) -{ - BtStatus btStatus; - - TRACE_FUNCTION("mfw_btips_radioOff()"); - - if (MFW_BTIPS_RADIO_ON == isBtRadioEnabled) - { - isBtRadioEnabled = MFW_BTIPS_RADIO_IN_PROGRESS; - btStatus = BTL_RadioOff(); - Assert(MFW_BTIPS_SUCCESS == mfw_btips_checkStatus(btStatus)); - } - else - { - mfw_BtipsReport(("APP MAIN: BT radio is already disabled")); - } -} - -/*--------------------------------------------------------------------------- - * btips_btlCallBack - *--------------------------------------------------------------------------- - * - * Synopsis: BTL Main application callback in BTS Context - * - * Return: - * - */ -static void btips_btlCallBack(const BtlEvent *event) -{ - T_BTIPS_MMI_IND btips_mmi_ind; - - TRACE_FUNCTION_P1("btips_btlCallBack %d", event->type); - btips_mmi_ind.mfwBtipsEventType = MFW_BTIPS_MAIN_EVENT; - switch (event->type) - { - case BTL_EVENT_RADIO_OFF_COMPLETE: - isBtRadioEnabled = MFW_BTIPS_RADIO_OFF; - btips_mmi_ind.data.btlBtEvent = BTL_EVENT_RADIO_OFF_COMPLETE; - btipsNotifyMFW(&btips_mmi_ind); - break; - - case BTL_EVENT_RADIO_ON_COMPLETE: - // Display Bluetooth Icon on the opening/default main window - isBtRadioEnabled = MFW_BTIPS_RADIO_ON; - btips_mmi_ind.data.btlBtEvent = BTL_EVENT_RADIO_ON_COMPLETE; - btipsNotifyMFW(&btips_mmi_ind); - break; - } -} - -/*--------------------------------------------------------------------------- - * mfw_btips_radioOff - *--------------------------------------------------------------------------- - * - * Synopsis: Disable BT radio. - * - * Return: TRUE if Disabling BT radio is successful, FALSE otherwise. - * - */ - -static void mfw_btips_btlCallBack(T_BTIPS_MMI_IND * para) -{ - MfwBtMainEvent event = para->data.btlBtEvent; - - TRACE_FUNCTION_P1("mfw_btips_btlCallBack %d", event); - - switch (event) - { - case BTL_EVENT_RADIO_OFF_COMPLETE: - mfw_btips_signal(E_BTIPS_POWEROFF_SUCCESS, NULL); - break; - - case BTL_EVENT_RADIO_ON_COMPLETE: - // Display Bluetooth Icon on the opening/default main window - mfw_btips_signal(E_BTIPS_POWERON_SUCCESS, NULL); - break; - - }; -} - -BOOL mfw_btips_checkStatus(BtStatus btStatus) -{ - BOOL mfwBtStatus = 0; - TRACE_EVENT_P1("mfw_btips_checkStatus : %s", pBT_Status(btStatus)); - switch(btStatus) - { - case BT_STATUS_SUCCESS: - case BT_STATUS_PENDING: - case BT_STATUS_IN_PROGRESS: - mfwBtStatus = MFW_BTIPS_SUCCESS; - break; - - case BTEVENT_HCI_FATAL_ERROR: - mfwBtStatus = MFW_BTIPS_FAILED; - TRACE_ERROR("mfw_btips_checkStatus - Fatal Error"); - mfw_btips_signal(E_BTIPS_FATAL_ERROR, NULL); - break; - - case BT_STATUS_INVALID_PARM: - mfwBtStatus = MFW_BTIPS_FAILED; - TRACE_ERROR("mfw_btips_checkStatus - Invalid Params"); - break; - - case BT_STATUS_DEVICE_NOT_FOUND: - mfwBtStatus = MFW_BTIPS_FAILED; - TRACE_ERROR("mfw_btips_checkStatus - BT_STATUS_DEVICE_NOT_FOUND"); - break; - - case BT_STATUS_HCI_INIT_ERR: - mfwBtStatus = MFW_BTIPS_FAILED; - TRACE_ERROR("mfw_btips_checkStatus - BT_STATUS_HCI_INIT_ERR"); - mfw_btips_signal(E_BTIPS_FATAL_ERROR, NULL); - break; - - default: - mfwBtStatus = MFW_BTIPS_SUCCESS; //For the time being - break; - } - return mfwBtStatus; -} - -static BOOL mfw_btips_createDemoRootDir(const BTHAL_U8 *fsPath) -{ - static char path[BTHAL_FS_MAX_PATH_LENGTH] = {'\0'}; - - BtFsStatus status; - BthalFsStat fileStat; - - if (BT_STATUS_HAL_FS_SUCCESS != BTHAL_FS_Stat((const BTHAL_U8 *)fsPath, &fileStat)) - { - /* First, create the root directory */ - status = BTHAL_FS_Mkdir((const BTHAL_U8 *)fsPath); - if ((status != BT_STATUS_HAL_FS_ERROR_EXISTS) && (status != BT_STATUS_HAL_FS_SUCCESS)) - { - Report(("Error: Unable to create Demo root dir %s\n", path)); - return FALSE; - } - - - } - - return TRUE; -} - -#endif -
--- a/src/ui/mfw/mfw_Btips.h Tue Jan 19 05:23:24 2021 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,270 +0,0 @@ -#ifndef DEF_MFW_BTIPS -#define DEF_MFW_BTIPS -/* ========================================================= -* Texas Instruments OMAP(TM) Platform Software -* (c) Copyright Texas Instruments, Incorporated. All Rights Reserved. -* -* Use of this software is controlled by the terms and conditions found -* in the license agreement under which this software has been supplied. -* ========================================================== */ -/* - $Project name: Basic Bluetooth MMI - $Project code: - $Module: Bluetooth BMG MFW - $File: Mfw_Btips.h - $Revision: 1.0 - $Author: Texas Instruments - $Date: 26/06/07 - -******************************************************************************** - - Description: - - This module provides the BTIPS BMG APPlication functionality. - -******************************************************************************** - $History: Mfw_Btips.h - - 26/06/07 Sasken original version - - $End - -*******************************************************************************/ - -#define MFW_BTIPS_SUCCESS 1 -#define MFW_BTIPS_FAILED 0 - -#define BT_FS_MAX_PATH_LENGTH 256 -#define BT_MAX_REM_DEV_NAME 248 -#define BT_DEMO_FOLDER_PATH "/MfwBtDemo" -/* Macro for sending events to UI - meanwhile, trace message to PCO Viewer */ -void mfw_BtipsReport(char *format,...); -#define mfw_BtipsReport(f) vsi_o_event_ttrace(f); - -#define BT_MAX_REM_DEV_NAME 248 -#define BT_MAX_OBJECT_NAME_LEN 256 - - -typedef U8 MfwBtMainEvent; - -typedef U8 BtEventType; - -typedef U8 MfwFtpsEventType; -typedef U8 MfwVgEventType; - -typedef struct _mfwBtBmgEvent -{ - BtEventType eventType; /* BtEventType - ME Event Type*/ - BtErrorCode errCode; /* BtErrorCode - Error code */ - BD_ADDR bdAddr; /* Device Address */ - union - { - U8 deviceName[BT_MAX_REM_DEV_NAME + 1]; - /* Results for BTEVENT_DISCOVER_SERVICES_RESULT event */ - SdpServicesMask discoveredServicesMask; - }p; - -}MfwBtBmgEvent; - -typedef struct _mfwBtOppsEvent -{ - BtEventType mfwOppsEventType; /* BtEventType - ME Event Type*/ - union - { - struct - { - U8 deviceName[BT_MAX_REM_DEV_NAME + 1]; - U8 oppObjectName[80]; - }opps; - }p; -}MfwBtOppsEvent; -typedef struct _mfwBtVgEvent -{ - MfwVgEventType event; - U8 deviceName[BT_MAX_REM_DEV_NAME + 1]; - BD_ADDR bdAddr; -}MfwBtVgEvent; - -typedef struct _mfwBtFtpsEvent -{ - MfwFtpsEventType event; - union - { - struct - { - U8 deviceName[BT_MAX_REM_DEV_NAME + 1]; - BD_ADDR bdAddr; - }ftpConnect; - struct - { - U8 deviceName[BT_MAX_REM_DEV_NAME + 1]; - BD_ADDR bdAddr; - }ftpDisconnect; - struct - { - U16 percent; - }ftpPercentComplete; - struct - { - U8 objectName[BT_MAX_OBJECT_NAME_LEN]; - }ftpComplete; - struct - { - U8 deviceName[BT_MAX_REM_DEV_NAME + 1]; - BD_ADDR bdAddr; - U8 objectName[BT_MAX_OBJECT_NAME_LEN]; - }ftpGetRequest; - struct - { - U8 deviceName[BT_MAX_REM_DEV_NAME + 1]; - BD_ADDR bdAddr; - U8 objectName[BT_MAX_OBJECT_NAME_LEN]; - }ftpPutRequest; - struct - { - U8 deviceName[BT_MAX_REM_DEV_NAME + 1]; - BD_ADDR bdAddr; - U8 objectName[BT_MAX_OBJECT_NAME_LEN]; - }ftpDeleteRequest; - - }p; - -}MfwBtFtpsEvent; - -typedef struct _mfwBtMdgEvent -{ - BtEventType mfwMdgEventType; /* BtEventType - ME Event Type*/ - union - { - struct - { - U8 deviceName[BT_MAX_REM_DEV_NAME + 1]; - }mdg; - }p; -}MfwBtMdgEvent; - -typedef U8 MfwBtOppcEvent; -typedef U8 MfwBtA2dpEvent; -/*mfwBtipsEventType modules*/ -#define MFW_BTIPS_MAIN_EVENT 0 -#define MFW_BTIPS_BMG_EVENT 1 -#define MFW_BTIPS_OPPS_EVENT 2 -#define MFW_BTIPS_OPPC_EVENT 3 -#define MFW_BTIPS_FTPS_EVENT 4 -#define MFW_BTIPS_VG_EVENT 5 -#define MFW_BTIPS_MDG_EVENT 6 - -#define MFW_BTIPS_FTPS_PUT_EVENT 1 -#define MFW_BTIPS_FTPS_GET_EVENT 2 -#define MFW_BTIPS_FTPS_DELETE_EVENT 3 -#define MFW_BTIPS_FTPS_COMPLETE_EVENT 4 //vamsee -#define MFW_BTIPS_FTPS_ABORTED_EVENT 5 //vamsee -#define MFW_BTIPS_FTPS_PUT_COMP_EVENT 6 -//#define MFW_BTIPS_FTPS_GET_COMP_EVENT 7 -#define MFW_BTIPS_FTPS_DELETE_COMP_EVENT 8 -#define MFW_BTIPS_FTPS_CONNECT_EVENT 9 -#define MFW_BTIPS_FTPS_DISCONNECT_EVENT 10 - - -#define MFW_BTIPS_VG_CONNECT_EVENT 1 -#define MFW_BTIPS_VG_DISCONNECT_EVENT 2 -#define MFW_BTIPS_VG_AUDIO_CONNECT_EVENT 3 -#define MFW_BTIPS_VG_AUDIO_DISCONNECT_EVENT 4 - -#define MFW_BTIPS_OPPS_PUSH_EVENT 1 -#define MFW_BTIPS_OPPS_PULL_EVENT 2 -#define MFW_BTIPS_OPPS_PUSH_COMP_EVENT 6 -#define MFW_BTIPS_OPPS_PULL_COMP_EVENT 4 -//#define MFW_BTIPS_OPPS_DISCONNECT_EVENT 4 - -typedef struct _T_BTIPS_MMI_IND -{ - U8 mfwBtipsEventType; - union - { - MfwBtMainEvent btlBtEvent; - MfwBtBmgEvent bmgBtEvent; - /*Give yr own required Structure definition for the data that is to be carried - from BTS context to the MMI (ACI) context*/ - MfwBtOppsEvent oppsBtEvent; - MfwBtOppcEvent oppcBtEvent; - MfwBtFtpsEvent ftpsBtEvent; - MfwBtVgEvent vgBtEvent; - MfwBtMdgEvent mdgBtEvent; - MfwBtA2dpEvent a2dpBtEvent; - - /*.....Event types can be defined for other modules*/ - }data; - -}T_BTIPS_MMI_IND; - -/******************BTIPS Generic EVENTS************************/ -#define E_BTIPS_POWERON_SUCCESS (T_MFW_EVENT)0x00000001 -#define E_BTIPS_POWERON_FAILURE (T_MFW_EVENT)0x00000002 -#define E_BTIPS_POWEROFF_SUCCESS (T_MFW_EVENT)0x00000004 -#define E_BTIPS_BMG_PAIRING_COMPLETE (T_MFW_EVENT)0x00000008 -#define E_BTIPS_INCOMING_PIN_REQ (T_MFW_EVENT)0x00000010 -#define E_BTIPS_BT_NOT_ON (T_MFW_EVENT)0x00000020 -#define E_BTIPS_FATAL_ERROR (T_MFW_EVENT)0x00000040 -#define E_BTIPS_FTPS_PUT_EVENT (T_MFW_EVENT)0x00000080 -#define E_BTIPS_FTPS_GET_EVENT (T_MFW_EVENT)0x00000100 -#define E_BTIPS_FTPS_COMPLETE_EVENT (T_MFW_EVENT)0x00400000 //sundeep -#define E_BTIPS_FTPS_ABORTED_EVENT (T_MFW_EVENT)0x00800000 //vamsee -#define E_BTIPS_FTPS_PUT_COMP_EVENT (T_MFW_EVENT)0x01000000 //sundeep -//#define E_BTIPS_FTPS_GET_COMP_EVENT (T_MFW_EVENT)0x02000000 //sundeep -#define E_BTIPS_FTPS_DELETE_COMP_EVENT (T_MFW_EVENT)0x04000000 //sundeep -#define E_BTIPS_FTPS_CONNECT_EVENT (T_MFW_EVENT)0x20000000 //sundeep -#define E_BTIPS_FTPS_DISCONNECT_EVENT (T_MFW_EVENT)0x40000000 //sundeep - - -#define E_BTIPS_FTPS_DELETE_EVENT (T_MFW_EVENT)0x00000200 -#define E_BTIPS_VG_CONNECT_EVENT (T_MFW_EVENT)0x00000400 -#define E_BTIPS_VG_DISCONNECT_EVENT (T_MFW_EVENT)0x00000800 -#define E_BTIPS_VG_AUDIO_CONNECT_EVENT (T_MFW_EVENT)0x00001000 -#define E_BTIPS_VG_AUDIO_DISCONNECT_EVENT (T_MFW_EVENT)0x00002000 - -/******************BMG EVENTS*********************************/ -#define E_BTIPS_BMG_NAME_RESULT (T_MFW_EVENT)0x00004000 -#define E_BTIPS_BMG_SEARCH_COMPLETE (T_MFW_EVENT)0x00008000 -#define E_BTIPS_BMG_SEARCH_CANCELLED (T_MFW_EVENT)0x00010000 -#define E_BTIPS_BMG_BOND_COMPLETE (T_MFW_EVENT)0x00020000 -#define E_BTIPS_BMG_DEVICE_SERVICES (T_MFW_EVENT)0x00040000 -#define E_BTIPS_OPPS_PUSH_EVENT (T_MFW_EVENT)0x00080000 -#define E_BTIPS_OPPS_PULL_EVENT (T_MFW_EVENT)0x00100000 -#define E_BTIPS_BMG_BOND_CANCELLED (T_MFW_EVENT)0x00200000 - -//#if 0 -#define E_BTIPS_OPPS_PULL_COMP_EVENT (T_MFW_EVENT)0x08000000 -#define E_BTIPS_OPPS_PUSH_COMP_EVENT (T_MFW_EVENT)0x10000000 -//#endif - -#define E_BTIPS_ALL_SERVICES (T_MFW_EVENT)0xFFFFFFFF - -typedef T_BTIPS_MMI_IND T_MFW_BTIPS_PARA; - -typedef struct -{ - T_MFW_EVENT emask; /* events of interest */ - T_MFW_EVENT event; /* current event */ - T_MFW_CB handler; - T_MFW_BTIPS_PARA para; -} T_MFW_BTIPS; - - -void Btips_ffs_log_message(char *LogMsg,...); - - -#ifdef FF_MMI_BTIPS_APP -#define BTIPS_MMI_IND 0x1107 //TISH: 0x110 this value is same as Camera primiive. -GLOBAL BOOL btipsPrimHandler (USHORT opc, void * data); -#endif//BT-MMI - FF_MMI_BTIPS_APP - -BOOL mfw_btips_checkStatus(BtStatus btStatus); - -void mfw_btips_signal(T_MFW_EVENT event, T_BTIPS_MMI_IND * para); -int mmi_btips_app_root_cb(T_MFW_EVENT evnt, void *para); -void mfw_btips_ftpsAcceptObjectRequest (BOOL flag); -void mfw_btips_ftpsDisconnect (void); - -#endif -
--- a/src/ui/mfw/mfw_BtipsA2dp.c Tue Jan 19 05:23:24 2021 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,913 +0,0 @@ -/* ========================================================= -* Texas Instruments OMAP(TM) Platform Software -* (c) Copyright Texas Instruments, Incorporated. All Rights Reserved. -* -* Use of this software is controlled by the terms and conditions found -* in the license agreement under which this software has been supplied. -* ========================================================== */ -/* - $Project name: Basic Bluetooth MMI - $Project code: - $Module: Bluetooth BMG APPlication - $File: mfw_BtipsA2dp.c - $Revision: 1.0 - $Author: Texas Instruments - $Date: 26/06/07 - -******************************************************************************** - - Description: - - This module provides the BTIPS BMG APPlication functionality. - -******************************************************************************** - $History: mfw_BtipsA2dp.c - - 26/06/07 Sasken original version - - $End - -*******************************************************************************/ - - - - -/******************************************************************************* - - Include files - -*******************************************************************************/ - -#define ENTITY_MFW - -#if BT_STACK == XA_ENABLED -#include <me.h> -#include <bttypes.h> -#include <sec.h> -#endif - -#include "btl_common.h" -#include "debug.h" -#include "vsi.h" -#include "overide.h" - -/* BTL includes */ -#include "btl_a2dp.h" -#include "btl_config.h" -#include "bthal_mm.h" - - -#if defined (NEW_FRAME) - -#include "typedefs.h" -#include "vsi.h" -#include "pei.h" -#include "custom.h" -#include "gsm.h" -#include "prim.h" - -#else - -#include "STDDEFS.H" -#include "custom.h" -#include "gsm.h" -#include "vsi.h" - -#endif -#include "mfw_BtipsA2dp.h" -#include "mfw_mfw.h" -#include "mfw_win.h" -#include "mfw_icn.h" /* included for mfw_mnu.h */ -#include "mfw_mnu.h" -#include "mfw_tim.h" -#include "mfw_kbd.h" -#include "mfw_sat.h" /* included for MmiDummy.h, included for MmiMenu.h */ -#include "mfw_btips.h" -#include "mfw_ffs.h" - -extern char szSelectedFileName[256]; -extern char* szSelectedFileExt; -extern int a2dp_files_count; -//Array to load fileNames in content directory -extern char* a2dp_file_names[A2DP_MAX_FILES]; - - -/*------------------------------------------------------------------------------- - * MAX_SUPPORTED_BITPOOL type - * - * Represents the maximum supported bitpool - */ -#define MAX_SUPPORTED_BITPOOL (53) - -/*------------------------------------------------------------------------------- - * MIN_SUPPORTED_BITPOOL type - * - * Represents the minimum supported bitpool - */ -#define MIN_SUPPORTED_BITPOOL (2) - -#define A2DP_MAX_NUM_STREAMS (BTL_CONFIG_A2DP_MAX_NUM_SBC_STREAMS_PER_CONTEXT + \ - BTL_CONFIG_A2DP_MAX_NUM_MPEG1_2_AUDIO_STREAMS_PER_CONTEXT) -static BOOL isStreamClosed[A2DP_MAX_NUM_STREAMS]; -static BOOL playingNow = FALSE; -static BOOL streamingNow = FALSE; -static BtSecurityLevel securityLevel = BSL_NO_SECURITY; -static BtlA2dpContext *btlA2dpContext = 0; -static BtlA2dpCodec codec; -BtlA2dpStreamId streamId = -1; -static BthalMmSbcInfo sbcLocalCap; -static BthalMmMpeg1_2_audioInfo mp3LocalCap; -static BOOL streamSbcFile = FALSE; -extern T_MFW_HND hA2dpDeviceWnd; -BOOL bPlayMp3File = FALSE; -BOOL bPlaySbcFile = FALSE; - -void APP_A2DP_StartPcmStream(BTHAL_U32 streamId); - -static void mfw_btips_a2dpEventCallBack(const BtlA2dpEvent *event); -static char * pCodecType(AvdtpCodecType CType); -static char * pAvError(AvdtpError Error); -static void mfw_btips_a2dpSetDefaultSbcLocalCap(void); -static void mfw_btips_a2dpSetDefaultMp3LocalCap(void); - -#ifdef FF_MMI_BTIPS_APP - -/*Function Definitions*/ -void APP_A2DP_StartPcmStream(BTHAL_U32 streamId) -{ - BtStatus status; - status = BTL_A2DP_StartStream(btlA2dpContext, streamId); - TRACE_FUNCTION_P1("BTL_A2DP_StartStream() returned %s.", - pBT_Status(status)); -} - -/******************************************************************************* - - $Function: mfw_btips_a2dpInit - - $Description: Function to initialise the a2dp file list. - - $Returns: None - - $Arguments: None - -*******************************************************************************/ -void mfw_btips_a2dpInit(void) -{ - BtStatus status; - TRACE_FUNCTION("mfw_btips_a2dpInit"); - - status = BTL_A2DP_Create(0, mfw_btips_a2dpEventCallBack, &securityLevel, &btlA2dpContext); - mfw_btips_a2dpSetDefaultSbcLocalCap(); - mfw_btips_a2dpSetDefaultMp3LocalCap(); - bthalMmSetExternalSbcEncoder(streamSbcFile); - bthalMmSetPcmPlatformSupportedCapabilities(&sbcLocalCap); - TRACE_FUNCTION("SBC Local capabilities has been set"); - - bthalMmSetMp3PlatformSupportedCapabilities(&mp3LocalCap); - TRACE_FUNCTION("MP3 Local capabilities has been set"); - - status = BTL_A2DP_Enable(btlA2dpContext, 0, (BTL_A2DP_SUPPORTED_FEATURES_PLAYER | BTL_A2DP_SUPPORTED_FEATURES_MIXER)); - - TRACE_FUNCTION_P1("BTL_A2DP_Enable() returned %s.", pBT_Status(status)); - if (status == BT_STATUS_SUCCESS) - { - OS_MemSet(isStreamClosed, TRUE, A2DP_MAX_NUM_STREAMS); - - } - else - { - TRACE_FUNCTION("A2DP Enable Failed!"); - } -} -/******************************************************************************* - - $Function: mfw_btips_a2dpPopulateFiles - - $Description:Populates the MIDI file names into the array - - $Returns: The count of the files in the directory - - $Arguments: file_names:Pointer to the arrayto store file names - max_files_count:Max file counts to be stored in array -*******************************************************************************/ - -int mfw_btips_a2dpPopulateFiles(char **file_names, int max_files_count,char* dir_name_p) -{ - - T_FFS_DIR dir = {0}; - char dest_name_p[100] = ""; - int i, files_count = 0; - char *fileExt; - - TRACE_FUNCTION("mfw_btips_a2dpPopulateFiles"); - - TRACE_FUNCTION_P1("a2dp_files_count - %s", dir_name_p); - if (ffs_opendir (dir_name_p, &dir) <= 0) - { - TRACE_FUNCTION("Cld not open Dir"); - - files_count = 0; - } - //Release previous allocated memory before allocating again - mfw_btips_a2dpUnpopulateFiles(file_names); - //read the file names - //file_count will be used to populate the array index - for (i = 0; ffs_readdir (&dir, dest_name_p, 100) > 0x0; i++) - { - - TRACE_FUNCTION_P1("Reading Dir - %s",dest_name_p); - (file_names[files_count]) = (char*)mfwAlloc(strlen(dest_name_p) + 1); - if(file_names[files_count] != NULL) - { - //Retrieve file extension.Store only the supported file formats in array - fileExt =mfw_btips_a2dpGetExtension(dest_name_p); - //List the MP3 files also.Mp3 files hsould not be listed or ULC - if ( (strcmp(fileExt, "mp3") == 0)) - { - - strcpy (file_names[files_count], dest_name_p); - TRACE_FUNCTION_P1("file_names - %s", file_names[files_count]); - files_count++; - } - else if ( (strcmp(fileExt, "wav")== 0)) - { - - strcpy (file_names[files_count], dest_name_p); - TRACE_FUNCTION_P1("file_names - %s", file_names[files_count]); - files_count++; - } - else if ( (strcmp(fileExt, "pcm")== 0)) - { - strcpy (file_names[files_count], dest_name_p); - TRACE_FUNCTION_P1("file_names - %s", file_names[files_count]); - files_count++; - } - else if(files_count >= max_files_count) - break; - } - else - { - //files_count = 0; - } - - } - //Closing the directory aa per the new FFS logic - ffs_closedir(dir); - - TRACE_EVENT_P1("read files_count is %d",files_count); - return files_count; -} -/******************************************************************************* - - $Function: mfw_btips_a2dpUnpopulateFiles - - $Description:Frees the memory allocated for the array - $Returns: None - - $Arguments: file_names:Pointer to the arrayto store file names - -*******************************************************************************/ -void mfw_btips_a2dpUnpopulateFiles(char **file_names) -{ - int i; - TRACE_FUNCTION("mfw_btips_a2dpUnpopulateFiles"); - - //Free the allocated memory for file names - for (i = 0; i<A2DP_MAX_FILES; i++) - { - if(file_names[i]) - { - mfwFree((U8 *)file_names[i],(U16)strlen(file_names[i]) + 1); - } - file_names[i]=NULL; - } - -} -/******************************************************************************* - - $Function: mfw_btips_a2dpGetExtension - - $Description: public function to retrieve the extension of a file - - $Returns:Extention of the filename - - $Arguments: scr- Filename - -*******************************************************************************/ - char *mfw_btips_a2dpGetExtension(char *src) -{ - int i,len; - - TRACE_FUNCTION("mfw_btips_a2dpGetExtension"); - len = strlen(src); - for(i = 0; i < len; i++){ - if(src[i] == '.'){ - return (src+i+1); - } - } - return (src+i); -} -/******************************************************************************* - - $Function: sounds_midi_return_file_number - - $Description: returns the file count - - $Returns: Count of the Midi files - - $Arguments: None - -*******************************************************************************/ -int mfw_btips_a2dpGetNumFiles(void) -{ - TRACE_FUNCTION("sounds_midi_return_file_number"); - TRACE_FUNCTION_P1("mfw_btips_a2dpGetNumFiles -a2dp_files_count - %d", a2dp_files_count); - if(a2dp_files_count<=0) - return 0; - else - return a2dp_files_count; - -} -/******************************************************************************* - - $Function: mfw_btips_a2dpGetFileName - - $Description: Returns the file name - - $Returns: Name of the file - - $Arguments: index:The index of the file, whose name has to be retrieved - -*******************************************************************************/ - -char* mfw_btips_a2dpGetFileName(UBYTE index) -{ - - TRACE_FUNCTION("mfw_btips_a2dpGetFileName"); - TRACE_EVENT_P2("A2dp_file_names[%d] is %s",index,(char *)a2dp_file_names[index]); - return (char *) a2dp_file_names[index]; - -} - -/******************************************************************************* - - $Function: mfw_btips_a2dpEventCallBack - - $Description: Returns the file name - - $Returns: Name of the file - - $Arguments: index:The index of the file, whose name has to be retrieved - -*******************************************************************************/ - -static void mfw_btips_a2dpEventCallBack(const BtlA2dpEvent *event) -{ - - A2dpError error = A2DP_ERR_NO_ERROR; - A2dpCallbackParms *Parms; - BOOL streamStopped = FALSE; - BtStatus status; -// char szSelectedFilePath[256] - - Parms = event->callbackParms; - - TRACE_FUNCTION_P1("mfw_btips_a2dpEventCallBack %d",Parms->event); - - switch (Parms->event) { - case A2DP_EVENT_STREAM_OPEN_IND: - TRACE_FUNCTION_P1("A2DP_EVENT_STREAM_OPEN_IND streamId %d.", event->streamId); - TRACE_FUNCTION_P2(" Codec: %s, Length: %d", - pCodecType(Parms->p.configReq->codec.codecType), - Parms->p.configReq->codec.elemLen); - - /*if (promptUserOnIncomingConAndStart) - { - AppReport("Please Accept or Reject open stream request"); - } - else - */ - { - /* Auto-accept connection */ - status = BTL_A2DP_OpenStreamResponse(btlA2dpContext, event->streamId, A2DP_ERR_NO_ERROR); - TRACE_FUNCTION_P1("BTL_A2DP_OpenStreamResponse() returned %s.", - pBT_Status(status)); - } - - break; - - case A2DP_EVENT_GET_CONFIG_IND: - TRACE_FUNCTION_P1("A2DP_EVENT_GET_CONFIG_IND streamId %d.", event->streamId); - TRACE_FUNCTION("To configure and open strean press 'Open Stream' button "); - /*if(streamId > 0) - { - mfw_btips_a2dpCloseStream(); - }*/ - - status = BTL_A2DP_OpenStream(btlA2dpContext, streamId); - isStreamClosed[event->streamId] = FALSE; - bthalMmStreamStateIsConnected(event->streamId, TRUE); - TRACE_FUNCTION_P1("BTL_A2DP_OpenStream() returned %s.", - pBT_Status(status)); - break; - - case A2DP_EVENT_STREAM_OPEN: - TRACE_FUNCTION_P1("A2DP_EVENT_STREAM_OPEN streamId %d.", event->streamId); - isStreamClosed[event->streamId] = FALSE; - bthalMmStreamStateIsConnected(event->streamId, TRUE); - if(bPlaySbcFile) - { - TRACE_FUNCTION("Opening PCM File "); - if(AppPcmSimOpenFile(szSelectedFileName)) - { - TRACE_FUNCTION("PCM File Open Success!!"); - } - else - { - TRACE_FUNCTION("PCM File Open Failed!!"); - } - } - - if(bPlayMp3File) - { - TRACE_FUNCTION("Opening Mp3 File "); - if(AppMp3OpenFile(szSelectedFileName)) - { - TRACE_FUNCTION("Mp3 File Open Success!!"); - } - else - { - TRACE_FUNCTION("Mp3 File Open Failed!!"); - } - status = BTL_A2DP_StartStream(btlA2dpContext, streamId); - TRACE_FUNCTION_P1("BTL_A2DP_StartStream() returned %s.", - pBT_Status(status)); - - } - - - break; - - case A2DP_EVENT_STREAM_IDLE: - TRACE_FUNCTION_P1("A2DP_EVENT_STREAM_IDLE streamId %d.", event->streamId); - isStreamClosed[event->streamId] = FALSE; - streamStopped = TRUE; - - break; - - case A2DP_EVENT_STREAM_CLOSED: - TRACE_FUNCTION_P1("A2DP_EVENT_STREAM_CLOSED streamId %d.", event->streamId); - isStreamClosed[event->streamId] = TRUE; - streamStopped = TRUE; - bthalMmStreamStateIsConnected(event->streamId, FALSE); - break; - - case A2DP_EVENT_STREAM_START_IND: - TRACE_FUNCTION_P1("A2DP_EVENT_STREAM_START_IND streamId %d.", event->streamId); - - /*if (promptUserOnIncomingConAndStart) - { - AppReport("Please Accept or Reject start stream request"); - } - else - */ - { - /* Auto-accept stream start */ - status = BTL_A2DP_StartStreamResponse(btlA2dpContext, event->streamId, A2DP_ERR_NO_ERROR); - TRACE_FUNCTION_P1("BTL_A2DP_StartStreamResponse() returned %s.", - pBT_Status(status)); - } - - break; - - case A2DP_EVENT_STREAM_STARTED: - TRACE_FUNCTION_P1("A2DP_EVENT_STREAM_STARTED streamId %d.", event->streamId); - - isStreamClosed[event->streamId] = FALSE; - streamingNow = TRUE; - if(bPlaySbcFile) - { - TRACE_FUNCTION("Playing PCM File "); - AppPcmSimPlayFile(); - } - else if(bPlayMp3File) - { - TRACE_FUNCTION("Playing Mp3 File "); - AppMp3PlayFile(); - - } - TRACE_FUNCTION_P1("Playing File %s : ", szSelectedFileName); - break; - - case A2DP_EVENT_STREAM_SUSPENDED: - TRACE_FUNCTION_P1("A2DP_EVENT_STREAM_SUSPENDED streamId %d.", event->streamId); - - isStreamClosed[event->streamId] = FALSE; - - if (Parms->error != AVDTP_ERR_NO_ERROR) - { - TRACE_FUNCTION_P2("Stream Suspend Failed, reason: %s, status: %s", - pAvError(Parms->error), - pBT_Status(Parms->status)); - } - /*switch (event->streamId) - { - case (0): - SendDlgItemMessage(AppWnd, IDC_STREAM0_OPEND, BM_SETCHECK, BST_CHECKED, 0L); - SendDlgItemMessage(AppWnd, IDC_STREAM0_STREAMING, BM_SETCHECK, BST_UNCHECKED, 0L); - break; - - case (1): - SendDlgItemMessage(AppWnd, IDC_STREAM1_OPEND, BM_SETCHECK, BST_CHECKED, 0L); - SendDlgItemMessage(AppWnd, IDC_STREAM1_STREAMING, BM_SETCHECK, BST_UNCHECKED, 0L); - break; - - case (2): - SendDlgItemMessage(AppWnd, IDC_STREAM2_OPEND, BM_SETCHECK, BST_CHECKED, 0L); - SendDlgItemMessage(AppWnd, IDC_STREAM2_STREAMING, BM_SETCHECK, BST_UNCHECKED, 0L); - break; - - case (3): - SendDlgItemMessage(AppWnd, IDC_STREAM3_OPEND, BM_SETCHECK, BST_CHECKED, 0L); - SendDlgItemMessage(AppWnd, IDC_STREAM3_STREAMING, BM_SETCHECK, BST_UNCHECKED, 0L); - break; - } - */ - break; - - case A2DP_EVENT_STREAM_ABORTED: - TRACE_FUNCTION_P1("A2DP_EVENT_STREAM_ABORTED streamId %d.", event->streamId); - if (Parms->error != AVDTP_ERR_NO_ERROR) { - TRACE_FUNCTION_P2("Stream Abort Failed, reason: %s, status: %s", - pAvError(Parms->error), - pBT_Status(Parms->status)); - } - /*switch (event->streamId) - { - case (0): - if(isStreamClosed[0] == FALSE) - { - - SendDlgItemMessage(AppWnd, IDC_STREAM0_IDLE, BM_SETCHECK, BST_CHECKED, 0L); - } - SendDlgItemMessage(AppWnd, IDC_STREAM0_OPEND, BM_SETCHECK, BST_UNCHECKED, 0L); - SendDlgItemMessage(AppWnd, IDC_STREAM0_STREAMING, BM_SETCHECK, BST_UNCHECKED, 0L); - break; - - case (1): - if(isStreamClosed[1] == FALSE) - { - - SendDlgItemMessage(AppWnd, IDC_STREAM1_IDLE, BM_SETCHECK, BST_CHECKED, 0L); - } - SendDlgItemMessage(AppWnd, IDC_STREAM1_OPEND, BM_SETCHECK, BST_UNCHECKED, 0L); - SendDlgItemMessage(AppWnd, IDC_STREAM1_STREAMING, BM_SETCHECK, BST_UNCHECKED, 0L); - break; - - case (2): - if(isStreamClosed[2] == FALSE) - { - - SendDlgItemMessage(AppWnd, IDC_STREAM2_IDLE, BM_SETCHECK, BST_CHECKED, 0L); - } - SendDlgItemMessage(AppWnd, IDC_STREAM2_OPEND, BM_SETCHECK, BST_UNCHECKED, 0L); - SendDlgItemMessage(AppWnd, IDC_STREAM2_STREAMING, BM_SETCHECK, BST_UNCHECKED, 0L); - break; - - case (3): - if(isStreamClosed[3] == FALSE) - { - - SendDlgItemMessage(AppWnd, IDC_STREAM3_IDLE, BM_SETCHECK, BST_CHECKED, 0L); - } - SendDlgItemMessage(AppWnd, IDC_STREAM3_OPEND, BM_SETCHECK, BST_UNCHECKED, 0L); - SendDlgItemMessage(AppWnd, IDC_STREAM3_STREAMING, BM_SETCHECK, BST_UNCHECKED, 0L); - break; - } -*/ - isStreamClosed[event->streamId] = FALSE; - streamStopped = TRUE; - bPlaySbcFile = FALSE; - bPlayMp3File = FALSE; - break; - - case A2DP_EVENT_DISABLED: - TRACE_FUNCTION("A2DP_EVENT_DISABLED"); - /*SendDlgItemMessage(AppWnd, IDC_STREAM0_IDLE, BM_SETCHECK, BST_UNCHECKED, 0L); - SendDlgItemMessage(AppWnd, IDC_STREAM0_OPEND, BM_SETCHECK, BST_UNCHECKED, 0L); - SendDlgItemMessage(AppWnd, IDC_STREAM0_STREAMING, BM_SETCHECK, BST_UNCHECKED, 0L); - SendDlgItemMessage(AppWnd, IDC_STREAM0_CLOSED, BM_SETCHECK, BST_UNCHECKED, 0L); - SendDlgItemMessage(AppWnd, IDC_STREAM1_IDLE, BM_SETCHECK, BST_UNCHECKED, 0L); - SendDlgItemMessage(AppWnd, IDC_STREAM1_OPEND, BM_SETCHECK, BST_UNCHECKED, 0L); - SendDlgItemMessage(AppWnd, IDC_STREAM1_STREAMING, BM_SETCHECK, BST_UNCHECKED, 0L); - SendDlgItemMessage(AppWnd, IDC_STREAM1_CLOSED, BM_SETCHECK, BST_UNCHECKED, 0L); - SendDlgItemMessage(AppWnd, IDC_STREAM2_IDLE, BM_SETCHECK, BST_UNCHECKED, 0L); - SendDlgItemMessage(AppWnd, IDC_STREAM2_OPEND, BM_SETCHECK, BST_UNCHECKED, 0L); - SendDlgItemMessage(AppWnd, IDC_STREAM2_STREAMING, BM_SETCHECK, BST_UNCHECKED, 0L); - SendDlgItemMessage(AppWnd, IDC_STREAM2_CLOSED, BM_SETCHECK, BST_UNCHECKED, 0L); - SendDlgItemMessage(AppWnd, IDC_STREAM3_IDLE, BM_SETCHECK, BST_UNCHECKED, 0L); - SendDlgItemMessage(AppWnd, IDC_STREAM3_OPEND, BM_SETCHECK, BST_UNCHECKED, 0L); - SendDlgItemMessage(AppWnd, IDC_STREAM3_STREAMING, BM_SETCHECK, BST_UNCHECKED, 0L); - SendDlgItemMessage(AppWnd, IDC_STREAM3_CLOSED, BM_SETCHECK, BST_UNCHECKED, 0L); - */ - streamStopped = TRUE; - - break; - - default: - TRACE_FUNCTION_P1("MFW A2DP Unexpected event %d!", Parms->event); - break; - } - - if ( streamStopped ) - { - streamingNow = FALSE; - } -} -/*--------------------------------------------------------------------------- - * pCodecType() - *--------------------------------------------------------------------------- - * - * Synopsis: Prints codec type message - * - */ -static char * pCodecType(AvdtpCodecType CType) -{ - switch (CType) { - case AVDTP_CODEC_TYPE_SBC: - return "SBC"; - case AVDTP_CODEC_TYPE_MPEG1_2_AUDIO: - return "MPEG1_2_AUDIO"; - case AVDTP_CODEC_TYPE_MPEG2_4_AAC: - return "MPEG2_4_AAC"; - case AVDTP_CODEC_TYPE_ATRAC: - return "ATRAC"; - case AVDTP_CODEC_TYPE_NON_A2DP: - return "Non-A2DP"; - default: - return "UNKNOWN"; - } -} -/*--------------------------------------------------------------------------- - * pAvError() - *--------------------------------------------------------------------------- - * - * Synopsis: Prints AV error message - * - */ -static char * pAvError(AvdtpError Error) -{ - switch (Error) { - case AVDTP_ERR_NO_ERROR: - return "AVDTP_ERR_NO_ERROR"; - case AVDTP_ERR_BAD_HEADER_FORMAT: - return "AVDTP_ERR_BAD_HEADER_FORMAT"; - case AVDTP_ERR_BAD_LENGTH: - return "AVDTP_ERR_BAD_LENGTH"; - case AVDTP_ERR_BAD_ACP_SEID: - return "AVDTP_ERR_BAD_ACP_SEID"; - case AVDTP_ERR_IN_USE: - return "AVDTP_ERR_IN_USE"; - case AVDTP_ERR_NOT_IN_USE: - return "AVDTP_ERR_NOT_IN_USE"; - case AVDTP_ERR_BAD_SERV_CATEGORY: - return "AVDTP_ERR_BAD_SERV_CATEGORY"; - case AVDTP_ERR_BAD_PAYLOAD_FORMAT: - return "AVDTP_ERR_BAD_PAYLOAD_FORMAT"; - case AVDTP_ERR_NOT_SUPPORTED_COMMAND: - return "AVDTP_ERR_NOT_SUPPORTED_COMMAND"; - case AVDTP_ERR_INVALID_CAPABILITIES: - return "AVDTP_ERR_INVALID_CAPABILITIES"; - case AVDTP_ERR_BAD_RECOVERY_TYPE: - return "AVDTP_ERR_BAD_RECOVERY_TYPE"; - case AVDTP_ERR_BAD_MEDIA_TRANSPORT_FORMAT: - return "AVDTP_ERR_BAD_MEDIA_TRANSPORT_FORMAT"; - case AVDTP_ERR_BAD_RECOVERY_FORMAT: - return "AVDTP_ERR_BAD_RECOVERY_FORMAT"; - case AVDTP_ERR_BAD_ROHC_FORMAT: - return "AVDTP_ERR_BAD_ROHC_FORMAT"; - case AVDTP_ERR_BAD_CP_FORMAT: - return "AVDTP_ERR_BAD_CP_FORMAT"; - case AVDTP_ERR_BAD_MULTIPLEXING_FORMAT: - return "AVDTP_ERR_BAD_MULTIPLEXING_FORMAT"; - case AVDTP_ERR_UNSUPPORTED_CONFIGURATION: - return "AVDTP_ERR_UNSUPPORTED_CONFIGURATION"; - case AVDTP_ERR_BAD_STATE: - return "AVDTP_ERR_BAD_STATE"; - case A2DP_ERR_BAD_SERVICE: - return" A2DP_ERR_BAD_SERVICE"; - case A2DP_ERR_INSUFFICIENT_RESOURCE: - return" A2DP_ERR_INSUFFICENT_RESOURCE"; - case A2DP_ERR_INVALID_CODEC_TYPE: - return" A2DP_ERR_INVALID_CODEC_TYPE"; - case A2DP_ERR_NOT_SUPPORTED_CODEC_TYPE: - return" A2DP_ERR_NOT_SUPPORTED_CODEC_TYPE"; - case A2DP_ERR_INVALID_SAMPLING_FREQUENCY: - return" A2DP_ERR_INVALID_SAMPLING_FREQUENCY"; - case A2DP_ERR_NOT_SUPPORTED_SAMP_FREQ: - return" A2DP_ERR_NOT_SUPPORTED_SAMP_FREQ"; - case A2DP_ERR_INVALID_CHANNEL_MODE: - return" A2DP_ERR_INVALID_CHANNEL_MODE"; - case A2DP_ERR_NOT_SUPPORTED_CHANNEL_MODE: - return" A2DP_ERR_NOT_SUPPORTED_CHANNEL_MODE"; - case A2DP_ERR_INVALID_SUBBANDS: - return" A2DP_ERR_INVALID_SUBBANDS"; - case A2DP_ERR_NOT_SUPPORTED_SUBBANDS: - return" A2DP_ERR_NOT_SUPPORTED_SUBBANDS"; - case A2DP_ERR_INVALID_ALLOCATION_METHOD: - return" A2DP_ERR_INVALID_ALLOCATION_METHOD"; - case A2DP_ERR_NOT_SUPPORTED_ALLOC_METHOD: - return" A2DP_ERR_NOT_SUPPORTED_ALLOC_METHOD"; - case A2DP_ERR_INVALID_MIN_BITPOOL_VALUE: - return" A2DP_ERR_INVALID_MIN_BITPOOL_VALUE"; - case A2DP_ERR_NOT_SUPPORTED_MIN_BITPOOL_VALUE: - return" A2DP_ERR_NOT_SUPPORTED_MIN_BITPOOL_VALUE"; - case A2DP_ERR_INVALID_MAX_BITPOOL_VALUE: - return" A2DP_ERR_INVALID_MAX_BITPOOL_VALUE"; - case A2DP_ERR_NOT_SUPPORTED_MAX_BITPOOL_VALUE: - return" A2DP_ERR_NOT_SUPPORTED_MAX_BITPOOL_VALUE"; - case A2DP_ERR_INVALID_LAYER: - return" A2DP_ERR_INVALID_LAYER"; - case A2DP_ERR_NOT_SUPPORTED_LAYER: - return" A2DP_ERR_NOT_SUPPORTED_LAYER"; - case A2DP_ERR_NOT_SUPPORTED_CRC: - return" A2DP_ERR_NOT_SUPPORTED_CRC"; - case A2DP_ERR_NOT_SUPPORTED_MPF: - return" A2DP_ERR_NOT_SUPPORTED_MPF"; - case A2DP_ERR_NOT_SUPPORTED_VBR: - return" A2DP_ERR_NOT_SUPPORTED_VBR"; - case A2DP_ERR_INVALID_BIT_RATE: - return" A2DP_ERR_INVALID_BIT_RATE"; - case A2DP_ERR_NOT_SUPPORTED_BIT_RATE: - return" A2DP_ERR_NOT_SUPPORTED_BIT_RATE"; - case A2DP_ERR_INVALID_OBJECT_TYPE: - return" A2DP_ERR_INVALID_OBJECT_TYPE"; - case A2DP_ERR_NOT_SUPPORTED_OBJECT_TYPE: - return" A2DP_ERR_NOT_SUPPORTED_OBJECT_TYPE"; - case A2DP_ERR_INVALID_CHANNELS: - return" A2DP_ERR_INVALID_CHANNELS"; - case A2DP_ERR_NOT_SUPPORTED_CHANNELS: - return" A2DP_ERR_NOT_SUPPORTED_CHANNELS"; - case A2DP_ERR_INVALID_VERSION: - return" A2DP_ERR_INVALID_VERSION"; - case A2DP_ERR_NOT_SUPPORTED_VERSION: - return" A2DP_ERR_NOT_SUPPORTED_VERSION"; - case A2DP_ERR_NOT_SUPPORTED_MAXIMUM_SUL: - return" A2DP_ERR_NOT_SUPPORTED_MAXIMUM_SUL"; - case A2DP_ERR_INVALID_BLOCK_LENGTH: - return" A2DP_ERR_INVALID_BLOCK_LENGTH"; - case A2DP_ERR_INVALID_CP_TYPE: - return" A2DP_ERR_INVALID_CP_TYPE"; - case A2DP_ERR_INVALID_CP_FORMAT: - return" A2DP_ERR_INVALID_CP_FORMAT"; - default: - return "UNKNOWN"; - } -} - - -/*--------------------------------------------------------------------------- - * mfw_btips_a2dpSetDefaultSbcLocalCap() - *--------------------------------------------------------------------------- - * - * Synopsis: Save local SBC capabilities - * - */ -static void mfw_btips_a2dpSetDefaultSbcLocalCap(void) -{ - sbcLocalCap.samplingFreq = ( BTHAL_MM_SBC_SAMPLING_FREQ_16000 | BTHAL_MM_SBC_SAMPLING_FREQ_32000|BTHAL_MM_SBC_SAMPLING_FREQ_44100 |BTHAL_MM_SBC_SAMPLING_FREQ_48000); - sbcLocalCap.channelMode = BTHAL_MM_SBC_CHANNEL_MODE_MONO | BTHAL_MM_SBC_CHANNEL_MODE_DUAL_CHANNEL | BTHAL_MM_SBC_CHANNEL_MODE_STEREO | BTHAL_MM_SBC_CHANNEL_MODE_JOINT_STEREO; - sbcLocalCap.blockLength = (BTHAL_MM_SBC_BLOCK_LENGTH_4 | BTHAL_MM_SBC_BLOCK_LENGTH_8 | BTHAL_MM_SBC_BLOCK_LENGTH_12 | BTHAL_MM_SBC_BLOCK_LENGTH_16); - sbcLocalCap.subbands = BTHAL_MM_SBC_SUBBANDS_8 | BTHAL_MM_SBC_SUBBANDS_4; - sbcLocalCap.allocationMethod = BTHAL_MM_SBC_ALLOCATION_METHOD_LOUDNESS | BTHAL_MM_SBC_ALLOCATION_METHOD_SNR; - sbcLocalCap.maxBitpoolValue = MAX_SUPPORTED_BITPOOL; - sbcLocalCap.minBitpoolValue = MIN_SUPPORTED_BITPOOL; -} - -/*--------------------------------------------------------------------------- - * mfw_btips_a2dpSetDefaultMp3LocalCap() - *--------------------------------------------------------------------------- - * - * Synopsis: Save local PM3 capabilities - * - */ -static void mfw_btips_a2dpSetDefaultMp3LocalCap(void) -{ - mp3LocalCap.bitRate = 0xFFFF; - mp3LocalCap.channelMode = (BTHAL_MM_MPEG1_2_AUDIO_CHANNEL_MODE_MONO | BTHAL_MM_MPEG1_2_AUDIO_CHANNEL_MODE_DUAL_CHANNEL | BTHAL_MM_MPEG1_2_AUDIO_CHANNEL_MODE_STEREO | BTHAL_MM_MPEG1_2_AUDIO_CHANNEL_MODE_JOINT_STEREO); - mp3LocalCap.crcProtection = BTHAL_MM_MPEG1_2_AUDIO_CRC_PROTECTION_SUPPORTED; - mp3LocalCap.layer = (BTHAL_MM_MPEG1_2_AUDIO_LAYER_1 | BTHAL_MM_MPEG1_2_AUDIO_LAYER_2 | BTHAL_MM_MPEG1_2_AUDIO_LAYER_3); - mp3LocalCap.mpf2 = BTHAL_MM_MPEG1_2_AUDIO_MPF2_SUPPORTED; - mp3LocalCap.samplingFreq = (BTHAL_MM_MPEG1_2_AUDIO_SAMPLING_FREQ_48000 | BTHAL_MM_MPEG1_2_AUDIO_SAMPLING_FREQ_44100 | BTHAL_MM_MPEG1_2_AUDIO_SAMPLING_FREQ_32000 | BTHAL_MM_MPEG1_2_AUDIO_SAMPLING_FREQ_24000 | BTHAL_MM_MPEG1_2_AUDIO_SAMPLING_FREQ_22050 | BTHAL_MM_MPEG1_2_AUDIO_SAMPLING_FREQ_16000); - mp3LocalCap.vbr = BTHAL_MM_MPEG1_2_AUDIO_VBR_SUPPORTED; - -} - BtStatus mfw_btips_a2dpConnectStream(BD_ADDR bdAddr) -{ - BtStatus status; - - TRACE_FUNCTION("mfw_btips_a2dpConnectStream"); - - if ( (strcmp(szSelectedFileExt, "mp3") == 0)) - { - bPlayMp3File = TRUE; - bPlaySbcFile = FALSE; - codec = BTL_A2DP_CODEC_MPEG1_2_AUDIO; - status = BTL_A2DP_ConnectStream(btlA2dpContext,&bdAddr, codec, &streamId); - if (status == BT_STATUS_PENDING) - { - TRACE_FUNCTION("Connecting Mp3 stream (opening signaling channel in process)..."); - } - else - { - TRACE_FUNCTION_P1("connecting Mp3 stream failed, status: %s", pBT_Status(status)); - } - } - else if ( (strcmp(szSelectedFileExt, "pcm") == 0)) - { - bPlaySbcFile = TRUE; - bPlayMp3File = FALSE; - codec = BTL_A2DP_CODEC_SBC; - status = BTL_A2DP_ConnectStream(btlA2dpContext,&bdAddr, codec, &streamId); - if (status == BT_STATUS_PENDING) - { - TRACE_FUNCTION("Connecting SBC stream (opening signaling channel in process)..."); - } - else - { - TRACE_FUNCTION_P1("connecting SBC stream failed, status: %s", pBT_Status(status)); - } - - } - else if ( (strcmp(szSelectedFileExt, "wav") == 0)) - { - bPlaySbcFile = TRUE; - bPlayMp3File = FALSE; - codec = BTL_A2DP_CODEC_SBC; - status = BTL_A2DP_ConnectStream(btlA2dpContext,&bdAddr, codec, &streamId); - if (status == BT_STATUS_PENDING) - { - TRACE_FUNCTION("Connecting SBC stream (opening signaling channel in process)..."); - } - else - { - TRACE_FUNCTION_P1("connecting SBC stream failed, status: %s", pBT_Status(status)); - } - - } - return status; -} - BtStatus mfw_btips_a2dpCloseStream() -{ - BtStatus status; - - TRACE_FUNCTION("mfw_btips_a2dpCloseStream"); - - if ( (strcmp(szSelectedFileExt, "mp3") == 0)) - { - //AppMp3StopFile(); - AppStopAudioFile(); - AppMp3CloseFile(); - } - else if ( (strcmp(szSelectedFileExt, "pcm") == 0)) - { - - AppPcmSimStopFile(); - AppPcmSimCloseFile(); - } - else if ( (strcmp(szSelectedFileExt, "wav") == 0)) - { - - AppPcmSimStopFile(); - AppPcmSimCloseFile(); - } - status = BTL_A2DP_CloseStream(btlA2dpContext, streamId); - TRACE_FUNCTION_P1("BTL_A2DP_CloseStream returned %s", pBT_Status(status)); - return status; -} - - BOOL mfw_btips_a2dpGetConnectedDevice (BD_ADDR *bdAddr, U8 *name) -{ - BtStatus status; - - status = BTL_A2DP_GetConnectedDevice (btlA2dpContext, streamId, bdAddr); - - if (status == BT_STATUS_SUCCESS) - { - mfw_btips_bmgGetDeviceName (bdAddr, name); - return TRUE; - } - return FALSE; -} - -BOOL mfw_btips_a2dpDisconnect (BD_ADDR bdAddr) -{ - BtStatus btStatus; - - btStatus = BTL_A2DP_CloseStream (btlA2dpContext, streamId); - - return TRUE; -} - -#endif
--- a/src/ui/mfw/mfw_BtipsA2dp.h Tue Jan 19 05:23:24 2021 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,52 +0,0 @@ -#ifndef DEF_MFW_BTIPS_A2DP -#define DEF_MFW_BTIPS_A2DP -/* ========================================================= -* Texas Instruments OMAP(TM) Platform Software -* (c) Copyright Texas Instruments, Incorporated. All Rights Reserved. -* -* Use of this software is controlled by the terms and conditions found -* in the license agreement under which this software has been supplied. -* ========================================================== */ -/* - $Project name: Basic Bluetooth MMI - $Project code: - $Module: Bluetooth BMG MFW - $File: Mfw_BtipsA2dp.h - $Revision: 1.0 - $Author: Texas Instruments - $Date: 26/06/07 - -******************************************************************************** - - Description: - - This module provides the BTIPS A2DP APPlication functionality. - -******************************************************************************** - $History: Mfw_BtipsA2dp.h - - 26/06/07 Sasken original version - - $End - -*******************************************************************************/ - -/* Maximum files to be displayed in the MMI */ -#define A2DP_MAX_FILES 10 -//Number of files in content directory. - - -/*Function Declarations*/ -int mfw_btips_a2dpPopulateFiles(char **file_names, int max_files_count, - char* dir_name_p); - -void mfw_btips_a2dpUnpopulateFiles(char **file_names); - char *mfw_btips_a2dpGetExtension(char *src); - int mfw_btips_a2dpGetNumFiles(void); - char* mfw_btips_a2dpGetFileName(UBYTE index); - BtStatus mfw_btips_a2dpConnectStream(BD_ADDR bdAddr); - BtStatus mfw_btips_a2dpCloseStream(); - -#endif - -
--- a/src/ui/mfw/mfw_BtipsBmg.c Tue Jan 19 05:23:24 2021 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,1203 +0,0 @@ -/* ========================================================= -* Texas Instruments OMAP(TM) Platform Software -* (c) Copyright Texas Instruments, Incorporated. All Rights Reserved. -* -* Use of this software is controlled by the terms and conditions found -* in the license agreement under which this software has been supplied. -* ========================================================== */ -/* - $Project name: Basic Bluetooth MMI - $Project code: - $Module: Bluetooth BMG MFW - $File: Mfw_Btips.c - $Revision: 1.0 - $Author: Texas Instruments - $Date: 26/06/07 - -******************************************************************************** - - Description: - - This module provides the BTIPS BMG APPlication functionality. - -******************************************************************************** - $History: Mfw_Btips.c - - 26/06/07 Sasken original version - - $End - -*******************************************************************************/ - - - - -/******************************************************************************* - - Include files - -*******************************************************************************/ - -#define ENTITY_MFW -/* includes */ - -#include <string.h> -#ifdef FF_MMI_BTIPS_APP - -/* BTIPS Includes */ -#include "me.h" -#include "osapi.h" -#include "btl_common.h" -#include "bthal_btdrv.h" -#include "bthal_pm.h" -#include "bttypes.h" -#include "goep.h" -#include "bpp.h" -#include "Debug.h" - -/* BTL includes */ -#include "btl_bmg.h" - -#endif -#if defined (NEW_FRAME) - -#include "typedefs.h" -#include "vsi.h" -#include "pei.h" -#include "custom.h" -#include "gsm.h" -#include "prim.h" - -#else - -#include "STDDEFS.H" -#include "custom.h" -#include "gsm.h" -#include "vsi.h" - -#endif - -#include "mfw_mfw.h" -#include "mfw_win.h" -#include "mfw_icn.h" /* included for mfw_mnu.h */ -#include "mfw_mnu.h" -#include "mfw_tim.h" -#include "mfw_kbd.h" -#include "mfw_sat.h" /* included for MmiDummy.h, included for MmiMenu.h */ - -#include "Mfw_Btips.h" -#include "Mfw_BtipsBmg.h" - - -#ifdef FF_MMI_BTIPS_APP - -#define BTL_BMG_MAX_PIN_LEN 16 -#define BTL_BMG_SEARCH_ALL 0 -#define BTL_BMG_SEARCH_AUDIO_MAJOR 1 -#define PME_APP_NAME "Locosto Phone" - - - -//extern BtlA2dpContext *btlA2dpContext ; -//extern BtlFtpsContext *ftpsContext; -/* Internal functions prototypes */ -void btips_bmgCallback (const BtlBmgEvent *); -extern UBYTE g_device_name[BT_MAX_REM_DEV_NAME]; -extern BOOL g_Outgoing; - -static BtlBmgContext *mfwBtipsBmgContext; - -/*--------------------------------------------------------------------------- - * mfw_btips_bmgGetDeviceName - *--------------------------------------------------------------------------- - * - * Synopsis: Send PIN code. - * - * Return: TRUE if name is available. Else convert the BD_ADDR itself to a string. - * - */ -BOOL mfw_btips_bmgGetDeviceName(const BD_ADDR *bdAddr, U8 *name) -{ - BtStatus btStatus; - BtlBmgDeviceRecord record; - TRACE_FUNCTION("mfw_btips_bmgGetDeviceName"); - btStatus = BTL_BMG_FindDeviceRecord(mfwBtipsBmgContext, bdAddr, &record); - if(BT_STATUS_SUCCESS == btStatus) - { - - strcpy(name, record.name); - } - else - { - bdaddr_ntoa(bdAddr, name); - } - return TRUE; -} -//26-07-07 -/*--------------------------------------------------------------------------- - * mfw_btips_bmgSetDeviceRecord - *--------------------------------------------------------------------------- - * - * Synopsis: Send PIN code. - * - * Return: TRUE if name is available. Else convert the BD_ADDR itself to a string. - * - */ -BOOL mfw_btips_bmgSetDeviceNameInRecord(const BD_ADDR *bdAddr, UBYTE *name) -{ - BtStatus btStatus; - BtlBmgDeviceRecord record; - TRACE_FUNCTION("mfw_btips_bmgGetDeviceName"); - btStatus = BTL_BMG_FindDeviceRecord(mfwBtipsBmgContext, bdAddr, &record); - if(BT_STATUS_SUCCESS == btStatus) - { - - OS_MemCopy(record.name, name, BT_MAX_REM_DEV_NAME); - BTL_BMG_SetDeviceRecord(mfwBtipsBmgContext, &record); - - } - else - { - bdaddr_ntoa(bdAddr, name); - } - return TRUE; -} - - -BOOL mfw_btips_bmgGetDeviceState (const BD_ADDR *bdAddr, BtRemDevState *state) -{ - TRACE_FUNCTION("mfw_btips_bmgGetDeviceState"); - BTL_BMG_GetRemDevState (mfwBtipsBmgContext, bdAddr, state); - return TRUE; -} - -/*--------------------------------------------------------------------------- - * mfw_btips_bmgSendPin - *--------------------------------------------------------------------------- - * - * Synopsis: Send PIN code. - * - * Return: TRUE if send PIN code is successful, FALSE otherwise. - * - */ -BOOL mfw_btips_bmgSendPin (const BD_ADDR *bdAddr, - const U8 *pin, - const U8 len) -{ - BtStatus btStatus; - - btStatus = BTL_BMG_PinReply(mfwBtipsBmgContext, bdAddr, pin, len, BPT_SAVE_TRUSTED); - return mfw_btips_checkStatus(btStatus); -} - -/*--------------------------------------------------------------------------- - * mfw_btips_bmgSendHciCommand - *--------------------------------------------------------------------------- - * - * Synopsis: Send an HCI Command. - * - * Return: TRUE if command was sent successfully, FALSE otherwise. - * - */ -BOOL mfw_btips_bmgSendHciCommand (const U16 hciCommand, - const U8 parmsLen, - const U8 *parms, - const U8 event) -{ - BtStatus btStatus; - - TRACE_FUNCTION_P1("mfw_btips_bmgSendHciCommand %x", hciCommand); - btStatus = BTL_BMG_SendHciCommand(mfwBtipsBmgContext, hciCommand, parmsLen, parms, event); - return mfw_btips_checkStatus(btStatus); -} - - -BOOL mfw_btips_bmgBond(const BD_ADDR *bdAddr, - const U8 *pin, - const U8 len) -{ - BtStatus btStatus; - btStatus = BTL_BMG_Bond(mfwBtipsBmgContext, bdAddr, pin, len, BPT_SAVE_TRUSTED); - return mfw_btips_checkStatus(btStatus); -} - -BOOL mfw_btips_bmgCancelBond(const BD_ADDR *bdAddr) -{ - BtStatus btStatus; - TRACE_FUNCTION("mfw_btips_bmgCancelBond"); - btStatus = BTL_BMG_CancelBond(mfwBtipsBmgContext, bdAddr); - return mfw_btips_checkStatus(btStatus); - -} -BOOL mfw_btips_bmgGetCodMajorValue(U8* CODMajorStr, U32 *CODMajor) -{ - BOOL result; - #if 0 - LINE_PARSER_ToLower(CODMajorStr); - - *CODMajor = COD_MAJOR_MISCELLANEOUS; - result = TRUE; - - if (strcmp((const char*)CODMajorStr, "comp") == 0) - { - *CODMajor = COD_MAJOR_COMPUTER; - } - else if (strcmp((const char*)CODMajorStr, "phone") == 0) - { - *CODMajor = COD_MAJOR_PHONE; - } - else if (strcmp((const char*)CODMajorStr, "lan") == 0) - { - *CODMajor = COD_MAJOR_LAN_ACCESS_POINT; - } - else if (strcmp((const char*)CODMajorStr, "audio") == 0) - { - *CODMajor = COD_MAJOR_AUDIO; - } - else if (strcmp((const char*)CODMajorStr, "periph") == 0) - { - *CODMajor = COD_MAJOR_PERIPHERAL; - } - else if (strcmp((const char*)CODMajorStr, "imaging") == 0) - { - *CODMajor = COD_MAJOR_IMAGING; - } - else if (strcmp((const char*)CODMajorStr, "none") == 0) - { - *CODMajor = COD_MAJOR_MISCELLANEOUS; - } - else - { - result = FALSE; - } -#endif - return result; -} - -BOOL mfw_btips_bmgGetLAPValue(U8* lapStr, U32 *lap) -{ - BOOL result; - #if 0 - LINE_PARSER_ToLower(lapStr); - - result = TRUE; - - if (strcmp((const char*)lapStr, "giac") == 0) - { - *lap = BT_IAC_GIAC; - } - if (strcmp((const char*)lapStr, "liac") == 0) - { - *lap = BT_IAC_LIAC; - } - else - { - result = FALSE; - } -#endif - return result; -} - -/*--------------------------------------------------------------------------- - * mfw_btips_bmgSearch - *--------------------------------------------------------------------------- - * - * Synopsis: Starts search process. - * - * Return: TRUE if search process is successfull, FALSE otherwise. - * - */ -BOOL mfw_btips_bmgCancelSearch (void) -{ - BtStatus btStatus = BT_STATUS_FAILED; - - TRACE_FUNCTION ("mfw_btips_bmgCancelSearch()"); - - btStatus = BTL_BMG_CancelSearch(mfwBtipsBmgContext); - TRACE_FUNCTION_P1("MFW_BTIPS_BMG :BTL_BMG_CancelSearch returned btStatus: %s", pBT_Status(btStatus)); - - return mfw_btips_checkStatus(btStatus); -} - -/*--------------------------------------------------------------------------- - * mfw_btips_bmgSearch - *--------------------------------------------------------------------------- - * - * Synopsis: Starts search process. - * - * Return: TRUE if search process is successfull, FALSE otherwise. - * - */ -BOOL mfw_btips_bmgSearch (BOOL searchType) -{ - BtStatus status = BT_STATUS_FAILED; - BtlBmgCodFilter CODFilter; - BtlBmgCodFilter *CODFilterPtr = 0; -// U8 lapStr[11]; - BOOL performNameRequest = TRUE; - U8 maxResp = 0; -// U8 CODMajorStr[21]; -// U32 CODMajor; - - TRACE_FUNCTION_P1 ("mfw_btips_bmgSearch TYPE = %d", searchType); - - switch(searchType) - { - case BTIPS_GENERIC_DEVICE_SEARCH: - status = BTL_BMG_SearchByCod(mfwBtipsBmgContext, - BTL_BMG_SEARCH_REGULAR, - BT_IAC_GIAC, - BT_INQ_TIME_GAP100, - MAX_RESPONSES, - 0, - performNameRequest, - SDP_SERVICE_NONE); - break; - case BTIPS_A2DP_DEVICE_SEARCH: - CODFilter.codFilterMask = BTL_BMG_SEARCH_COD_FILTER_SERVICE_CLS|BTL_BMG_SEARCH_COD_FILTER_SERVICE_CLS; - CODFilter.serviceClass = COD_RENDERING|COD_AUDIO; - CODFilter.majorDeviceClass = COD_MAJOR_AUDIO; - status = BTL_BMG_SearchByCod(mfwBtipsBmgContext, - BTL_BMG_SEARCH_REGULAR, - BT_IAC_GIAC, - BT_INQ_TIME_GAP100, - MAX_RESPONSES, - &CODFilter, - performNameRequest, - SDP_SERVICE_NONE); - break; - - case BTIPS_OPP_DEVICE_SEARCH: - CODFilter.codFilterMask = BTL_BMG_SEARCH_COD_FILTER_SERVICE_CLS; - CODFilter.serviceClass = COD_OBJECT_TRANSFER; - status = BTL_BMG_SearchByCod(mfwBtipsBmgContext, - BTL_BMG_SEARCH_REGULAR, - BT_IAC_GIAC, - BT_INQ_TIME_GAP100, - MAX_RESPONSES, - &CODFilter, - performNameRequest, - SDP_SERVICE_NONE); - - break; - case BTIPS_HSHF_DEVICE_SEARCH: - CODFilter.codFilterMask = BTL_BMG_SEARCH_COD_FILTER_MAJOR_DEV_CLS; - CODFilter.majorDeviceClass = COD_MAJOR_AUDIO; - status = BTL_BMG_SearchByCod(mfwBtipsBmgContext, - BTL_BMG_SEARCH_REGULAR, - BT_IAC_GIAC, - BT_INQ_TIME_GAP100, - MAX_RESPONSES, - &CODFilter, - performNameRequest, - SDP_SERVICE_NONE); - break; - - } - - - mfw_BtipsReport(("MFW_BTIPS_BMG :BTL_BMG_SearchByCod returned status: %s", pBT_Status(status))); - return mfw_btips_checkStatus(status); -} - -/*--------------------------------------------------------------------------- - * mfw_btips_bmgGetLocalDeviceName - *--------------------------------------------------------------------------- - * - * Synopsis: Extract the currently set local name - * - * Return: - * - */ -BOOL mfw_btips_bmgGetLocalDeviceName(U8 *name) -{ - BtStatus btStatus; - U8 len = 0; - btStatus = BTL_BMG_GetLocalDeviceName(mfwBtipsBmgContext, name, &len); - return mfw_btips_checkStatus(btStatus); - -} - - -/*--------------------------------------------------------------------------- - * mfw_btips_bmgSetLocalDeviceName - *--------------------------------------------------------------------------- - * - * Synopsis: Set local name (Send a null terminated string) of our device. - * - * Return: TRUE if setting local name is successfull, FALSE otherwise. - * - */ -BOOL mfw_btips_bmgSetLocalDeviceName (U8 *name) -{ - U8 len = 0; - - BtStatus btStatus = BT_STATUS_FAILED; - len = (U8)(OS_StrLen((const char *)(name))); - name[len]=0; - btStatus = BTL_BMG_SetLocalDeviceName(mfwBtipsBmgContext, (U8 *)(name), len+1); - return mfw_btips_checkStatus(btStatus); -} - -/*--------------------------------------------------------------------------- - * mfw_btips_bmgSetPhoneVisibility - *--------------------------------------------------------------------------- - * - * Synopsis: Set Accessibility of the BT device. - * - * Return: . - * - */ -BOOL mfw_btips_bmgSetPhoneVisibility(BOOL status) -{ - BtStatus btStatus; - - BtAccessibleMode modeNC; - //BtAccessModeInfo infoNC; - BtAccessibleMode modeC; - //BtAccessModeInfo infoC; - - TRACE_FUNCTION("mfw_btips_bmgSetPhoneVisibility"); - - btStatus = BTL_BMG_GetAccessibleMode(mfwBtipsBmgContext, - &modeNC, - 0, - &modeC, - 0); - - TRACE_EVENT_P2("BTL_BMG_GetAccessibleMode %d, %d", modeNC, modeC); - - if(TRUE == status) - { - modeNC = BAM_GENERAL_ACCESSIBLE; - modeC = BAM_GENERAL_ACCESSIBLE; - } - else - { - modeNC = BAM_CONNECTABLE_ONLY; - modeC = BAM_CONNECTABLE_ONLY; - } - - btStatus = BTL_BMG_SetAccessibleMode(mfwBtipsBmgContext, - &modeNC, - 0, - &modeC, - 0); - - TRACE_EVENT_P2("BTL_BMG_SetAccessibleMode %d, %d", modeNC, modeC); - - return mfw_btips_checkStatus(btStatus); - -} - -/*--------------------------------------------------------------------------- - * mfw_btips_bmgSetPhoneVisibility - *--------------------------------------------------------------------------- - * - * Synopsis: Set Accessibility of the BT device. - * - * Return: . - * - */ -BOOL mfw_btips_bmgGetPhoneVisibility(void) -{ - BtStatus btStatus; - - BtAccessibleMode modeNC; - - BtAccessibleMode modeC; - - - TRACE_FUNCTION("mfw_btips_bmgSetPhoneVisibility"); - - btStatus = BTL_BMG_GetAccessibleMode(mfwBtipsBmgContext, - &modeNC, - 0, - &modeC, - 0); - - if(modeNC == BAM_GENERAL_ACCESSIBLE) - return TRUE; - - return FALSE; - -} -/*--------------------------------------------------------------------------- - * mfw_btips_bmgDeviceDelete - *--------------------------------------------------------------------------- - * - * Synopsis: Delete a record with the given "bdAddr" from the device database. - * - * Return: . - * - */ -BOOL mfw_btips_bmgDeviceDelete(const BD_ADDR *bdAddr) -{ - BtStatus btStatus; - - btStatus = BTL_BMG_DeleteDeviceRecord(mfwBtipsBmgContext, bdAddr); - mfw_BtipsReport(("BTL_BMG_GetNumberOfDeviceRecords() returned %s.\n", pBT_Status(btStatus))); - return mfw_btips_checkStatus(btStatus); -} - -/*--------------------------------------------------------------------------- - * mfw_btips_bmg_getPairedDevices - *--------------------------------------------------------------------------- - * - * Synopsis: Enumerate the device database. - * - * Return: . - * - */ -BOOL mfw_btips_bmg_getPairedDevices(Bmg_DeviceList *pairedDeviceList, U32 *count) -{ - BtStatus btStatus; - U32 index, numOfDevicesDB; - BtlBmgDeviceRecord deviceRecord; - *count = 0; - - TRACE_FUNCTION ("mfw_btips_bmg_getPairedDevices()"); - - /* Checks if the DB is empty or not*/ - btStatus= BTL_BMG_GetNumberOfDeviceRecords(mfwBtipsBmgContext, &numOfDevicesDB); - mfw_BtipsReport(("BTL_BMG_GetNumberOfDeviceRecords() returned %s.\n", pBT_Status(btStatus))); - if(numOfDevicesDB!=0) - { - /*Current limitation is to have a display of only BT_MAX_DEVICE_LIST devices*/ - for (index=0;index <numOfDevicesDB && index <= BT_MAX_DEVICE_LIST; index++) - { - btStatus=BTL_BMG_EnumDeviceRecords(mfwBtipsBmgContext, index, &deviceRecord); - mfw_BtipsReport(("BTL_BMG_EnumDeviceRecords() returned %s for %d: %s", pBT_Status(btStatus), index, deviceRecord.name)); - if (btStatus == BT_STATUS_SUCCESS) - { - OS_MemCopy((U8*)&pairedDeviceList[index].bdAddr, (U8*)&deviceRecord.bdAddr, sizeof(BD_ADDR)); - strcpy(pairedDeviceList[index].name, deviceRecord.name); - pairedDeviceList[index].myIndex = index; - } - } - *count = index; - return TRUE; - } - return mfw_btips_checkStatus(btStatus); -} - - - -/*--------------------------------------------------------------------------- - * mfw_btips_bmg_getConnectedDevices - *--------------------------------------------------------------------------- - * - * Synopsis: Enumerate the device database. - * - * Return: . - * - */ -BOOL mfw_btips_bmg_getConnectedDevices(Bmg_ConnectedDeviceList *ConnectedDeviceList, U32 *count) -{ - BtStatus btStatus; - U32 index;//, numOfDevicesDB; -// BtlBmgDeviceRecord deviceRecord; - U32 profile_count=0; - BD_ADDR bdAddr; - - char name[BT_MAX_REM_DEV_NAME]; - U32 ServiceID; - *count = 0; - - TRACE_FUNCTION ("mfw_btips_bmg_getConnectedDevices()"); - - for (index=0;index <BTIPS_MAX_PROFILE_COUNT; index++) - { - btStatus = mfw_btips_bmg_getConnectedDevicesForProfile(index,&bdAddr,name,&ServiceID); - if (btStatus) - { - memset(&ConnectedDeviceList[*count].name,0,BT_MAX_REM_DEV_NAME*sizeof(UBYTE)); - memset(&ConnectedDeviceList[*count].bdAddr,0,sizeof(BD_ADDR)); - OS_MemCopy((U8*)&ConnectedDeviceList[*count].bdAddr,(U8*)&bdAddr, sizeof(BD_ADDR)); - strcpy(ConnectedDeviceList[*count].name, name); - ConnectedDeviceList[*count].myIndex = *count; - ConnectedDeviceList[*count].ServiceId= ServiceID; - ServiceID = 0; - (*count)++; - } - - } - - return mfw_btips_checkStatus(btStatus); -} - -U32 mfw_btips_bmg_getConnectedDevicesCount(void) -{ - BtStatus btStatus; - U32 index, count=0; - BD_ADDR bdAddr; - - char name[BT_MAX_REM_DEV_NAME]; - U32 ServiceID; - - - TRACE_FUNCTION ("mfw_btips_bmg_getConnectedDevicesCount()"); - - for (index=0;index <BTIPS_MAX_PROFILE_COUNT; index++) - { - btStatus = mfw_btips_bmg_getConnectedDevicesForProfile(index,&bdAddr,name,&ServiceID); - - if (btStatus) - { - count++; - } - } - return count; -} - -BOOL mfw_btips_bmg_getConnectedDevicesForProfile(U32 profile_num, BD_ADDR *bdAddr, U8 *name, U32 *ServiceID) -{ - - - BOOL status; - - switch(profile_num) - { - - case BTIPS_SDP_SERVICE_A2DP: - status = mfw_btips_a2dpGetConnectedDevice(bdAddr, name); - if(TRUE ==status) - *ServiceID = BTIPS_SDP_SERVICE_A2DP; - TRACE_EVENT_P1("mfw_btips_bmg_getConnectedDevicesForProfile A2DP name =%s ",name); - break; - - - case BTIPS_SDP_SERVICE_VG: - status=mfw_btips_vgGetConnectedDevice(bdAddr, name); - if(TRUE ==status) - *ServiceID = BTIPS_SDP_SERVICE_VG; - - TRACE_EVENT_P1("mfw_btips_bmg_getConnectedDevicesForProfile OPPC name =%s ",name); - break; - - - - case BTIPS_SDP_SERVICE_OPPC: - status=mfw_btips_oppcGetConnectedDevice(bdAddr, name); - if(TRUE ==status) - *ServiceID = BTIPS_SDP_SERVICE_OPPC; - - TRACE_EVENT_P1("mfw_btips_bmg_getConnectedDevicesForProfile OPPC name =%s ",name); - break; - - case BTIPS_SDP_SERVICE_OPPS: - - status=mfw_btips_oppsGetConnectedDevice(bdAddr, name); - if(TRUE ==status) - *ServiceID = BTIPS_SDP_SERVICE_OPPS; - - TRACE_EVENT_P1("mfw_btips_bmg_getConnectedDevicesForProfile OPPS name =%s ",name); - break; - - - case BTIPS_SDP_SERVICE_FTPS: - - status=mfw_btips_ftpsGetConnectedDevice(bdAddr, name); - if(TRUE ==status) - *ServiceID = BTIPS_SDP_SERVICE_FTPS; - - TRACE_EVENT_P1("mfw_btips_bmg_getConnectedDevicesForProfile FTPS name =%s ",name); - break; - - - default: - break; - } - return status; -} - -#if 0 - -/*--------------------------------------------------------------------------- - * APP_BMG_SetSecurityMode - *--------------------------------------------------------------------------- - * - * Synopsis: Set the security level of our device. - * - * Return: TRUE if setting the security level is successfull, FALSE otherwise. - * - */ -BOOL APP_BMG_SetSecurityMode (void) -{ - BtStatus status = BT_STATUS_FAILED; - U8 SecLevel; - - LINE_PARSER_GetNextU8(&SecLevel, FALSE); - status = BTL_BMG_SetSecurityMode(mfwBtipsBmgContext, (SecLevel+1)); - mfw_BtipsReport(("MFW_BTIPS_BMG :BTL_BMG_SetSecurityMode returned status: %s", pBT_Status(status))); - if (status == BT_STATUS_SUCCESS) - { - return TRUE; - } - return FALSE; -} - - -/*--------------------------------------------------------------------------- - * APP_BMG_SetSecurityMode - *--------------------------------------------------------------------------- - * - * Synopsis: Get the security level of our device. - * - * Return: TRUE if getting the security level is successfull, FALSE otherwise. - * - */ -BOOL APP_BMG_GetSecurityMode (void) -{ - BtStatus status = BT_STATUS_FAILED; - BtSecurityMode CurrentSecLevel; - - status = BTL_BMG_GetSecurityMode(mfwBtipsBmgContext, &CurrentSecLevel); - mfw_BtipsReport(("MFW_BTIPS_BMG :APP_BMG_GetSecurityMode returned status: %s", pBT_Status(status))); - if (status == BT_STATUS_SUCCESS) - { - mfw_BtipsReport(("MFW_BTIPS_BMG : Current security mode is: %d", (CurrentSecLevel-1))); - return TRUE; - } - return FALSE; -} - -#endif - -/*--------------------------------------------------------------------------- - * APP_BMG_AuthorizeDeviceReply - *--------------------------------------------------------------------------- - * - * Synopsis: Reply for authorization request of another device. - * - * Return: TRUE if Autorization reply is successfull, FALSE otherwise. - * - */ -BOOL mfw_btips_bmgAuthorizeDeviceReply (BOOL auth, BD_ADDR *BdAddr) -{ - BtStatus btStatus = BT_STATUS_FAILED; - U8 AuthorizationType;//, BD_array[BDADDR_NTOA_SIZE]; - AuthorizationType = auth? BTL_BMG_AUTHORIZED_NOT_TRUSTED: BTL_BMG_NOT_AUTHORIZED; -// btStatus = BTL_BMG_AuthorizeDeviceReply(mfwBtipsBmgContext, &BdAddr, (BtlBmgAuthorizationType) (AuthorizationType)); - if (btStatus == BT_STATUS_SUCCESS) - { - return TRUE; - } - return FALSE; -} - - -/*--------------------------------------------------------------------------- - * mfw_btips_bmgInit - *--------------------------------------------------------------------------- - * - * Synopsis: BMG application initialization. - * - * Return: NONE. - * - */ -void mfw_btips_bmgInit (void) -{ - BtStatus btStatus = BT_STATUS_FAILED; - - btStatus = BTL_BMG_Create(0, btips_bmgCallback, &mfwBtipsBmgContext); - Assert(btStatus == BT_STATUS_SUCCESS); - - btStatus = BTL_BMG_SetEventForwardingMode(mfwBtipsBmgContext, BTL_BMG_EVENT_FORWARDING_ALL_EVENTS); - Assert(btStatus == BT_STATUS_SUCCESS); - -#if 0 - btStatus = BTL_BMG_SetClassOfDevice(mfwBtipsBmgContext, (COD_MAJOR_PHONE | COD_MINOR_PHONE_CELLULAR)); - Assert(btStatus == BT_STATUS_SUCCESS); -#endif - - mfw_BtipsReport(("BMGA_Init() complete.\n")); -} - -/*--------------------------------------------------------------------------- - * mfw_btips_bmgDeinit - *--------------------------------------------------------------------------- - * - * Synopsis: BMG application deinitialization. - * - * Return: NONE. - * - */ -void mfw_btips_bmgDeinit(void) -{ - BtStatus btStatus = BT_STATUS_FAILED; - - btStatus = BTL_BMG_Destroy(&mfwBtipsBmgContext); - Assert(btStatus == BT_STATUS_SUCCESS); - - mfw_BtipsReport(("BMGA_Deinit() complete.\n")); -} - -/*--------------------------------------------------------------------------- - * btips_bmgCallback - *--------------------------------------------------------------------------- - * - * Synopsis: Callback function to handle BMG profile events invoked in BTS context. - * - * Return: NONE. - * - */ -void btips_bmgCallback (const BtlBmgEvent *bmgEvent) -{ - const BtEvent *event = bmgEvent->event; - BtStatus btStatus = BT_STATUS_FAILED; - char bdAddr[BDADDR_NTOA_SIZE]; - char *name; - T_BTIPS_MMI_IND btips_mmi_ind; - - TRACE_FUNCTION_P1("btips_bmgCallback: %s", pME_Event(event->eType)); - btips_mmi_ind.mfwBtipsEventType = MFW_BTIPS_BMG_EVENT; - btips_mmi_ind.data.bmgBtEvent.eventType = event->eType; - btips_mmi_ind.data.bmgBtEvent.errCode =event->errCode; - - switch (event->eType) - { - - case BTEVENT_LINK_CONNECT_IND: - btStatus = BTL_BMG_GetRemoteDeviceName(mfwBtipsBmgContext, &event->p.remDev->bdAddr); - break; - case BTEVENT_HCI_INITIALIZED: - btStatus = BTL_BMG_SetLocalDeviceName(mfwBtipsBmgContext, (U8 *)PME_APP_NAME, (U8)(sizeof(PME_APP_NAME))); - mfw_BtipsReport(("MFW_BTIPS_BMG :BTL_BMG_SetLocalDeviceName returned status: %s", pBT_Status(btStatus))); - - 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))); - mfw_BtipsReport(("MFW_BTIPS_BMG :BTL_BMG_SetDefaultLinkPolicy returned status: %s", pBT_Status(btStatus))); - - btStatus = BTL_BMG_SetSecurityMode(mfwBtipsBmgContext, BSM_SEC_LEVEL_2); - mfw_BtipsReport(("MFW_BTIPS_BMG :BTL_BMG_SetSecurityMode returned status: %s", pBT_Status(btStatus))); - - btipsNotifyMFW(btips_mmi_ind); - break; - - case BTEVENT_HCI_DEINITIALIZED: - btipsNotifyMFW(btips_mmi_ind); - break; - - - case BTEVENT_HCI_FAILED: - btipsNotifyMFW(&btips_mmi_ind); - break; - - case BTEVENT_PAIRING_COMPLETE: - TRACE_EVENT_P2("Pairing with %s complete. status %s.\n", bdaddr_ntoa( &event->p.remDev->bdAddr, bdAddr), pHC_Status(event->errCode)); - OS_MemCopy((U8*)&btips_mmi_ind.data.bmgBtEvent.bdAddr, (U8*)&event->p.remDev->bdAddr, sizeof(BD_ADDR)); - btipsNotifyMFW(&btips_mmi_ind); - break; - - case BTEVENT_BOND_RESULT: - if (event->errCode != BEC_NO_ERROR) - { - TRACE_EVENT_P2("Bond attempt to %s failed. Reason %s.", bdaddr_ntoa(&event->p.bdAddr, bdAddr), pHC_Status(event->errCode)); - } - else - { - TRACE_EVENT_P1("Bond to %s ended successfully", bdaddr_ntoa(&event->p.bdAddr, bdAddr)); - } - - OS_MemCopy((U8*)&btips_mmi_ind.data.bmgBtEvent.bdAddr, (U8*)&event->p.bdAddr, sizeof(BD_ADDR)); - - btipsNotifyMFW(&btips_mmi_ind); - break; - - case BTEVENT_BOND_CANCELLED: - btipsNotifyMFW(&btips_mmi_ind); - break; - - case BTEVENT_PIN_REQ: - if (event->errCode == BT_STATUS_SUCCESS) - { - T_BTIPS_MMI_IND btipsMmiInd = {0}; - BtlBmgDeviceRecord record; - - - btStatus=BTL_BMG_GetRemoteDeviceName(mfwBtipsBmgContext, &event->p.remDev->bdAddr); - TRACE_EVENT_P1("BTEVENT_PIN_REQ btStatus %d",btStatus); - /* Prompt the user for a PIN code */ - mfw_BtipsReport(("Please Enter PIN Code for %s", bdaddr_ntoa(&event->p.remDev->bdAddr, bdAddr))); - } - else - { - /* Cancel the PIN code request */ - mfw_BtipsReport ((("BMG: Pin code couldn't be displayed because of an error"))); - } - OS_MemCopy((U8*)&btips_mmi_ind.data.bmgBtEvent.bdAddr, (U8*)&event->p.remDev->bdAddr, sizeof(BD_ADDR)); - btipsNotifyMFW(&btips_mmi_ind); - break; - - case BTEVENT_AUTHORIZATION_REQ: - TRACE_EVENT_P1("Authorization request received from %s",bdaddr_ntoa(&event->p.remDev->bdAddr, bdAddr)); - break; - - case BTEVENT_INQUIRY_RESULT: - mfw_BtipsReport(("Inquiry result arrived, BD address: %s", bdaddr_ntoa(&event->p.inqResult.bdAddr, bdAddr))); - break; - - case BTEVENT_SEARCH_COMPLETE: - case BTEVENT_SEARCH_CANCELLED: - TRACE_EVENT_P1("Search %s ", ((event->eType == BTEVENT_SEARCH_COMPLETE) ? ("completed") : ("cancelled"))); - btipsNotifyMFW(&btips_mmi_ind); - break; - - case BTEVENT_INQUIRY_COMPLETE: - case BTEVENT_INQUIRY_CANCELED: - TRACE_EVENT_P1("Inquiry %s ", ((event->eType == BTEVENT_INQUIRY_COMPLETE) ? ("completed") : ("cancelled"))); - //btipsNotifyMFW(&btips_mmi_ind); - break; - - case BTEVENT_NAME_RESULT: - - if (event->errCode == BEC_NO_ERROR) - { - OS_MemCopy((U8*)&btips_mmi_ind.data.bmgBtEvent.bdAddr, (U8*)&event->p.meToken->p.name.bdAddr, sizeof(BD_ADDR)); - if (event->p.meToken->p.name.io.out.len == 0) - { - name = "Unknown"; - strcpy(btips_mmi_ind.data.bmgBtEvent.p.deviceName, bdaddr_ntoa(&event->p.meToken->p.name.bdAddr, bdAddr)); - } - else - { - name = (char *)(event->p.meToken->p.name.io.out.name); - if (name) - { - } - else - { - TRACE_EVENT("BTEVENT_NAME_RESULT Name = NULL"); - } - strcpy(btips_mmi_ind.data.bmgBtEvent.p.deviceName, name); - } - TRACE_EVENT_P2("Received name %s for device %s", name, bdaddr_ntoa(&event->p.meToken->p.name.bdAddr, bdAddr)); - btipsNotifyMFW(&btips_mmi_ind); - } - else - { - /* Record that the name request failed. Next time we'll skip it. */ - mfw_BtipsReport(("BMG: Name request for %s failed, status %s.\n", - bdaddr_ntoa(&event->p.meToken->p.name.bdAddr, bdAddr), - pHC_Status(event->errCode))); - } - break; - case BTEVENT_DISCOVER_SERVICES_RESULT : - btips_mmi_ind.data.bmgBtEvent.p.discoveredServicesMask = event->p.discoveredServices.discoveredServicesMask; - bdaddr_ntoa(&event->p.discoveredServices.bdAddr, bdAddr); - OS_MemCopy((U8*)&btips_mmi_ind.data.bmgBtEvent.bdAddr , (U8*)&event->p.discoveredServices.bdAddr, sizeof(BD_ADDR)); - btips_mmi_ind.data.bmgBtEvent.p.discoveredServicesMask = event->p.discoveredServices.discoveredServicesMask; - TRACE_EVENT_P2("Discover Services %x for %s",event->p.discoveredServices.discoveredServicesMask, bdAddr); - btipsNotifyMFW(&btips_mmi_ind); - break; - default: - break; - } -} - - -/************************************************************************ - BMG in ACI Context Module Start -************************************************************************/ -void mfw_btips_bmgCallback( T_BTIPS_MMI_IND * para) -{ - MfwBtBmgEvent bmgBtEvent = para->data.bmgBtEvent; - - TRACE_FUNCTION_P1("mfw_btips_bmgCallback - %s", pME_Event(bmgBtEvent.eventType)); - - switch(bmgBtEvent.eventType) - { - case BTEVENT_HCI_DEINITIALIZED: - break; - - case BTEVENT_HCI_INITIALIZED: - mfw_btips_bmgSetPhoneVisibility(TRUE); - break; - - case BTEVENT_HCI_FAILED: - mfw_btips_signal(E_BTIPS_POWERON_FAILURE, NULL); - break; - - case BTEVENT_PAIRING_COMPLETE: - mfw_btips_signal(E_BTIPS_BMG_PAIRING_COMPLETE, para); - break; - - case BTEVENT_BOND_RESULT: - mfw_btips_signal(E_BTIPS_BMG_BOND_COMPLETE, para); - break; - - case BTEVENT_BOND_CANCELLED: - mfw_btips_signal(E_BTIPS_BMG_BOND_CANCELLED, NULL); - break; - - case BTEVENT_PIN_REQ: - if (bmgBtEvent.errCode == BT_STATUS_SUCCESS) - { - mfw_btips_signal(E_BTIPS_INCOMING_PIN_REQ, para); - } - break; - - case BTEVENT_NAME_RESULT: - - TRACE_EVENT_P1("Received name for device %s", bmgBtEvent.p.deviceName); - mfw_btips_signal(E_BTIPS_BMG_NAME_RESULT, para); - break; - - case BTEVENT_SEARCH_COMPLETE: - mfw_btips_signal(E_BTIPS_BMG_SEARCH_COMPLETE, NULL); - break; - case BTEVENT_SEARCH_CANCELLED: - mfw_btips_signal(E_BTIPS_BMG_SEARCH_CANCELLED, NULL); - break; - - case BTEVENT_INQUIRY_COMPLETE: - break; - - case BTEVENT_INQUIRY_CANCELED: - break; - case BTEVENT_DISCOVER_SERVICES_RESULT: - TRACE_FUNCTION("mfw_btips_bmgCallback BTEVENT_DISCOVER_SERVICES_RESULT"); - mfw_btips_signal(E_BTIPS_BMG_DEVICE_SERVICES, para); - break; - - default: - break; - } -} -BOOL mfw_btips_bmgDeviceSetConnectPermissionAllow(const BD_ADDR *bdAddr,BOOL permission ) -{ - - BtlBmgDeviceRecord record; - - BtStatus btStatus = BT_STATUS_FAILED; - - TRACE_FUNCTION("mfw_btips_bmgDeviceSetConnectPermissionAllow()"); - - btStatus = BTL_BMG_FindDeviceRecord(mfwBtipsBmgContext, bdAddr, &record); - TRACE_EVENT_P1("BTL_BMG_FindDeviceRecord in mfw_btips_bmgDeviceSetConnectPermissionAllow returned - %d", btStatus); - - if(BT_STATUS_SUCCESS == btStatus) - { - record.trusted = TRUE; - 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 - - btStatus = BTL_BMG_SetDeviceRecord(mfwBtipsBmgContext, &record); - - TRACE_EVENT_P1("BTL_BMG_SetDeviceRecord in mfw_btips_bmgDeviceSetConnectPermissionAllow returned - %d", btStatus); - } - - return mfw_btips_checkStatus(btStatus); - - - -} - -BOOL mfw_btips_bmgDeviceSetConnectPermissionAsk(const BD_ADDR *bdAddr,BOOL permission) -{ - - BtlBmgDeviceRecord record; - - BtStatus btStatus = BT_STATUS_FAILED; - - TRACE_FUNCTION("mfw_btips_bmgDeviceSetConnectPermissionAsk()"); - - - btStatus = BTL_BMG_FindDeviceRecord(mfwBtipsBmgContext, bdAddr,&record); - - TRACE_EVENT_P1("BTL_BMG_FindDeviceRecord in mfw_btips_bmgDeviceSetConnectPermissionAsk returned - %d", btStatus); - - - if(BT_STATUS_SUCCESS == btStatus) - { - record.trusted = FALSE; - - record.trustedPerService= 0; //Not sure if this is the way to set the bits in the mask field - - btStatus = BTL_BMG_SetDeviceRecord(mfwBtipsBmgContext, &record); - - TRACE_EVENT_P1("BTL_BMG_SetDeviceRecord in mfw_btips_bmgDeviceSetConnectPermissionAsk returned - %d", btStatus); - - } - - return mfw_btips_checkStatus(btStatus); - - -} - - -BOOL mfw_btips_bmgSetRemoteDeviceName( const BD_ADDR *bdAddr, U8 *name) -{ - - BtStatus btStatus = BT_STATUS_FAILED; - - BtlBmgDeviceRecord record; - - TRACE_FUNCTION("mfw_btips_bmgSetRemoteDeviceName()"); - - btStatus = BTL_BMG_FindDeviceRecord(mfwBtipsBmgContext, bdAddr,&record); - - if(BT_STATUS_SUCCESS == btStatus) - { - strcpy(record.name, name); - btStatus = BTL_BMG_SetDeviceRecord(mfwBtipsBmgContext, &record); - } - return mfw_btips_checkStatus(btStatus); -} - - //vamsee -/* Get the Services Supported by the Remote Device*/ -U32 mfw_btips_bmgDeviceGetServices(const BD_ADDR *bdAddr) -{ - - BtlBmgDeviceRecord record; - BtStatus btStatus = BT_STATUS_FAILED; - TRACE_FUNCTION("mfw_btips_bmgDeviceGetServices()"); - btStatus = BTL_BMG_FindDeviceRecord(mfwBtipsBmgContext, bdAddr, &record); - TRACE_EVENT_P1("Record Services %x",record.services); - return record.services; -} - -BOOL mfw_btips_bmg_DiscoverServices(const BD_ADDR *bdAddr, SdpServicesMask sdpServicesMask) -{ - BtStatus btStatus; - - TRACE_EVENT_P1("mfw_btips_bmg_DiscoverServices Discover %x",sdpServicesMask); - - btStatus = BTL_BMG_DiscoverServices(mfwBtipsBmgContext, bdAddr, sdpServicesMask); - return mfw_btips_checkStatus(btStatus); -} - -BOOL mfw_btips_bmgSetDeviceRecord( const BD_ADDR *bdAddr, U32 sdpSericesMask) -{ - - - BtStatus btStatus = BT_STATUS_FAILED; - - BtlBmgDeviceRecord record; - - TRACE_FUNCTION("mfw_btips_bmgSetDeviceRecord()"); - - btStatus = BTL_BMG_FindDeviceRecord(mfwBtipsBmgContext, bdAddr,&record); - - if(BT_STATUS_SUCCESS == btStatus) - { - TRACE_EVENT_P1("mfw_btips_bmgSetDeviceRecord() %x",sdpSericesMask); - - record.services = sdpSericesMask; - - TRACE_EVENT_P1("Record Services %x",record.services); - - btStatus = BTL_BMG_SetDeviceRecord(mfwBtipsBmgContext, &record); - } - return mfw_btips_checkStatus(btStatus); -} - -/************************************************************************ - BMG in ACI Context Module End -************************************************************************/ - - - - -#endif -
--- a/src/ui/mfw/mfw_BtipsBmg.h Tue Jan 19 05:23:24 2021 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,105 +0,0 @@ -#ifndef DEF_MFW_BTIPS_BMG -#define DEF_MFW_BTIPS_BMG -/* ========================================================= -* Texas Instruments OMAP(TM) Platform Software -* (c) Copyright Texas Instruments, Incorporated. All Rights Reserved. -* -* Use of this software is controlled by the terms and conditions found -* in the license agreement under which this software has been supplied. -* ========================================================== */ -/* - $Project name: Basic Bluetooth MMI - $Project code: - $Module: Bluetooth BMG MFW - $File: Mfw_BtipsBmg.h - $Revision: 1.0 - $Author: Texas Instruments - $Date: 26/06/07 - -******************************************************************************** - - Description: - - This module provides the BTIPS BMG APPlication functionality. - -******************************************************************************** - $History: Mfw_BtipsBmg.h - - 26/06/07 Sasken original version - - $End - -*******************************************************************************/ - - -#define BT_MAX_DEVICE_LIST 10 -#define MAX_RESPONSES 10 //limit the number of Inquiry responses to 10 - -#include <me.h> -#include <Bttypes.h> - -typedef struct _Bmg_DeviceList -{ - U8 myIndex; - BD_ADDR bdAddr; - UBYTE name[BT_MAX_REM_DEV_NAME]; -}Bmg_DeviceList; - -typedef struct _Bmg_ConnectedDeviceList -{ - U8 myIndex; - BD_ADDR bdAddr; - UBYTE name[BT_MAX_REM_DEV_NAME]; - U32 ServiceId; -}Bmg_ConnectedDeviceList ; - -typedef enum { - BTIPS_GENERIC_DEVICE_SEARCH=0, - BTIPS_A2DP_DEVICE_SEARCH, - BTIPS_OPP_DEVICE_SEARCH, - BTIPS_HSHF_DEVICE_SEARCH, - BTIPS_DEVICE_SERVICES_SEARCH, - BTIPS_CONNECTED_DEVICES_SEARCH -}BTIPS_SEARCH_TYPES; - -typedef enum{ - - BTIPS_SDP_SERVICE_FTPS=0, - BTIPS_SDP_SERVICE_OPPC, - BTIPS_SDP_SERVICE_OPPS, - BTIPS_SDP_SERVICE_VG, - BTIPS_SDP_SERVICE_A2DP, - BTIPS_MAX_PROFILE_COUNT, - -}BTIPS_SERVICE_TYPES; - -BOOL mfw_btips_bmgDeviceDelete(const BD_ADDR *bdAddr); -BOOL mfw_btips_bmgSetPhoneVisibility(BOOL status); -BOOL mfw_btips_bmgGetPhoneVisibility(void); -BOOL mfw_btips_bmgSendPin (const BD_ADDR *bdAddr, - const U8 *pin, - const U8 len); -BOOL mfw_btips_bmgBond(const BD_ADDR *bdAddr, - const U8 *pin, - const U8 len); - -BOOL mfw_btips_bmgSetLocalDeviceName (U8 *name); -BOOL mfw_btips_bmgGetLocalDeviceName(U8 *name); -BOOL mfw_btips_bmgSetRemoteDeviceName( const BD_ADDR *bdAddr, U8 *name); -BOOL mfw_btips_bmgSetDeviceRecord( const BD_ADDR *bdAddr, U32 sdpSericesMask); -BOOL mfw_btips_bmg_getPairedDevices(Bmg_DeviceList *pairedDeviceList, U32 *count); -BOOL mfw_btips_bmg_getConnectedDevices(Bmg_ConnectedDeviceList *pairedDeviceList, U32 *count); -U32 mfw_btips_bmg_getConnectedDevicesCount(void); -BOOL mfw_btips_bmg_getConnectedDevicesForProfile(U32 profile_num, BD_ADDR *bdAddr,U8 *name, U32 *ServiceId); -BOOL mfw_btips_bmgDeviceSetConnectPermissionAllow(const BD_ADDR *bdAddr,BOOL permission); -BOOL mfw_btips_bmgDeviceSetConnectPermissionAsk(const BD_ADDR *bdAddr,BOOL permission); -U32 mfw_btips_bmgDeviceGetServices(const BD_ADDR *bdAddr); -BOOL mfw_btips_ftpsGetConnectedDevice (BD_ADDR *bdAddr, U8 *name); -BOOL mfw_btips_bmgGetDeviceState (const BD_ADDR *bdAddr, BtRemDevState *state); -BOOL mfw_btips_bmgSetDeviceNameInRecord(const BD_ADDR *bdAddr, UBYTE *name); -BOOL mfw_btips_bmg_DiscoverServices(const BD_ADDR *bdAddr, SdpServicesMask sdpServicesMask); - - -#endif - -
--- a/src/ui/mfw/mfw_BtipsFtps.c Tue Jan 19 05:23:24 2021 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,539 +0,0 @@ -/* ========================================================= -* Texas Instruments OMAP(TM) Platform Software -* (c) Copyright Texas Instruments, Incorporated. All Rights Reserved. -* -* Use of this software is controlled by the terms and conditions found -* in the license agreement under which this software has been supplied. -* ========================================================== */ -/* - $Project name: Basic Bluetooth MMI - $Project code: - $Module: Bluetooth BMG MFW - $File: Mfw_Btips.c - $Revision: 1.0 - $Author: Texas Instruments - $Date: 26/06/07 - -******************************************************************************** - - Description: - - This module provides the BTIPS FTP Server APPlication functionality. - -******************************************************************************** - $History: Mfw_BtipsFtps.c - - 26/06/07 Sasken original version - - $End - -*******************************************************************************/ - - - - -/******************************************************************************* - - Include files - -*******************************************************************************/ - -#define ENTITY_MFW -/* includes */ - -#include <string.h> - -#if defined (NEW_FRAME) - -#include "typedefs.h" -#include "vsi.h" -#include "pei.h" -#include "custom.h" -#include "gsm.h" -#include "prim.h" - -#else - -#include "STDDEFS.H" -#include "custom.h" -#include "gsm.h" -#include "vsi.h" - -#endif - -#ifdef FF_MMI_BTIPS_APP - -#include "osapi.h" - -/* GPF Includes */ -#include "typedefs.h" -#include "vsi.h" -//#include "../p_btt.h" - -#if BT_STACK == XA_ENABLED -#include <me.h> -#include <bttypes.h> -#include <sec.h> -#endif - -#include "btl_common.h" -#include "btl_bmg.h" -#include "debug.h" - -#include "goep.h" -#include "ftp.h" - -/* BTL inclides */ -#include "btl_ftps.h" - -#include "bthal_fs.h" - -#include "mfw_mfw.h" -#include "mfw_win.h" -#include "mfw_icn.h" /* included for mfw_mnu.h */ -#include "mfw_mnu.h" -#include "mfw_tim.h" -#include "mfw_kbd.h" -#include "mfw_sat.h" /* included for MmiDummy.h, included for MmiMenu.h */ - -#include "Mfw_Btips.h" -#include "Mfw_BtipsBmg.h" - -/* Internal Global variables for FTP Server*/ -static BtlFtpsContext *ftpsContext = 0; -static BtSecurityLevel securityLevel = BSL_NO_SECURITY; -static BD_ADDR bdAddr; - - -/**************************************************************************** - * - * Internal Function prototypes - * - ***************************************************************************/ -static void btips_ftpsCallBack(const BtlFtpsEvent *event); -#ifdef WIN32 -const char *pBT_Status(I8 Status); -#else -static const char *pBT_Status(I8 Status); -#endif -static const char *GoepOpName(GoepOperation Op); - - -/**************************************************************************** - * - * RAM data - * - ****************************************************************************/ - -#if OBEX_AUTHENTICATION == XA_ENABLED -static char realm[20]; /* OBEX realm */ -static char password[20]; /* OBEX Authentication password */ -static char userId[20]; /* OBEX Authentication userId */ -#endif /* OBEX_AUTHENTICATION == XA_ENABLED */ - -static char rootPath[80]; -static BtlFtpsObjectRequestMask objectRequestMask; -static BOOL accept; -char BTStr[20]; -/*--------------------------------------------------------------------------- - * mfw_btips_ftpsInit - *--------------------------------------------------------------------------- - * - * Synopsis: Create and Enable the FTP Server . - * - * Return: void - * - */ - -void mfw_btips_ftpsInit (void) -{ - BtStatus status; - - OS_StrCpy(realm, "MyRealm"); - OS_StrCpy(password, "MyPassword"); - OS_StrCpy(userId, "MyUserId"); - - OS_StrCpy(rootPath, "/"); - - status = BTL_FTPS_Create ((BtlAppHandle *) 0, btips_ftpsCallBack, - &securityLevel, &ftpsContext); - - Report(("BTL_FTPS_Create() returned %s.",pBT_Status(status))); - - OS_StrCpy (rootPath, BT_DEMO_FOLDER_PATH); - - status = BTL_FTPS_Enable(ftpsContext, 0, rootPath); - - Report(("BTL_FTPS_Enable() returned %s.",pBT_Status(status))); - - status = BTL_FTPS_ConfigObjectRequest ( ftpsContext, - BTL_FTPS_OBJECT_REQUEST_PUSH | - BTL_FTPS_OBJECT_REQUEST_PULL | - BTL_FTPS_OBJECT_REQUEST_DELETE ); - - Report(("BTL_FTPS_ConfigObjectRequest() returned %s.",pBT_Status(status))); - -} - -/*--------------------------------------------------------------------------- - * mfw_btips_ftpsAbort - *--------------------------------------------------------------------------- - * - * Synopsis: Requests the current operation be aborted. - * - * Return: void - * - */ -void mfw_btips_ftpsAbort(void) -{ - BtStatus status; - - status = BTL_FTPS_Abort(ftpsContext, OBRC_CONFLICT); - - Report(("BTL_FTPS_Abort() returned %s.",pBT_Status(status))); - -} - -/*--------------------------------------------------------------------------- - * mfw_btips_ftpsAcceptObjectRequest - *--------------------------------------------------------------------------- - * - * Synopsis: This function must be called after receiving object request from the client, - * in order to accept or reject the request. - * - * Return: BOOL - * - */ -void mfw_btips_ftpsAcceptObjectRequest (BOOL flag) -{ - BtStatus status; - - status = BTL_FTPS_AcceptObjectRequest (ftpsContext, flag); - - Report(("BTL_FTPS_AcceptObjectRequest() returned %s.", pBT_Status(status))); -} - -/*--------------------------------------------------------------------------- - * mfw_btips_ftpsSetSecurityLevel - *--------------------------------------------------------------------------- - * - * Synopsis: Sets security level for the given FTPS context. - * - * Return: TRUE if security level is ON, else FALSE. - * - */ -BOOL mfw_btips_ftpsSetSecurityLevel (void) -{ - BtStatus status; - BtSecurityLevel newSecurityLevel = securityLevel; - - status = BTL_FTPS_SetSecurityLevel (ftpsContext, &newSecurityLevel); - - Report(("BTL_FTPS_SetSecurityLevel() returned %s.", pBT_Status(status))); - - return TRUE; -} - - -#if OBEX_AUTHENTICATION == XA_ENABLED -/*--------------------------------------------------------------------------- - * mfw_btips_ftpsObexAuthenticationResponse - *--------------------------------------------------------------------------- - * - * Synopsis: Responde to OBEX auth. - * - * Return: void - * - */ -BOOL mfw_btips_ftpsObexAuthenticationResponse (void) -{ - BtStatus status; - - status = BTL_FTPS_ObexAuthenticationResponse (ftpsContext, userId, password); - - Report(("BTL_FTPS_ObexAuthenticationResponse() returned %s.",pBT_Status(status))); - - return ((status == BT_STATUS_SUCCESS) ? (TRUE) : (FALSE)); -} -#endif /* OBEX_AUTHENTICATION == XA_ENABLED */ - -BOOL mfw_btips_ftpsGetConnectedDevice (BD_ADDR *bdAddr, U8 *name) -{ - BtStatus status; - - status = BTL_FTPS_GetConnectedDevice (ftpsContext, bdAddr); - - if (status == BT_STATUS_SUCCESS) - { - mfw_btips_bmgGetDeviceName (bdAddr, name); - return TRUE; - } - return FALSE; -} - -void mfw_btips_ftpsDisconnect (void) -{ - BTL_FTPS_Disconnect (ftpsContext); -} - - -/*--------------------------------------------------------------------------- - * btips_ftpsCallBack - *--------------------------------------------------------------------------- - * - * Synopsis: This function processes FTP Events received from BTL, only events requested in BTL_FTPS_ConfigObjectRequest - * will be received - * Return: void - * - */ -static void btips_ftpsCallBack(const BtlFtpsEvent *event) -{ - char addr[BDADDR_NTOA_SIZE]; - T_BTIPS_MMI_IND btips_mmi_ind; - BtlBmgDeviceRecord record; - BtStatus status; - - TRACE_FUNCTION_P1("btips_ftpsCallback %d", event->ftpsEvent->event); - - btips_mmi_ind.mfwBtipsEventType = MFW_BTIPS_FTPS_EVENT; - - - /* First process only events that are not "object" related. */ - switch ( event->ftpsEvent->event) - { - case FTPS_EVENT_TP_CONNECTED: - BTL_FTPS_GetConnectedDevice(ftpsContext, &bdAddr); - TRACE_FUNCTION_P1("FTP Server: Transport Connection is up to %s.", bdaddr_ntoa(&bdAddr, addr)); - break; - - case FTPS_EVENT_TP_DISCONNECTED: - TRACE_FUNCTION(("FTP Server: Transport Connection has been disconnected.")); - break; - -#if OBEX_AUTHENTICATION == XA_ENABLED - - case FTPS_EVENT_AUTH_CHALLENGE: - TRACE_FUNCTION_P1("FTP Server: Received Authenticate Challenge for %s operation.", - GoepOpName(event->ftpsEvent->oper)); -#if OBEX_MAX_REALM_LEN > 0 - Report(("FTP Server: Realm: %s, charset %d , Options %d.", - event->ftpsEvent->info.challenge.realm+1, event->ftpsEvent->info.challenge.realm[0], event->ftpsEvent->info.challenge.options)); -#endif /* OBEX_MAX_REALM_LEN > 0 */ - - mfw_btips_ftpsObexAuthenticationResponse ( ); - break; - -#endif /* OBEX_AUTHENTICATION == XA_ENABLED */ - - case FTPS_EVENT_START: - TRACE_FUNCTION_P1("FTP Server: Receiving a %s operation.", GoepOpName(event->ftpsEvent->oper)); - break; - - case FTPS_EVENT_ABORTED: - TRACE_FUNCTION_P1("FTPServer: %s operation aborted.", GoepOpName(event->ftpsEvent->oper)); - btips_mmi_ind.data.ftpsBtEvent.event = MFW_BTIPS_FTPS_ABORTED_EVENT; - btipsNotifyMFW(&btips_mmi_ind); - break; - - case FTPS_EVENT_COMPLETE: - TRACE_FUNCTION_P1("FTPServer: %s operation complete.", GoepOpName(event->ftpsEvent->oper)); - switch(event->ftpsEvent->oper) - { - case GOEP_OPER_PUSH: - btips_mmi_ind.data.ftpsBtEvent.event = MFW_BTIPS_FTPS_PUT_COMP_EVENT; - break; - case GOEP_OPER_DELETE: - btips_mmi_ind.data.ftpsBtEvent.event = MFW_BTIPS_FTPS_DELETE_COMP_EVENT; - break; - case GOEP_OPER_CONNECT: - btips_mmi_ind.data.ftpsBtEvent.event = MFW_BTIPS_FTPS_CONNECT_EVENT; - break; - case GOEP_OPER_DISCONNECT: - btips_mmi_ind.data.ftpsBtEvent.event = MFW_BTIPS_FTPS_DISCONNECT_EVENT; - break; - } - btipsNotifyMFW(&btips_mmi_ind); - break; - - case FTPS_EVENT_OBJECT_PROGRESS: - Report(("FTPServer: %d percent of progress was complete.", - (event->ftpsEvent->info.progress.currPos/event->ftpsEvent->info.progress.maxPos)*100)); - break; - - case FTPS_EVENT_OBJECT_REQUEST: - Report(("FTP Object request : operation \"%s\".", GoepOpName(event->ftpsEvent->oper))); - Report(("FTP Object request: name \"%s\".", event->ftpsEvent->info.request.name)); - Report(("FTP Object request: length \"%d\".", event->ftpsEvent->info.request.objectLen)); - TRACE_FUNCTION("FTP Please accept or reject!"); - -#if 0 - status = BTL_BMG_DDB_FindRecord (bdAddr, &record); - if (status == BT_STATUS_SUCCESS) - { -#endif - if (event->ftpsEvent->oper == GOEP_OPER_PUSH) - { - btips_mmi_ind.data.ftpsBtEvent.event = MFW_BTIPS_FTPS_PUT_EVENT; - strcpy (btips_mmi_ind.data.ftpsBtEvent.p.ftpPutRequest.objectName, event->ftpsEvent->info.request.name); -// strcpy (btips_mmi_ind.data.ftpsBtEvent.p.ftpPutRequest.deviceName, record.name); -// btips_mmi_ind.data.ftpsBtEvent.p.ftpPutRequest.bdAddr = bdAddr; - mfw_btips_ftpsGetConnectedDevice (&(btips_mmi_ind.data.ftpsBtEvent.p.ftpPutRequest.bdAddr), btips_mmi_ind.data.ftpsBtEvent.p.ftpPutRequest.deviceName); - } - else if (event->ftpsEvent->oper == GOEP_OPER_PULL) - { - btips_mmi_ind.data.ftpsBtEvent.event = MFW_BTIPS_FTPS_GET_EVENT; - strcpy (btips_mmi_ind.data.ftpsBtEvent.p.ftpGetRequest.objectName, event->ftpsEvent->info.request.name); -// strcpy (btips_mmi_ind.data.ftpsBtEvent.p.ftpGetRequest.deviceName, record.name); -// btips_mmi_ind.data.ftpsBtEvent.p.ftpGetRequest.bdAddr = bdAddr; - mfw_btips_ftpsGetConnectedDevice (&(btips_mmi_ind.data.ftpsBtEvent.p.ftpGetRequest.bdAddr), btips_mmi_ind.data.ftpsBtEvent.p.ftpGetRequest.deviceName); - } - else if (event->ftpsEvent->oper == GOEP_OPER_DELETE) - { - btips_mmi_ind.data.ftpsBtEvent.event = MFW_BTIPS_FTPS_DELETE_EVENT; - strcpy (btips_mmi_ind.data.ftpsBtEvent.p.ftpDeleteRequest.objectName, event->ftpsEvent->info.request.name); -#if 0 - strcpy (btips_mmi_ind.data.ftpsBtEvent.p.ftpDeleteRequest.deviceName, record.name); - btips_mmi_ind.data.ftpsBtEvent.p.ftpDeleteRequest.bdAddr = bdAddr; -#endif - mfw_btips_ftpsGetConnectedDevice (&(btips_mmi_ind.data.ftpsBtEvent.p.ftpDeleteRequest.bdAddr), btips_mmi_ind.data.ftpsBtEvent.p.ftpDeleteRequest.deviceName); - } - else - { - break; - } - - btipsNotifyMFW(&btips_mmi_ind); -#if 0 - } -#endif - break; - } -} - -void mfw_btips_ftpsCallback(T_BTIPS_MMI_IND * mmiInd) -{ - MfwBtFtpsEvent ftpsBtEvent = mmiInd->data.ftpsBtEvent; - - TRACE_FUNCTION_P1("mfw_btips_ftpsCallback Event = %x", ftpsBtEvent.event); - switch(ftpsBtEvent.event) - { - case MFW_BTIPS_FTPS_PUT_EVENT: - mfw_btips_signal(E_BTIPS_FTPS_PUT_EVENT, mmiInd); - break; - - case MFW_BTIPS_FTPS_GET_EVENT: - mfw_btips_signal(E_BTIPS_FTPS_GET_EVENT, mmiInd); - break; - - case MFW_BTIPS_FTPS_DELETE_EVENT: - mfw_btips_signal(E_BTIPS_FTPS_DELETE_EVENT, mmiInd); - break; - - case MFW_BTIPS_FTPS_COMPLETE_EVENT: - mfw_btips_signal(E_BTIPS_FTPS_COMPLETE_EVENT,mmiInd); - break; - - case MFW_BTIPS_FTPS_ABORTED_EVENT: - mfw_btips_signal(E_BTIPS_FTPS_ABORTED_EVENT,mmiInd); - break; - - case MFW_BTIPS_FTPS_CONNECT_EVENT: - mfw_btips_signal(E_BTIPS_FTPS_CONNECT_EVENT,mmiInd); - break; - - case MFW_BTIPS_FTPS_DISCONNECT_EVENT: - mfw_btips_signal(E_BTIPS_FTPS_DISCONNECT_EVENT,mmiInd); - break; - - case MFW_BTIPS_FTPS_PUT_COMP_EVENT: - mfw_btips_signal(E_BTIPS_FTPS_PUT_COMP_EVENT,mmiInd); - break; - - case MFW_BTIPS_FTPS_DELETE_COMP_EVENT: - mfw_btips_signal(E_BTIPS_FTPS_DELETE_COMP_EVENT,mmiInd); - break; - - } -} - -/*--------------------------------------------------------------------------- - * GoepOpName - *--------------------------------------------------------------------------- - * - * Synopsis: Return a pointer to the name of the current server operation. - * - * Return: ASCII String pointer. - * - */ -static const char *GoepOpName(GoepOperation Op) -{ - switch (Op) { - case GOEP_OPER_PUSH: - return "Push"; - case GOEP_OPER_PULL: - return "Pull"; - case GOEP_OPER_CONNECT: - return "Connect"; - case GOEP_OPER_DISCONNECT: - return "Disconnect"; - case GOEP_OPER_SETFOLDER: - return "Set Folder"; - case GOEP_OPER_DELETE: - return "Delete"; - case GOEP_OPER_ABORT: - return "Abort"; - } - return "Unknown"; -} - -/*--------------------------------------------------------------------------- - * General Purpose Debug functions - *--------------------------------------------------------------------------- - */ -const char *pBT_Status(I8 Status) -{ - switch (Status) { - case BT_STATUS_SUCCESS: - return ("Success"); - case BT_STATUS_FAILED: - return ("Failed"); - case BT_STATUS_PENDING: - return ("Pending"); - case BT_STATUS_BUSY: - return ("Busy"); - case BT_STATUS_NO_RESOURCES: - return ("No Resources"); - case BT_STATUS_NOT_FOUND: - return ("Not Found"); - case BT_STATUS_DEVICE_NOT_FOUND: - return ("Device Not Found"); - case BT_STATUS_CONNECTION_FAILED: - return ("Connection Failed"); - case BT_STATUS_TIMEOUT: - return ("Timeout"); - case BT_STATUS_NO_CONNECTION: - return ("No Connection"); - case BT_STATUS_INVALID_PARM: - return ("Invalid parameter"); - case BT_STATUS_IN_PROGRESS: - return ("In Progress"); - case BT_STATUS_RESTRICTED: - return ("Restricted"); - case BT_STATUS_INVALID_TYPE: - return ("Invalid Type"); - case BT_STATUS_HCI_INIT_ERR: - return ("HCI Initialization Error"); - case BT_STATUS_NOT_SUPPORTED: - return ("Not Supported"); - case BT_STATUS_IN_USE: - return ("In Use"); - case BT_STATUS_SDP_CONT_STATE: - return ("SDP Continue"); - case BT_STATUS_CANCELLED: - return ("Cancelled"); - } - return ("UNKNOWN"); -} - -#endif -
--- a/src/ui/mfw/mfw_BtipsMdg.c Tue Jan 19 05:23:24 2021 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,857 +0,0 @@ -/* ========================================================= -* Texas Instruments OMAP(TM) Platform Software -* (c) Copyright Texas Instruments, Incorporated. All Rights Reserved. -* -* Use of this software is controlled by the terms and conditions found -* in the license agreement under which this software has been supplied. -* ========================================================== */ -/* - $Project name: Basic Bluetooth MMI - $Project code: - $Module: Bluetooth BMG MFW - $File: Mfw_Btips.c - $Revision: 1.0 - $Author: Texas Instruments - $Date: 26/06/07 - -******************************************************************************** - - Description: - - This module provides the BTIPS BMG APPlication functionality. - -******************************************************************************** - $History: Mfw_Btips.c - - 26/06/07 Sasken original version - - $End - -*******************************************************************************/ - - - - -/******************************************************************************* - - Include files - -*******************************************************************************/ - -#define ENTITY_MFW -/* includes */ - -#include <string.h> - -#if defined (NEW_FRAME) - -#include "typedefs.h" -#include "vsi.h" -#include "pei.h" -#include "custom.h" -#include "gsm.h" -#include "prim.h" - -#else - -#include "STDDEFS.H" -#include "custom.h" -#include "gsm.h" -#include "vsi.h" - -#include "bttypes.h" -#include "sec.h" -#include "spp.h" -#include "osapi.h" -#include "debug.h" -#include "btl_mdg.h" - -#endif - -#ifdef FF_MMI_BTIPS_APP - -/* Macro for sending events to UI - meanwhile, trace message to PCO Viewer */ -extern int vsi_o_state_ttrace ( const char * const format, ... ); -#define UI_DISPLAY(s) vsi_o_state_ttrace s - -#include "bttypes.h" -#include "sec.h" -#include "spp.h" -#include "osapi.h" -#include "debug.h" -//#include "../lineparser.h" -#include "btl_mdg.h" -//#include "../app_main.h" - - -/******************************************************************************** - * - * Constants - * - *******************************************************************************/ - -/* MDG Application states */ -#define MDGA_SERVER_STATE_NONE (0) -#define MDGA_SERVER_STATE_ENABLED (1) -#define MDGA_SERVER_STATE_DISABLING (2) -#define MDGA_SERVER_STATE_DT_CONNECTED (3) -#define MDGA_SERVER_STATE_MODEM_CONNECTED (4) -#define MDGA_SERVER_STATE_CONNECTED (5) - -/* Security level of the MDG Application */ -#define MDGA_SECURITY_LEVEL (BSL_AUTHENTICATION_IN | BSL_AUTHENTICATION_OUT) - -/* Max number of Rx Sync packets - this value will be given to peer serial port - * as amount of credits for RFCOMM credit based flow control */ -#define MDGA_MAX_NUM_OF_RX_SYNC_PACKETS (5) - - -/******************************************************************************** - * - * Types - * - *******************************************************************************/ - -/* Structure to keep track of server information */ -typedef struct -{ - U8 state; - const BtSecurityLevel securityLevel; - BtlMdgServerContext *serverContext; - BtlMdgServerSettings serverSettings; - SppLineStatus lineStatus; -} MdgaServer; - - -/******************************************************************************** - * - * Function prototypes - * - *******************************************************************************/ -void mfw_btips_mdgInit(void); -void MDGA_Deinit(void); -void MDGA_Enable(U8 serverIndex); -void MDGA_Disable(U8 serverIndex); -void MDGA_GetSecurityLevel(U8 serverIndex); -void MDGA_SetSecurityLevel(U8 serverIndex, BtSecurityLevel *securityLevel); -void MDGA_GetComSettings(U8 serverIndex); -void MDGA_SetComSettings(U8 serverIndex, SppComSettings *comSettings); -void MDGA_GetConnectedDevice(U8 serverIndex); -void MDGA_TerminateDataCall(void); - -void mfw_btips_mdgCallback(const BtlMdgCallbackParms *parms); -static const char *MdgaEventName(BtlMdgServerEvent mdgEvent); -static const char *MdgaStateName(int state); - - -/******************************************************************************** - * - * Globals - * - *******************************************************************************/ - -static MdgaServer mdgaServers[] = -{ - { - MDGA_SERVER_STATE_NONE, MDGA_SECURITY_LEVEL, NULL, - {BTL_SPP_SERVICE_TYPE_DUN, - "BTIPS DUN", - {SPP_SERVER_PORT, - BTL_SPP_SERVICE_TYPE_DUN, - SPP_PORT_DATA_PATH_TX_SYNC | SPP_PORT_DATA_PATH_RX_ASYNC, - MDGA_MAX_NUM_OF_RX_SYNC_PACKETS, - {SPP_COM_SETTING_BAUDRATE_DEFAULT, - SPP_COM_SETTING_DATA_FORMAT_DEFAULT, - SPP_COM_SETTING_FLOW_CONTROL_DEFAULT, - SPP_COM_SETTING_XON_CHAR_DEFAULT, - SPP_COM_SETTING_XOFF_CHAR_DEFAULT, - 0 - } - }, - }, - 0 - } -}; - -#define MDGA_NUM_SERVERS (sizeof(mdgaServers) / sizeof(MdgaServer)) - - -/******************************************************************************** - * - * Function definitions - * - *******************************************************************************/ - - /*------------------------------------------------------------------------------- - * mfw_btips_mdgInit() - * - * Initialize application module. - * - * Type: - * Synchronous. - * - * Parameters: - * None. - * - * Returns: - * None. - */ -void mfw_btips_mdgInit() -{ - BtStatus status; - U32 idx; - MdgaServer *server = &mdgaServers[0]; - - Report(("mfw_btips_mdgInit")); - - /* Create and enable all MDG servers */ - for (idx=0; idx<MDGA_NUM_SERVERS; idx++, server++) - { - /* Create MDG server */ - status = BTL_MDG_Create(0, - mfw_btips_mdgCallback, - &server->securityLevel, - &server->serverContext); - if (BT_STATUS_SUCCESS != status) - { - Report(("MDGA: BTL_MDG_Create() failed for server %s, status %s", - server->serverSettings.serviceName, - pBT_Status(status))); - } - else - { - /* Enable MDG server */ - status = BTL_MDG_Enable(server->serverContext, - &server->serverSettings); - - if (BT_STATUS_SUCCESS != status) - { - Report(("MDGA: BTL_MDG_Enable() failed for server %s, status %s", - server->serverSettings.serviceName, - pBT_Status(status))); - } - else - { - server->state = MDGA_SERVER_STATE_ENABLED; - } - } - } -} - -/*------------------------------------------------------------------------------- - * MDGA_Deinit() - * - * Deinitialize application module. - * - * Type: - * Synchronous. - * - * Parameters: - * None. - * - * Returns: - * None. - */ -void MDGA_Deinit() -{ - BtStatus status; - U32 idx; - MdgaServer *server = &mdgaServers[0]; - - Report(("MDGA_Deinit")); - - /* Disable and destroy all MDG servers */ - for (idx=0; idx<MDGA_NUM_SERVERS; idx++, server++) - { - /* Check whether the server was enabled and not in DISABLING state */ - if ((server->state >= MDGA_SERVER_STATE_ENABLED) && - (MDGA_SERVER_STATE_DISABLING != server->state)) - { - /* Disable MDG server */ - status = BTL_MDG_Disable(server->serverContext); - - if (BT_STATUS_SUCCESS == status) - { - /* Destroy MDG server */ - status = BTL_MDG_Destroy(&server->serverContext); - - if (BT_STATUS_SUCCESS != status) - { - Report(("MDGA: BTL_MDG_Destroy() failed for server %s, status %s", - server->serverSettings.serviceName, - pBT_Status(status))); - } - else - { - server->state = MDGA_SERVER_STATE_NONE; - } - } - else if ((BT_STATUS_PENDING == status) || (BT_STATUS_IN_PROGRESS == status)) - { - /* Continue disabling server in mfw_btips_mdgCallback() */ - server->state = MDGA_SERVER_STATE_DISABLING; - } - else - { - Report(("MDGA: BTL_MDG_Disable() failed, status %s", pBT_Status(status))); - } - } - } -} - -/*------------------------------------------------------------------------------- - * MDGA_Enable() - * - * Processes command 'enable'. - * - * Type: - * Synchronous. - * - * Parameters: - * serverIndex - index of the server. - * - * Returns: - * None. - */ -void MDGA_Enable(U8 serverIndex) -{ - BtStatus status; - MdgaServer *server; - - server = &mdgaServers[serverIndex]; - - /* Check validity of the command */ - if (server->state >= MDGA_SERVER_STATE_ENABLED) - { - Report(("MDGA: server %s is already enabled", - server->serverSettings.serviceName)); - return; - } - - /* Create MDG server */ - status = BTL_MDG_Create(0, - mfw_btips_mdgCallback, - &server->securityLevel, - &server->serverContext); - if (BT_STATUS_SUCCESS != status) - { - Report(("MDGA: BTL_MDG_Create() failed, status %s", - pBT_Status(status))); - } - else - { - /* Enable MDG server */ - status = BTL_MDG_Enable(server->serverContext, - &server->serverSettings); - - if (BT_STATUS_SUCCESS != status) - { - Report(("MDGA: BTL_MDG_Enable() failed, status %s", - pBT_Status(status))); - } - else - { - server->state = MDGA_SERVER_STATE_ENABLED; - UI_DISPLAY(("MDGA: server %s enabled", - server->serverSettings.serviceName)); - } - } - - return; -} - -/*------------------------------------------------------------------------------- - * MDGA_Disable() - * - * Processes command 'enable'. - * - * Type: - * Synchronous. - * - * Parameters: - * serverIndex - index of the server. - * - * Returns: - * None. - */ -void MDGA_Disable(U8 serverIndex) -{ - BtStatus status; - MdgaServer *server = &mdgaServers[serverIndex]; - - /* Check validity of the command */ - if (server->state < MDGA_SERVER_STATE_ENABLED) - { - Report(("MDGA: server %s is not enabled", - server->serverSettings.serviceName)); - return; - } - - /* Disable MDG server */ - status = BTL_MDG_Disable(server->serverContext); - - if (BT_STATUS_SUCCESS == status) - { - /* Destroy MDG server */ - status = BTL_MDG_Destroy(&server->serverContext); - - if (BT_STATUS_SUCCESS != status) - { - Report(("MDGA: BTL_MDG_Destroy() failed, status %s", - pBT_Status(status))); - } - else - { - server->state = MDGA_SERVER_STATE_NONE; - UI_DISPLAY(("MDGA: server %s disabled", - server->serverSettings.serviceName)); - } - } - else if ((BT_STATUS_PENDING == status) || (BT_STATUS_IN_PROGRESS == status)) - { - /* Continue disabling server in mfw_btips_mdgCallback() */ - server->state = MDGA_SERVER_STATE_DISABLING; - UI_DISPLAY(("MDGA: disabling server %s", - server->serverSettings.serviceName)); - } - else - { - Report(("MDGA: BTL_MDG_Disable() failed, status %s", pBT_Status(status))); - } - - return; -} - -/*------------------------------------------------------------------------------- - * MDGA_GetSecurityLevel() - * - * Processes command 'getsec'. - * - * Type: - * Synchronous. - * - * Parameters: - * serverIndex - index of the server. - * - * Returns: - * None. - */ -void MDGA_GetSecurityLevel(U8 serverIndex) -{ - BtStatus status; - BtSecurityLevel securityLevel; - MdgaServer *server = &mdgaServers[serverIndex]; - - status = BTL_MDG_GetSecurityLevel(server->serverContext, &securityLevel); - - if (BT_STATUS_SUCCESS == status) - { - UI_DISPLAY(("UI_EVENT: MDGA got security level %d for server %s", - securityLevel, - server->serverSettings.serviceName)); - } - else - { - Report(("MDGA: BTL_MDG_GetSecurityLevel() failed for server %s, status %s", - server->serverSettings.serviceName, - pBT_Status(status))); - } - - return; -} - -/*------------------------------------------------------------------------------- - * MDGA_SetSecurityLevel() - * - * Processes command 'setsec'. - * - * Type: - * Synchronous. - * - * Parameters: - * serverIndex - index of the server. - * - * Returns: - * None. - */ -void MDGA_SetSecurityLevel(U8 serverIndex, BtSecurityLevel *securityLevel) -{ - BtStatus status; - MdgaServer *server = &mdgaServers[serverIndex]; - - status = BTL_MDG_SetSecurityLevel(server->serverContext, securityLevel); - - if (BT_STATUS_SUCCESS == status) - { - UI_DISPLAY(("UI_EVENT: MDGA set security level %d for server %s", - *securityLevel, - server->serverSettings.serviceName)); - } - else - { - Report(("MDGA: BTL_MDG_SetSecurityLevel() failed for server %s, status %s", - server->serverSettings.serviceName, - pBT_Status(status))); - } - - return; -} - -/*------------------------------------------------------------------------------- - * MDGA_GetComSettings() - * - * Processes command 'getcomset'. - * - * Type: - * Synchronous. - * - * Parameters: - * serverIndex - index of the server. - * - * Returns: - * None. - */ -void MDGA_GetComSettings(U8 serverIndex) -{ - BtStatus status; - SppComSettings comSettings; - MdgaServer *server = &mdgaServers[serverIndex]; - - status = BTL_MDG_GetComSettings(server->serverContext, &comSettings); - - if (BT_STATUS_SUCCESS == status) - { - UI_DISPLAY(("UI_EVENT: MDGA got com settings for server %s -", server->serverSettings.serviceName)); - UI_DISPLAY(("UI_EVENT: MDGA baudrate 0x%02x, data format 0x%02x, flow control 0x%02x, XON 0x%02x, XOFF 0x%02x", - comSettings.baudRate, - comSettings.dataFormat, - comSettings.flowControl, - comSettings.xonChar, - comSettings.xoffChar)); - } - else - { - Report(("MDGA: BTL_MDG_GetComSettings() failed for server %s, status %s", - server->serverSettings.serviceName, - pBT_Status(status))); - } - - return; -} - -/*------------------------------------------------------------------------------- - * MDGA_SetComSettings() - * - * Processes command 'setcomset'. - * - * Type: - * Synchronous. - * - * Parameters: - * serverIndex - index of the server. - * - * Returns: - * None. - */ -void MDGA_SetComSettings(U8 serverIndex, SppComSettings *comSettings) -{ - BtStatus status; - MdgaServer *server = &mdgaServers[serverIndex]; - - status = BTL_MDG_SetComSettings(server->serverContext, comSettings); - - if (BT_STATUS_SUCCESS == status) - { - UI_DISPLAY(("UI_EVENT: MDGA set com settings for server %s -", server->serverSettings.serviceName)); - UI_DISPLAY(("UI_EVENT: MDGA baudrate 0x%02x, data format 0x%02x, flow control 0x%02x, XON 0x%02x, XOFF 0x%02x, parm mask 0x%04x", - comSettings->baudRate, - comSettings->dataFormat, - comSettings->flowControl, - comSettings->xonChar, - comSettings->xoffChar, - comSettings->parmMask)); - } - else if ((BT_STATUS_PENDING != status) && (BT_STATUS_IN_PROGRESS != status)) - { - Report(("MDGA: BTL_MDG_GetComSettings() failed for server %s, status %s", - server->serverSettings.serviceName, - pBT_Status(status))); - } - - return; -} - -/*------------------------------------------------------------------------------- - * MDGA_GetConnectedDevice() - * - * Processes command 'getcondev'. - * - * Type: - * Synchronous. - * - * Parameters: - * serverIndex - index of the server. - * - * Returns: - * None. - */ -void MDGA_GetConnectedDevice(U8 serverIndex) -{ - BtStatus status; - BD_ADDR bdAddr; - char addr[BDADDR_NTOA_SIZE]; - MdgaServer *server = &mdgaServers[serverIndex]; - - status = BTL_MDG_GetConnectedDevice(server->serverContext, &bdAddr); - - if (BT_STATUS_SUCCESS == status) - { - UI_DISPLAY(("UI_EVENT: MDGA server %s is connected to %s", - server->serverSettings.serviceName, - bdaddr_ntoa((const BD_ADDR *)&bdAddr, addr))); - } - else - { - Report(("MDGA: MdgaGetConnectedDevice() failed for server %s, status %s", - server->serverSettings.serviceName, - pBT_Status(status))); - } - - return; -} - -/*------------------------------------------------------------------------------- - * MDGA_TerminateDataCall() - * - * Processes command 'termdatacall'. - * - * Type: - * Synchronous. - * - * Parameters: - * None. - * - * Returns: - * None. - */ -void MDGA_TerminateDataCall() -{ - return; -} - -/*------------------------------------------------------------------------------- - * mfw_btips_mdgCallback() - * - * Callback function for receiving BTL MDG events. - * - * Type: - * Synchronous. - * - * Parameters: - * parms - received event. - * - * Returns: - * None. - */ - -void mfw_btips_mdgCallback(const BtlMdgCallbackParms *parms) -{ - BtStatus status; - MdgaServer *server; - int idx; - - TRACE_EVENT_P1("mfw_btips_mdgCallback - %d", parms->event); - /* Find a server according to given BTL MDG context */ - for (idx = 0, server=&mdgaServers[0]; idx<MDGA_NUM_SERVERS; idx++, server++) - { - if (server->serverContext == parms->serverContext) - { - break; - } - } - - /* Check whether we found a port in array of clients */ - if (MDGA_NUM_SERVERS == idx) - { - - /* Server is not found */ - Report(("MDGA: server's context is unknown")); - return; - } - - /* Display received event and server's service name */ - UI_DISPLAY(("UI_EVENT: MDGA received event %s for server %s", - MdgaEventName(parms->event), - server->serverSettings.serviceName)); - - /* Change port's state according to event */ - switch(parms->event) - { - case BTL_MDG_SERVER_EVENT_ENABLED: - server->state = MDGA_SERVER_STATE_ENABLED; - break; - - case BTL_MDG_SERVER_EVENT_DISABLED: - if (MDGA_SERVER_STATE_DISABLING == server->state) - { - /* Destroy MDG server */ - status = BTL_MDG_Destroy(&server->serverContext); - - if (BT_STATUS_SUCCESS != status) - { - Report(("MDGA: BTL_MDG_Destroy() failed, status %s", - pBT_Status(status))); - } - else - { - server->state = MDGA_SERVER_STATE_NONE; - UI_DISPLAY(("MDGA: server %s disabled", - server->serverSettings.serviceName)); - } - } - break; - - case BTL_MDG_SERVER_EVENT_DT_CONNECTED: - if (MDGA_SERVER_STATE_MODEM_CONNECTED == server->state) - { - server->state = MDGA_SERVER_STATE_CONNECTED; - } - else - { - server->state = MDGA_SERVER_STATE_DT_CONNECTED; - } - break; - - case BTL_MDG_SERVER_EVENT_DT_DISCONNECTED: - if (MDGA_SERVER_STATE_CONNECTED == server->state) - { - server->state = MDGA_SERVER_STATE_MODEM_CONNECTED; - } - else if (MDGA_SERVER_STATE_DISABLING != server->state) - { - server->state = MDGA_SERVER_STATE_ENABLED; - } - break; - - case BTL_MDG_SERVER_EVENT_MODEM_CONNECTED: - if (MDGA_SERVER_STATE_DT_CONNECTED == server->state) - { - server->state = MDGA_SERVER_STATE_CONNECTED; - } - else - { - server->state = MDGA_SERVER_STATE_DT_CONNECTED; - } - break; - - case BTL_MDG_SERVER_EVENT_MODEM_DISCONNECTED: - if (MDGA_SERVER_STATE_CONNECTED == server->state) - { - server->state = MDGA_SERVER_STATE_DT_CONNECTED; - } - else if (MDGA_SERVER_STATE_DISABLING != server->state) - { - server->state = MDGA_SERVER_STATE_ENABLED; - } - break; - - default: - break; - } - - /* Display server's new state */ - Report(("MDGA: %s server's state %s", - server->serverSettings.serviceName, - MdgaStateName(server->state))); -} - -/*------------------------------------------------------------------------------- - * MdgaEventName() - * - * Gets event's name. - * - * Type: - * Synchronous. - * - * Parameters: - * mdgEvent - event. - * - * Returns: - * String with event's name. - */ -static const char *MdgaEventName(BtlMdgServerEvent mdgEvent) -{ - switch (mdgEvent) - { - case BTL_MDG_SERVER_EVENT_INITIALIZED: - return "BTL_MDG_SERVER_EVENT_INITIALIZED"; - - case BTL_MDG_SERVER_EVENT_DEINITIALIZED: - return "BTL_MDG_SERVER_EVENT_DEINITIALIZED"; - - case BTL_MDG_SERVER_EVENT_ENABLED: - return "BTL_MDG_SERVER_EVENT_ENABLED"; - - case BTL_MDG_SERVER_EVENT_DISABLED: - return "BTL_MDG_SERVER_EVENT_DISABLED"; - - case BTL_MDG_SERVER_EVENT_DT_CONNECTED: - return "BTL_MDG_SERVER_EVENT_DT_CONNECTED"; - - case BTL_MDG_SERVER_EVENT_DT_DISCONNECTED: - return "BTL_MDG_SERVER_EVENT_DT_DISCONNECTED"; - - case BTL_MDG_SERVER_EVENT_MODEM_CONNECTED: - return "BTL_MDG_SERVER_EVENT_MODEM_CONNECTED"; - - case BTL_MDG_SERVER_EVENT_MODEM_DISCONNECTED: - return "BTL_MDG_SERVER_EVENT_MODEM_DISCONNECTED"; - - default: - return "MDGA: server received unknown event"; - } -} - -/*------------------------------------------------------------------------------- - * MdgaStateName() - * - * Gets state's name. - * - * Type: - * Synchronous. - * - * Parameters: - * state - server's state. - * - * Returns: - * String with state's name. - */ -static const char *MdgaStateName(int state) -{ - switch (state) - { - case MDGA_SERVER_STATE_NONE: - return "MDGA_SERVER_STATE_NONE"; - - case MDGA_SERVER_STATE_ENABLED: - return "MDGA_SERVER_STATE_ENABLED"; - - case MDGA_SERVER_STATE_DISABLING: - return "MDGA_SERVER_STATE_DISABLING"; - - case MDGA_SERVER_STATE_DT_CONNECTED: - return "MDGA_SERVER_STATE_DT_CONNECTED"; - - case MDGA_SERVER_STATE_MODEM_CONNECTED: - return "MDGA_SERVER_STATE_MODEM_CONNECTED"; - - case MDGA_SERVER_STATE_CONNECTED: - return "MDGA_SERVER_STATE_CONNECTED"; - - default: - return "MDG server unknown state"; - } -} - -#endif -
--- a/src/ui/mfw/mfw_BtipsOppc.c Tue Jan 19 05:23:24 2021 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,1001 +0,0 @@ -/* ========================================================= -* Texas Instruments OMAP(TM) Platform Software -* (c) Copyright Texas Instruments, Incorporated. All Rights Reserved. -* -* Use of this software is controlled by the terms and conditions found -* in the license agreement under which this software has been supplied. -* ========================================================== */ -/* - $Project name: Basic Bluetooth MMI - $Project code: - $Module: Bluetooth BMG MFW - $File: Mfw_BtipsOppc.c - $Revision: 1.0 - $Author: Texas Instruments - $Date: 26/06/07 - -******************************************************************************** - - Description: - - This module provides the OPP Client APPlication functionality. - -******************************************************************************** - $History: Mfw_BtipsOppc.c - - 26/06/07 Sasken original version - - $End - -*******************************************************************************/ - - - - -/******************************************************************************* - - Include files - -*******************************************************************************/ - -#define ENTITY_MFW -/* includes */ - -#include <string.h> - -#if defined (NEW_FRAME) - -#include "typedefs.h" -#include "vsi.h" -#include "pei.h" -#include "custom.h" -#include "gsm.h" -#include "prim.h" - -#else - -#include "STDDEFS.H" -#include "custom.h" -#include "gsm.h" -#include "vsi.h" - -#endif - -#ifdef FF_MMI_BTIPS_APP -#include "osapi.h" -#include "btl_common.h" -#include "debug.h" - -//#include "../app_main.h" -#include "btl_oppc.h" -#include "btl_config.h" -#include "bthal_fs.h" -//#include "../../btl/inc/int/obstore.h" -#include "obstore.h" - -#include "mfw_BtipsOppc.h" -#include "Mfw_mfw.h" -#include "mfw_Btips.h" -#include "mfw_ffs.h" - -extern int oppc_files_count; -//Array to load fileNames in content directory -extern char* oppc_file_names[OPPC_MAX_FILES]; - -/* Macro for sending events to UI - meanwhile, trace message to PCO Viewer */ -extern int vsi_o_state_ttrace ( const char * const format, ... ); -#define UI_DISPLAY(s) vsi_o_state_ttrace s - -/******************************************************************************** - * - * Constants - * - *******************************************************************************/ - - -/******************************************************************************* - * - * Macro definitions - * - ******************************************************************************/ -#define OPPCA_BUFF_MAX (1 * 512) - -#define BTL_CONFIG_OPP_MAX_FILE_NAME_LEN min(GOEP_MAX_UNICODE_LEN/2-2, BTHAL_FS_MAX_FILE_NAME_LENGTH) - - -#define OPPCA_CHECK_FS_NAME_LEN(fsPath) \ - (OS_StrLen(fsPath) < (BTL_CONFIG_OPP_MAX_FILE_NAME_LEN + BTHAL_FS_MAX_PATH_LENGTH + 1)) - - - - - -/******************************************************************************* - * - * OPPC External Function prototypes - * - ******************************************************************************/ - -void mfw_btips_oppcInit(void); -void mfw_btips_oppcDeinit(void); - -void mfw_btips_oppcEncapsulatePush(const char *fsPushPath, BD_ADDR *bd_addr); -void mfw_btips_oppcEncapsulatePull(const char *fsPullPath, BD_ADDR *bd_addr); -void mfw_btips_oppcEncapsulateExchange(const char *fsPushPath, const char *fsPullPath, BD_ADDR *bd_addr); - - - - - - - -/*------------------------------------------------------------------------------- - * OppcaCurrOperation type - * - * Defines the OPPCA current operation. - */ -typedef U8 OppcaCurrOperation; - -#define OPPCA_OPER_NONE 0x00 -#define OPPCA_OPER_BASIC_PULL 0x01 /* Pull */ -#define OPPCA_OPER_BASIC_PUSH 0x02 /* Push */ -#define OPPCA_OPER_BASIC_EXCHANGE 0x03 /* Push-Pull */ -#define OPPCA_OPER_ENC_PULL 0x04 /* Connect-Pull-Disconnect */ -#define OPPCA_OPER_ENC_PUSH 0x05 /* Connect-Push-Disconnect */ -#define OPPCA_OPER_ENC_EXCHANGE 0x06 /* Connect-Push-Pull-Disconnect */ - - -/*------------------------------------------------------------------------------- - * OppcaState type - * - * Defines the OPPCA current state. - */ -typedef U8 OppcaState; - -#define OPPCA_IDLE 0x00 /* OBEX and Transport disconnected */ -#define OPPCA_CONNECTING 0x01 /* OBEX connecting */ -#define OPPCA_TP_CONNECTED 0x02 /* Transport connected */ -#define OPPCA_CONNECTED 0x03 /* OBEX connected */ -#define OPPCA_DISCONNECTING 0x04 /* OBEX disconnecting */ -#define OPPCA_TP_DISCONNECTING 0x05 /* Transport disconnecting */ -#define OPPCA_DISABLING 0x06 /* OBEX and Transport disabling */ - - -typedef struct _OppcaData -{ - OppcaState state; - - BOOL isConnected; - - BOOL operationOngoing; - - BtSecurityLevel securityLevel; - - BtlObjectLocation objLocation; - - OppcaCurrOperation currOper; - - /* Memory Objects */ - char pushBuff[OPPCA_BUFF_MAX]; - char pullBuff[OPPCA_BUFF_MAX]; - -} OppcaData; - - -/******************************************************************************** - * - * Globals - * - *******************************************************************************/ - -static OppcaData oppClient; -static BtlOppcContext *oppcContext = 0; - -static char ObPushName[BTL_CONFIG_OPP_MAX_FILE_NAME_LEN + 1] = {'\0'}; -static char ObPullName[BTL_CONFIG_OPP_MAX_FILE_NAME_LEN + 1] = {'\0'}; - -extern char push_file_name[]; - -/******************************************************************************* - * - * Internal Function prototypes - * - ******************************************************************************/ -static void btips_oppcCallback(const BtlOppcEvent *Event); - -static const char *mfw_btips_oppcGoepOpName(GoepOperation Op); - -static BOOL mfw_btips_oppcBuildPushObject(BtlObject *objToPush, const char *fsPath, char *buff); -static BOOL mfw_btips_oppcBuildPullObject(BtlObject *objToPull, const char *fsPath, char *buff); - -static BOOL mfw_btips_oppcConvertToMemPushObject(BtlObject *obj, const char *fsPushPathh, char *buff); -static void mfw_btips_oppcSetFsPushObject(BtlObject *obj, const char *fsPushPath); -static void mfw_btips_oppcSetFsPullObject(BtlObject *obj, const char *fsPullPath); -static void mfw_btips_oppcSetMemPullObject(BtlObject *obj, const char *fsPullPath, char *buff); - -/*--------------------------------------------------------------------------- - * mfw_btips_oppcInit - *--------------------------------------------------------------------------- - * - * Synopsis: Initialize the OBEX Client for the OPP application - * and the Object Store. - * - * Return: void - * - */ -void mfw_btips_oppcInit(void) -{ - BtStatus status; - - oppClient.state = OPPCA_IDLE; - oppClient.isConnected = FALSE; - oppClient.operationOngoing = FALSE; - oppClient.securityLevel = BSL_NO_SECURITY; - oppClient.currOper = OPPCA_OPER_NONE; - oppClient.objLocation = BTL_OBJECT_LOCATION_FS; - - status = BTL_OPPC_Create((BtlAppHandle *)0, btips_oppcCallback, &oppClient.securityLevel, &oppcContext); - TRACE_EVENT_P1("BTL_OPPC_Create() returned %s.",pBT_Status(status)); - - status = BTL_OPPC_Enable(oppcContext); - TRACE_EVENT_P1("BTL_OPPC_Enable() returned %s.",pBT_Status(status)); -} - - -/*--------------------------------------------------------------------------- - * mfw_btips_oppcDeinit - *--------------------------------------------------------------------------- - * - * Synopsis: Deinitialize the OBEX Client protocol. - * - * Return: void - * - */ -void mfw_btips_oppcDeinit(void) -{ - BtStatus status; - - status = BTL_OPPC_Disable(oppcContext); - - Report(("BTL_OPPC_Disable() returned %s.",pBT_Status(status))); - - if (status == BT_STATUS_SUCCESS) - { - status = BTL_OPPC_Destroy(&oppcContext); - - Report(("BTL_OPPC_Destroy() returned %s.", pBT_Status(status))); - - oppClient.state = OPPCA_IDLE; - oppClient.isConnected = FALSE; - oppClient.operationOngoing = FALSE; - } - else - { - oppClient.state = OPPCA_DISABLING; - } -} - - -/*--------------------------------------------------------------------------- - * mfw_btips_oppcEncapsulatePush - *--------------------------------------------------------------------------- - * - * Synopsis: Initiate an OBEX Object Push procedure. - * Includes Connect and Disconnect from the opp server. - * If the given BD_ADDR is NULL, a search is performed. - * - * Return: void - * - */ -void mfw_btips_oppcEncapsulatePush(const char *fsPushPath, BD_ADDR *bd_addr) -{ - BtStatus status; - BtlObject objToPush; - - Report(("mfw_btips_oppcEncapsulatePush: fsPushPath = %s", fsPushPath)); - - if (TRUE != OPPCA_CHECK_FS_NAME_LEN(fsPushPath)) - { - Report(("mfw_btips_oppcEncapsulatePush: Can't push. fsPushPath too long")); - return; - } - - if (TRUE != mfw_btips_oppcBuildPushObject(&objToPush, fsPushPath, oppClient.pushBuff)) - { - Report(("OPPCA_BasicPull: Can't pull")); - return; - } - - status = BTL_OPPC_ConnectPushDisconnect(oppcContext, bd_addr, &objToPush); - - Report(("BTL_OPPC_ConnectPushDisconnect() returned %s.", pBT_Status(status))); - if (status == OB_STATUS_PENDING) - { - Report(("mfw_btips_oppcEncapsulatePush(): Started ...")); - oppClient.operationOngoing = TRUE; - oppClient.currOper = OPPCA_OPER_ENC_PUSH; - } -} - - -/*--------------------------------------------------------------------------- - * mfw_btips_oppcEncapsulatePull - *--------------------------------------------------------------------------- - * - * Synopsis: Initiate an OBEX Business Card Pull procedure. - * Includes Connect and Disconnect from the opp server. - * If the given BD_ADDR is NULL, a search is performed. - * - * Return: void - * - */ -void mfw_btips_oppcEncapsulatePull(const char *fsPullPath, BD_ADDR *bd_addr) -{ - BtStatus status; - BtlObject objToPull; - - Report(("mfw_btips_oppcEncapsulatePull: fsPullPath = %s", fsPullPath)); - - if (TRUE != OPPCA_CHECK_FS_NAME_LEN(fsPullPath)) - { - Report(("mfw_btips_oppcEncapsulatePull: Can't pull. fsPullPath too long")); - return; - } - - if (TRUE != mfw_btips_oppcBuildPullObject(&objToPull, fsPullPath, oppClient.pullBuff)) - { - Report(("mfw_btips_oppcEncapsulatePull: Can't pull")); - return; - } - - status = BTL_OPPC_ConnectPullDisconnect(oppcContext, bd_addr, &objToPull); - - Report(("BTL_OPPC_Pull() returned %s.", pBT_Status(status))); - - if (status == OB_STATUS_PENDING) - { - Report(("mfw_btips_oppcEncapsulatePull(): Started ...")); - oppClient.operationOngoing = TRUE; - oppClient.currOper = OPPCA_OPER_ENC_PULL; - } -} - - -/*--------------------------------------------------------------------------- - * mfw_btips_oppcEncapsulateExchange - *--------------------------------------------------------------------------- - * - * Synopsis: Initiate an OBEX Business Card Exchange procedure. - * Includes Connect and Disconnect from the opp server. - * If the given BD_ADDR is NULL, a search is performed. - * - * Return: void - * - */ -void mfw_btips_oppcEncapsulateExchange(const char *fsPushPath, const char *fsPullPath, BD_ADDR *bd_addr) -{ - BtStatus status; - BtlObject objToPush, objToPull; - - Report(("mfw_btips_oppcEncapsulateExchange: fsPushPath = %s, fsPullPath = %s", fsPushPath, fsPullPath)); - - - /* -------- Push Operation --------- */ - - if (TRUE != OPPCA_CHECK_FS_NAME_LEN(fsPushPath)) - { - Report(("mfw_btips_oppcEncapsulateExchange: Can't push. fsPushath too long")); - return; - } - - if (TRUE != mfw_btips_oppcBuildPushObject(&objToPush, fsPushPath, oppClient.pushBuff)) - { - Report(("mfw_btips_oppcEncapsulateExchange: Can't push")); - return; - } - - /* -------- Pull Operation --------- */ - - if (TRUE != OPPCA_CHECK_FS_NAME_LEN(fsPullPath)) - { - Report(("mfw_btips_oppcEncapsulateExchange: Can't pull. fsPullPath too long")); - return; - } - - if (TRUE != mfw_btips_oppcBuildPullObject(&objToPull, fsPullPath, oppClient.pullBuff)) - { - Report(("mfw_btips_oppcEncapsulateExchange: Can't pull")); - return; - } - - - status = BTL_OPPC_ConnectExchangeDisconnect(oppcContext, bd_addr, &objToPush, &objToPull); - - Report(("BTL_OPPC_ConnectExchangeDisconnect() returned %s.", pBT_Status(status))); - - if (status == OB_STATUS_PENDING) - { - Report(("mfw_btips_oppcEncapsulateExchange(): Started ...")); - oppClient.operationOngoing = TRUE; - oppClient.currOper = OPPCA_OPER_ENC_EXCHANGE; - } -} - - -/*--------------------------------------------------------------------------- - * btips_oppcCallback - *--------------------------------------------------------------------------- - * - * Synopsis: This function processes OBEX Client protocol events. - * - * Return: void - * - */ -static void btips_oppcCallback(const BtlOppcEvent *Event) -{ - BD_ADDR bdAddr; - char addr[BDADDR_NTOA_SIZE]; - BtStatus status; - - switch (Event->oppcEvent->event) - { - case OPPC_EVENT_COMPLETE: - - TRACE_EVENT_P1("btips_oppcCallback: The current %s is complete.", mfw_btips_oppcGoepOpName(Event->oppcEvent->oper)); - - switch (Event->oppcEvent->oper) - { - case GOEP_OPER_CONNECT: - TRACE_EVENT_P1("btips_oppcCallback: Transport Connection has been established with %s", bdaddr_ntoa(&bdAddr, addr)); - BTL_OPPC_GetConnectedDevice(oppcContext, &bdAddr); - oppClient.state = OPPCA_CONNECTED; - oppClient.isConnected = TRUE; - break; - - case GOEP_OPER_DISCONNECT: - TRACE_EVENT("btips_oppcCallback: Transport Connection has been disconnected."); - oppClient.isConnected = FALSE; - oppClient.state = OPPCA_IDLE; - oppClient.operationOngoing = FALSE; - break; - - - case GOEP_OPER_PULL: - - switch(oppClient.currOper) - { - case OPPCA_OPER_BASIC_PULL: - oppClient.operationOngoing = FALSE; - break; - - case OPPCA_OPER_BASIC_EXCHANGE: - oppClient.operationOngoing = FALSE; - break; - } - - break; - - - case GOEP_OPER_PUSH: - - switch(oppClient.currOper) - { - case OPPCA_OPER_BASIC_PUSH: - oppClient.operationOngoing = FALSE; - break; - } - break; - } - break; - - case OPPC_EVENT_ABORTED: - - UI_DISPLAY(("btips_oppcCallback: %s operation failed.", mfw_btips_oppcGoepOpName(Event->oppcEvent->oper))); - break; - - case OPPC_EVENT_TP_CONNECTED: - - BTL_OPPC_GetConnectedDevice(oppcContext, &bdAddr); - UI_DISPLAY(("btips_oppcCallback: Transport Connection is up to %s.", bdaddr_ntoa(&bdAddr, addr))); - - oppClient.state = OPPCA_TP_CONNECTED; - oppClient.isConnected = TRUE; - break; - - case OPPC_EVENT_TP_DISCONNECTED: - - UI_DISPLAY(("btips_oppcCallback: Transport Connection has been disconnected.")); - - - oppClient.isConnected = FALSE; - oppClient.operationOngoing = FALSE; - - if (oppClient.state != OPPCA_DISABLING) - { - oppClient.state = OPPCA_IDLE; - } - break; - - - case OPPC_EVENT_DISCOVERY_FAILED: - - UI_DISPLAY(("btips_oppcCallback: Discovery Failure.")); - oppClient.state = OPPCA_IDLE; - break; - - case OPPC_EVENT_NO_SERVICE_FOUND: - - UI_DISPLAY(("btips_oppcCallback: No OBEX Service Found.")); - oppClient.state = OPPCA_IDLE; - break; - - - case OPPC_EVENT_OBJECT_PROGRESS: - - UI_DISPLAY(("btips_oppcCallback: progress bar ...")); - - break; - - - case OPPC_EVENT_DISABLED: - - UI_DISPLAY(("btips_oppcCallback: Receiving OPPC_EVENT_DISABLED.")); - - if (OPPCA_DISABLING == oppClient.state) - { - status = BTL_OPPC_Destroy(&oppcContext); - - Report(("BTL_OPPC_Destroy() returned %s.", pBT_Status(status))); - } - - oppClient.state = OPPCA_IDLE; - break; - - default: - - UI_DISPLAY(("btips_oppcCallback: Unexpected event: %i", Event->oppcEvent->event)); - break; - } -} - - -/*--------------------------------------------------------------------------- - * mfw_btips_oppcGoepOpName - *--------------------------------------------------------------------------- - * - * Synopsis: Return a pointer to the name of the current operation. - * - * Return: ASCII String pointer. - * - */ -static const char *mfw_btips_oppcGoepOpName(GoepOperation Op) -{ - switch (Op) - { - case GOEP_OPER_PUSH: - return "Push"; - case GOEP_OPER_PULL: - return "Pull"; - case GOEP_OPER_CONNECT: - return "Connect"; - case GOEP_OPER_DISCONNECT: - return "Disconnect"; - case GOEP_OPER_ABORT: - return "Abort"; - case GOEP_OPER_DELETE: - return "Delete"; - case GOEP_OPER_SETFOLDER: - return "Set Folder"; - } - return "Unknown"; -} - - -/*--------------------------------------------------------------------------- - * mfw_btips_oppcBuildPushObject() - * - * Synopsis: Build push object - * - * Return: TRUE - success FALSE - failed - * - */ -static BOOL mfw_btips_oppcBuildPushObject(BtlObject *objToPush, const char *fsPath, char *buff) -{ - if (oppClient.objLocation == BTL_OBJECT_LOCATION_MEM) - { - if (TRUE != mfw_btips_oppcConvertToMemPushObject(objToPush, fsPath, buff)) - { - return FALSE; - } - } - else if (oppClient.objLocation == BTL_OBJECT_LOCATION_FS) - { - mfw_btips_oppcSetFsPushObject(objToPush, fsPath); - } - - return TRUE; -} - - -/*--------------------------------------------------------------------------- - * mfw_btips_oppcBuildPullObject() - * - * Synopsis: Build push object - * - * Return: TRUE - success FALSE - failed - * - */ -static BOOL mfw_btips_oppcBuildPullObject(BtlObject *objToPull, const char *fsPath, char *buff) -{ - if (oppClient.objLocation == BTL_OBJECT_LOCATION_MEM) - { - mfw_btips_oppcSetMemPullObject(objToPull, fsPath, buff); - } - else if (oppClient.objLocation == BTL_OBJECT_LOCATION_FS) - { - mfw_btips_oppcSetFsPullObject(objToPull, fsPath); - } - - return TRUE; -} - - -/*--------------------------------------------------------------------------- - * mfw_btips_oppcConvertToMemPushObject() - * - * Synopsis: Function for testing OPP from memory objects. Convert file object to memory object by reading the - * file and modifying proper fileds uses a static buffer, so only one such object can be supported at a time - * maximum file size is 512 KB - * - * Return: void - * - */ -static BOOL mfw_btips_oppcConvertToMemPushObject(BtlObject *obj, const char *fsPushPath, char *buff) -{ - BtFsStatus btFsStatus; - BthalFsFileDesc fd; - BTHAL_U32 numRead; - BthalFsStat FileStat; - - btFsStatus = BTHAL_FS_Stat((const BTHAL_U8 *)fsPushPath, &FileStat); - if(btFsStatus != BT_STATUS_HAL_FS_SUCCESS) - { - Report(("Client: Error - File was not found %s", fsPushPath)); - return FALSE; - } - - if (FileStat.size > OPPCA_BUFF_MAX) - { - Report(("Client: Error pushed file > %d bytes", OPPCA_BUFF_MAX)); - return FALSE; - } - - btFsStatus = BTHAL_FS_Open((const BTHAL_U8 *)fsPushPath, - BTHAL_FS_O_RDONLY | BTHAL_FS_O_BINARY, /* Read Only */ - (BthalFsFileDesc *)&fd); - - if (btFsStatus == BT_STATUS_HAL_FS_SUCCESS) - { - btFsStatus = BTHAL_FS_Read(fd, oppClient.pushBuff, OPPCA_BUFF_MAX, &numRead); - - if (btFsStatus == BT_STATUS_HAL_FS_SUCCESS) - { - Report(("Client: fsPushPath = %s, numRead = %d", fsPushPath, numRead)); - } - - BTHAL_FS_Close(fd); - - /* Extract object name from fsPath */ - OBSTORE_ExtractObjName(fsPushPath, ObPushName); - - obj->objectLocation = BTL_OBJECT_LOCATION_MEM; - obj->objectName = ObPushName; - obj->location.memLocation.memAddr = buff; - obj->location.memLocation.size = numRead; - obj->objectMimeType = "text/x-vCard"; - } - else - { - Report(("Client: Error - could not open %s", fsPushPath)); - return FALSE; - } - - return TRUE; -} - - -/*--------------------------------------------------------------------------- - * mfw_btips_oppcSetMemPullObject() - * - * Synopsis: Function for testing OPP from memory objects. - * Sets memory object fields prior to PULL operation - * - * Return: void - * - */ -static void mfw_btips_oppcSetMemPullObject(BtlObject *obj, const char *fsPullPath, char *buff) -{ - OBSTORE_ExtractObjName(fsPullPath, ObPullName); - - obj->objectLocation = BTL_OBJECT_LOCATION_MEM; - - obj->location.fsLocation.fsPath = NULL; - obj->location.memLocation.memAddr = buff; - obj->location.memLocation.size = OPPCA_BUFF_MAX; - - obj->objectMimeType = "text/x-vCard";; - obj->objectName = ObPullName; -} - - -/*--------------------------------------------------------------------------- - * mfw_btips_oppcSetFsPushObject() - * - * Synopsis: Function for testing OPP from FS Push objects. - * - * Return: void - * - */ -static void mfw_btips_oppcSetFsPushObject(BtlObject *obj, const char *fsPushPath) -{ - OBSTORE_ExtractObjName(fsPushPath, ObPushName); - - obj->objectName = ObPushName; - obj->location.fsLocation.fsPath = fsPushPath; - - /* This should be provided by the user (i.e. this is just an example) */ - obj->objectMimeType = "text/x-vCard"; - obj->objectLocation = BTL_OBJECT_LOCATION_FS; -} - - -/*--------------------------------------------------------------------------- - * mfw_btips_oppcSetFsPullObject() - * - * Synopsis: Function for testing OPP from FS Pull objects. - * - * Return: void - * - */ -static void mfw_btips_oppcSetFsPullObject(BtlObject *obj, const char *fsPullPath) -{ - OBSTORE_ExtractObjName(fsPullPath, ObPullName); - - obj->objectName = ObPullName; - obj->location.fsLocation.fsPath = fsPullPath; - obj->objectMimeType = "text/x-vCard"; - obj->objectLocation = BTL_OBJECT_LOCATION_FS; -} - -/*--------------------------------------------------------------------------- - * mfw_btips_oppcCallback - *--------------------------------------------------------------------------- - * - * Synopsis: This function processes OBEX client protocol events. - * - * Return: void - * - */ -void mfw_btips_oppcCallback(T_BTIPS_MMI_IND *para) -{ - -} - -/******************************************************************************* - - $Function: mfw_btips_oppcPopulateFiles - - $Description:Populates file names into the array - - $Returns: The count of the files in the directory - - $Arguments: file_names:Pointer to the arrayto store file names - max_files_count:Max file counts to be stored in array -*******************************************************************************/ -int mfw_btips_oppcPopulateFiles(char **file_names, int max_files_count,char* dir_name_p) -{ - - T_FFS_DIR dir = {0}; - char dest_name_p[100] = ""; - int i, files_count = 0; - char *fileExt; - - TRACE_FUNCTION_P1("mfw_btips_oppcPopulateFiles from directory %s", dir_name_p); - - if (ffs_opendir (dir_name_p, &dir) <= 0) - { - TRACE_ERROR("Could not open Dir"); - - files_count = 0; - } - //Release previous allocated memory before allocating again - mfw_btips_oppcUnpopulateFiles(file_names); - //read the file names - //file_count will be used to populate the array index - for (i = 0; ffs_readdir (&dir, dest_name_p, 100) > 0x0; i++) - { - if((strcmp(dest_name_p, ".") == 0) || (strcmp(dest_name_p, "..") == 0)) - continue; - TRACE_FUNCTION_P1("Reading Dir - %s",dest_name_p); - (file_names[files_count]) = (char*)mfwAlloc(strlen(dest_name_p) + 1); - if(file_names[files_count] != NULL) - { - #if 0 - //Retrieve file extension.Store only the supported file formats in array - fileExt =mfw_btips_oppcGetExtension(dest_name_p); - //List the MP3 files also.Mp3 files hsould not be listed or ULC - if ( (strcmp(fileExt, "mp3") == 0)) - { - strcpy (file_names[files_count], dest_name_p); - files_count++; - } - else if ( (strcmp(fileExt, "wav")== 0)) - { - strcpy (file_names[files_count], dest_name_p); - files_count++; - } - else if ( (strcmp(fileExt, "pcm")== 0)) - { - strcpy (file_names[files_count], dest_name_p); - files_count++; - } - else if(files_count >= max_files_count) - break; - #endif - strcpy (file_names[files_count], dest_name_p); - TRACE_FUNCTION_P1("file_names - %s", file_names[files_count]); - files_count++; - if(files_count >= max_files_count) - break; - } - else - { - //files_count = 0; - } - - } - //Closing the directory aa per the new FFS logic - ffs_closedir(dir); - - TRACE_EVENT_P1("read files_count is %d",files_count); - TRACE_FUNCTION_P1("read files_count is %d",files_count); - return files_count; -} -/******************************************************************************* - - $Function: mfw_btips_oppcUnpopulateFiles - - $Description:Frees the memory allocated for the array - $Returns: None - - $Arguments: file_names:Pointer to the arrayto store file names - -*******************************************************************************/ -void mfw_btips_oppcUnpopulateFiles(char **file_names) -{ - int i; - TRACE_FUNCTION("mfw_btips_oppcUnpopulateFiles"); - mfw_BtipsReport("mfw_btips_oppcUnpopulateFiles"); - - //Free the allocated memory for file names - for (i = 0; i<OPPC_MAX_FILES; i++) - { - if(file_names[i]) - { - mfwFree((U8 *)file_names[i],(U16)strlen(file_names[i]) + 1); - } - file_names[i]=NULL; - } - -} - -/******************************************************************************* - - $Function: mfw_btips_oppcGetExtension - - $Description: public function to retrieve the extension of a file - - $Returns:Extention of the filename - - $Arguments: scr- Filename - -*******************************************************************************/ - char *mfw_btips_oppcGetExtension(char *src) -{ - int i,len; - - TRACE_FUNCTION("mfw_btips_oppcGetExtension"); - mfw_BtipsReport("mfw_btips_oppcGetExtension"); - len = strlen(src); - for(i = 0; i < len; i++){ - if(src[i] == '.'){ - return (src+i+1); - } - } - return (src+i); -} -/******************************************************************************* - - $Function: mfw_btips_oppcGetNumFiles - - $Description: returns the file count - - $Returns: Count of the Midi files - - $Arguments: None - -*******************************************************************************/ -int mfw_btips_oppcGetNumFiles(void) -{ - TRACE_FUNCTION_P1("mfw_btips_oppcGetNumFiles -oppc_files_count - %d", oppc_files_count); - if(oppc_files_count<=0) - return 0; - else - return oppc_files_count; - -} -/******************************************************************************* - - $Function: mfw_btips_oppcGetFileName - - $Description: Returns the file name - - $Returns: Name of the file - - $Arguments: index:The index of the file, whose name has to be retrieved - -*******************************************************************************/ - -char* mfw_btips_oppcGetFileName(UBYTE index) -{ - - TRACE_FUNCTION_P2("oppc_file_names[%d] is %s",index,(char *)oppc_file_names[index]); - return (char *) oppc_file_names[index]; -} -/******************************************************************************* - - $Function: mfw_btips_oppcGetConnectDevice - - $Description: Returns the TRUE when succeeds - $Returns: TRUE or FALSE - - $Arguments: - -*******************************************************************************/ - -BOOL mfw_btips_oppcGetConnectedDevice (BD_ADDR *bdAddr, U8 *name) -{ - BtStatus status; - char bdaddrstring[BDADDR_NTOA_SIZE]; - - status = BTL_OPPC_GetConnectedDevice (oppcContext, bdAddr); - bdaddr_ntoa(bdAddr,bdaddrstring); - TRACE_FUNCTION_P1("mfw_btips_ftpsGetConnectDevice OPPC %s ",bdaddrstring); - - if (status == BT_STATUS_SUCCESS) - { - mfw_btips_bmgGetDeviceName (bdAddr, name); - TRACE_FUNCTION_P1("mfw_btips_oppcGetConnectDevice OPPC name %s ",name); - return TRUE; - } - return FALSE; -} - -void mfw_btips_oppc_Disconnect(void) -{ - BtStatus status; - - if (oppClient.isConnected == TRUE) - { - status = BTL_OPPC_Disconnect(oppcContext); - Report(("BTL_OPPC_Disconnect() returned %s.", pBT_Status(status))); - } - else - { - Report(("mfw_btips_oppc_Disconnect: Client is not connected!")); - } -} - - -#endif -
--- a/src/ui/mfw/mfw_BtipsOppc.h Tue Jan 19 05:23:24 2021 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,53 +0,0 @@ -#ifndef DEF_MFW_BTIPS_OPPC_H -#define DEF_MFW_BTIPS_OPPC_H -/* ========================================================= -* Texas Instruments OMAP(TM) Platform Software -* (c) Copyright Texas Instruments, Incorporated. All Rights Reserved. -* -* Use of this software is controlled by the terms and conditions found -* in the license agreement under which this software has been supplied. -* ========================================================== */ -/* - $Project name: Basic Bluetooth MMI - $Project code: - $Module: Bluetooth BMG MFW - $File: Mfw_BtipsA2dp.h - $Revision: 1.0 - $Author: Texas Instruments - $Date: 26/06/07 - -******************************************************************************** - - Description: - - This module provides the BTIPS A2DP APPlication functionality. - -******************************************************************************** - $History: Mfw_BtipsA2dp.h - - 26/06/07 Sasken original version - - $End - -*******************************************************************************/ - -/* Maximum files to be displayed in the MMI */ -#define OPPC_MAX_FILES 10 -//Number of files in content directory. - - -/*Function Declarations*/ -int mfw_btips_oppcPopulateFiles(char **file_names, int max_files_count, - char* dir_name_p); - -void mfw_btips_oppcUnpopulateFiles(char **file_names); - char *mfw_btips_oppcGetExtension(char *src); - int mfw_btips_oppcGetNumFiles(void); - char* mfw_btips_oppcGetFileName(UBYTE index); - BOOL mfw_btips_oppcGetConnectedDevice (BD_ADDR *bdAddr, U8 *name); - void mfw_btips_oppc_Disconnect(void); - - -#endif - -
--- a/src/ui/mfw/mfw_BtipsOpps.c Tue Jan 19 05:23:24 2021 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,866 +0,0 @@ -/* ========================================================= -* Texas Instruments OMAP(TM) Platform Software -* (c) Copyright Texas Instruments, Incorporated. All Rights Reserved. -* -* Use of this software is controlled by the terms and conditions found -* in the license agreement under which this software has been supplied. -* ========================================================== */ -/* - $Project name: Basic Bluetooth MMI - $Project code: - $Module: Bluetooth BMG MFW - $File: mfw_BtipsOpps.c - $Revision: 1.0 - $Author: Texas Instruments - $Date: 26/06/07 - -******************************************************************************** - - Description: - - This module provides the BTIPS BMG APPlication functionality. - -******************************************************************************** - $History: mfw_BtipsOpps.c - - 26/06/07 Sasken original version - - $End - -*******************************************************************************/ - - - - -/******************************************************************************* - - Include files - -*******************************************************************************/ - -#define ENTITY_MFW -/* includes */ - -#include <string.h> - -#if defined (NEW_FRAME) - -#include "typedefs.h" -#include "vsi.h" -#include "pei.h" -#include "custom.h" -#include "gsm.h" -#include "prim.h" - -#else - -#include "STDDEFS.H" -#include "custom.h" -#include "gsm.h" -#include "vsi.h" - -#endif - -#ifdef FF_MMI_BTIPS_APP -#include "btl_bmg.h" - -/* Macro for sending events to UI - meanwhile, trace message to PCO Viewer */ -extern int vsi_o_state_ttrace ( const char * const format, ... ); -#define UI_DISPLAY(s) vsi_o_state_ttrace s - -#include "osapi.h" -#include "btl_common.h" -#include "debug.h" - -#include "btl_opps.h" -#include "btl_config.h" -#include "bthal_config.h" -#include "bthal_fs.h" - -#include "Mfw_mfw.h" -#include "Mfw_Btips.h" - - - -/******************************************************************************** - * - * Constants - * - *******************************************************************************/ - -#define OPPSA_DEFAULT_VCARD_NAME "mycard.vcf" -#define OPPSA_ACCEPT_DEFAULT_DIR "/MfwBtDemo" - -#define OPPSA_DEFAULT_FULL_NAME "/MfwBtDemo/default/mycard.vcf" - -#define OPPSA_SERVER_NAME "OBEX Object Push" - -#define OPPSA_DEFAULT_FULL_DIR "/MfwBtDemo" - -#define OPPSA_NEW_PUSH_NAME "pushed_file.vcf"//sundeep - -#define OPPSA_PULL_USE_DEFAULT_OBJ (0x01)//sundeep -#define OPPSA_PULL_USE_NEW_OBJ (0x02)//sundeep -#define OPPSA_NEW_VCARD_NAME "mycard_t.vcf" -#define OPPSA_NEW_FULL_NAME "/QbInbox/default_object/mycard_t.vcf" -typedef U8 OppsaPullUseObject; - - /******************************************************************************* - * - * Macro definitions - * - ******************************************************************************/ -#define OPPSA_BUFF_MAX (1 * 512) - - -#define OPPSA_CHECK_OBJ_LOCATION(objectLocation) \ - ((objectLocation == BTL_OBJECT_LOCATION_FS) || \ - (objectLocation == BTL_OBJECT_LOCATION_MEM)) -//sundeep -static char userPushFileName[BTHAL_FS_MAX_FILE_NAME_LENGTH + 1] = {'\0'}; -static char userPushPath[BTHAL_FS_MAX_PATH_LENGTH + 1] = {'\0'}; -static char userPushFsPath[BTHAL_FS_MAX_FILE_NAME_LENGTH + BTHAL_FS_MAX_PATH_LENGTH + 1] = {'\0'}; - - -/******************************************************************************* - * - * OPP External Function prototypes - * - ******************************************************************************/ -#if 1 -void mfw_btips_oppsInit(void); -void mfw_btips_oppsDeinit(void); -void mfw_btips_opps_AbortServer(void); -void mfw_btips_opps_Disconnect(void); -void mfw_btips_opps_GetConnectedDevice(void); -BOOL mfw_btips_opps_GetSecurityLevel(void); -BOOL mfw_btips_opps_SetSecurityLevel(BtSecurityLevel level); -void mfw_btips_oppsAcceptObjectRequest(BOOL accept); -void OPPSA_SetObjLocation(BtlObjectLocation objLocation); -#endif - - -/*------------------------------------------------------------------------------- - * OppsaState type - * - * Defines the OPPS current state. - */ -typedef U8 OppsaState; - -#define OPPSA_IDLE 0x00 /* OBEX and Transport disconnected */ -#define OPPSA_CONNECTING 0x01 /* OBEX connecting */ -#define OPPSA_TP_CONNECTED 0x02 /* Transport connected */ -#define OPPSA_CONNECTED 0x03 /* OBEX connected */ -#define OPPSA_DISCONNECTING 0x04 /* OBEX disconnecting */ -#define OPPSA_TP_DISCONNECTING 0x05 /* Transport disconnecting */ -#define OPPSA_DISABLING 0x06 /* OBEX and Transport disabling */ - - -typedef struct _OppsaData -{ - OppsaState state; - - BOOL isConnected; - - BOOL operationOngoing; - - BtSecurityLevel securityLevel; - - OppsOperation serverOperation; - - BtlObjectLocation objLocation; - - /* Memory Objects */ - char pushBuff[OPPSA_BUFF_MAX]; - char pullBuff[OPPSA_BUFF_MAX]; - -} OppsaData; - - -/******************************************************************************** - * - * Globals - * - *******************************************************************************/ - -static OppsaData oppServer; - -static BtlOppsContext *oppsContext = 0; - - -/******************************************************************************* - * - * Internal Function prototypes - * - ******************************************************************************/ -static void btips_oppsCallback(const BtlOppsEvent *Event); -static const char *mfw_btips_oppsGoepOpName(GoepOperation Op); -//static void mfw_btips_oppsSetDefaultObject(BtlObject *obj, const char *ObName, const char* fullPath);//sundeep -static void mfw_btips_oppsSetDefaultObject(BtlObject *obj, OppsaPullUseObject useObj); -static void mfw_btips_oppsSetToMemObject(BtlObject *obj, char *buff); -static void mfw_btips_oppsSetToFsObject(BtlObject *obj, char *userPushFileName, char *userPushPath); -static void mfw_btips_oppsCreateDefaultVCardFile(void); -BOOL mfw_btips_oppsGetConnectedDevice (BD_ADDR *bdAddr, U8 *name); -BOOL mfw_btips_OppsDisconnect (); - -/*--------------------------------------------------------------------------- - * mfw_btips_oppsInit - *--------------------------------------------------------------------------- - * - * Synopsis: Initialize the OBEX server for the OPP application - * and the Object Store. - * - * Return: voidOppsaPullUseObject useObj - * - */ -void mfw_btips_oppsInit(void) -{ - BtStatus status; - BtlObject serverObject; - - oppServer.securityLevel = BSL_NO_SECURITY; - oppServer.state = OPPSA_IDLE; - oppServer.isConnected = FALSE; - oppServer.operationOngoing = FALSE; - oppServer.objLocation = BTL_OBJECT_LOCATION_FS; - - status = BTL_OPPS_Create((BtlAppHandle *)0, btips_oppsCallback, &oppServer.securityLevel, &oppsContext); - Report(("BTL_OPPS_Create() returned %s.",pBT_Status(status))); - - mfw_btips_oppsCreateDefaultVCardFile(); - - //mfw_btips_oppsSetDefaultObject(&serverObject, OPPSA_DEFAULT_VCARD_NAME, OPPSA_DEFAULT_FULL_NAME);//sundeep - mfw_btips_oppsSetDefaultObject(&serverObject, OPPSA_PULL_USE_DEFAULT_OBJ); - status = BTL_OPPS_SetDefaultObject(&serverObject); - Report(("BTL_OPPS_SetDefaultObject() returned %s.",pBT_Status(status))); - - status = BTL_OPPS_Enable(oppsContext, "OPPS Server", BTL_OPPS_SUPPORTED_FORMATS_ANY); - Report(("BTL_OPPS_Enable() returned %s.",pBT_Status(status))); -} - - -/*--------------------------------------------------------------------------- - * mfw_btips_oppsDeinit - *--------------------------------------------------------------------------- - * - * Synopsis: Deinitialize the OBEX Server protocol. - * - * Return: voidOPPSA_PULL_USE_DEFAULT_OBJ - * - */ - -void mfw_btips_oppsDeinit(void) -{ - BtStatus status; - - status = BTL_OPPS_Disable(oppsContext); - - Report(("BTL_OPPS_Disable() returned %s.",pBT_Status(status))); - - if (status == BT_STATUS_SUCCESS) - { - status = BTL_OPPS_Destroy(&oppsContext); - - Report(("BTL_OPPS_Destroy() returned %s.", pBT_Status(status))); - - oppServer.state = OPPSA_IDLE; - oppServer.isConnected = FALSE; - oppServer.operationOngoing = FALSE; - } - else - { - oppServer.state = OPPSA_DISABLING; - } -} - - -/*--------------------------------------------------------------------------- - * mfw_btips_opps_AbortServer - *--------------------------------------------------------------------------- - * - * Synopsis: Requests the current operation to be aborted. - * - * Return: void - * - */ -void mfw_btips_opps_AbortServer(void) -{ - BtStatus status; - - if (oppServer.operationOngoing == TRUE) - { - status = BTL_OPPS_Abort(oppsContext, OBRC_CONFLICT); - Report(("BTL_OPPS_Abort() returned %s.",pBT_Status(status))); - } - else - { - Report(("mfw_btips_opps_AbortServer: No ongoing OPP operation!")); - } -} - - -/*--------------------------------------------------------------------------- - * mfw_btips_opps_Disconnect - *--------------------------------------------------------------------------- - * - * Synopsis: Disconnects - * - */ -void mfw_btips_opps_Disconnect(void) -{ - BtStatus status; - - if (oppServer.isConnected == TRUE) - { - status = BTL_OPPS_Disconnect(oppsContext); - Report(("BTL_OPPS_Disconnect() returned %s.", pBT_Status(status))); - } - else - { - Report(("mfw_btips_opps_Disconnect: Server is not connected!")); - } -} - - - - -/*--------------------------------------------------------------------------- - * mfw_btips_opps_SetSecurityLevel - * - * Synopsis: Set the OPP Server security level. - * - * Return: void - * - */ -BOOL mfw_btips_opps_SetSecurityLevel(BtSecurityLevel level) -{ - BtStatus status; - BtSecurityLevel securityLevel; - BOOL ret_val; - - securityLevel = oppServer.securityLevel; - - if (securityLevel & level) - { - securityLevel &= (~level); - ret_val = FALSE; - } - else - { - securityLevel |= level; - ret_val = TRUE; - } - - status = BTL_OPPS_SetSecurityLevel(oppsContext, &securityLevel); - - Report(("BTL_OPPS_SetSecurityLevel() returned %s.", pBT_Status(status))); - - if (status == BT_STATUS_SUCCESS) - { - oppServer.securityLevel = securityLevel; - } - - return ((status == BT_STATUS_SUCCESS) ? (ret_val) : (!ret_val)); -} - - -/*--------------------------------------------------------------------------- - * mfw_btips_opps_GetSecurityLevel - *--------------------------------------------------------------------------- - * - * Synopsis: Gets security level for the given OPPC context. - * - * Return: TRUE if security level is ON, else FALSE. - * - */ -BOOL mfw_btips_opps_GetSecurityLevel(void) -{ - BtStatus status; - BtSecurityLevel securityLevel; - - status = BTL_OPPS_GetSecurityLevel(oppsContext, &securityLevel); - - Report(("BTL_OPPS_GetSecurityLevel() returned %s.",pBT_Status(status))); - - switch (securityLevel) - { - case 0: - Report(("Security level: BSL_NO_SECURITY")); - break; - case 1: - Report(("Security level: BSL_AUTHENTICATION_IN")); - break; - case 2: - Report(("Security level: BSL_AUTHORIZATION_IN")); - break; - case 4: - Report(("Security level: BSL_ENCRYPTION_IN")); - break; - case 3: - Report(("Security level: BSL_AUTHENTICATION_IN")); - Report(("and BSL_AUTHORIZATION_IN")); - break; - case 5: - Report(("Security level: BSL_AUTHENTICATION_IN")); - Report(("and BSL_ENCRYPTION_IN")); - break; - case 6: - Report(("Security level: BSL_AUTHORIZATION_IN")); - Report(("and BSL_ENCRYPTION_IN")); - break; - case 7: - Report(("Security level: BSL_AUTHENTICATION_IN")); - Report(("and BSL_AUTHORIZATION_IN")); - Report(("and BSL_ENCRYPTION_IN")); - break; - default: - Report(("Error: Wrong security level")); - break; - - } - - return ((status == BT_STATUS_SUCCESS) ? (TRUE) : (FALSE)); -} - - -/*--------------------------------------------------------------------------- - * OPPSA_AcceptObjectRequest - *--------------------------------------------------------------------------- - * - * Synopsis: Accept the pending object request. - * - * Return: void - * - */ -void mfw_btips_oppsAcceptObjectRequest(BOOL accept) -{ - BtStatus status; - BtlObject serverObject; - - TRACE_FUNCTION_P1("mfw_btips_oppsAcceptObjectRequest - %d", accept); - if (TRUE != OPPSA_CHECK_OBJ_LOCATION(oppServer.objLocation)) - { - Report(("OPPSA_AcceptObjectRequest: Invalid objectLocation")); - return; - } - - if (accept == FALSE) - { - mfw_btips_oppsSetToFsObject(&serverObject, userPushFileName, OPPSA_ACCEPT_DEFAULT_DIR); - - status = BTL_OPPS_AcceptObjectRequest(oppsContext, FALSE, &serverObject); - - Report(("BTL_OPPS_AcceptObjectRequest() returned %s.", pBT_Status(status))); - } - else - { - if (oppServer.serverOperation == GOEP_OPER_PUSH) - { - if (oppServer.objLocation == BTL_OBJECT_LOCATION_MEM) - { - mfw_btips_oppsSetToMemObject(&serverObject, oppServer.pushBuff); - } - else if (oppServer.objLocation == BTL_OBJECT_LOCATION_FS) - { - mfw_btips_oppsSetToFsObject(&serverObject, userPushFileName, OPPSA_ACCEPT_DEFAULT_DIR); - } - } - else if (oppServer.serverOperation == GOEP_OPER_PULL) - { - if (oppServer.objLocation == BTL_OBJECT_LOCATION_MEM) - { - mfw_btips_oppsSetToMemObject(&serverObject, oppServer.pullBuff); - } - else if (oppServer.objLocation == BTL_OBJECT_LOCATION_FS) - { - mfw_btips_oppsSetToFsObject(&serverObject, userPushFileName, OPPSA_ACCEPT_DEFAULT_DIR); - } - } - - status = BTL_OPPS_AcceptObjectRequest(oppsContext, accept, &serverObject); - - Report(("BTL_OPPS_AcceptObjectRequest() returned %s.", pBT_Status(status))); - } -} - - -/*--------------------------------------------------------------------------- - * OPPSA_SetObjLocation - *--------------------------------------------------------------------------- - * - * Synopsis: Set the object Location (Memory or FS) - * - * Return: None - * - */ -void OPPSA_SetObjLocation(BtlObjectLocation objLocation) -{ - oppServer.objLocation = objLocation; -} - - -/*--------------------------------------------------------------------------- - * btips_oppsCallback - *--------------------------------------------------------------------------- - * - * Synopsis: This function processes OBEX server protocol events. - * - * Return: void - * - */ -void btips_oppsCallback(const BtlOppsEvent *Event) -{ - /* Local variables */ - static BD_ADDR bdAddr; - char addr[BDADDR_NTOA_SIZE]; - BtStatus status = BT_STATUS_FAILED; - BtlBmgDeviceRecord record; - T_BTIPS_MMI_IND btips_mmi_ind; - - btips_mmi_ind.mfwBtipsEventType = MFW_BTIPS_OPPS_EVENT; - - TRACE_EVENT_P1("btips_oppsCallback %d", Event->oppsEvent->event); - /* Save the GOEP operation for future use */ - oppServer.serverOperation = Event->oppsEvent->oper; - - switch (Event->oppsEvent->event) - { - case OPPS_EVENT_START: - TRACE_EVENT_P1("Server: Starting %s operation.", mfw_btips_oppsGoepOpName(Event->oppsEvent->oper)); - oppServer.operationOngoing = TRUE; - break; - - case OPPS_EVENT_COMPLETE: - TRACE_EVENT_P1("Server: %s operation complete.", mfw_btips_oppsGoepOpName(Event->oppsEvent->oper)); - oppServer.operationOngoing = FALSE; -//#if 0 - if (Event->oppsEvent ->oper == GOEP_OPER_PUSH) - { - btips_mmi_ind.data.oppsBtEvent.mfwOppsEventType = MFW_BTIPS_OPPS_PUSH_COMP_EVENT; - } - if(Event->oppsEvent ->oper == GOEP_OPER_PULL) - { - btips_mmi_ind.data.oppsBtEvent.mfwOppsEventType = MFW_BTIPS_OPPS_PULL_COMP_EVENT; - } - btipsNotifyMFW(&btips_mmi_ind); -#if 0 - if (Event->oppsEvent ->oper == GOEP_OPER_DISCONNECT) - { - btips_mmi_ind.data.oppsBtEvent.mfwOppsEventType = MFW_BTIPS_OPPS_DISCONNECT_EVENT; - } - btipsNotifyMFW(&btips_mmi_ind); -#endif - break; - - case OPPS_EVENT_ABORTED: - TRACE_EVENT_P1("Server: GOEP %s operation failed or aborted.", mfw_btips_oppsGoepOpName(Event->oppsEvent->oper)); - oppServer.isConnected = FALSE; - oppServer.operationOngoing = FALSE; - oppServer.state = OPPSA_IDLE; - break; - - case OPPS_EVENT_TP_CONNECTED: - BTL_OPPS_GetConnectedDevice(oppsContext, &bdAddr); - TRACE_EVENT_P1("Server: Transport Connection is up to %s.", bdaddr_ntoa(&bdAddr, addr)); - oppServer.state = OPPSA_TP_CONNECTED; - oppServer.isConnected = TRUE; - break; - - case OPPS_EVENT_TP_DISCONNECTED: - TRACE_EVENT("Server: Transport Connection has been disconnected."); - oppServer.isConnected = FALSE; - oppServer.operationOngoing = FALSE; - if (oppServer.state != OPPSA_DISABLING) - { - oppServer.state = OPPSA_IDLE; - } - break; - - case OPPS_EVENT_OBJECT_PROGRESS: - TRACE_EVENT("OPPSA_Callback: progress bar ..."); - break; - - case OPPS_EVENT_OBJECT_REQUEST: - TRACE_EVENT_P1("Server: Incoming object request: %s operation.", mfw_btips_oppsGoepOpName(Event->oppsEvent->oper)); - TRACE_EVENT_P3("Server: Name: %s, Type: %s, Size: %u.", Event->oppsEvent->info.request.name, - Event->oppsEvent->info.request.type, Event->oppsEvent->info.request.objectLen); - TRACE_EVENT("Server: Please accept or reject!"); - status = BTL_BMG_DDB_FindRecord(bdAddr, &record); - Report(("BTL_BMG_DDB_FindRecord() returned %s.", pBT_Status(status))); - btips_mmi_ind.data.oppsBtEvent.mfwOppsEventType = Event->oppsEvent ->oper; - strcpy(btips_mmi_ind.data.oppsBtEvent.p.opps.deviceName, record.name); - strcpy(btips_mmi_ind.data.oppsBtEvent.p.opps.oppObjectName, Event ->oppsEvent->info.request.name); -#if 1 - btipsNotifyMFW(&btips_mmi_ind); -#else - mfw_btips_oppsAcceptObjectRequest(TRUE); -#endif - break; - - case OPPS_EVENT_DISABLED: - UI_DISPLAY(("Server: Receiving OPPS_EVENT_DISABLED.")); - if (OPPSA_DISABLING == oppServer.state) - { - status = BTL_OPPS_Destroy(&oppsContext); - Report(("BTL_OPPS_Destroy() returned %s.", pBT_Status(status))); - } - oppServer.state = OPPSA_IDLE; - break; - - default: - UI_DISPLAY(("Server: Unexpected event: %i", Event->oppsEvent->event)); - break; - - } -} - -/*--------------------------------------------------------------------------- - * mfw_btips_oppsCallback - *--------------------------------------------------------------------------- - * - * Synopsis: This function processes OBEX server protocol events. - * - * Return: void - * - */ -void mfw_btips_oppsCallback(T_BTIPS_MMI_IND *para) -{ - - MfwBtOppsEvent oopsBtEvent = para->data.oppsBtEvent; - TRACE_FUNCTION_P1("mfw_btips_oppsCallback %d", oopsBtEvent.mfwOppsEventType); - - switch(oopsBtEvent.mfwOppsEventType) - { - case OPPS_OPER_PUSH: - mfw_btips_signal(E_BTIPS_OPPS_PUSH_EVENT, para); - break; - - case OPPS_OPER_PULL: - mfw_btips_signal(E_BTIPS_OPPS_PULL_EVENT, para); - break; -//#if 0 - case MFW_BTIPS_OPPS_PUSH_COMP_EVENT: - mfw_btips_signal(E_BTIPS_OPPS_PUSH_COMP_EVENT, para); - break; - - case MFW_BTIPS_OPPS_PULL_COMP_EVENT: - mfw_btips_signal(E_BTIPS_OPPS_PULL_COMP_EVENT, para); -//#endif - } - -} - -/*--------------------------------------------------------------------------- - * mfw_btips_oppsGoepOpName - *--------------------------------------------------------------------------- - * - * Synopsis: Return a pointer to the name of the current operation. - * - * Return: ASCII String pointer. - * - */ -static const char *mfw_btips_oppsGoepOpName(GoepOperation Op) -{ - switch (Op) - { - case GOEP_OPER_PUSH: - return "Push"; - case GOEP_OPER_PULL: - return "Pull"; - case GOEP_OPER_CONNECT: - return "Connect"; - case GOEP_OPER_DISCONNECT: - return "Disconnect"; - case GOEP_OPER_ABORT: - return "Abort"; - case GOEP_OPER_DELETE: - return "Delete"; - case GOEP_OPER_SETFOLDER: - return "Set Folder"; - } - return "Unknown"; -} - - -/*--------------------------------------------------------------------------- - * mfw_btips_oppsSetDefaultObject() - * - * Synopsis: Function for setting the OPPS default object. - * - * Return: void - * - */ -//static void mfw_btips_oppsSetDefaultObject(BtlObject *obj, const char *ObName, const char* fullPath) -static void mfw_btips_oppsSetDefaultObject(BtlObject *obj, OppsaPullUseObject useObj) -{ - switch (useObj) - { - case OPPSA_PULL_USE_DEFAULT_OBJ: - obj->objectName = (const BtlUtf8 *)OPPSA_DEFAULT_VCARD_NAME; - obj->location.fsLocation.fsPath = (const BtlUtf8 *)OPPSA_DEFAULT_FULL_NAME; - break; - - case OPPSA_PULL_USE_NEW_OBJ: - obj->objectName = (const BtlUtf8 *)OPPSA_NEW_VCARD_NAME; - obj->location.fsLocation.fsPath = (const BtlUtf8 *)OPPSA_NEW_FULL_NAME; - break; - } - // obj->objectName = ObName; - //obj->location.fsLocation.fsPath = fullPath; - - obj->objectMimeType = "text/x-vCard"; - obj->objectLocation = oppServer.objLocation; -} - -/*--------------------------------------------------------------------------- - * mfw_btips_oppsSetToMemObject() - * - * Synopsis: Function for testing OPP from memory objects. - * Sets memory object fields prior to PULL operation - * - * Return: void - * - */ -static void mfw_btips_oppsSetToMemObject(BtlObject *obj, char *buff) -{ - obj->objectLocation = BTL_OBJECT_LOCATION_MEM; - obj->location.fsLocation.fsPath = NULL; - obj->location.memLocation.memAddr = buff; - obj->location.memLocation.size = OPPSA_BUFF_MAX; - - obj->objectMimeType = NULL; -} - -/*--------------------------------------------------------------------------- - * mfw_btips_oppsSetToFsObject() - * - * Synopsis: Function for testing OPP from memory objects. - * Sets FS object - * - * Return: void - * - */ -static void mfw_btips_oppsSetToFsObject(BtlObject *obj, char *userPushFileName, char *userPushPath) -{ - U16 len; - /* ToDo: obj->objectName - - [NULL]- pushed objects are saved in C:\QInbox location - - ["defaultPushed.vcf"] - pushed objects are saved in C:\QInbox location, - and then rename to "defaultPushed.vcf" file. - */ - - //obj->objectName = "defaultPushed.vcf"; - obj->objectName = NULL; - obj->objectMimeType = NULL; - obj->objectLocation = BTL_OBJECT_LOCATION_FS; - //obj->location.fsLocation.fsPath = OPPSA_ACCEPT_DEFAULT_DIR; - if (userPushFileName[0] == '\0') - { - OS_StrCpyUtf8(userPushFileName, (const char *)OPPSA_NEW_PUSH_NAME); - } - - userPushFsPath[0] = '\0'; - OS_StrCpyUtf8(userPushFsPath, userPushPath); - len = OS_StrLenUtf8(userPushFsPath); - userPushFsPath[len] = BTHAL_FS_PATH_DELIMITER; - userPushFsPath[++len] = '\0'; - OS_StrCatUtf8(userPushFsPath, userPushFileName); - - userPushFileName[0] = '\0'; - - obj->location.fsLocation.fsPath = (const BtlUtf8 *)userPushFsPath; -} - -/*--------------------------------------------------------------------------- - * OppsaUiCreateDefaultVCardFile - *--------------------------------------------------------------------------- - * - * Synopsis: Creates the default VCard file - * - * Return: void. - * - */ -static void mfw_btips_oppsCreateDefaultVCardFile(void) -{ - static char content[] = "BEGIN:VCARD\nVERSION:2.1\nN:Adam;Smith\nFN:Adam Smith\nTEL;WORK;VOICE:erez972-76271234\nTEL;CELL:972-9-54-785345\n \ - X-IRMC-LUID:0000000089112FB8F5ED98469F141223445D85EC0700651F055323C0104ABA16A3A82F42C81E000000D0841B0000B783C70B99B5BE4CAF782AB8DD188B6D0000DF0956010000\n \ - END:VCARD"; - - BtFsStatus btFsStatus; - BthalFsFileDesc fp; - BTHAL_U32 pNumWritten; - BTHAL_INT nSize; - - /* Creates / Overwrites the current default VCard file */ - - //BTHAL_FS_Remove(OPPSA_DEFAULT_FULL_NAME); - btFsStatus = BTHAL_FS_Open((const BTHAL_U8 *)OPPSA_DEFAULT_FULL_NAME, - BTHAL_FS_O_RDWR| BTHAL_FS_O_BINARY, (BthalFsFileDesc *)&fp); - if (BT_STATUS_HAL_FS_SUCCESS == btFsStatus) - { - BTHAL_FS_Close(fp); - return; - } - btFsStatus = BTHAL_FS_Open((const BTHAL_U8 *)OPPSA_DEFAULT_FULL_NAME, - BTHAL_FS_O_CREATE | BTHAL_FS_O_RDWR | BTHAL_FS_O_BINARY, /* Create file */ - (BthalFsFileDesc *)&fp); - if (BT_STATUS_HAL_FS_SUCCESS != btFsStatus) - { - Report(("OppsaUiCreateDefaultVCardFile(): Error - could not create Default VCard file %s.", OPPSA_DEFAULT_FULL_NAME)); - Report(("Make sure that %s directory exists !.", OPPSA_DEFAULT_FULL_DIR)); - return; - } - - nSize = OS_StrLen(content); - - if (BT_STATUS_HAL_FS_SUCCESS == BTHAL_FS_Write(fp, (void*)content, nSize, &pNumWritten)) - { - Report(("OppsaUiCreateDefaultVCardFile(): Default VCard file \"%s\" created successfully.", OPPSA_DEFAULT_FULL_NAME)); - } - else - { - Report(("OppsaUiCreateDefaultVCardFile(): Error - Unable to create default VCard file.")); - } - - - BTHAL_FS_Close(fp); - - Report(("OppsaUiCreateDefaultVCardFile(): nSize = %d, pNumWritten = %d", nSize, pNumWritten)); -} - -/******************************************************************************* - - $Function: mfw_btips_oppsGetConnectDevice - - $Description: Returns the TRUE when succeeds - $Returns: TRUE or FALSE - - $Arguments: - -*******************************************************************************/ - -BOOL mfw_btips_oppsGetConnectedDevice (BD_ADDR *bdAddr, U8 *name) -{ - BtStatus status; - - - status = BTL_OPPS_GetConnectedDevice (oppsContext, bdAddr); - - - - - if (status == BT_STATUS_SUCCESS) - { - mfw_btips_bmgGetDeviceName (bdAddr, name); - TRACE_FUNCTION_P1("mfw_btips_oppsGetConnectDevice OPPS name %s ",name); - return TRUE; - } - return FALSE; -} - - - -#endif -
--- a/src/ui/mfw/mfw_BtipsVg.c Tue Jan 19 05:23:24 2021 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,480 +0,0 @@ -/* ========================================================= -* Texas Instruments OMAP(TM) Platform Software -* (c) Copyright Texas Instruments, Incorporated. All Rights Reserved. -* -* Use of this software is controlled by the terms and conditions found -* in the license agreement under which this software has been supplied. -* ========================================================== */ -/* - $Project name: Basic Bluetooth MMI - $Project code: - $Module: Bluetooth BMG MFW - $File: Mfw_Btips.c - $Revision: 1.0 - $Author: Texas Instruments - $Date: 26/06/07 - -******************************************************************************** - - Description: - - This module provides the BTIPS BMG APPlication functionality. - -******************************************************************************** - $History: Mfw_Btips.c - - 26/06/07 Sasken original version - - $End - -*******************************************************************************/ - - - - -/******************************************************************************* - - Include files - -*******************************************************************************/ - -#define ENTITY_MFW -/* includes */ - -#include <string.h> - -#if defined (NEW_FRAME) - -#include "typedefs.h" -#include "vsi.h" -#include "pei.h" -#include "custom.h" -#include "gsm.h" -#include "prim.h" - -#else - -#include "STDDEFS.H" -#include "custom.h" -#include "gsm.h" -#include "vsi.h" - -#endif - -#ifdef FF_MMI_BTIPS_APP - -#include "osapi.h" - -/* GPF Includes */ -#include "typedefs.h" -#include "vsi.h" -//#include "../p_btt.h" - -#if BT_STACK == XA_ENABLED -#include <me.h> -#include <bttypes.h> -#include <sec.h> -#endif - -#include "btl_common.h" -#include "btl_bmg.h" -#include "debug.h" - -#include "bthal_fs.h" -#include "mfw_mfw.h" -#include "mfw_win.h" -#include "mfw_icn.h" /* included for mfw_mnu.h */ -#include "mfw_mnu.h" -#include "mfw_tim.h" -#include "mfw_kbd.h" -#include "mfw_sat.h" /* included for MmiDummy.h, included for MmiMenu.h */ - -/* BTL inclides */ -#include "hfg.h" -#include "btl_vg.h" -#include "btl_vgi.h" -#include "Mfw_Btips.h" -#include "Mfw_BtipsBmg.h" -#include "mfw_BtipsVg.h" - -static void btips_vgCallback(const BtlVgEvent *event); - -static const BtSecurityLevel noSecurity = BSL_NO_SECURITY; -static const BtlVgAudioSourcesAction noActions = {0}; -static AtAgFeatures features = HFG_FEATURE_REJECT | HFG_FEATURE_RING_TONE; - -static BOOL closingVoiceGateway = FALSE; - -static BtlVgChannelId mfwBtipsVgChannelId = BTL_VG_CHANNEL_ID_NONE; -static BtlVgContext *mfwBtipsVgContext =0; -static int audio_on_hands_free = 0; - -/*--------------------------------------------------------------------------- - * mfw_btips_vgInit - *--------------------------------------------------------------------------- - * - * Synopsis: VG application initialization. - * - * Return: NONE. - * - */ - -void mfw_btips_vgInit ( ) -{ - if (BT_STATUS_SUCCESS != BTL_VG_Create(0, btips_vgCallback, &noSecurity, &mfwBtipsVgContext)) - { - TRACE_FUNCTION("BTL_VG_Create failed"); - } - - if (BT_STATUS_PENDING != BTL_VG_Enable(mfwBtipsVgContext, 0, &features, &noActions)) - { - TRACE_FUNCTION("BTL_VG_Enable failed"); - } -} - -BOOL mfw_btips_vgGetConnectedDevice (BD_ADDR *bdAddr, U8 *name) -{ - BtStatus status; - - TRACE_FUNCTION("mfw_btips_vgGetConnectedDevice"); - - status = BTL_VG_GetConnectedDevice (mfwBtipsVgContext, mfwBtipsVgChannelId, bdAddr); - - if (status == BT_STATUS_SUCCESS) - { - mfw_btips_bmgGetDeviceName (bdAddr, name); - return TRUE; - } - return FALSE; -} - -BOOL mfw_btips_vgIsDeviceConnected (BD_ADDR bdAddr) -{ - BtRemDevState state; - - TRACE_FUNCTION("mfw_btips_vgIsDeviceConnected"); - - if (mfwBtipsVgChannelId != BTL_VG_CHANNEL_ID_NONE) - { -#if 0 - BD_ADDR connectedDev; - BTL_VG_GetConnectedDevice (mfwBtipsVgContext, mfwBtipsVgChannelId, &connectedDev) -#endif - mfw_btips_bmgGetDeviceState (&bdAddr, &state); - if (state == BDS_CONNECTED) - { - return TRUE; - } - } - return FALSE; - -} - -BOOL mfw_btips_vgConnect (BD_ADDR bdAddr) -{ - BtStatus btStatus; - - TRACE_FUNCTION("mfw_btips_vgConnect"); - - btStatus = BTL_VG_Connect (mfwBtipsVgContext, &bdAddr, BTL_VG_AUDIO_SOURCE_MODEM); - - if (BT_STATUS_IN_USE == btStatus) - { - TRACE_FUNCTION("VG APP: An SLC to a remote device already exists"); - TRACE_FUNCTION("VG APP: Disconnect or perform handover to connect to a new device"); - } - return mfw_btips_checkStatus(btStatus); -} - -BOOL mfw_btips_vgDisconnect (BD_ADDR bdAddr) -{ - BtStatus btStatus; - - TRACE_FUNCTION("mfw_btips_vgDisconnect"); - - btStatus = BTL_VG_Disconnect (mfwBtipsVgContext, mfwBtipsVgChannelId); - return mfw_btips_checkStatus(btStatus); -} - -BOOL mfw_btips_vgTransferAudioToPhone (void) -{ - BtStatus btStatus; - - TRACE_FUNCTION("mfw_btips_vgTransferAudioToPhone"); - - if ((mfwBtipsVgChannelId != BTL_VG_CHANNEL_ID_NONE) && (audio_on_hands_free == 1)) - { - btStatus = BTL_VG_DisconnectAudio (mfwBtipsVgContext, mfwBtipsVgChannelId); - } - return mfw_btips_checkStatus(btStatus); -} - -BOOL mfw_btips_vgTransferAudioToHF (void) -{ - BtStatus btStatus; - - TRACE_FUNCTION_P1("mfw_btips_vgTransferAudioToHF audio_on_hands_free=%d", audio_on_hands_free); - - if ((mfwBtipsVgChannelId != BTL_VG_CHANNEL_ID_NONE) && (audio_on_hands_free == 0)) - { - btStatus = BTL_VG_ConnectAudio (mfwBtipsVgContext, mfwBtipsVgChannelId); - } - return mfw_btips_checkStatus(btStatus); -} - -BOOL mfw_btips_vgIsAudioOnPhone (void) -{ - - TRACE_FUNCTION("mfw_btips_vgIsAudioOnPhone"); - if (audio_on_hands_free == 0) - { - return TRUE; - } - else if (mfwBtipsVgChannelId != BTL_VG_CHANNEL_ID_NONE) - { - return FALSE; - } - else - { - return TRUE; - } -} - -BOOL mfw_btips_vgIsAudioOnHF (void) -{ - if (audio_on_hands_free == 1) - { - return TRUE; - } - else if (mfwBtipsVgChannelId != BTL_VG_CHANNEL_ID_NONE) - { - return FALSE; - } - else - { - return TRUE; - } -} - -BOOL mfw_btips_vgIsHandOverPossible (void) -{ - if (audio_on_hands_free == 1) - { - return TRUE; - } - else - { - return FALSE; - } -} - -void btips_vgCallback(const BtlVgEvent *event) -{ - T_BTIPS_MMI_IND btips_mmi_ind; - BtStatus status; - char str[MFW_VG_APP_AT_STR_LEN]; - U16 strLen; - U16 scoHandle = 0; - - TRACE_FUNCTION_P1("btips_vgCallback %d", event->type); - - btips_mmi_ind.mfwBtipsEventType = MFW_BTIPS_VG_EVENT; - - switch (event->type) - { - case BTL_VG_EVENT_SLC_REQUEST: - TRACE_EVENT("VG APP: SLC request from device:"); - break; - - case BTL_VG_EVENT_ADDITIONAL_SERVICE_CONNECT_REQ: - TRACE_EVENT("VG APP: Addtional SLC request received from device:"); - break; - - case BTL_VG_EVENT_SLC_CONNECTED: - mfwBtipsVgChannelId = event->channelId; - TRACE_EVENT("VG APP: Connection established"); - /* turn off inband ring tone */ - if (BT_STATUS_SUCCESS != BTL_VG_EnableInbandRingTone(mfwBtipsVgContext, event->channelId, FALSE)) - { - TRACE_EVENT("VG_APP: Error disabling inband ring tone after SLC established"); - } - btips_mmi_ind.data.vgBtEvent.event = MFW_BTIPS_VG_CONNECT_EVENT; - - status = BTL_VG_GetConnectedDevice (mfwBtipsVgContext, event->channelId, - &(btips_mmi_ind.data.vgBtEvent.bdAddr)); - if (status == BT_STATUS_SUCCESS) - { - mfw_btips_bmgGetDeviceName (&(btips_mmi_ind.data.vgBtEvent.bdAddr), - btips_mmi_ind.data.vgBtEvent.deviceName); - - btipsNotifyMFW (&btips_mmi_ind); - } - - break; - - case BTL_VG_EVENT_SLC_DISCONNECTED: - mfwBtipsVgChannelId = BTL_VG_CHANNEL_ID_NONE; - TRACE_EVENT("VG APP: Connection lost"); - btips_mmi_ind.data.vgBtEvent.event = MFW_BTIPS_VG_DISCONNECT_EVENT; - #ifdef FF_MMI_FMRADIO_APP - if(mfw_fmRadio_isFmOverBT()) - { - /*Inform FM module of the SLC disconnection*/ - mfw_fmRadio_listenViaBT(FALSE); - mfw_fmRadio_setFmOverBT(FALSE, 0); - } - #endif - - btipsNotifyMFW (&btips_mmi_ind); - - break; - - case BTL_VG_EVENT_HANDOVER_COMPLETED: - mfwBtipsVgChannelId = event->channelId; - TRACE_EVENT("VG APP: Handover completed"); - break; - - case BTL_VG_EVENT_AUDIO_CONNECTED: - { - HfgChannel *handsfreeChannel; - BtlVgChannel *vgChannel; - CmgrHandler cmgrHandler; - scoHandle = 0x101; - btips_mmi_ind.data.vgBtEvent.event = MFW_BTIPS_VG_AUDIO_CONNECT_EVENT; -#if 0 - vgChannel = &(event->context->channels[event->channelId]); - handsfreeChannel = &(vgChannel->c.handsfreeChannel); - cmgrHandler = handsfreeChannel->cmgrHandler; - scoHandle = cmgrHandler.scoConnect->scoHciHandle; - - TRACE_EVENT_P1("VG APP: Audio connection established, scoHandle = %x", scoHandle); -#endif - audio_on_hands_free = 1; - -#ifdef FF_MMI_FMRADIO_APP - if(mfw_fmRadio_isFmOverBT()) - { - /*Send VS commands to BRF for routing FM audio to BT headset*/ - mfw_fmRadio_setFmOverBT(TRUE, scoHandle); - } -#endif - btipsNotifyMFW (&btips_mmi_ind); - - } break; - - case BTL_VG_EVENT_AUDIO_DISCONNECTED: - TRACE_EVENT("VG APP: Audio conenction lost"); - btips_mmi_ind.data.vgBtEvent.event = MFW_BTIPS_VG_AUDIO_DISCONNECT_EVENT; - - audio_on_hands_free = 0; -#ifdef FF_MMI_FMRADIO_APP - if(mfw_fmRadio_isFmOverBT()) - { - /*Inform FM module of the SLC disconnection*/ - mfw_fmRadio_listenViaBT(FALSE); - mfw_fmRadio_setFmOverBT(FALSE, 0); - } -#endif - - btipsNotifyMFW (&btips_mmi_ind); - - break; - - case BTL_VG_EVENT_PHONE_NUMBER_REQUESTED: - TRACE_EVENT("VG APP: unsupported event: BTL_VG_EVENT_PHONE_NUMBER_REQUESTED"); - break; - - case BTL_VG_EVENT_MICROPHONE_VOLUME: - TRACE_EVENT_P1("VG APP: microphone volume: %u", event->p.volume); - break; - - case BTL_VG_EVENT_SPEAKER_VOLUME: - TRACE_EVENT_P1("VG APP: speaker volume: %u", event->p.volume); - break; - - case BTL_VG_EVENT_VOICE_RECOGNITION_STATUS: - TRACE_EVENT_P1("VG APP: voice recognition is :%s", (event->p.enabled ? "enabled" : "disabled")); - break; - -#if HFG_FEATURE_RING_TONE & HFG_SDK_FEATURES - - case BTL_VG_EVENT_INBAND_RING_STATUS: - TRACE_EVENT_P1("VG APP: inband ringing is: %s", (event->p.enabled ? "enabled" : "disabled")); - break; -#endif - - case BTL_VG_EVENT_UNRECOGNIZED_AT_COMMAND: - strLen = event->p.atCommand->commandLength; - if (strLen > MFW_VG_APP_AT_STR_LEN ) - { - TRACE_EVENT("VG APP: AT Command string is too long"); - strLen = MFW_VG_APP_AT_STR_LEN - 1; - } - OS_MemCopy((U8*)str, (const U8*) event->p.atCommand->atCommand, strLen); - str[strLen] = '\0'; - TRACE_EVENT_P1("VG APP: unrecognized AT command: %s", str); - if (BT_STATUS_SUCCESS != BTL_VG_SentAtError(event->context, event->channelId, ATCME_OP_NOT_SUPPORTED)) - { - TRACE_EVENT("VG APP: BTL_VG_SentAtError failed"); - } - break; - - case BTL_VG_EVENT_VG_CONTEXT_ENABLED: - TRACE_EVENT("VG APP: VG is enabled"); - break; - - case BTL_VG_EVENT_VG_CONTEXT_DISABLED: - TRACE_EVENT("VG APP: VG is disabled"); - if (TRUE == closingVoiceGateway) - { - BtStatus status; - - status = BTL_VG_Destroy(&mfwBtipsVgContext); - TRACE_EVENT_P1("BTL_VG_Destroy returned: %s", pBT_Status(status)); - closingVoiceGateway = FALSE; - } - break; - - default: - TRACE_EVENT_P1("VG APP: Unexpected VG event: %u", event->type); - break; - } - -} -void mfw_btips_vgCallback (T_BTIPS_MMI_IND * mmiInd) -{ - MfwBtVgEvent vgBtEvent = mmiInd->data.vgBtEvent; - - TRACE_FUNCTION_P1("mfw_btips_vgCallback: Event %d", vgBtEvent.event); - - switch (vgBtEvent.event) - { - case MFW_BTIPS_VG_CONNECT_EVENT: - #ifdef FF_MMI_FMRADIO_APP - if(mfw_fmRadio_isFmOverBT()) - { - /*Automatically create the SCO for FM Radio routing - In this case Modem Audio will not be routed to the MSCI port, hence - all GSM calls will be answered on the Phone Handset ONLY*/ - mfw_btips_vgTransferAudioToHF(); - } - #endif - mfw_btips_signal(E_BTIPS_VG_CONNECT_EVENT, mmiInd); - break; - - case MFW_BTIPS_VG_DISCONNECT_EVENT: - mfw_btips_signal(E_BTIPS_VG_DISCONNECT_EVENT, mmiInd); - break; - - case MFW_BTIPS_VG_AUDIO_CONNECT_EVENT: - mfw_btips_signal(E_BTIPS_VG_AUDIO_CONNECT_EVENT, mmiInd); - break; - - case MFW_BTIPS_VG_AUDIO_DISCONNECT_EVENT: - mfw_btips_signal(E_BTIPS_VG_AUDIO_DISCONNECT_EVENT, mmiInd); - break; - } -} - -#endif -
--- a/src/ui/mfw/mfw_BtipsVg.h Tue Jan 19 05:23:24 2021 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,58 +0,0 @@ -#ifndef DEF_MFW_BTIPS_VG -#define DEF_MFW_BTIPS_VG -/* ========================================================= -* Texas Instruments OMAP(TM) Platform Software -* (c) Copyright Texas Instruments, Incorporated. All Rights Reserved. -* -* Use of this software is controlled by the terms and conditions found -* in the license agreement under which this software has been supplied. -* ========================================================== */ -/* - $Project name: Basic Bluetooth MMI - $Project code: - $Module: Bluetooth BMG MFW - $File: Mfw_BtipsVg.h - $Revision: 1.0 - $Author: Texas Instruments - $Date: 26/06/07 - -******************************************************************************** - - Description: - - This module provides the BTIPS VG APPlication functionality. - -******************************************************************************** - $History: Mfw_BtipsVg.h - - 26/06/07 Sasken original version - - $End - -*******************************************************************************/ - -/* Maximum files to be displayed in the MMI */ - -#define MFW_VG_APP_AT_STR_LEN 100 - - -BOOL mfw_btips_vgConnect (BD_ADDR bdAddr); - -BOOL mfw_btips_vgDisconnect (BD_ADDR bdAddr); - -BOOL mfw_btips_vgIsDeviceConnected (BD_ADDR bdAddr); - -BOOL mfw_btips_vgTransferAudioToPhone (void); - -BOOL mfw_btips_vgTransferAudioToPhone (void); - -BOOL mfw_btips_vgIsAudioOnPhone (void); - -BOOL mfw_btips_vgIsAudioOnHF (void); - -BOOL mfw_btips_vgIsHandOverPossible (void); -BOOL mfw_btips_vgGetConnectedDevice (BD_ADDR *bdAddr, U8 *name); - -#endif - -