Microbug / nRF51822

Fork of nRF51822 by Nordic Semiconductor

Files at this revision

API Documentation at this revision

Comitter:
rgrover1
Date:
Fri May 08 15:33:59 2015 +0100
Parent:
157:0fa76927dcfe
Child:
159:22a551904ffc
Commit message:
Synchronized with git rev c426e977
Author: Rohit Grover
add a securityMode arg to processLinkSecuredEvent

Changed in this revision

btle/btle_security.cpp Show annotated file Show diff for this revision Revisions of this file
--- a/btle/btle_security.cpp	Fri May 08 15:33:58 2015 +0100
+++ b/btle/btle_security.cpp	Fri May 08 15:33:59 2015 +0100
@@ -158,9 +158,39 @@
             nRF51Gap::getInstance().processSecurityProcedureCompletedEvent(p_event->event_param.p_gap_param->conn_handle,
                                                                            (Gap::SecurityCompletionStatus_t)(p_event->event_param.p_gap_param->params.auth_status.auth_status));
             break;
-        case DM_EVT_LINK_SECURED:
-            nRF51Gap::getInstance().processLinkSecuredEvent(p_event->event_param.p_gap_param->conn_handle);
+        case DM_EVT_LINK_SECURED: {
+            unsigned securityMode                    = p_event->event_param.p_gap_param->params.conn_sec_update.conn_sec.sec_mode.sm;
+            unsigned level                           = p_event->event_param.p_gap_param->params.conn_sec_update.conn_sec.sec_mode.lv;
+            Gap::SecurityMode_t resolvedSecurityMode = Gap::SECURITY_MODE_NO_ACCESS;
+            switch (securityMode) {
+                case 1:
+                    switch (level) {
+                        case 1:
+                            resolvedSecurityMode = Gap::SECURITY_MODE_ENCRYPTION_OPEN_LINK;
+                            break;
+                        case 2:
+                            resolvedSecurityMode = Gap::SECURITY_MODE_ENCRYPTION_NO_MITM;
+                            break;
+                        case 3:
+                            resolvedSecurityMode = Gap::SECURITY_MODE_ENCRYPTION_WITH_MITM;
+                            break;
+                    }
+                    break;
+                case 2:
+                    switch (level) {
+                        case 1:
+                            resolvedSecurityMode = Gap::SECURITY_MODE_SIGNED_NO_MITM;
+                            break;
+                        case 2:
+                            resolvedSecurityMode = Gap::SECURITY_MODE_SIGNED_WITH_MITM;
+                            break;
+                    }
+                    break;
+            }
+
+            nRF51Gap::getInstance().processLinkSecuredEvent(p_event->event_param.p_gap_param->conn_handle, resolvedSecurityMode);
             break;
+        }
         case DM_EVT_DEVICE_CONTEXT_STORED:
             nRF51Gap::getInstance().processSecurityContextStoredEvent(p_event->event_param.p_gap_param->conn_handle);
             break;