NimBLE-Arduino 1.4.2
Loading...
Searching...
No Matches
NimBLEHIDDevice.h
1/*
2 * NimBLEHIDDevice.h
3 *
4 * Created: on Oct 06 2020
5 * Author wakwak-koba
6 *
7 * Originally:
8 *
9 * BLEHIDDevice.h
10 *
11 * Created on: Jan 03, 2018
12 * Author: chegewara
13 */
14
15#ifndef _BLEHIDDEVICE_H_
16#define _BLEHIDDEVICE_H_
17
18#include "nimconfig.h"
19#if defined(CONFIG_BT_ENABLED) && defined(CONFIG_BT_NIMBLE_ROLE_BROADCASTER)
20
21#include "NimBLECharacteristic.h"
22#include "NimBLEService.h"
23#include "NimBLEDescriptor.h"
24#include "HIDTypes.h"
25
26#define GENERIC_HID 0x03C0
27#define HID_KEYBOARD 0x03C1
28#define HID_MOUSE 0x03C2
29#define HID_JOYSTICK 0x03C3
30#define HID_GAMEPAD 0x03C4
31#define HID_TABLET 0x03C5
32#define HID_CARD_READER 0x03C6
33#define HID_DIGITAL_PEN 0x03C7
34#define HID_BARCODE 0x03C8
35
36#define PNPVersionField(MajorVersion, MinorVersion, PatchVersion) ((MajorVersion << 16) & 0xFF00) | ((MinorVersion << 8) & 0x00F0) | (PatchVersion & 0x000F)
37
42public:
44 virtual ~NimBLEHIDDevice();
45
46 void reportMap(uint8_t* map, uint16_t);
47 void startServices();
48
52
54 void manufacturer(std::string name);
55 //NimBLECharacteristic* pnp();
56 void pnp(uint8_t sig, uint16_t vid, uint16_t pid, uint16_t version);
57 //NimBLECharacteristic* hidInfo();
58 void hidInfo(uint8_t country, uint8_t flags);
59 NimBLECharacteristic* batteryLevel();
60 void setBatteryLevel(uint8_t level);
61
62
63 //NimBLECharacteristic* reportMap();
65 NimBLECharacteristic* inputReport(uint8_t reportID);
66 NimBLECharacteristic* outputReport(uint8_t reportID);
67 NimBLECharacteristic* featureReport(uint8_t reportID);
71
72private:
73 NimBLEService* m_deviceInfoService; //0x180a
74 NimBLEService* m_hidService; //0x1812
75 NimBLEService* m_batteryService = 0; //0x180f
76
77 NimBLECharacteristic* m_manufacturerCharacteristic; //0x2a29
78 NimBLECharacteristic* m_pnpCharacteristic; //0x2a50
79 NimBLECharacteristic* m_hidInfoCharacteristic; //0x2a4a
80 NimBLECharacteristic* m_reportMapCharacteristic; //0x2a4b
81 NimBLECharacteristic* m_hidControlCharacteristic; //0x2a4c
82 NimBLECharacteristic* m_protocolModeCharacteristic; //0x2a4e
83 NimBLECharacteristic* m_batteryLevelCharacteristic; //0x2a19
84};
85
86#endif /* CONFIG_BT_ENABLED && CONFIG_BT_NIMBLE_ROLE_BROADCASTER */
87#endif /* _BLEHIDDEVICE_H_ */
The model of a BLE Characteristic.
Definition: NimBLECharacteristic.h:63
A model of a BLE Human Interface Device.
Definition: NimBLEHIDDevice.h:41
NimBLEService * deviceInfo()
Returns a pointer to the device information service.
Definition: NimBLEHIDDevice.cpp:247
NimBLECharacteristic * protocolMode()
Returns a pointer to the protocol mode characteristic.
Definition: NimBLEHIDDevice.cpp:209
NimBLEService * batteryService()
Returns a pointer to the battery service.
Definition: NimBLEHIDDevice.cpp:261
void hidInfo(uint8_t country, uint8_t flags)
Sets the HID Information characteristic value.
Definition: NimBLEHIDDevice.cpp:135
NimBLECharacteristic * manufacturer()
Create a manufacturer characteristic (this characteristic is optional).
Definition: NimBLEHIDDevice.cpp:94
NimBLECharacteristic * bootInput()
Creates a keyboard boot input report characteristic.
Definition: NimBLEHIDDevice.cpp:188
NimBLECharacteristic * featureReport(uint8_t reportID)
Create feature report characteristic.
Definition: NimBLEHIDDevice.cpp:175
void pnp(uint8_t sig, uint16_t vid, uint16_t pid, uint16_t version)
Sets the Plug n Play characteristic value.
Definition: NimBLEHIDDevice.cpp:117
void startServices()
Start the HID device services. This function called when all the services have been created.
Definition: NimBLEHIDDevice.cpp:85
NimBLECharacteristic * hidControl()
Returns a pointer to the HID control point characteristic.
Definition: NimBLEHIDDevice.cpp:202
void reportMap(uint8_t *map, uint16_t)
Set the report map data formatting information.
Definition: NimBLEHIDDevice.cpp:77
void setBatteryLevel(uint8_t level)
Set the battery level characteristic value.
Definition: NimBLEHIDDevice.cpp:217
NimBLECharacteristic * inputReport(uint8_t reportID)
Create input report characteristic.
Definition: NimBLEHIDDevice.cpp:145
NimBLECharacteristic * outputReport(uint8_t reportID)
Create output report characteristic.
Definition: NimBLEHIDDevice.cpp:160
NimBLECharacteristic * bootOutput()
Create a keyboard boot output report characteristic.
Definition: NimBLEHIDDevice.cpp:195
NimBLEService * hidService()
Returns a pointer to the HID service.
Definition: NimBLEHIDDevice.cpp:254
The model of a BLE server.
Definition: NimBLEServer.h:46
The model of a BLE service.
Definition: NimBLEService.h:34