HCI Events (Windows Embedded CE 6.0)
The HCI_EVENT_INDICATION structure declared in bt_ddi.h, declares the full set of Bluetooth HCI events as defined by the HCI Specification at this Official Bluetooth Wireless Info Web site.
HCI events are raised either as a result of an action by a peer Bluetooth device or by executing HCI Commands on the device.
For example, issuing the HCI_CreateConnection command to the Bluetooth controller raises HCI_CommandStatusEvent that notifies the stack that a command has been accepted for execution.
This event is followed by an HCI_ConnectionCompleteEvent notification. This is raised when the connection is established or rejected. Other events, such as HCI_ConnectionRequestEvent, only occur as a result of an action on the peer Bluetooth device.
In addition, there are events such as HCI_LinkKeyChangedEvent that occur either as a result of executed command, or in response to an action by a peer Bluetooth device without a command being executed.
All events declared in HCI_EVENT_INDICATION contain both user context and call context. The following code example shows the function pointer declaration for the HCI_ConnectionCompleteEvent event handler.
typedef int (*HCI_ConnectionCompleteEvent) (void *pUserContext, void *pCallContext, unsigned char status, unsigned short connection_handle, BD_ADDR *pba, unsigned char link_type, unsigned char encryption_mode);
The HCI layer matches events to commands that are currently in execution and returns the call context of the executing command in pCallContext. The command is completedonly after the corresponding event is raised. If the event is raised asynchronously, then pCallContext is NULL.
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 HCI_StackEvent .