Delta
/
BLE_HIDScanner_DELTA
Example for BLE HID scanner
Fork of BLE_HIDScanner_DELTA by
Diff: HIDService.h
- Revision:
- 2:9f46fa6237dd
- Parent:
- 1:8bca989a70be
--- a/HIDService.h Tue Feb 07 02:51:56 2017 +0000 +++ b/HIDService.h Mon Mar 27 09:58:38 2017 +0000 @@ -2,6 +2,9 @@ #define __BLE_HID_SERVICE_H__ #include "BLE.h" + +#define BLE_UUID_DESCRIPTOR_REPORT_REFERENCE 0x2908 + /** * @class Human Interface Device Service * @brief BLE Human Interface Device Service. This service displays the Glucose measurement value represented as a 16bit Float format.<br> @@ -9,19 +12,31 @@ * @Email: marco.missyou@gmail.com */ +typedef struct { + uint8_t ID; + uint8_t type; +} report_reference_t; + +enum ReportType { + INPUT_REPORT = 0x1, + OUTPUT_REPORT = 0x2, + FEATURE_REPORT = 0x3, +}; + extern const uint8_t KeyboardReportMap[76]; class HIDService { public: - HIDService(BLEDevice &_ble, const uint8_t* key = &KeyboardReportMap[0]): + HIDService(BLE &_ble, const uint8_t* key = &KeyboardReportMap[0]): ble(_ble), protocol_modeValue(1), // Report Protocol Mode(1), Boot Protocol Mode(0) KeyboardMap(key), Protocol_Mode(GattCharacteristic::UUID_PROTOCOL_MODE_CHAR, &protocol_modeValue, 1, 1, GattCharacteristic::BLE_GATT_CHAR_PROPERTIES_WRITE_WITHOUT_RESPONSE|GattCharacteristic::BLE_GATT_CHAR_PROPERTIES_READ), - ReportMap(GattCharacteristic::UUID_REPORT_MAP_CHAR, KeyboardMap.getPointer(), 76, sizeof(KeyboardMap), GattCharacteristic::BLE_GATT_CHAR_PROPERTIES_READ |GattCharacteristic::BLE_GATT_CHAR_PROPERTIES_NOTIFY), - Report(GattCharacteristic::UUID_REPORT_CHAR, reportValue.getPointer(), 8, 8, GattCharacteristic::BLE_GATT_CHAR_PROPERTIES_NOTIFY|GattCharacteristic::BLE_GATT_CHAR_PROPERTIES_READ), + ReportMap(GattCharacteristic::UUID_REPORT_MAP_CHAR, KeyboardMap.getPointer(), 76, sizeof(KeyboardMap), GattCharacteristic::BLE_GATT_CHAR_PROPERTIES_READ), + Report(GattCharacteristic::UUID_REPORT_CHAR, reportValue.getPointer(), 8, 8, GattCharacteristic::BLE_GATT_CHAR_PROPERTIES_NOTIFY|GattCharacteristic::BLE_GATT_CHAR_PROPERTIES_READ|GattCharacteristic::BLE_GATT_CHAR_PROPERTIES_WRITE, inputReportDescriptors(), 1), HID_Information(GattCharacteristic::UUID_HID_INFORMATION_CHAR, hidInformation.getPointer(), 4, 4, GattCharacteristic::BLE_GATT_CHAR_PROPERTIES_READ), - HID_Control_Point(GattCharacteristic::UUID_HID_CONTROL_POINT_CHAR, &hidcontrolPointer, 1, 1, GattCharacteristic::BLE_GATT_CHAR_PROPERTIES_WRITE_WITHOUT_RESPONSE) + HID_Control_Point(GattCharacteristic::UUID_HID_CONTROL_POINT_CHAR, &hidcontrolPointer, 1, 1, GattCharacteristic::BLE_GATT_CHAR_PROPERTIES_WRITE_WITHOUT_RESPONSE), + inputReportReferenceDescriptor(BLE_UUID_DESCRIPTOR_REPORT_REFERENCE,(uint8_t *)&inputReportReferenceData, 2, 2) { static bool serviceAdded = false; /* We should only ever need to add the heart rate service once. */ if (serviceAdded) { @@ -73,6 +88,16 @@ return KeyboardMap; } }; + + GattAttribute** HIDService::inputReportDescriptors() { + inputReportReferenceData.ID = 0; + inputReportReferenceData.type = INPUT_REPORT; + + static GattAttribute *descs[] = { + &inputReportReferenceDescriptor, + }; + return descs; + } private: struct ReportStructure { @@ -114,7 +139,7 @@ }; private: - BLEDevice &ble; + BLE &ble; uint8_t protocol_modeValue; ReportStructure reportValue; uint8_t hidcontrolPointer; @@ -128,5 +153,7 @@ // ReadOnlyGattCharacteristic Boot_Mouse_Input_Report; GattCharacteristic HID_Information; GattCharacteristic HID_Control_Point; + GattAttribute inputReportReferenceDescriptor; + report_reference_t inputReportReferenceData; }; #endif /* #ifndef __BLE_GLUCOSE_SERVICE_H__*/ \ No newline at end of file