/*======================================================
FILE:  AEEBTAG.h

SERVICES:  Bluetooth Audio Gateway Interface for BREW

DESCRIPTION:  Interface definitions for Audio Gateway Interface over BT

PUBLIC CLASSES: Not Applicable

INITIALIZATION AND SEQUENCING REQUIREMENTS: Not Applicable
        
        Copyright © 1999-2002 QUALCOMM Incorporated.
               All Rights Reserved.
            QUALCOMM Proprietary/GTDR
=====================================================*/
#ifndef _AEEBTAG_H_
#define _AEEBTAG_H_

#ifdef __cplusplus
extern "C" {
#endif

enum tagAEEBTAGConnectmode {
  AEEBT_AG_CONN_AG_ORIG_MODE,        /* do only page from AG , Client mode*/
  AEEBT_AG_CONN_HS_ORIG_MODE         /* do only pagescan on AG , Server Mode*/
};
#ifdef AEE_SIMULATOR
typedef unsigned AEEBTAGConnectmode;
#else
typedef int8 AEEBTAGConnectmode;
#endif


	// Blue tooth Device Address
typedef PACKED struct tagAEEBTAGInfo
{
  AEEBTAddr             bdaddr;    // Head set BT device address
  AEEBTRCServerChannel     usrvc;  // Head Set Server Channel Number
  AEEBTAGConnectmode    btMode;    // Mode of Connected
} GCCPACKED AEEBTAGInfo;

typedef int32	AEEBTAGEvent;

#define  AEEBT_EV_AG_NOEVENTS          0           // No more events from BT Stack
#define  AEEBT_EV_AG_ENABLED           1           // BT Audio Gateway Enabled
#define  AEEBT_EV_AG_DISABLED          2           // BT Audio Gateway Disable
#define  AEEBT_EV_AG_HEADSET_PICKUP    3           //  User picked up the Head set
#define  AEEBT_EV_AG_DISCONNECT_REQUEST 4          // User Disconnected the Headset
#define  AEEBT_EV_AG_AUDIO_CONNECTED   5           // Audio Channel was connecte
#define  AEEBT_EV_AG_AUDIO_DISCONNECTED 6          // Audio Channel was disconnected
#define  AEEBT_EV_AG_AUDIO_CONN_TIMEOUT 7
#define  AEEBT_EV_AG_ERROR				8				// Error occured during command processing	


typedef int32	AEEBTAGCmd;
#define	   AEEBT_CMD_RING_HEADSET		1		// Ring the headset
#define	   AEEBT_CMD_AUDIO_CONNECT		2		// Connect the Audio channel
#define	   AEEBT_CMD_SET_SPKR_GAIN		3		// Increase/decrease the Speaker gain
#define	   AEEBT_CMD_SET_HS_GAIN		4		// Increase/decrease the Headset gain
#define	   AEEBT_CMD_DISCONNECT			5		//Disconnect the Audio Gateway


// Bluetooth Audio Gateway Interface definitions


typedef struct IBTAG IBTAG;
AEEINTERFACE(IBTAG) 
{
  INHERIT_IBase(IBTAG);
  int32 (*Open)(IBTAG *po, AEEBTAGInfo* pBTAGInfo, AEECallback *pcb);
  int32 (*SendCommand)(IBTAG *po, AEEBTAGCmd cmdcode, uint32 cmdval);
  int32 (*GetEvent)(IBTAG *po, AEEBTAGEvent *evtcode);
  int32 (*GetLastError)(IBTAG *po);
};

/*=====================================================================
  DATA STRUCTURE DOCUMENTATION
======================================================================= 

AEEBTAGConnectmode

Description:
   AEEBTAGConnectmode specifies the connection mode for the Bluetooth
   device running the audio gateway profile. 

Definition:
   typedef enum tagAEEBTAGConnectmode
   {
     AEEBT_AG_CONN_AG_ORIG_MODE,
     AEEBT_AG_CONN_HS_ORIG_MODE 
   } AEEBTAGConnectmode;

Members:
     Possible Values:
      AEEBT_AG_CONN_AG_ORIG_MODE : Only page from the AG device (client mode).
      AEEBT_AG_CONN_HS_ORIG_MODE : Only scan pages from AG clients (server mode).


Comments:
   None.


See Also:
   None
======================================================================= 

AEEBTAGEvent

Description:
   AEEBTAGEvent specifies the Bluetooth Audio Gateway event. 

Definition:
   typedef int32	AEEBTAGEvent;


Members:
     Possible Values:
      AEEBT_EV_AG_NOEVENTS           :  No more events from BT Stack
      AEEBT_EV_AG_ENABLED            :  BT Audio Gateway Enabled
      AEEBT_EV_AG_DISABLED           :  BT Audio Gateway Disable
      AEEBT_EV_AG_HEADSET_PICKUP     :  User picked up the Head set
      AEEBT_EV_AG_DISCONNECT_REQUEST :  User Disconnected the Headset
      AEEBT_EV_AG_AUDIO_CONNECTED    :  Audio Channel was connecte
      AEEBT_EV_AG_AUDIO_DISCONNECTED :  Audio Channel was disconnected
      AEEBT_EV_AG_AUDIO_CONN_TIMEOUT :  Connection timeout
      AEEBT_EV_AG_ERROR              :  Error occured during command processing

Comments:
   None.


See Also:
   None
======================================================================= 

AEEBTAGCmd

Description:
   AEEBTAGCmd specifies the Bluetooth Audio Gateway commands. 

Definition:
   typedef int32	AEEBTAGCmd;

Members:
     Possible Values:
      AEEBT_CMD_RING_HEADSET	: Ring the headset
      AEEBT_CMD_AUDIO_CONNECT	: Connect the Audio channel
      AEEBT_CMD_SET_SPKR_GAIN	: Increase/decrease the Speaker gain
      AEEBT_CMD_SET_HS_GAIN	: Increase/decrease the Headset gain
      AEEBT_CMD_DISCONNECT		: Disconnect the Audio Gateway



Comments:
   None.


See Also:
   None

======================================================================= 

AEEBTAGInfo

Description:
   AEEBTAGInfo specifies the Bluetooth audio gateway information
   when requesting to open the audio gateway. 

Definition:
   typedef PACKED struct tagAEEBTAGInfo
   {
     AEEBTAddr					bdaddr; 
     AEEBTRCServerChannel		usrvc;	
     AEEBTAGConnectmode		btMode;	
   } GCCPACKED AEEBTAGInfo;


Members:
 
   bdaddr - Head set BT device address.
   usrvc  - Head Set Server Channel Number
   btMode - Mode of Connection.


Comments:
   None.


See Also:
   AEEBTAddr, AEEBTRCServerChannel, AEEBTAGConnectmode	

=======================================================================*/ 
/*======================================================================= 

  INTERFACES   DOCUMENTATION
======================================================================= 


Interface Name: IBTAG

Description: 
    The IBTAG Interface functions are used to open, close  and manage a audio gateway to
	a headset

	FUNCTIONS in this Interface

	IBTAG_Open
	IBTAG_SendCommand
	IBTAG_GetEvent

USAGE:

	a. Open a Bluetooth Audio Gateway Port Using IBTAG_Open.
	b. Send a Command Using IBTAG_SendCommand
	c. On Occurence of Any event Retrieve all the events using IBTAG_GetEvent repetitively 
	until user get AEEBT_EV_AG_NOEVENTS
===========================================================================*/

/*===========================================================================
Function:  IBTAG_Open

Description:
  Open the Audio Gateway using the BT

Prototype:
  int32 IBTAG_Open(IBTAG *po, AEEBTAGInfo* pBTAGInfo, AEECallback *pcb);

Parameters:
		pBTAGInfo : The Connection Information for tthe Headset.
		pcb : The Callback Scheduled on occurence of Any Event on this port.
		If user cancels this callback the Port Will not be usable any more by the
		user.

Return Value:
  SUCCESS :
  EFAILED :Failure in opening the Audio Gateway
 
===========================================================================*/


/*===========================================================================
Function:  IBTAG_SendCommand

Description:
  Send 

Prototype:
  int32 IBTAG_SendCommand(IBTAG *po, AEEBTAGCmd cmdcode, uint32 cmdval);

Parameters:
		AEEBTAGCmd: Command Code. The valid values are
			AEEBT_CMD_RING_HEADSET		// Ring the headset
			AEEBT_CMD_AUDIO_CONNECT,	// Connect the Audio channel
			AEEBT_CMD_SET_SPKR_GAIN,	// Increase/decrease the Speaker gain
			AEEBT_CMD_SET_HS_GAIN,		// Increase/decrease the Headset gain
			AEEBT_CMD_DISCONNECT		//Disconnect the Audio Gateway

		cmdval : a 32 bit value as command parameter. This parameter is used with the following commands only
					AEEBT_CMD_SET_SPKR_GAIN
					AEEBT_CMD_SET_HS_GAIN
Return Value:
  SUCCESS : 
  EFAILED : Failure in sending the command
	On occurrence of any event, in response to  the above commands the callback is scheduled. 
	In the callback the user should call IBTAG_GetEvent to read the events out of the event queue.

Return Value:
  SUCCESS : 
  EFAILED : Failure in sending the command
 ===========================================================================*/

/*===========================================================================
Function:  IBTAG_GetEvent

Description:
  Get the Event code which occured on the device

Prototype:
  int32 IBTAG_GetEvent(IBTAG *po, AEEBTAGEvent* pevt)

Parameters:
	pevt; Return value for the event code. 
		pevt; Return value for the event code.  
	The valid return values are
		AEEBT_EV_AG_NOEVENTS,				// No more events from BT Stack
		AEEBT_EV_AG_ENABLED,				// BT Audio Gateway Enabled
		AEEBT_EV_AG_DISABLED,				// BT Audio Gateway Disabled
		AEEBT_EV_AG_HEADSET_PICKUP,			//  User picked up the Head set
		AEEBT_EV_AG_DISCONNECT_REQUEST,		// User Disconnected the Headset
		AEEBT_EV_AG_AUDIO_CONNECTED,		// Audio Channel was connected
		AEEBT_EV_AG_AUDIO_DISCONNECTED,		// Audio Channel was disconnected
		AEEBT_EV_AG_AUDIO_CONN_TIMEOUT,
		AEEBT_EV_AG_ERROR					// Error occured during command processing

Return Value:
  SUCCESS : 
  EFAILED : Failure in getting the event
 ===========================================================================*/

/*===========================================================================
Function:  IBTAG_GetLastError

Description:
  Get the Last Error code 

Prototype:
  int32 IBTAG_GetLastError(IBTAG *po)

Parameters:
	pevt; Return value for the event code. 
Return Value:
	Bluetooth specific Error code.
 ===========================================================================*/

// BASE AEE INTERFACE

#define IBTAG_AddRef(p)                 AEEGETPVTBL((p),IBTSDP)->AddRef((p))
#define IBTAG_Release(p)                AEEGETPVTBL((p),IBTSDP)->Release((p))
#define IBTAG_QueryInterface(p,i,ppo)   AEEGETPVTBL((p),IBTSDP)->QueryInterface((p),(i),(ppo))

// Audio  Interface
#define IBTAG_Open(p, pBTAGInfo, pcb)						AEEGETPVTBL((p),IBTAG)->Open((p),(pBTAGInfo),(pcb))
#define IBTAG_SendCommand(p, cmdcode, cmdval)				AEEGETPVTBL((p),IBTAG)->SendCommand((p),(cmdcode),(cmdval))
#define IBTAG_GetEvent(p, pevtcode)							AEEGETPVTBL((p),IBTAG)->SendCommand((p),(pevtcode))
#define IBTAG_GetLastError(p)								AEEGETPVTBL((p),IBTAG)->GetLastError((p))
  
#ifdef __cplusplus
}
#endif
#endif  //_AEEBTSDP_H_

