Fork of BLE_SecureHeartRate : should this 'work' i.e. require a secure connection on an nRF51-DK? Hopefully I'm just missing something obvious - or is this broken?

Dependencies:   BLE_API mbed nRF51822

Fork of BLE_SecureHeartRate by Bluetooth Low Energy

Revision:
3:b852bf8d6fad
Parent:
2:2d9d4b271af8
Child:
5:ed2cb43f3589
--- a/main.cpp	Wed Jun 03 09:11:21 2015 +0000
+++ b/main.cpp	Thu Jun 04 08:02:36 2015 +0000
@@ -16,15 +16,9 @@
 
 #include "mbed.h"
 #include "BLEDevice.h"
-#include "HeartRateSecSampleSrv.h"
+#include "HeartRateSecService.h"
 #include "DeviceInformationService.h"
 
-/* Enable the following if you need to throttle the connection interval. This has
- * the effect of reducing energy consumption after a connection is made;
- * particularly for applications where the central may want a fast connection
- * interval.*/
-#define UPDATE_PARAMS_FOR_LONGER_CONNECTION_INTERVAL 0
-
 BLEDevice  ble;
 DigitalOut led1(LED1);
 
@@ -39,7 +33,6 @@
     ble.startAdvertising(); // restart advertising
 }
 
-
 void periodicCallback(void)
 {
     led1 = !led1; /* Do blinky on LED1 while we're waiting for BLE events */
@@ -49,49 +42,44 @@
     triggerSensorPolling = true;
 }
 
-
 void connectionCallback(Gap::Handle_t handle, Gap::addr_type_t peerAddrType, const Gap::Address_t peerAddr,
-                                              Gap::addr_type_t ownAddrType,  const Gap::Address_t ownAddr,
-                                              const Gap::ConnectionParams_t * pParam)
+                        Gap::addr_type_t ownAddrType,  const Gap::Address_t ownAddr,
+                        const Gap::ConnectionParams_t * pParam)
 {
     printf("Connected!\r\n");
 }
 
-
 void passkeyDisplayCallback(Gap::Handle_t handle, const Gap::Passkey_t passkey)
 {
-    uint8_t i;
-    
     printf("Input passKey: ");
-    for(i = 0; i < 6; i++) {
+    for (unsigned i = 0; i < Gap::ADDR_LEN; i++) {
         printf("%c ", passkey[i]);
     }
     printf("\r\n");
 }
 
-
 void securitySetupCompletedCallback(Gap::Handle_t handle, Gap::SecurityCompletionStatus_t status)
 {
-    if(!status) {
+    if (status == Gap::SEC_STATUS_SUCCESS) {
         printf("Security success\r\n", status);
     } else {
         printf("Security failed\r\n", status);
     }
 }
 
-
 int main(void)
 {
     led1 = 1;
     Ticker ticker;
     ticker.attach(periodicCallback, 1); // blink LED every second
-    printf("Started\r\n");
     
     /* Initialize BLE module */
     ble.init();
     
     /* Initialize BLE security */
-    ble.initializeSecurity(true, true, Gap::IO_CAPS_DISPLAY_ONLY, NULL);
+    bool enableBonding = true;
+    bool requireMITM   = true;
+    ble.initializeSecurity(enableBonding, requireMITM, Gap::IO_CAPS_DISPLAY_ONLY);
     
     /* Set callback functions */
     ble.onConnection(connectionCallback);
@@ -137,4 +125,4 @@
             ble.waitForEvent(); // low power wait for event
         }
     }
-}
+}
\ No newline at end of file