NimBLE-Arduino 2.1.2
Loading...
Searching...
No Matches
NimBLEHIDDevice Class Reference

A model of a BLE Human Interface Device. More...

#include <NimBLEHIDDevice.h>

Public Member Functions

 NimBLEHIDDevice (NimBLEServer *server)
 Construct a default NimBLEHIDDevice object.
 
void setReportMap (uint8_t *map, uint16_t)
 Set the report map data formatting information.
 
void startServices ()
 Start the HID device services. This function called when all the services have been created.
 
bool setManufacturer (const std::string &name)
 Get the manufacturer characteristic (this characteristic is optional).
 
void setPnp (uint8_t sig, uint16_t vid, uint16_t pid, uint16_t version)
 Sets the Plug n Play characteristic value.
 
void setHidInfo (uint8_t country, uint8_t flags)
 Sets the HID Information characteristic value.
 
void setBatteryLevel (uint8_t level, bool notify=false)
 Set the battery level characteristic value.
 
NimBLECharacteristicgetBatteryLevel ()
 Get the battery level characteristic.
 
NimBLECharacteristicgetReportMap ()
 Get the report map characteristic.
 
NimBLECharacteristicgetHidControl ()
 Get the HID control point characteristic.
 
NimBLECharacteristicgetInputReport (uint8_t reportId)
 Get the input report characteristic.
 
NimBLECharacteristicgetOutputReport (uint8_t reportId)
 Get the output report characteristic.
 
NimBLECharacteristicgetFeatureReport (uint8_t reportId)
 Get the feature report characteristic.
 
NimBLECharacteristicgetProtocolMode ()
 Get the HID protocol mode characteristic.
 
NimBLECharacteristicgetBootInput ()
 Get a keyboard boot input report characteristic.
 
NimBLECharacteristicgetBootOutput ()
 Create a keyboard boot output report characteristic.
 
NimBLECharacteristicgetPnp ()
 Get the PnP characteristic.
 
NimBLECharacteristicgetHidInfo ()
 Get the HID information characteristic.
 
NimBLEServicegetDeviceInfoService ()
 Get the manufacturer characteristic.
 
NimBLEServicegetHidService ()
 Get the HID service.
 
NimBLEServicegetBatteryService ()
 Get the battery service.
 

Detailed Description

A model of a BLE Human Interface Device.

Constructor & Destructor Documentation

◆ NimBLEHIDDevice()

NimBLEHIDDevice::NimBLEHIDDevice ( NimBLEServer server)

Construct a default NimBLEHIDDevice object.

Parameters
[in]serverA pointer to the server instance this HID Device will use.

Member Function Documentation

◆ getBatteryLevel()

NimBLECharacteristic * NimBLEHIDDevice::getBatteryLevel ( )

Get the battery level characteristic.

Returns
A pointer to the battery level characteristic

◆ getBatteryService()

NimBLEService * NimBLEHIDDevice::getBatteryService ( )

Get the battery service.

Returns
A pointer to the battery service.

◆ getBootInput()

NimBLECharacteristic * NimBLEHIDDevice::getBootInput ( )

Get a keyboard boot input report characteristic.

Returns
A pointer to the boot input report characteristic, or nullptr on error.

This will create the characteristic if not already created.

◆ getBootOutput()

NimBLECharacteristic * NimBLEHIDDevice::getBootOutput ( )

Create a keyboard boot output report characteristic.

Returns
A pointer to the boot output report characteristic, or nullptr on error.

This will create the characteristic if not already created.

◆ getDeviceInfoService()

NimBLEService * NimBLEHIDDevice::getDeviceInfoService ( )

Get the manufacturer characteristic.

Returns
A pointer to the manufacturer characteristic.

◆ getFeatureReport()

NimBLECharacteristic * NimBLEHIDDevice::getFeatureReport ( uint8_t  reportId)

Get the feature report characteristic.

Parameters
[in]reportIdFeature report ID, the same as in report map for feature object related to the characteristic.
Returns
NimBLECharacteristic* A pointer to feature report characteristic. Store this value to avoid computational overhead.
nullptr If the report is already created as an input or output report.

This will create the characteristic if not already created.

◆ getHidControl()

NimBLECharacteristic * NimBLEHIDDevice::getHidControl ( )

Get the HID control point characteristic.

Returns
A pointer to the HID control point characteristic.

◆ getHidInfo()

NimBLECharacteristic * NimBLEHIDDevice::getHidInfo ( )

Get the HID information characteristic.

Returns
A pointer to the HID information characteristic.

◆ getHidService()

NimBLEService * NimBLEHIDDevice::getHidService ( )

Get the HID service.

Returns
A pointer to the HID service.

◆ getInputReport()

NimBLECharacteristic * NimBLEHIDDevice::getInputReport ( uint8_t  reportId)

Get the input report characteristic.

Parameters
[in]reportIdInput report ID, the same as in report map for input object related to the characteristic.
Returns
NimBLECharacteristic* A pointer to the input report characteristic. Store this value to avoid computational overhead.
nullptr If the report is already created as an output or feature report.

This will create the characteristic if not already created.

◆ getOutputReport()

NimBLECharacteristic * NimBLEHIDDevice::getOutputReport ( uint8_t  reportId)

Get the output report characteristic.

Parameters
[in]reportIdOutput report ID, the same as in report map for output object related to the characteristic.
Returns
NimBLECharacteristic* A pointer to the output report characteristic. Store this value to avoid computational overhead.
nullptr If the report is already created as an input or feature report.

This will create the characteristic if not already created.

◆ getPnp()

NimBLECharacteristic * NimBLEHIDDevice::getPnp ( )

Get the PnP characteristic.

Returns
A pointer to the PnP characteristic.

◆ getProtocolMode()

NimBLECharacteristic * NimBLEHIDDevice::getProtocolMode ( )

Get the HID protocol mode characteristic.

Returns
a pointer to the protocol mode characteristic.

◆ getReportMap()

NimBLECharacteristic * NimBLEHIDDevice::getReportMap ( )

Get the report map characteristic.

Returns
A pointer to the report map characteristic.

◆ setBatteryLevel()

void NimBLEHIDDevice::setBatteryLevel ( uint8_t  level,
bool  notify = false 
)

Set the battery level characteristic value.

Parameters
[in]levelThe battery level value.
[in]notifyIf true sends a notification to the peer device, otherwise not. default = false

◆ setHidInfo()

void NimBLEHIDDevice::setHidInfo ( uint8_t  country,
uint8_t  flags 
)

Sets the HID Information characteristic value.

Parameters
[in]countryThe country code for the device.
[in]flagsThe HID Class Specification release number to use.

◆ setManufacturer()

bool NimBLEHIDDevice::setManufacturer ( const std::string &  name)

Get the manufacturer characteristic (this characteristic is optional).

The characteristic will be created if not already existing.

Returns
True if the name was set and/or the characteristic created.

◆ setPnp()

void NimBLEHIDDevice::setPnp ( uint8_t  sig,
uint16_t  vid,
uint16_t  pid,
uint16_t  version 
)

Sets the Plug n Play characteristic value.

Parameters
[in]sigThe vendor ID source number.
[in]vidThe vendor ID number.
[in]pidThe product ID number.
[in]versionThe produce version number.

◆ setReportMap()

void NimBLEHIDDevice::setReportMap ( uint8_t *  map,
uint16_t  size 
)

Set the report map data formatting information.

Parameters
[in]mapA pointer to an array with the values to set.
[in]sizeThe number of values in the array.