clean up, update HID
This commit is contained in:
1 parent
4142ee63e4
commit
a6861aee31
5 files changed
+44
-21
No files matched your search
@@ -49,7 +49,7 @@ __StackTop:
|
||||
#ifdef __HEAP_SIZE
|
||||
.equ Heap_Size, __HEAP_SIZE
|
||||
#else
|
||||
.equ Heap_Size, 24576 /* TODO Should be all space left */
|
||||
.equ Heap_Size, 25600 /* TODO Should be all space left */
|
||||
#endif
|
||||
.globl __HeapBase
|
||||
.globl __HeapLimit
|
||||
|
||||
@@ -49,7 +49,7 @@
|
||||
#define CFG_GAP_ADV_TIMEOUT_S 30
|
||||
|
||||
#define CFG_BLE_TX_POWER_LEVEL 0
|
||||
#define CFG_DEFAULT_NAME "Bluefruit"
|
||||
#define CFG_DEFAULT_NAME "Bluefruit52"
|
||||
|
||||
|
||||
// Converts an integer of 1.25ms units to msecs
|
||||
|
||||
@@ -44,13 +44,27 @@ enum
|
||||
REPORT_ID_GAMEPAD
|
||||
};
|
||||
|
||||
// LED Indicator Kana | Compose | Scroll Lock | CapsLock | NumLock
|
||||
// HID_REPORT_ID ( REPORT_ID_KEYBOARD + 2 ),
|
||||
// HID_USAGE_PAGE ( HID_USAGE_PAGE_LED ),
|
||||
// /* 5-bit Led report */
|
||||
// HID_USAGE_MIN ( 1 ),
|
||||
// HID_USAGE_MAX ( 5 ),
|
||||
// HID_REPORT_COUNT ( 5 ),
|
||||
// HID_REPORT_SIZE ( 1 ),
|
||||
// HID_OUTPUT ( HID_DATA | HID_VARIABLE | HID_ABSOLUTE ),
|
||||
// /* led padding */
|
||||
// HID_REPORT_COUNT ( 1 ),
|
||||
// HID_REPORT_SIZE ( 3 ),
|
||||
// HID_OUTPUT ( HID_CONSTANT ),
|
||||
|
||||
uint8_t const hid_report_descriptor[] =
|
||||
{
|
||||
//------------- Keyboard Report -------------//
|
||||
HID_USAGE_PAGE ( HID_USAGE_PAGE_DESKTOP ),
|
||||
HID_USAGE ( HID_USAGE_DESKTOP_KEYBOARD ),
|
||||
HID_COLLECTION ( HID_COLLECTION_APPLICATION ),
|
||||
HID_REPORT_ID ( REPORT_ID_KEYBOARD ),
|
||||
// HID_REPORT_ID ( REPORT_ID_KEYBOARD + 0 ),
|
||||
HID_USAGE_PAGE( HID_USAGE_PAGE_KEYBOARD ),
|
||||
// 8 bits Modifier Keys (Shfit, Control, Alt)
|
||||
HID_USAGE_MIN ( 224 ),
|
||||
@@ -199,7 +213,7 @@ uint8_t const hid_report_descriptor[] =
|
||||
};
|
||||
|
||||
BLEHidAdafruit::BLEHidAdafruit(void)
|
||||
: BLEHidGeneric(1, 0, 0)
|
||||
: BLEHidGeneric(1, 1, 0)
|
||||
{
|
||||
_kbd_leds = 0;
|
||||
}
|
||||
@@ -209,8 +223,7 @@ err_t BLEHidAdafruit::start(void)
|
||||
uint16_t input_len[1] = { sizeof(hid_keyboard_report_t) };
|
||||
uint16_t output_len[1] = { sizeof(_kbd_leds) } ;
|
||||
|
||||
// setReportLen(input_len, output_len, NULL);
|
||||
setReportLen(input_len, NULL, NULL);
|
||||
setReportLen(input_len, output_len, NULL);
|
||||
|
||||
setBootProtocol(true, false);
|
||||
setReportMap(hid_report_descriptor, sizeof(hid_report_descriptor));
|
||||
|
||||
@@ -203,7 +203,7 @@ BLEHidGeneric::BLEHidGeneric(uint8_t num_input, uint8_t num_output, uint8_t num_
|
||||
|
||||
_chr_protocol = NULL;
|
||||
_chr_inputs = _chr_outputs = _chr_features = NULL;
|
||||
_chr_boot_keyboard = _chr_boot_mouse = NULL;
|
||||
_chr_boot_keyboard_input = _chr_boot_keyboard_output = _chr_boot_mouse_input = NULL;
|
||||
|
||||
_output_cbs = NULL;
|
||||
|
||||
@@ -288,7 +288,7 @@ err_t BLEHidGeneric::start(void)
|
||||
_chr_inputs[i].setUuid(UUID16_CHR_REPORT);
|
||||
_chr_inputs[i].setProperties(CHR_PROPS_READ | CHR_PROPS_NOTIFY);
|
||||
_chr_inputs[i].setPermission(SECMODE_ENC_NO_MITM, SECMODE_NO_ACCESS);
|
||||
_chr_inputs[i].setReportRefDescriptor(i, REPORT_TYPE_INPUT);
|
||||
_chr_inputs[i].setReportRefDescriptor(i+0, REPORT_TYPE_INPUT);
|
||||
|
||||
// Input report len is configured, else variable len up to 255
|
||||
if ( _input_len ) _chr_inputs[i].setFixedLen( _input_len[i] );
|
||||
@@ -302,13 +302,15 @@ err_t BLEHidGeneric::start(void)
|
||||
_chr_outputs[i].setUuid(UUID16_CHR_REPORT);
|
||||
_chr_outputs[i].setProperties(CHR_PROPS_READ | CHR_PROPS_WRITE | CHR_PROPS_WRITE_WO_RESP);
|
||||
_chr_outputs[i].setPermission(SECMODE_ENC_NO_MITM, SECMODE_NO_ACCESS);
|
||||
_chr_outputs[i].setReportRefDescriptor(i, REPORT_TYPE_OUTPUT);
|
||||
_chr_outputs[i].setReportRefDescriptor(i+0, REPORT_TYPE_OUTPUT);
|
||||
_chr_outputs[i].setWriteCallback(blehidgeneric_output_cb);
|
||||
|
||||
// Input report len is configured, else variable len up to 255
|
||||
if ( _output_len ) _chr_outputs[i].setFixedLen( _output_len[i] );
|
||||
|
||||
VERIFY_STATUS( _chr_outputs[i].start() );
|
||||
|
||||
_chr_outputs[i].write( (uint8_t) 0 );
|
||||
}
|
||||
|
||||
// Report Map (HID Report Descriptor)
|
||||
@@ -322,21 +324,28 @@ err_t BLEHidGeneric::start(void)
|
||||
// Boot Keyboard Input Report
|
||||
if ( _boot_keyboard )
|
||||
{
|
||||
_chr_boot_keyboard = new BLECharacteristic(UUID16_CHR_BOOT_KEYBOARD_INPUT_REPORT);
|
||||
_chr_boot_keyboard->setProperties(CHR_PROPS_READ | CHR_PROPS_NOTIFY);
|
||||
_chr_boot_keyboard->setFixedLen(sizeof(hid_keyboard_report_t));
|
||||
_chr_boot_keyboard->setPermission(SECMODE_ENC_NO_MITM, SECMODE_NO_ACCESS);
|
||||
VERIFY_STATUS(_chr_boot_keyboard->start());
|
||||
_chr_boot_keyboard_input = new BLECharacteristic(UUID16_CHR_BOOT_KEYBOARD_INPUT_REPORT);
|
||||
_chr_boot_keyboard_input->setProperties(CHR_PROPS_READ | CHR_PROPS_NOTIFY);
|
||||
_chr_boot_keyboard_input->setFixedLen(8); // boot keyboard is 8 bytes
|
||||
_chr_boot_keyboard_input->setPermission(SECMODE_ENC_NO_MITM, SECMODE_NO_ACCESS);
|
||||
VERIFY_STATUS(_chr_boot_keyboard_input->start());
|
||||
|
||||
_chr_boot_keyboard_output = new BLECharacteristic(UUID16_CHR_BOOT_KEYBOARD_OUTPUT_REPORT);
|
||||
_chr_boot_keyboard_output->setProperties(CHR_PROPS_READ | CHR_PROPS_WRITE | CHR_PROPS_WRITE_WO_RESP);
|
||||
_chr_boot_keyboard_output->setFixedLen(1); // boot keyboard is 1 byte
|
||||
_chr_boot_keyboard_output->setPermission(SECMODE_ENC_NO_MITM, SECMODE_NO_ACCESS);
|
||||
VERIFY_STATUS(_chr_boot_keyboard_output->start());
|
||||
_chr_boot_keyboard_output->write((uint8_t) 0);
|
||||
}
|
||||
|
||||
// Boot Mouse Input Report
|
||||
if ( _boot_mouse )
|
||||
{
|
||||
_chr_boot_mouse = new BLECharacteristic(UUID16_CHR_BOOT_MOUSE_INPUT_REPORT);
|
||||
_chr_boot_mouse->setProperties(CHR_PROPS_READ | CHR_PROPS_NOTIFY);
|
||||
_chr_boot_mouse->setFixedLen(sizeof(hid_mouse_report_t));
|
||||
_chr_boot_mouse->setPermission(SECMODE_ENC_NO_MITM, SECMODE_NO_ACCESS);
|
||||
VERIFY_STATUS(_chr_boot_mouse->start());
|
||||
_chr_boot_mouse_input = new BLECharacteristic(UUID16_CHR_BOOT_MOUSE_INPUT_REPORT);
|
||||
_chr_boot_mouse_input->setProperties(CHR_PROPS_READ | CHR_PROPS_NOTIFY);
|
||||
_chr_boot_mouse_input->setFixedLen(sizeof(hid_mouse_report_t));
|
||||
_chr_boot_mouse_input->setPermission(SECMODE_ENC_NO_MITM, SECMODE_NO_ACCESS);
|
||||
VERIFY_STATUS(_chr_boot_mouse_input->start());
|
||||
}
|
||||
|
||||
// HID Info
|
||||
|
||||
@@ -122,8 +122,9 @@ class BLEHidGeneric : public BLEService
|
||||
BLECharacteristic* _chr_outputs;
|
||||
BLECharacteristic* _chr_features;
|
||||
|
||||
BLECharacteristic* _chr_boot_keyboard;
|
||||
BLECharacteristic* _chr_boot_mouse;
|
||||
BLECharacteristic* _chr_boot_keyboard_input;
|
||||
BLECharacteristic* _chr_boot_keyboard_output;
|
||||
BLECharacteristic* _chr_boot_mouse_input;
|
||||
|
||||
BLECharacteristic _chr_control;
|
||||
|
||||
|
||||
Reference in new issue
Block a user