Opening Connections

Other versions of this page are also available for the following:

Windows Mobile Not SupportedWindows Embedded CE Supported

8/28/2008

When the Bluetooth stack initializes, it calls the HCI_SetCallback function of the HCI Transport interface. It passes a callback that is used by HCI transport layer to indicate insertion or removal of hardware.

The stack can also call the HCI_StartHardware and HCI_StopHardware functions to make the physical layer simulate an ejection or insertion of a controller, whether it is removable or not.

The following code shows the function definitions from Bt_hcip.h.

enum HCI_EVENT {
   DEVICE_UP,
   DEVICE_DOWN,
   DEVICE_ERROR
};
typedef int (*HCI_TransportCallback) (HCI_EVENT eEvent, void *pEvent);
int HCI_SetCallback (HCI_TransportCallback pfCallback);
int HCI_StartHardware (void);
int HCI_StopHardware (void);

When an insertion is signaled, the stack calls the HCI_OpenConnection function. If it returns TRUE, the transport is considered to be active.

When HCI_OpenConnection returns TRUE, the Bluetooth stack calls the HCI_ReadHciParameters function.

In the HCI_PARAMETERS structure passed as an argument, it fills out only the size and version field. The transport driver must ensure that the version of the stack matches the version of the transport driver exactly.

The HCI transport is responsible for filling the HCI_PARAMETERS structure completely. Important members of this structure indicate minimum buffers required for incoming packets, and maximum buffers allowed for outgoing packets, as well as the version of the Bluetooth hardware.

#define HCI_INTERFACE_VERSION_1_0       0x00010000
#define HCI_HARDWARE_VERSION_V_1_0_A    0
#define HCI_HARDWARE_VERSION_V_1_0_B    1
#define HCI_HARDWARE_VERSION_V_1_1      2
#define HCI_DEFAULT_WRITE_TIMEOUT       15000
#define HCI_FLAGS_NORESET               0x00000001
#define HCI_FLAGS_NOLOCALNAME           0x00000002
#define HCI_FLAGS_NOROLESWITCH          0x00000004
//
// Note:
//   iMaxSize parameters MUST fit the biggest HCI command
//     (HCI_RemoteNameRequest as of this writing is 257 bytes,
//      see also bt_ddi.h::HCI_MAX_COMMAND_LENGTH)
//   iReadBufferHeader and iWriteBufferHeader MUST be 4-bytes aligned
//
typedef struct __hci_parameters 
{
  unsigned int uiSize; // structure size
  unsigned int fInterfaceVersion; // interface version
  int iMaxSizeRead; // Max size of read packet (not including headers and 
                    //trailers)
  int iMaxSizeWrite; // Max size of write packet (not including headers 
                     //and trailers)
  int iReadBufferHeader; // Hint : read may contain up to as much 
                         //transport header bytes
  int iReadBufferTrailer; // Hint : read may contain up to as much 
                          //transport trailer bytes
  int iWriteBufferHeader; // Number of bytes to preallocate for transport 
                          //header
  int iWriteBufferTrailer; // Number of bytes to preallocate for transport 
                           //trailer
  int uiFlags; // Flags
  int fHardwareVersion; // Bluetooth spec version of hardware
  unsigned int uiResetDelay; // milliseconds : delay next command after 
                             //reset by this much
  unsigned int uiWriteTimeout; // milliseconds : abort if card does not 
                           //respond in this time (use the default above)
  unsigned int uiDriftFactor; // milliseconds : inquiry data is good for 
                              //this long
  int iScoWriteLowNumPackets; // Minimum number of outstanding SCO write 
                             //packets in backlog (0 - use default)
  int iScoWriteNumPackets; // Maximum number of outstanding SCO write 
                           //packets in backlog (0 - use default)
  int iScoWritePacketSize; // Size of each SCO packet (0 - use default, -1 
                           //- SCO not supported)
  int iScoSampleSize; // Sample size of SCO packet (8 or 16 bits)
} HCI_PARAMETERS;
int HCI_ReadHciParameters (HCI_PARAMETERS  *pParms);

See Also

Concepts

Bluetooth HCI Transport Layer