ble nano hid over gatt

Dependencies:   BLE_API mbed-dev nRF51822

Revision:
9:d1daefbf1fbd
Parent:
6:f1c3ea8bc850
Child:
10:1aed2481a743
--- a/HIDController_BLE.cpp	Thu Jul 21 08:45:27 2016 +0900
+++ b/HIDController_BLE.cpp	Thu Jul 21 21:33:56 2016 +0900
@@ -69,6 +69,7 @@
 
 static void onConnect(const Gap::ConnectionCallbackParams_t *params) {
 	printf("onConnect\r\n");
+	// If a bond is created, the HID Device should write the address of the HID Host in the HID Device controller’s white list and set the HID Device controller’s advertising filter policy to ‘process scan and connection requests only from devices in the White List’.
 }
 
 static void onDisconnect(const Gap::DisconnectionCallbackParams_t *params) {
@@ -137,6 +138,11 @@
 		GapAdvertisingData::BREDR_NOT_SUPPORTED |
 		GapAdvertisingData::LE_GENERAL_DISCOVERABLE
 	);
+	// shoud be LE_LIMITED_DISCOVERABLE
+//	error = ble.gap().accumulateAdvertisingPayload(
+//		GapAdvertisingData::BREDR_NOT_SUPPORTED |
+//		GapAdvertisingData::LE_LIMITED_DISCOVERABLE
+//	);
 	if (error != BLE_ERROR_NONE) goto return_error;
 
 	printf("set COMPLETE_LIST_16BIT_SERVICE_IDS\r\n");
@@ -151,9 +157,9 @@
 	ble.gap().setAdvertisingType(GapAdvertisingParams::ADV_CONNECTABLE_UNDIRECTED);
 
 	printf("set advertising interval\r\n");
-	ble.gap().setAdvertisingInterval(50);
-	// XXX
-	// ble.gap().setAdvertisingTimeout(0);
+	ble.gap().setAdvertisingInterval(30);
+	printf("set advertising timeout\r\n");
+	ble.gap().setAdvertisingTimeout(180);
 
 	printf("set keyboard\r\n");
 	error = ble.gap().accumulateAdvertisingPayload(GapAdvertisingData::KEYBOARD);
@@ -210,3 +216,9 @@
 		keyboardService->deleteReportData(key);
 	}
 }
+
+void HIDController::queueCurrentReportData() {
+	if (keyboardService) {
+		keyboardService->queueCurrentReportData();
+	}
+}