-
-
Notifications
You must be signed in to change notification settings - Fork 208
Expand file tree
/
Copy pathNimBLEHIDDevice.h
More file actions
90 lines (78 loc) · 3.67 KB
/
NimBLEHIDDevice.h
File metadata and controls
90 lines (78 loc) · 3.67 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
/*
* Copyright 2020-2025 Ryan Powell <ryan@nable-embedded.io> and
* esp-nimble-cpp, NimBLE-Arduino contributors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef NIMBLE_CPP_HIDDEVICE_H_
#define NIMBLE_CPP_HIDDEVICE_H_
#include "syscfg/syscfg.h"
#if CONFIG_BT_NIMBLE_ENABLED && MYNEWT_VAL(BLE_ROLE_BROADCASTER) && MYNEWT_VAL(BLE_ROLE_PERIPHERAL)
# include <stdint.h>
# include <string>
# define GENERIC_HID 0x03C0
# define HID_KEYBOARD 0x03C1
# define HID_MOUSE 0x03C2
# define HID_JOYSTICK 0x03C3
# define HID_GAMEPAD 0x03C4
# define HID_TABLET 0x03C5
# define HID_CARD_READER 0x03C6
# define HID_DIGITAL_PEN 0x03C7
# define HID_BARCODE 0x03C8
# define PNPVersionField(MajorVersion, MinorVersion, PatchVersion) \
((MajorVersion << 16) & 0xFF00) | ((MinorVersion << 8) & 0x00F0) | (PatchVersion & 0x000F)
class NimBLEServer;
class NimBLEService;
class NimBLECharacteristic;
/**
* @brief A model of a BLE Human Interface Device.
*/
class NimBLEHIDDevice {
public:
NimBLEHIDDevice(NimBLEServer* server);
void setReportMap(uint8_t* map, uint16_t);
void startServices() __attribute__((deprecated("Services are now started by the server when start() is called, "
"this function is no longer needed and will be removed in a future release.")));
bool setManufacturer(const std::string& name);
void setPnp(uint8_t sig, uint16_t vid, uint16_t pid, uint16_t version);
void setHidInfo(uint8_t country, uint8_t flags);
void setBatteryLevel(uint8_t level, bool notify = false);
NimBLECharacteristic* getBatteryLevel();
NimBLECharacteristic* getReportMap();
NimBLECharacteristic* getHidControl();
NimBLECharacteristic* getInputReport(uint8_t reportId);
NimBLECharacteristic* getOutputReport(uint8_t reportId);
NimBLECharacteristic* getFeatureReport(uint8_t reportId);
NimBLECharacteristic* getProtocolMode();
NimBLECharacteristic* getBootInput();
NimBLECharacteristic* getBootOutput();
NimBLECharacteristic* getPnp();
NimBLECharacteristic* getHidInfo();
NimBLEService* getDeviceInfoService();
NimBLEService* getHidService();
NimBLEService* getBatteryService();
private:
NimBLEService* m_deviceInfoSvc{nullptr}; // 0x180a
NimBLEService* m_hidSvc{nullptr}; // 0x1812
NimBLEService* m_batterySvc{nullptr}; // 0x180f
NimBLECharacteristic* m_manufacturerChr{nullptr}; // 0x2a29
NimBLECharacteristic* m_pnpChr{nullptr}; // 0x2a50
NimBLECharacteristic* m_hidInfoChr{nullptr}; // 0x2a4a
NimBLECharacteristic* m_reportMapChr{nullptr}; // 0x2a4b
NimBLECharacteristic* m_hidControlChr{nullptr}; // 0x2a4c
NimBLECharacteristic* m_protocolModeChr{nullptr}; // 0x2a4e
NimBLECharacteristic* m_batteryLevelChr{nullptr}; // 0x2a19
NimBLECharacteristic* locateReportCharacteristicByIdAndType(uint8_t reportId, uint8_t reportType);
};
#endif // CONFIG_BT_NIMBLE_ENABLED && MYNEWT_VAL(BLE_ROLE_BROADCASTER) && MYNEWT_VAL(BLE_ROLE_PERIPHERAL)
#endif // NIMBLE_CPP_HIDDEVICE_H_