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

FILE:      AEEBTSDP.h
 
SERVICES:  Bluetooth Service Discovery Interface
 
DESCRIPTION: This file provides defintions for the Service discovery protocol over Bluetooth.

PUBLIC CLASSES:  Not Applicable

INITIALIZATION AND SEQUENCING REQUIREMENTS:


        Copyright © 1999-2002 QUALCOMM Incorporated.
               All Rights Reserved.
            QUALCOMM Proprietary/GTDR
===========================================================================*/
#ifndef _AEEBTSDP_H_
#define _AEEBTSDP_H_
#include "AEE.h"
#include "AEEBT.h"

#ifdef __cplusplus
extern "C" {
#endif

typedef int32  AEEBTSDPResultCode;

typedef int32  AEEBTSDPJobType;

#define	 AEEBT_SDP_DEVICEDISCOVERY  1
#define  AEEBT_SDP_NAMEREQ			2
#define AEEBT_SDP_RCSERVERREQ		3


// Discovered Device  List
// User should allocate this structure as follows
// sizeof(AEEBTDeviceListResult) + (unumdevices - 1) * sizeof(AEEBTDevice);
typedef struct tagDevicelist
{
    AEEBTSDPResultCode	 errcode;
	uint8				 unumdevices; 
	AEEBTDevice			 btdevices[1]; // Place holder for Multiple Devices based on unumdevices
} AEEBTDeviceListResult;

// Device's Server Channel
typedef struct tagBTServerChannel
{
    AEEBTSDPResultCode		errcode;
	AEEBTServerChannel		btServerChannel;
} AEEBTServerChannelResult;

// Device's Name
typedef struct tagBTDeviceName
{
    AEEBTSDPResultCode	errcode;
	AEEBTDeviceName		btDeviceName;
} AEEBTDeviceNameResult;



// Bluetooth Service Discovery Interface definitions

typedef struct IBTSDP IBTSDP;
AEEINTERFACE(IBTSDP) 
{
  INHERIT_IQueryInterface(IBTSDP);
  int32 (*DiscoverDevices)(IBTSDP *po,AEECallback *pcb, AEEBTDeviceListResult *pResult);
  int32 (*GetRemoteServerChannel)(IBTSDP *po, AEEBTAddr *pbdaddr,uint16 service_class, AEECallback *pcb, AEEBTServerChannelResult *pResult);
  int32 (*GetDeviceName)(IBTSDP *po, AEEBTAddr *pbdaddr, AEECallback *pcb, AEEBTDeviceNameResult *pResult);
};

// BASE AEE INTERFACE

#define IBTSDP_AddRef(p)                 AEEGETPVTBL((p),IBTSDP)->AddRef((p))
#define IBTSDP_Release(p)                AEEGETPVTBL((p),IBTSDP)->Release((p))
#define IBTSDP_QueryInterface(p,i,ppo)   AEEGETPVTBL((p),IBTSDP)->QueryInterface((p),(i),(ppo))

// SDP Interface
#define IBTSDP_DiscoverDevices(p,cb, pres)				   AEEGETPVTBL((p),IBTSDP)->DiscoverDevices((p),(cb), (pres))
#define IBTSDP_GetDeviceName(p,pbd, cb, pres)			   AEEGETPVTBL((p),IBTSDP)->GetDeviceName((p),(pbd),(cb), (pres))
#define IBTSDP_GetRemoteServerChannel(p,pbd,svc, cb, pres) AEEGETPVTBL((p),IBTSDP)->GetRemoteServerChannel((p),(pbd),(svc), (cb), (pres))

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

AEEBTDeviceListResult

Description:
   AEEBTDeviceListResult contains the results of IBTSDP_DiscoverDevices. 

Definition:
   typedef struct tagDevicelist
   {
      AEEBTSDPResultCode	 errcode;
	   uint8				       unumdevices; 
	   AEEBTDevice			    btdevices[1];
   } AEEBTDeviceListResult;


Members:
 
   errcode     - Error code for the IBTSDP_DiscoverDevices request.
   unumDevices - Number of devices discovered.
   btDevices   - Array of Device specifications for each of the devices
                 discovered.


Comments:
   The user should allocate this structure as follows:
   sizeof(AEEBTDeviceListResult) + (unumdevices - 1) * sizeof(AEEBTDevice);.


See Also:
   AEEBTDevice

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

AEEBTServerChannelResult

Description:
   AEEBTServerChannelResult specifies the structure in which the results
   of IBTSDP_GetRemoteServerChannel request are returned. 

Definition:
   typedef struct tagBTServerChannel
   {
      AEEBTSDPResultCode		errcode;
	   AEEBTServerChannel		btServerChannel;
   } AEEBTServerChannelResult;

Members:
 
   errcode     - Error code for the IBTSDP_DiscoverDevices request.
   btServerChannel - Specifications of the channel to get service
                     from remote Bluetooth device.


Comments:
   None.


See Also:
   AEEBTServerChannel

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

AEEBTDeviceNameResult

Description:
   AEEBTDeviceNameResult specifies the structure in which the results
   of IBTSDP_GetDeviceName request are returned. 

Definition:
typedef struct tagBTDeviceName
{
   AEEBTSDPResultCode	errcode;
	AEEBTDeviceName		btDeviceName;
} AEEBTDeviceNameResult;

Members:
 
   errcode      - Error code for the IBTSDP_DiscoverDevices request.
   btDeviceName - Bluetooth name of the device whose address was specified
                  in the request.


Comments:
   None.


See Also:
   AEEBTDeviceName, AEEBTAddr

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

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


Interface Name: IBTSDP
Description: 
    The IBTSDP Interface functions are used to Discover Devices and Query the Device name and
	associated Server Channel.

	FUNCTIONS in this Interface

	IBTSIOPORT_DiscoverDevices
	IBTSIOPORT_GetDeviceName
	IBTSIOPORT_GetRemoteServerChannel

USAGE:
	a. To Discover the Devices
		1. Create a IBTSDPInterface
		2. Allocate a Structure AEEBTDeviceListResult with appropriate size based on the requested
		number of devices.
		3 Initialize a AEE Callback to be scheduleb on completeion of Discovery
		4. Call the Function IBTSDP_DiscoverDevices with the appropriate parameters.
		5. On completion of the Discovery, the callback is scheduled. On execution of the callback
		Inpsect the AEEBTDeviceListResult structure.

	b. To Query the Device Name
		1. Create a IBTSDPInterface
		2. Allocate a Structure AEEBTDeviceNameResult.
		3 Initialize a AEE Callback to be scheduled on completeion of Discovery
		4. Call the Function IBTSDP_GetDeviceName with the appropriate parameters.
		5. On completion of the Discovery, the callback is scheduled. On execution of the callback
		Inpsect the AEEBTDeviceNameResult structure.
	c. To Query the Device Name
		1. Create a IBTSDPInterface
		2. Allocate a Structure AEEBTServerChannelResult.
		3 Initialize a AEE Callback to be scheduled on completeion of Discovery
		4. Call the Function IBTSDP_GetRemoteServerChannel with the appropriate parameters.
		5. On completion of the Discovery, the callback is scheduled. On execution of the callback
		Inpsect the AEEBTServerChannelResult structure.
===========================================================================*/

/*===========================================================================
Function:  IBTSDP_DiscoverDevices

Description:
  Start the Blue tooth Device Discovery process.

Prototype:
  int32 IBTSDP_DiscoverDevices)(IBTSDP *po, AEECallback *pcb, AEEBTDeviceListResult *pResult);

Parameters:
		pcb : The Callback Scheduled on completion of the the Discovery
		pResult: Ptr to the Result Record. The User should allocate AEEBTDeviceListResult Record based
		on the Requested number of Devices
Return Value:
  SUCCESS : If there was an error in scheduling a Discovery
  EFAILED : Discovery Failed.
 
   The callback Stores the Response of the BT Device Discovery in pResult
===========================================================================*/


/*===========================================================================
Function:  IBTSDP_GetRemoteServerChannel

Description:
  Start the Blue tooth Server Channel Query.

Prototype:
  int32 IBTSDP_GetRemoteServerChannel(IBTSDP *po, AEEBT_Addr *pbd_addr AEECallback *pcb, AEEBTServerChannelResult *pResult)

Parameters:
		pbd_addr: the BT device Address used for the query
		pcb : The Callback Scheduled on completion of the the Discovery
		pResult: Ptr to the Result Record. The User should allocate AEESDPReqRsp Record.
Return Value:
  SUCCESS : If there was an error in scheduling a Discovery
  EFAILED : Query Failed.
 
   The callback Stores the Response of the BT Device Query
===========================================================================*/

/*===========================================================================
Function:  IBTSDP_GetDeviceName

Description:
  Start the Blue tooth Name Query for a specified Device

Prototype:
  int32 IBTSDP_GetDeviceName)(IBTSDP *po, AEEBT_Addr *pbd_addr AEECallback *pcb, AEEBTDeviceNameResult *pResult)

Parameters:
		pbd_addr: the BT device Address used for the query
		pcb : The Callback Scheduled on completion of the the Discovery
		pResult: Ptr to the Result Record. The User should allocate AEEBTDeviceNameResult Record.
Return Value:
  SUCCESS : If there was an error in scheduling a Discovery
  EFAILED : Query Failed.
 
   The callback Stores the Response of the BT Device Name Query
===========================================================================*/

#ifdef __cplusplus
}
#endif
#endif  //_AEEBTSDP_H_

