#ifndef BTGLUE_H
#define BTGLUE_H
/*====*====*====*====*====*====*====*====*====*====*====*====*====*====*====*

         B L U E T O O T H    R F C O M M    TO    S I O    INTERFACE

DESCRIPTION
  This module contains an application that cross-connects RFCOMM to SIO.

Copyright (c) 2000 by QUALCOMM Incorporated. All Rights Reserved.
*====*====*====*====*====*====*====*====*====*====*====*====*====*====*====*/


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


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

                     INCLUDE FILES FOR MODULE

===========================================================================*/
#include <stdlib.h>
#include <string.h>
#include "customer.h"
#ifndef WIN32
#include "comdef.h"
#endif
#include <string.h>
#include "rex.h"
#include "queue.h"
#include "dsm.h"
#include "mc.h"
#include "task.h"
#include "sio.h"
#include "assert.h"
#include "bt.h"
#include "bti.h"
#include "btcmdi.h"
#include "btdebug.h"
#include "btmsg.h"
#include "btrcmsgi.h"
#include "btrci.h"
#include "btutils.h"
#include "OEMBTSIO.h"


/*-------------------------------------------------------------------------*/
/*                                                                         */
/*                         Data Definitions                                */
/*                                                                         */
/*-------------------------------------------------------------------------*/


typedef enum
{
  BTGLUE_EVT_NONE			= 0x0000,
  BTGLUE_EVT_FIRST			= OEMBTSIO_ST_CONNECTED,
  BTGLUE_EVT_CONNECTED		= OEMBTSIO_ST_CONNECTED,
  BTGLUE_EVT_CONNECTFAILED	= OEMBTSIO_ST_CONNECTFAILED,
  BTGLUE_EVT_READABLE		= OEMBTSIO_ST_READABLE,
  BTGLUE_EVT_WRITABLE		= OEMBTSIO_ST_WRITEABLE,
  BTGLUE_EVT_DISCONNECTED	= OEMBTSIO_ST_DISCONNECTED,
  BTGLUE_EVT_LAST			= OEMBTSIO_ST_DISCONNECTED
} btglue_event_type;



typedef uint32	btglue_porthandle;

#define BTGLUE_INVALID_HANDLE	OEMBTSIO_INVALID_HANDLE


typedef void	(*btglue_portcallback)(btglue_event_type evttype, btglue_porthandle porthandle, void *dataptr);

typedef struct
{
  bt_bd_addr_type		remote_bd_addr;
  uint8                 server_channel;
  boolean				master;
  btglue_portcallback	port_callback;			
} btglue_sio_params_type;


/*---------------------------------------------------------------------------
 SIO Status type.  Indicates the different results of SIO operation.
---------------------------------------------------------------------------*/

typedef enum
{
  BTGLUE_BADP_S = 1,                   /* Bad parameter                        */
  BTGLUE_UNAVAIL_S,
  BTGLUE_DONE_S                        /* For bounds checking only             */
} btglue_status_type;

void btglue_sio_init(PFNBTSIOWAKEUP);
void btglue_process_bt_ev_queue(void);

btglue_status_type btglue_sio_cmd_open
(
  btglue_sio_params_type*  open_ptr, btglue_porthandle	*porthandle
);

sint15 btglue_sio_cmd_transmit
(
  btglue_porthandle   porthandle,
  byte*			     dataptr,  uint32			nbytes
);

sint15 btglue_sio_cmd_receive
(
  btglue_porthandle   porthandle,
  byte*			     dataptr,
  uint32			 nbytes
);
void btglue_sio_cmd_close
(
  btglue_porthandle	porthandle
);

boolean btglue_port_writable
(
  btglue_porthandle   port_index
);
boolean btglue_port_readable
(
  btglue_porthandle   port_index
);

#endif
