ble nano hid over gatt

Dependencies:   BLE_API mbed-dev nRF51822

Revision:
17:3233ee19f716
Parent:
16:345eebc4f259
Child:
18:5d0232c9e70e
--- a/HIDController_BLE.cpp	Mon Aug 22 12:28:47 2016 +0000
+++ b/HIDController_BLE.cpp	Mon Aug 22 12:58:29 2016 +0000
@@ -72,7 +72,11 @@
 
 
 static void onConnect(const Gap::ConnectionCallbackParams_t *params) {
-	printf("onConnect\r\n");
+	printf("onConnect: ");
+		for (unsigned i = 0; i < Gap::ADDR_LEN; i++) {
+		printf("%02x", params->peerAddr[i]);
+	}
+	printf("\r\n");
     peerAddress.type = params->peerAddrType;
     memcpy(peerAddress.address, params->peerAddr, Gap::ADDR_LEN);
 }
@@ -150,7 +154,7 @@
 	ble.gap().onConnection(onConnect);
 	ble.gap().onTimeout(onTimeout);
 
-	printf("setup ble security manager\r\n");
+	// printf("setup ble security manager\r\n");
 	ble.securityManager().onSecuritySetupInitiated(securitySetupInitiatedCallback);
 	ble.securityManager().onPasskeyDisplay(passkeyDisplayCallback);
 	ble.securityManager().onSecuritySetupCompleted(securitySetupCompletedCallback);
@@ -162,11 +166,11 @@
 	}
 	
 
-	printf("new KeyboardService\r\n");
+	// printf("new KeyboardService\r\n");
 	keyboardService = new KeyboardService(ble);
-	printf("new DeviceInformationService\r\n");
+	// printf("new DeviceInformationService\r\n");
 	deviceInformationService = new DeviceInformationService(ble, "lowreal.net", MODEL_NAME, SERIAL_NUMBER, HARDWARE_REVISION, FIRMWARE_REVISION, SOFTWARE_REVISION);
-	printf("new BatteryService\r\n");
+	// printf("new BatteryService\r\n");
 	batteryService = new BatteryService(ble, 100);
 	/** TODO STUCK with BLE NANO
 	printf("new DFUService\r\n");
@@ -175,11 +179,11 @@
 	
 	updateBatteryLevel();
 
-	printf("setup connection params\r\n");
+	//printf("setup connection params\r\n");
 
     ble.gap().setPreferredConnectionParams(&connectionParams);
 
-	printf("general setup\r\n");
+	// printf("general setup\r\n");
 	error = ble.gap().accumulateAdvertisingPayload(
 		GapAdvertisingData::BREDR_NOT_SUPPORTED |
 		GapAdvertisingData::LE_GENERAL_DISCOVERABLE
@@ -191,34 +195,34 @@
 //	);
 	if (error != BLE_ERROR_NONE) goto return_error;
 
-	printf("set COMPLETE_LIST_16BIT_SERVICE_IDS\r\n");
+	// printf("set COMPLETE_LIST_16BIT_SERVICE_IDS\r\n");
 	error = ble.gap().accumulateAdvertisingPayload(
 		GapAdvertisingData::COMPLETE_LIST_16BIT_SERVICE_IDS,
 		(uint8_t*)uuid16_list, sizeof(uuid16_list)
 	);
 	if (error != BLE_ERROR_NONE) goto return_error;
 
-	printf("set advertising\r\n");
+	// printf("set advertising\r\n");
 	// see 5.1.2: HID over GATT Specification (pg. 25)
 	ble.gap().setAdvertisingType(GapAdvertisingParams::ADV_CONNECTABLE_UNDIRECTED);
 
-	printf("set advertising interval\r\n");
+	// printf("set advertising interval\r\n");
 	ble.gap().setAdvertisingInterval(30);
-	printf("set advertising timeout\r\n");
+	// printf("set advertising timeout\r\n");
 	ble.gap().setAdvertisingTimeout(180);
 
-	printf("set keyboard\r\n");
+	// printf("set keyboard\r\n");
 	error = ble.gap().accumulateAdvertisingPayload(GapAdvertisingData::KEYBOARD);
 	if (error != BLE_ERROR_NONE) goto return_error;
 
-	printf("set complete local name\r\n");
+	// printf("set complete local name\r\n");
 	error = ble.gap().accumulateAdvertisingPayload(
 		GapAdvertisingData::COMPLETE_LOCAL_NAME,
 		DEVICE_NAME, sizeof(DEVICE_NAME)
 	);
 	if (error != BLE_ERROR_NONE) goto return_error;
 
-	printf("set device name\r\n");
+	// printf("set device name\r\n");
 	error = ble.gap().setDeviceName(DEVICE_NAME);
 	if (error != BLE_ERROR_NONE) goto return_error;
 	// ble.gap().setTxPower(-12);