BLE mouse with uBit ( still some issues to resolve )

Dependencies:   BLE_API microbit_ble_mouse mbed nRF51822

Fork of microbit_mouse_BLE by Shahariar Hossain

Embed: (wiki syntax)

« Back to documentation index

KeyboardService Class Reference

KeyboardService Class Reference

HID-over-Gatt keyboard service. More...

#include <KeyboardService.h>

Inherits HIDServiceBase.

Public Member Functions

virtual ble_error_t send (const report_t report)
 Send raw report.
ble_error_t keyUpCode (void)
 Send an empty report, representing keyUp event.
ble_error_t keyDownCode (uint8_t key, uint8_t modifier)
 Send a character, defined by a modifier (CTRL, SHIFT, ALT) and the key.
virtual int _putc (int c)
 Push a key on the internal FIFO.
virtual void sendCallback (void)
 Pop a key from the internal FIFO, and attempt to send it over BLE.
virtual void onDataSent (unsigned count)
 Restart report ticker if it was disabled, after too many consecutive failures.
virtual ble_error_t read (report_t report)
 Read Report.

Protected Member Functions

virtual void startReportTicker (void)
 Start the ticker that sends input reports at regular interval.
virtual void stopReportTicker (void)
 Stop the input report ticker.
GattAttribute ** inputReportDescriptors ()
 Create the Gatt descriptor for a report characteristic.
HID_information_t * HIDInformation ()
 Create the HID information structure.

Detailed Description

HID-over-Gatt keyboard service.

Send keyboard reports over BLE. Users should rely on the high-level functions provided by the Stream API. Because we can't send batches of HID reports, we store pending keys in a circular buffer and rely on the report ticker to spread them over time.

 BLE ble;
 KeyboardService kbd(ble);

 void once_connected_and_paired_callback(void)
 {
     // Sequentially send keys 'Shift'+'h', 'e', 'l', 'l', 'o', '!' and <enter>
     kbd.printf("Hello!\n");
 }

Definition at line 183 of file KeyboardService.h.


Member Function Documentation

virtual int _putc ( int  c ) [virtual]

Push a key on the internal FIFO.

Parameters:
cASCII character to send
Returns:
0 on success, or ENOMEM when the FIFO is full.

Definition at line 281 of file KeyboardService.h.

HID_information_t * HIDInformation (  ) [protected, inherited]

Create the HID information structure.

Definition at line 202 of file HIDServiceBase.cpp.

GattAttribute ** inputReportDescriptors (  ) [protected, inherited]

Create the Gatt descriptor for a report characteristic.

Definition at line 171 of file HIDServiceBase.cpp.

ble_error_t keyDownCode ( uint8_t  key,
uint8_t  modifier 
)

Send a character, defined by a modifier (CTRL, SHIFT, ALT) and the key.

Parameters:
keyCharacter to send (as defined in USB HID Usage Tables)
modifierOptional modifiers (logical OR of enum MODIFIER_KEY)
Returns:
BLE_ERROR_NONE on success, or an error code otherwise.

Definition at line 266 of file KeyboardService.h.

ble_error_t keyUpCode ( void   )

Send an empty report, representing keyUp event.

Definition at line 253 of file KeyboardService.h.

virtual void onDataSent ( unsigned  count ) [virtual]

Restart report ticker if it was disabled, after too many consecutive failures.

This is called by the BLE stack.

Parameters:
countNumber of reports (notifications) sent

Definition at line 347 of file KeyboardService.h.

ble_error_t read ( report_t  report ) [virtual, inherited]

Read Report.

Parameters:
reportReport to fill. Must be of size outputReportLength
Returns:
The read status

Definition at line 215 of file HIDServiceBase.cpp.

virtual ble_error_t send ( const report_t  report ) [virtual]

Send raw report.

Should only be called by sendCallback.

Definition at line 218 of file KeyboardService.h.

virtual void sendCallback ( void   ) [virtual]

Pop a key from the internal FIFO, and attempt to send it over BLE.

Definition at line 302 of file KeyboardService.h.

void startReportTicker ( void   ) [protected, virtual, inherited]

Start the ticker that sends input reports at regular interval.

Note:
reportTickerIsActive describes the state of the ticker and can be used by HIDS implementations.

Definition at line 155 of file HIDServiceBase.cpp.

void stopReportTicker ( void   ) [protected, virtual, inherited]

Stop the input report ticker.

Definition at line 162 of file HIDServiceBase.cpp.