Skip to content

Commit

Permalink
rename hid client setProtocolMode() to setBootMode()
Browse files Browse the repository at this point in the history
  • Loading branch information
hathach committed Jun 6, 2019
1 parent 79252a5 commit f84899f
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 19 deletions.
Expand Up @@ -111,9 +111,9 @@ void connect_callback(uint16_t conn_handle)
Serial.print("Country code: "); Serial.println(hidInfo[2]);
Serial.printf("HID Flags : 0x%02X\n", hidInfo[3]);

// BLEClientHidAdafruit currently only suports Boot Protocol Mode
// BLEClientHidAdafruit currently only supports Boot Protocol Mode
// for Keyboard and Mouse. Let's set the protocol mode on prph to Boot Mode
hid.setProtocolMode(HID_PROTOCOL_MODE_BOOT);
hid.setBootMode(true);

// Enable Keyboard report notification if present on prph
if ( hid.keyboardPresent() ) hid.enableKeyboard();
Expand Down
3 changes: 0 additions & 3 deletions libraries/Bluefruit52Lib/keywords.txt
Expand Up @@ -471,9 +471,6 @@ SECMODE_SIGNED_WITH_MITM LITERAL1
# HID Constants
#######################################

HID_PROTOCOL_MODE_BOOT LITERAL1
HID_PROTOCOL_MODE_REPORT LITERAL1

MOUSE_BUTTON_LEFT LITERAL1
MOUSE_BUTTON_RIGHT LITERAL1
MOUSE_BUTTON_MIDDLE LITERAL1
Expand Down
5 changes: 3 additions & 2 deletions libraries/Bluefruit52Lib/src/clients/BLEClientHidAdafruit.cpp
Expand Up @@ -127,9 +127,10 @@ uint8_t BLEClientHidAdafruit::getCountryCode(void)
return info[2];
}

bool BLEClientHidAdafruit::setProtocolMode(uint8_t mode)
bool BLEClientHidAdafruit::setBootMode(bool boot)
{
return _protcol_mode.write8(mode);
// 0 is boot, 1 is protocol
return _protcol_mode.write8(1-boot);
}

/*------------------------------------------------------------------*/
Expand Down
Expand Up @@ -58,7 +58,7 @@ class BLEClientHidAdafruit : public BLEClientService
bool getHidInfo(uint8_t info[4]);
uint8_t getCountryCode(void);

bool setProtocolMode(uint8_t mode);
bool setBootMode(bool boot);

// Keyboard API
bool keyboardPresent(void);
Expand Down
6 changes: 3 additions & 3 deletions libraries/Bluefruit52Lib/src/services/BLEHidGeneric.cpp
Expand Up @@ -46,7 +46,7 @@ BLEHidGeneric::BLEHidGeneric(uint8_t num_input, uint8_t num_output, uint8_t num_
: BLEService(UUID16_SVC_HUMAN_INTERFACE_DEVICE), _chr_control(UUID16_CHR_HID_CONTROL_POINT)
{
_has_keyboard = _has_mouse = false;
_protocol_mode = HID_PROTOCOL_MODE_REPORT;
_report_mode = true; // default is report mode

_report_map = NULL;
_report_map_len = 0;
Expand Down Expand Up @@ -135,7 +135,7 @@ void BLEHidGeneric::blehid_generic_protocol_mode_cb(uint16_t conn_hdl, BLECharac
(void) conn_hdl;

BLEHidGeneric& svc = (BLEHidGeneric&) chr->parentService();
svc._protocol_mode = *data;
svc._report_mode = (*data); // 0 is boot, 1 Report

LOG_LV2("HID", "Protocol Mode : %d (0 Boot, 1 Report)", *data);
}
Expand All @@ -160,7 +160,7 @@ err_t BLEHidGeneric::begin(void)
_chr_protocol->setFixedLen(1);
_chr_protocol->setWriteCallback(BLEHidGeneric::blehid_generic_protocol_mode_cb);
VERIFY_STATUS( _chr_protocol->begin() );
_chr_protocol->write8(_protocol_mode);
_chr_protocol->write8(_report_mode);
}

// Input reports
Expand Down
10 changes: 2 additions & 8 deletions libraries/Bluefruit52Lib/src/services/BLEHidGeneric.h
Expand Up @@ -44,12 +44,6 @@
// include usb hid definitions
#include "tinyusb/src/class/hid/hid.h"

enum
{
HID_PROTOCOL_MODE_BOOT = 0,
HID_PROTOCOL_MODE_REPORT = 1
};

extern const uint8_t hid_ascii_to_keycode[128][2];
extern const uint8_t hid_keycode_to_ascii[128][2];

Expand Down Expand Up @@ -90,7 +84,7 @@ class BLEHidGeneric : public BLEService

virtual err_t begin(void);

bool isBootMode(void) { return _protocol_mode == HID_PROTOCOL_MODE_BOOT; }
bool isBootMode(void) { return !_report_mode; }

// Send Report to default connection
bool inputReport(uint8_t reportID, void const* data, int len);
Expand All @@ -109,7 +103,7 @@ class BLEHidGeneric : public BLEService

bool _has_keyboard;
bool _has_mouse;
bool _protocol_mode;
bool _report_mode;

uint8_t _hid_info[4];
const uint8_t* _report_map;
Expand Down

0 comments on commit f84899f

Please sign in to comment.