forked from sandeepmistry/arduino-BLEPeripheral
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBLEHIDReportMapCharacteristic.cpp
More file actions
46 lines (34 loc) · 1.15 KB
/
BLEHIDReportMapCharacteristic.cpp
File metadata and controls
46 lines (34 loc) · 1.15 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
#include "BLEHIDReportMapCharacteristic.h"
BLEHIDReportMapCharacteristic::BLEHIDReportMapCharacteristic() :
BLEConstantCharacteristic("2a4b", NULL, 0),
_hids(NULL),
_numHids(0)
{
}
unsigned char BLEHIDReportMapCharacteristic::valueSize() const {
unsigned char valueSize = 0;
for (unsigned char i = 0; i < this->_numHids; i++) {
valueSize += this->_hids[i]->getDescriptorLength();
}
return valueSize;
}
unsigned char BLEHIDReportMapCharacteristic::valueLength() const {
return this->valueSize();
}
unsigned char BLEHIDReportMapCharacteristic::operator[] (int offset) const {
unsigned char value = 0x00;
unsigned char totalOffset = 0;
for (unsigned char i = 0; i < this->_numHids; i++) {
unsigned char descriptorLength = this->_hids[i]->getDescriptorLength();
if ((offset >= totalOffset) && (offset < (totalOffset + descriptorLength))) {
value = this->_hids[i]->getDescriptorValueAtOffset(offset - totalOffset);
break;
}
totalOffset += descriptorLength;
}
return value;
}
void BLEHIDReportMapCharacteristic::setHids(BLEHID** hids, unsigned char numHids) {
this->_hids = hids;
this->_numHids = numHids;
}