auto change connection interval to 11.25 - 15ms when starting BLEHidAdafruit

This commit is contained in:
hathach committed 2017-02-28 15:20:29 +07:00
1 parent bf3937fa8d
commit 839f89af93
3 files changed
+20 -5

No files matched your search

+1 -1
View File
@@ -101,7 +101,7 @@ int cprintf(const char * format, ...);
#define PRINT_HEX(x) \
do {\
cprintf("%s: %d: " #x " = ", __PRETTY_FUNCTION__, __LINE__);\
cprintf("%s: %d: " #x " = 0x", __PRETTY_FUNCTION__, __LINE__);\
char fmt[] = "%00X\n";\
fmt[2] += 2*sizeof(x); /* Hex with correct size */\
cprintf(fmt, (x) );\
@@ -26,8 +26,6 @@ void setup()
Serial.println("Bluefruit52 HID Keyboard Example");
Bluefruit.begin();
// HID Device can have a min connection interval of 9*1.25 = 11.25 ms
Bluefruit.setConnInterval(9, 16); // min = 9*1.25=11.25 ms, max = 16*1.25=20ms
Bluefruit.setName("Bluefruit52");
// Configure and Start Device Information Service
@@ -40,9 +38,21 @@ void setup()
// Configure and Start BLE Uart Service
bleuart.start();
// BLE HID
/* Start BLE HID
* Note: Apple requires BLE device must have min connection interval >= 20m
* ( The smaller the connection interval the faster we could send data).
* However for HID and MIDI device, Apple could accept min connection interval
* up to 11.25 ms. Therefore BLEHidAdafruit::start() will try to set the min and max
* connection interval to 11.25 ms and 15 ms respectively for best performance.
*/
blehid.start();
/* Set connection interval (min, max) to your perferred value.
* Note: It is already set by BLEHidAdafruit::start() to 11.25ms - 15ms
* min = 9*1.25=11.25 ms, max = 12*1.25= 15 ms
*/
/* Bluefruit.setConnInterval(9, 12); */
// Setup Advertising Packet
setupAdv();
@@ -213,7 +213,12 @@ err_t BLEHidAdafruit::start(void)
enableBootProtocol(true, true);
setReportMap(hid_report_descriptor, sizeof(hid_report_descriptor));
return BLEHidGeneric::start();
VERIFY_STATUS( BLEHidGeneric::start() );
// Attemp to change the connection interval to 11.25-15 ms when starting HID
Bluefruit.setConnInterval(9, 12);
return ERROR_NONE;
}
/*------------------------------------------------------------------*/