Share via


WEC7/WEC2013/WinCE: Bluetooth driver

Introduction

Bluetooth is a short-range and low power cable-replacement technology originally developed for exchanging data over short distances from fixed and mobile devices, creating personal area networks (PANs).

This article gives the details of Bluetooth driver in Windows CE, mainly, the HCI Transport driver, which is the only customizable layer in Windows CE Bluetooth.

The Bluetooth stack is provided by Microsoft, and developer needs to develop an HCI transport driver such as USB or SDIO client drivers.

Bluetooth architecture in WinCE

See more details on WinCE Bluetooth architecture on MSDN documentations here.

Host Controller Interface (HCI) Architecture

The HCI provides a command interface to the baseband controller and link manager, and access to configuration parameters. This interface provides a uniform method of accessing the Bluetooth baseband capabilities.

Using HCI, a BT application can access BT Hardware without knowledge of the transport layer or other hardware implementation details.

In systems where the higher layers are run on a host device's processor and lower layers on a BT device, an interface is needed between the higher and lower layers.

The BT standard defines the HCI.

HCI Packet Types

The BT standard for the host controller interface defines the following:

1.  Command packets used by the host to control the module

2.  Event packets used by the module to inform the host of changes in the lower   layers

3.  Data packets to pass voice and data between host and module

HCI Command packets

The host to control the Bluetooth module and to monitor its status uses HCI commands.  Commands are transferred using HCI command packets

If a command can complete immediately, an HCI_Command_Complete is returned to indicate that the command has been dealt with.

If a command cannot complete immediately, an HCI_Command_Status event is returned immediately, and another event is returned later when the command has completed.

The Opcode parameter is divided into two fields, called the OpCode Group Field (OGF) and OpCode Command Field (OCF).

The OGF occupies the upper 6 bits of the Opcode, while the OCF occupies the remaining 10 bits.

HCI Data packets

HCI ACL Data Packets

HCI ACL Data Packets are used to exchange data between the Host and Controller.

HCI Synchronous Data Packets

HCI synchronous (SCO and eSCO) Data Packets are used to exchange synchronous data between the Host and Controller.

HCI Event packets

The HCI Event Packet is used by the Controller to notify the Host when events occur. The Host must be able to accept HCI Event Packets with up to 255 octets of data excluding the HCI Event Packet header.

HCI Commands - Example

WEC7 Initialization sequence

The first command that is sent from stack to HCI transport layer is 0x0C03 (Reset).

It will be followed by following sequence of commands

HCI Command     : Read buffer size  (0x1005)
HCI Event       : Command Status    (0x0E)
HCI Command     : Read BD address   (0x1009)
HCI Event       : Command Status    (0x0E)
HCI Command     : Write local name  (0x0C13)
HCI Event       : Command Status    (0x0E)
HCI Command     : Write scan enable     (0x0C1A)
HCI Event       : Command Status    (0x0E)
HCI Command     : Write class of device (0x0C24)
HCI Event       : Command Status    (0x0E)
HCI Command     : Read Local Version Information (0x1001)
HCI Event       : Command Status    (0x0E)
HCI Command     : Read Local Supported Commands (0x1003)
HCI Event       : Command Status    (0x0E)
...
...

Scanning sequence

HCI Command   : Inquiry (0x0401)
HCI Event           : Command Status (0x0F)
HCI Event           : Inquiry Result (0x02) or Extended Inquiry   Result(0x2F)   and/or Inquiry Result with RSSI (0x22)
HCI Event           : Inquiry Complete (0x01)
HCI Command   : Remote Name Request (0x0419)
HCI Event           : Command Status (0x0F)
HCI Event           : Remote Name Request Complete (0x07)

Pairing / Connection sequence

HCI Command   : Create Connection   (0x0405)
HCI Event     : Command Status   (0x0F)
HCI Event     : Connection Complete   (0x03)
HCI Command   : Read Clock Offset    (0x041F)
HCI Event     : Max Slots Change  (0x1B)
HCI Event     : Read Clock Offset Complete  (0x1C)
HCI Command   : Write Link Policy Settings (0x080D)
HCI Event     : Command Status   (0x0F)
HCI Command   : Read Remote Extended Features    (0x041C)
HCI Event     : Command Status   (0x0F)
HCI Event     : Read Remote Extended Features Complete (0x07)
HCI Command   : Authentication Requested  (0x0411)
HCI Event      : Command Complete   (0x0E)
HCI Event      : IO Capability Request  (0x31)
HCI Command   : IO Capability Request Reply  (0x042B)
HCI Event      : Command Complete   (0x0E)
HCI Event      : IO Capability Response  (0x32)
...

Will be followed by ACL/SCO data packets...

HCI Transport layer driver in WEC7

This is the only layer in WEC7 which can be modified.

WEC7 provides the HCI transport layer driver for generic bluetooth devices, (CSR BT dongle) though USB and UART.

For SDIO interface, the driver needs to be ported from WinCE6.0 to WEC7.

For non-generic modules such as Redpine 9113 BT module, HCI transport layer should be modified according to the module datasheet/Linux driver.

HCI Transport layer driver - Registry

[HKEY_LOCAL_MACHINE\Software\Microsoft\Bluetooth\Transports\PnP\{GUID}]
"flags"=dword:80000000
"driver"="bthusb.dll"
"resetdelay"=dword:0
"PacketSize"=dword:200
"BlockSize"=dword:5
 
[HKEY_LOCAL_MACHINE\Software\Microsoft\Bluetooth\sys]
"Power"=dword:1                        ;; Radio on by default
"ScanMode"=dword:3                 ;; Radio is discoverable
"DisableAutoSuspend"=dword:1 ;; Allow suspend when connected
 
[HKEY_LOCAL_MACHINE\Drivers\USB\LoadClients\5656_37139\Default\Default\Bluetooth_USB_Driver]
"DLL"="bthusb.dll"
 
[HKEY_LOCAL_MACHINE\Drivers\SDCARD\ClientDrivers\Custom\MANF-041B-CARDID-9330-FUNC-1]
"Dll"="bthsdio.dll"

WEC7 Catalog items and SYSGEN variables

Bluetooth Stack with Universal Loadable Driver  SYSGEN_BTH
Bluetooth Settings                              SYSGEN_BTH_SETTINGS
Bluetooth HID - Keyboard                        SYSGEN_BTH_HID_KEYBOARD
Bluetooth HID - Mouse                           SYSGEN_BTH_HID_MOUSE
Bluetooth HS/HF and Audio Gateway Service       SYSGEN_BTH_AG
Bluetooth PAN                                   SYSGEN_BTH_PAN
Bluetooth Profile Management APIs               SYSGEN_BTH_BTHUTIL
Bluetooth services                              SYSGEN_BTH_BTHSSVC
OBEX Client                                     SYSGEN_OBEX_CLIENT
OBEX Server                                     SYSGEN_OBEX_SERVER
OBEX File Browser                               SYSGEN_OBEX_FILEBROWSER
OBEX Inbox                                      SYSGEN_OBEX_INBOX
Bluetooth utilities                             SYSGEN_BTH_UTILS
Bluetooth audio                                 SYSGEN_BTH_AUDIO
Bluetooth modem                                 SYSGEN_BTH_MODEM