ble nano hid over gatt

Dependencies:   BLE_API mbed-dev nRF51822

Revision:
82:af52d37b1946
Parent:
81:fbe7358e38a4
Child:
83:2e940d154f8b
--- a/KeyboardService.h	Sat Sep 03 23:07:36 2016 +0900
+++ b/KeyboardService.h	Sat Sep 03 23:16:07 2016 +0900
@@ -132,8 +132,7 @@
 			featureReport       = featureReportData.raw,
 			inputReportLength   = sizeof(inputReportData),
 			outputReportLength  = sizeof(outputReportData),
-			featureReportLength = sizeof(featureReportData),
-			reportTickerDelay   = 20
+			featureReportLength = sizeof(featureReportData)
 		),
 		bootKeyboardInputReportCharacteristic(GattCharacteristic::UUID_BOOT_KEYBOARD_INPUT_REPORT_CHAR,
 			(uint8_t *)inputReport, inputReportLength, inputReportLength,
@@ -219,7 +218,7 @@
 		DEBUG_PRINTF_BLE("Q %d\r\n", bufferCount);
 		bufferCount++;
 		inputReportBuffer.push(inputReportData);
-		startReportTicker();
+		sendAvailable = true;
 	}
 
 	uint8_t toModifierBit(const uint8_t keycode) const {
@@ -244,11 +243,6 @@
 		}
 		return 0;
 	}
-
-	virtual void sendCallback(void) {
-		// do not call printf in this function... it cause BLE_STACK_BUSY
-		sendAvailable = true;
-	}
 	
 	void processSend() {
 		if (!sendAvailable) {
@@ -261,7 +255,6 @@
 		if (!isSending) {
 			if (!inputReportBuffer.pop(inputReportDataSending)) {
 				// 送るデータがないなら送信をやめる
-				stopReportTicker();
 				return;
 			}
 			bufferCount--;
@@ -274,7 +267,7 @@
 			if (busyCount++ > 10) {
 				DEBUG_PRINTF_BLE("BLE_STACK_BUSY\r\n");
 				busyCount = 0;
-				stopReportTicker();
+				sendAvailable = false;
 			}
 			// retry after
 			return;
@@ -283,7 +276,7 @@
 	}
 
 	virtual void onDataSent(unsigned int count) {
-		startReportTicker();
+		sendAvailable = true;
 	}
 
 	virtual void onDataWritten(const GattWriteCallbackParams *params) {
@@ -301,12 +294,6 @@
 			protocolMode = params->data[0];
 		}
 	}
-
-	virtual void stopReportTicker(void) {
-		if (reportTickerIsActive) {
-			HIDServiceBase::stopReportTicker();
-		}
-	}
 };