HCI_EstablishDeviceContext

This function is used to establish a connection to HCI stack layer.

Int HCI_EstablishDeviceContext(
  Void* pUserContext,
  UINT uiControl,
  BD_ADDR* pba,
  UINT class_of_device,
  UCHAR link_type,
  HCI_EVENT_INDICATION* pInd,
  HCI_CALLBACKS* pCall,
  HCI_INTERFACE* pInt,
  int* pcDataHeaders,
  int* pcDataTrailers,
  HANDLE* phDeviceContext
);

Parameters

  • pUserContext
    [in] Pointer to the user context information. It is used in asynchronous event indications.

  • uiControl
    [in] Defines which filter to use, as shown in the following table.

    Filter Value
    BTH_CONTROL_ROUTE_ALL 0x00000001
    BTH_CONTROL_DEVICEONLY 0x00001000

    The value can also be a combination of the following filters.

    Filter Value
    BTH_CONTROL_ROUTE_BY_ADDR 0x00000010
    BTH_CONTROL_ROUTE_BY_COD 0x00000020
    BTH_CONTROL_ROUTE_BY_LINKTYPE 0x00000040
    BTH_CONTROL_ROUTE_HARDWARE 0x00000100
    BTH_CONTROL_ROUTE_SECURITY 0x00000080
  • pba
    [in] Pointer to the Bluetooth device address, if BTH_CONTROL_ROUTE_BY_ADDR.

  • class_of_device
    [in] Device class, if BTH_CONTROL_ROUTE_BY_COD.

  • link_type
    [in] Link type, if BTH_CONTROL_ROUTE_BY_LINKTYPE.

  • pInd
    [in] Pointer to the event interface table.

  • pCall
    [in] Pointer to the callback table.

  • pInt
    [out] Pointer to HCI command interface table.

  • pcDataHeaders
    [out] Size of data headers used internally by HCI to be pre-allocated in data packets.

  • pcDataTrailers
    [out] Size of data trailers used internally by HCI to be pre-allocated in data packets.

  • phDeviceContext
    [out] Pointer to the device context handle.

Return Values

ERROR_SUCCESS indicates successful completion.

Remarks

If the stack wants to only accept connections from one device, it issues BTH_CONTROL_ROUTE_BY_ADDR and provides a pointer to pba. If it is prepared to accept only SCO connections, it provides the appropriate link_type and BTH_CONTROL_ROUTE_BY_LINKTYPE. The same hold true for class of device.

BTH_CONTROL_ROUTE_SECURITY is specifically implemented to support security manager layers. If a layer installs itself with this flag, the link key/pin requests for all connections are forwarded to it.

BTH_CONTROL_ROUTE_ALL is reserved for the default handler. Only one stack layer can be a default handler. In the Bluetooth stack, this role is handled by L2CAP.

BTH_CONTROL_ROUTE_DEVICEONLY is specifically reserved for management layers that do not accept incoming connections at all. There may be more than one of these.

Every event that is generated by Bluetooth hardware — such as a connection request, command completion event, or command status event — is routed to the stack layer that specifies it in the StackEvent call.

Output parameters pcDataHeaders and pcDataTrailers define how many bytes must be reserved in the data packet by upper layer for HCI level protocol headers and trailers. Incoming data packets must have BD_BUFFER::cStart to be set to *pcDataHeaders, and BD_BUFFER::cEnd to be equal to BD_BUFFER::cSize - *pcDataHeaders.

Requirements

OS Versions: Windows CE .NET 4.0 and later.
Header: Bt_hcip.h.
Link Library: Btd.lib.

See Also

BD_BUFFER

Last updated on Wednesday, April 13, 2005

© 2005 Microsoft Corporation. All rights reserved.