Zoltan Hudak / UsbHostMAX3421E

Dependents:   UsbHostMAX3421E_Hello

Embed: (wiki syntax)

« Back to documentation index

BTHID Class Reference

This BluetoothService class implements support for Bluetooth HID devices. More...

#include <BTHID.h>

Inherits BluetoothService.

Inherited by PS4BT.

Public Member Functions

 BTHID (BTD *p, bool pair=false, const char *pin="0000")
 Constructor for the BTHID class.
HIDReportParser * GetReportParser (uint8_t id)
 Get HIDReportParser.
bool SetReportParser (uint8_t id, HIDReportParser *prs)
 Set HIDReportParser to be used.
void setProtocolMode (uint8_t mode)
 Set HID protocol mode.
void pair (void)
 Call this to start the pairing sequence with a device.
void attachOnInit (void(*funcOnInit)(void))
 Used to call your own function when the device is successfully initialized.
void setLeds (struct KBDLEDS data)
 Used to set the leds on a keyboard.

Data Fields

bool connected
 True if a device is connected.

Protected Member Functions

bool checkHciHandle (uint8_t *buf, uint16_t handle)
 Used to check if the incoming L2CAP data matches the HCI Handle.
Overridable functions
virtual void ParseBTHIDData (uint8_t len __attribute__((unused)), uint8_t *buf __attribute__((unused)))
 Used to parse Bluetooth HID data to any class that inherits this class.
virtual void OnInitBTHID ()
 Called when a device is connected.
virtual void ResetBTHID ()
 Used to reset any buffers in the class that inherits this.

Protected Attributes

uint8_t control_scid [2]
 L2CAP source CID for HID_Control.
uint8_t interrupt_scid [2]
 L2CAP source CID for HID_Interrupt.
void(* pFuncOnInit )(void)
 Pointer to function called in onInit().
BTDpBtd
 Pointer to BTD instance.
uint16_t hci_handle
 The HCI Handle for the connection.
uint32_t l2cap_event_flag
 L2CAP flags of received Bluetooth events.
uint8_t identifier
 Identifier for L2CAP commands.

BluetoothService implementation

void disconnect ()
 Used this to disconnect the devices.
void ACLData (uint8_t *ACLData)
 Used to pass acldata to the services.
void Run ()
 Used to run part of the state machine.
void Reset ()
 Use this to reset the service.
void onInit ()
 Called when a device is successfully initialized.

Detailed Description

This BluetoothService class implements support for Bluetooth HID devices.

Definition at line 29 of file BTHID.h.


Constructor & Destructor Documentation

BTHID ( BTD p,
bool  pair = false,
const char *  pin = "0000" 
)

Constructor for the BTHID class.

Parameters:
pPointer to the BTD class instance.
pairSet this to true in order to pair with the device. If the argument is omitted then it will not pair with it. One can use PAIR to set it to true.
pinWrite the pin to BTD::btdPin. If argument is omitted, then "0000" will be used.

Definition at line 23 of file BTHID.cpp.


Member Function Documentation

void ACLData ( uint8_t *  ACLData ) [protected, virtual]

Used to pass acldata to the services.

Parameters:
ACLDataIncoming acldata.

Implements BluetoothService.

Definition at line 56 of file BTHID.cpp.

void attachOnInit ( void(*)(void)  funcOnInit ) [inherited]

Used to call your own function when the device is successfully initialized.

Parameters:
funcOnInitFunction to call.

Definition at line 592 of file BTD.h.

bool checkHciHandle ( uint8_t *  buf,
uint16_t  handle 
) [protected, inherited]

Used to check if the incoming L2CAP data matches the HCI Handle.

Definition at line 605 of file BTD.h.

void disconnect (  ) [virtual]

Used this to disconnect the devices.

Implements BluetoothService.

Definition at line 49 of file BTHID.cpp.

HIDReportParser* GetReportParser ( uint8_t  id )

Get HIDReportParser.

Parameters:
idID of parser.
Returns:
Returns the corresponding HIDReportParser. Returns NULL if id is not valid.

Definition at line 49 of file BTHID.h.

void onInit (  ) [protected, virtual]

Called when a device is successfully initialized.

Use attachOnInit(void (*funcOnInit)(void)) to call your own function. This is useful for instance if you want to set the LEDs in a specific way.

Implements BluetoothService.

Definition at line 112 of file BTHID.h.

virtual void OnInitBTHID (  ) [protected, virtual]

Called when a device is connected.

Reimplemented in PS4BT.

Definition at line 129 of file BTHID.h.

void pair ( void   )

Call this to start the pairing sequence with a device.

Definition at line 91 of file BTHID.h.

virtual void ParseBTHIDData ( uint8_t len   __attribute__(unused),
uint8_t *buf   __attribute__(unused) 
) [protected, virtual]

Used to parse Bluetooth HID data to any class that inherits this class.

Parameters:
lenThe length of the incoming data.
bufPointer to the data buffer.

Definition at line 125 of file BTHID.h.

void Reset (  ) [protected, virtual]

Use this to reset the service.

Implements BluetoothService.

Definition at line 41 of file BTHID.cpp.

virtual void ResetBTHID (  ) [protected, virtual]

Used to reset any buffers in the class that inherits this.

Reimplemented in PS4BT.

Definition at line 133 of file BTHID.h.

void Run (  ) [protected, virtual]

Used to run part of the state machine.

Implements BluetoothService.

Definition at line 344 of file BTHID.cpp.

void setLeds ( struct KBDLEDS  data )

Used to set the leds on a keyboard.

Parameters:
dataSee KBDLEDS in hidboot.h

Definition at line 81 of file BTHID.h.

void setProtocolMode ( uint8_t  mode )

Set HID protocol mode.

Parameters:
modeHID protocol to use. Either USB_HID_BOOT_PROTOCOL or HID_RPT_PROTOCOL.

Definition at line 72 of file BTHID.h.

bool SetReportParser ( uint8_t  id,
HIDReportParser *  prs 
)

Set HIDReportParser to be used.

Parameters:
idId of parser.
prsPointer to HIDReportParser.
Returns:
Returns true if the HIDReportParser is set. False otherwise.

Definition at line 61 of file BTHID.h.


Field Documentation

bool connected

True if a device is connected.

Definition at line 88 of file BTHID.h.

uint8_t control_scid[2] [protected]

L2CAP source CID for HID_Control.

Definition at line 139 of file BTHID.h.

uint16_t hci_handle [protected, inherited]

The HCI Handle for the connection.

Definition at line 616 of file BTD.h.

uint8_t identifier [protected, inherited]

Identifier for L2CAP commands.

Definition at line 622 of file BTD.h.

uint8_t interrupt_scid[2] [protected]

L2CAP source CID for HID_Interrupt.

Definition at line 142 of file BTHID.h.

uint32_t l2cap_event_flag [protected, inherited]

L2CAP flags of received Bluetooth events.

Definition at line 619 of file BTD.h.

BTD* pBtd [protected, inherited]

Pointer to BTD instance.

Definition at line 613 of file BTD.h.

void(* pFuncOnInit)(void) [protected, inherited]

Pointer to function called in onInit().

Definition at line 610 of file BTD.h.