USB Host Shield 2.0
Public Member Functions | Public Attributes | Protected Attributes | List of all members
BTHID Class Reference

#include <BTHID.h>

Inheritance diagram for BTHID:
Inheritance graph
[legend]
Collaboration diagram for BTHID:
Collaboration graph
[legend]

Public Member Functions

 BTHID (BTD *p, bool pair=false, const char *pin="0000")
 
HIDReportParserGetReportParser (uint8_t id)
 
bool SetReportParser (uint8_t id, HIDReportParser *prs)
 
void setProtocolMode (uint8_t mode)
 
void pair (void)
 
uint32_t getLastMessageTime ()
 
void setLeds (struct KBDLEDS data)
 
void setLeds (uint8_t data)
 
- Public Member Functions inherited from BluetoothService
 BluetoothService (BTD *p)
 
void attachOnInit (void(*funcOnInit)(void))
 

Public Attributes

bool connected
 

Protected Member Functions

Overridable functions
virtual void ParseBTHIDData (uint8_t len, uint8_t *buf)
 
virtual void ParseBTHIDControlData (uint8_t len, uint8_t *buf)
 
virtual void OnInitBTHID ()
 
virtual void ResetBTHID ()
 
- Protected Member Functions inherited from BluetoothService
bool checkHciHandle (uint8_t *buf, uint16_t handle)
 

Protected Attributes

uint8_t control_scid [2]
 
uint8_t interrupt_scid [2]
 
uint8_t l2cap_sdp_state
 
uint8_t sdp_scid [2]
 
- Protected Attributes inherited from BluetoothService
void(* pFuncOnInit )(void)
 
BTDpBtd
 
uint16_t hci_handle
 
uint32_t l2cap_event_flag
 
uint8_t identifier
 

BluetoothService implementation

void disconnect ()
 
void ACLData (uint8_t *ACLData)
 
void Run ()
 
void Reset ()
 
void onInit ()
 

Detailed Description

This BluetoothService class implements support for Bluetooth HID devices.

Definition at line 29 of file BTHID.h.

Constructor & Destructor Documentation

◆ BTHID()

BTHID::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

◆ disconnect()

void BTHID::disconnect ( )
virtual

Used this to disconnect the devices.

Implements BluetoothService.

Definition at line 53 of file BTHID.cpp.

◆ GetReportParser()

HIDReportParser* BTHID::GetReportParser ( uint8_t  id)
inline

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.

◆ SetReportParser()

bool BTHID::SetReportParser ( uint8_t  id,
HIDReportParser prs 
)
inline

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.

◆ setProtocolMode()

void BTHID::setProtocolMode ( uint8_t  mode)
inline

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.

◆ setLeds() [1/2]

void BTHID::setLeds ( struct KBDLEDS  data)
inline

Used to set the leds on a keyboard.

Parameters
dataSee KBDLEDS in hidboot.h

Definition at line 81 of file BTHID.h.

◆ setLeds() [2/2]

void BTHID::setLeds ( uint8_t  data)

Used to set the leds on a keyboard.

Parameters
dataSee KBDLEDS in hidboot.h

Definition at line 630 of file BTHID.cpp.

◆ pair()

void BTHID::pair ( void  )
inline

Call this to start the pairing sequence with a device

Definition at line 91 of file BTHID.h.

◆ getLastMessageTime()

uint32_t BTHID::getLastMessageTime ( )
inline

Used to get the millis() of the last Bluetooth DATA input report received on the interrupt channel. This can be used detect if the connection to a Bluetooth device is lost fx if the battery runs out or if it gets out of range.

Returns
Timestamp in milliseconds of the last Bluetooth DATA input report received on the interrupt channel.

Definition at line 101 of file BTHID.h.

◆ ACLData()

void BTHID::ACLData ( uint8_t *  ACLData)
protectedvirtual

Used to pass acldata to the services.

Parameters
ACLDataIncoming acldata.

Implements BluetoothService.

Definition at line 63 of file BTHID.cpp.

◆ Run()

void BTHID::Run ( )
protectedvirtual

Used to run part of the state machine.

Implements BluetoothService.

Definition at line 560 of file BTHID.cpp.

◆ Reset()

void BTHID::Reset ( )
protectedvirtual

Use this to reset the service.

Implements BluetoothService.

Definition at line 43 of file BTHID.cpp.

◆ onInit()

void BTHID::onInit ( )
inlineprotectedvirtual

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 121 of file BTHID.h.

◆ ParseBTHIDData()

virtual void BTHID::ParseBTHIDData ( uint8_t  len,
uint8_t *  buf 
)
inlineprotectedvirtual

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.

Reimplemented in XBOXONESBT, SwitchProBT, PS5BT, and PS4BT.

Definition at line 134 of file BTHID.h.

◆ ParseBTHIDControlData()

virtual void BTHID::ParseBTHIDControlData ( uint8_t  len,
uint8_t *  buf 
)
inlineprotectedvirtual

Same as ParseBTHIDData for reports that are sent through the interrupt pipe (in response to a GET_REPORT).

Definition at line 141 of file BTHID.h.

◆ OnInitBTHID()

virtual void BTHID::OnInitBTHID ( )
inlineprotectedvirtual

Called when a device is connected

Reimplemented in XBOXONESBT, SwitchProBT, PS5BT, and PS4BT.

Definition at line 145 of file BTHID.h.

◆ ResetBTHID()

virtual void BTHID::ResetBTHID ( )
inlineprotectedvirtual

Used to reset any buffers in the class that inherits this

Reimplemented in XBOXONESBT, SwitchProBT, PS5BT, and PS4BT.

Definition at line 149 of file BTHID.h.

Member Data Documentation

◆ connected

bool BTHID::connected

True if a device is connected

Definition at line 88 of file BTHID.h.

◆ control_scid

uint8_t BTHID::control_scid[2]
protected

L2CAP source CID for HID_Control

Definition at line 155 of file BTHID.h.

◆ interrupt_scid

uint8_t BTHID::interrupt_scid[2]
protected

L2CAP source CID for HID_Interrupt

Definition at line 158 of file BTHID.h.

◆ l2cap_sdp_state

uint8_t BTHID::l2cap_sdp_state
protected

Definition at line 160 of file BTHID.h.

◆ sdp_scid

uint8_t BTHID::sdp_scid[2]
protected

Definition at line 161 of file BTHID.h.


The documentation for this class was generated from the following files: