ble nano hid over gatt

Dependencies:   BLE_API mbed-dev nRF51822

Revision:
82:af52d37b1946
Parent:
79:0095bfb18c57
Child:
83:2e940d154f8b
--- a/HIDServiceBase.cpp	Sat Sep 03 23:07:36 2016 +0900
+++ b/HIDServiceBase.cpp	Sat Sep 03 23:16:07 2016 +0900
@@ -47,8 +47,7 @@
                                report_t     featureReport,
                                uint8_t      inputReportLength,
                                uint8_t      outputReportLength,
-                               uint8_t      featureReportLength,
-                               uint8_t      inputReportTickerDelay) :
+                               uint8_t      featureReportLength) :
     ble(_ble),
     connected (false),
     reportMapLength(reportMapSize),
@@ -100,10 +99,7 @@
     HIDInformationCharacteristic(GattCharacteristic::UUID_HID_INFORMATION_CHAR, const_cast<HID_information_t*>(&HID_information)),
     HIDControlPointCharacteristic(GattCharacteristic::UUID_HID_CONTROL_POINT_CHAR,
             &controlPointCommand, 1, 1,
-            GattCharacteristic::BLE_GATT_CHAR_PROPERTIES_WRITE_WITHOUT_RESPONSE),
-
-    reportTickerDelay(inputReportTickerDelay),
-    reportTickerIsActive(false)
+            GattCharacteristic::BLE_GATT_CHAR_PROPERTIES_WRITE_WITHOUT_RESPONSE)
 {
 }
 
@@ -145,21 +141,6 @@
 	ble.gattServer().onDataSent(this, &HIDServiceBase::onDataSent);
 	ble.gattServer().onDataWritten(this, &HIDServiceBase::onDataWritten);
 
-	/*
-	 * Change preferred connection params, in order to optimize the notification frequency. Most
-	 * OSes seem to respect this, even though they are not required to.
-	 *
-	 * Some OSes don't handle reconnection well, at the moment, so we set the maximum possible
-	 * timeout, 32 seconds
-	 */
-	uint16_t minInterval = Gap::MSEC_TO_GAP_DURATION_UNITS(reportTickerDelay / 2);
-	if (minInterval < 6)
-		minInterval = 6;
-	uint16_t maxInterval = minInterval * 2;
-	Gap::ConnectionParams_t params = {minInterval, maxInterval, 0, 3200};
-
-	ble.gap().setPreferredConnectionParams(&params);
-
 	SecurityManager::SecurityMode_t securityMode = SecurityManager::SECURITY_MODE_ENCRYPTION_NO_MITM;
 	protocolModeCharacteristic.requireSecurity(securityMode);
 	reportMapCharacteristic.requireSecurity(securityMode);
@@ -168,20 +149,7 @@
 	featureReportCharacteristic.requireSecurity(securityMode);
 }
 
-void HIDServiceBase::startReportTicker(void) {
-    if (reportTickerIsActive)
-        return;
-    reportTicker.attach_us(this, &HIDServiceBase::sendCallback, reportTickerDelay * 1000);
-    reportTickerIsActive = true;
-}
-
-void HIDServiceBase::stopReportTicker(void) {
-    reportTicker.detach();
-    reportTickerIsActive = false;
-}
-
 void HIDServiceBase::onDataSent(unsigned count) {
-    startReportTicker();
 }
 
 void HIDServiceBase::onDataWritten(const GattWriteCallbackParams *params) {