Nordic stack and drivers for the mbed BLE API Modified for HRM 1017 and correct DISCONNECT event processing

Fork of nRF51822 by Nordic Semiconductor

Files at this revision

API Documentation at this revision

Comitter:
Rohit Grover
Date:
Fri Jul 11 13:52:12 2014 +0100
Parent:
41:6e66cd970659
Child:
43:e1d294ed29c4
Commit message:
white space diffs

Changed in this revision

btle/btle_gap.cpp Show annotated file Show diff for this revision Revisions of this file
nordic/ble/ble_conn_params.cpp Show annotated file Show diff for this revision Revisions of this file
--- a/btle/btle_gap.cpp	Thu Jul 10 12:12:18 2014 +0100
+++ b/btle/btle_gap.cpp	Fri Jul 11 13:52:12 2014 +0100
@@ -33,21 +33,15 @@
 {
     ble_gap_conn_params_t gap_conn_params = {0};
 
-    gap_conn_params.min_conn_interval = msec_to_1_25msec(
-                                            CFG_GAP_CONNECTION_MIN_INTERVAL_MS);  // in 1.25ms units
-    gap_conn_params.max_conn_interval = msec_to_1_25msec(
-                                            CFG_GAP_CONNECTION_MAX_INTERVAL_MS);  // in 1.25ms unit
+    gap_conn_params.min_conn_interval = msec_to_1_25msec(CFG_GAP_CONNECTION_MIN_INTERVAL_MS);  // in 1.25ms units
+    gap_conn_params.max_conn_interval = msec_to_1_25msec(CFG_GAP_CONNECTION_MAX_INTERVAL_MS);  // in 1.25ms unit
     gap_conn_params.slave_latency     = CFG_GAP_CONNECTION_SLAVE_LATENCY;
-    gap_conn_params.conn_sup_timeout  =
-        CFG_GAP_CONNECTION_SUPERVISION_TIMEOUT_MS / 10; // in 10ms unit
+    gap_conn_params.conn_sup_timeout  = CFG_GAP_CONNECTION_SUPERVISION_TIMEOUT_MS / 10; // in 10ms unit
 
     ble_gap_conn_sec_mode_t sec_mode;
     BLE_GAP_CONN_SEC_MODE_SET_OPEN(&sec_mode); // no security is needed
 
-    ASSERT_STATUS( sd_ble_gap_device_name_set(&sec_mode,
-                   (const uint8_t *)
-                   CFG_GAP_LOCAL_NAME,
-                   strlen(CFG_GAP_LOCAL_NAME)));
+    ASSERT_STATUS( sd_ble_gap_device_name_set(&sec_mode, (const uint8_t *) CFG_GAP_LOCAL_NAME, strlen(CFG_GAP_LOCAL_NAME)));
     ASSERT_STATUS( sd_ble_gap_appearance_set(CFG_GAP_APPEARANCE));
     ASSERT_STATUS( sd_ble_gap_ppcp_set(&gap_conn_params));
     ASSERT_STATUS( sd_ble_gap_tx_power_set(CFG_BLE_TX_POWER_LEVEL));
--- a/nordic/ble/ble_conn_params.cpp	Thu Jul 10 12:12:18 2014 +0100
+++ b/nordic/ble/ble_conn_params.cpp	Fri Jul 11 13:52:12 2014 +0100
@@ -33,16 +33,10 @@
     // Check if interval is within the acceptable range.
     // NOTE: Using max_conn_interval in the received event data because this contains
     //       the client's connection interval.
-    if (
-        (p_conn_params->max_conn_interval >= m_preferred_conn_params.min_conn_interval)
-        && 
-        (p_conn_params->max_conn_interval <= m_preferred_conn_params.max_conn_interval)
-    )
-    {
+    if ((p_conn_params->max_conn_interval >= m_preferred_conn_params.min_conn_interval) &&
+        (p_conn_params->max_conn_interval <= m_preferred_conn_params.max_conn_interval)) {
         return true;
-    }
-    else
-    {
+    } else {
         return false;
     }
 }
@@ -59,7 +53,7 @@
         if (m_update_count <= m_conn_params_config.max_conn_params_update_count)
         {
             uint32_t err_code;
-            
+
             // Parameters are not ok, send connection parameters update request.
             err_code = sd_ble_gap_conn_param_update(m_conn_handle, &m_preferred_conn_params);
             if ((err_code != NRF_SUCCESS) && (m_conn_params_config.error_handler != NULL))
@@ -70,24 +64,24 @@
         else
         {
             m_update_count = 0;
-            
+
             // Negotiation failed, disconnect automatically if this has been configured
             if (m_conn_params_config.disconnect_on_fail)
             {
                 uint32_t err_code;
-                
+
                 err_code = sd_ble_gap_disconnect(m_conn_handle, BLE_HCI_CONN_INTERVAL_UNACCEPTABLE);
                 if ((err_code != NRF_SUCCESS) && (m_conn_params_config.error_handler != NULL))
                 {
                     m_conn_params_config.error_handler(err_code);
                 }
             }
-            
+
             // Notify the application that the procedure has failed
             if (m_conn_params_config.evt_handler != NULL)
             {
                 ble_conn_params_evt_t evt;
-                
+
                 evt.evt_type = BLE_CONN_PARAMS_EVT_FAILED;
                 m_conn_params_config.evt_handler(&evt);
             }
@@ -99,13 +93,13 @@
 uint32_t ble_conn_params_init(const ble_conn_params_init_t * p_init)
 {
     uint32_t err_code;
-    
+
     m_conn_params_config = *p_init;
     m_change_param = false;
     if (p_init->p_conn_params != NULL)
     {
         m_preferred_conn_params = *p_init->p_conn_params;
-        
+
         // Set the connection params in stack
         err_code = sd_ble_gap_ppcp_set(&m_preferred_conn_params);
         if (err_code != NRF_SUCCESS)
@@ -125,7 +119,7 @@
 
     m_conn_handle  = BLE_CONN_HANDLE_INVALID;
     m_update_count = 0;
-    
+
     return app_timer_create(&m_conn_params_timer_id,
                             APP_TIMER_MODE_SINGLE_SHOT,
                             update_timeout_handler);
@@ -145,14 +139,14 @@
     {
         uint32_t err_code;
         uint32_t timeout_ticks;
-        
+
         if (m_change_param)
         {
             // Notify the application that the procedure has failed
             if (m_conn_params_config.evt_handler != NULL)
             {
                 ble_conn_params_evt_t evt;
-                
+
                 evt.evt_type = BLE_CONN_PARAMS_EVT_FAILED;
                 m_conn_params_config.evt_handler(&evt);
             }
@@ -182,7 +176,7 @@
         if (m_conn_params_config.evt_handler != NULL)
         {
             ble_conn_params_evt_t evt;
-            
+
             evt.evt_type = BLE_CONN_PARAMS_EVT_SUCCEEDED;
             m_conn_params_config.evt_handler(&evt);
         }
@@ -197,7 +191,7 @@
     m_conn_handle         = p_ble_evt->evt.gap_evt.conn_handle;
     m_current_conn_params = p_ble_evt->evt.gap_evt.params.connected.conn_params;
     m_update_count        = 0;  // Connection parameter negotiation should re-start every connection
-    
+
     // Check if we shall handle negotiation on connect
     if (m_conn_params_config.start_on_notify_cccd_handle == BLE_GATT_HANDLE_INVALID)
     {
@@ -214,7 +208,7 @@
 
     // Stop timer if running
     m_update_count = 0; // Connection parameters updates should happen during every connection
-    
+
     err_code = app_timer_stop(m_conn_params_timer_id);
     if ((err_code != NRF_SUCCESS) && (m_conn_params_config.error_handler != NULL))
     {
@@ -271,19 +265,19 @@
         case BLE_GAP_EVT_CONNECTED:
             on_connect(p_ble_evt);
             break;
-            
+
         case BLE_GAP_EVT_DISCONNECTED:
             on_disconnect(p_ble_evt);
             break;
-            
+
         case BLE_GATTS_EVT_WRITE:
             on_write(p_ble_evt);
             break;
-            
+
         case BLE_GAP_EVT_CONN_PARAM_UPDATE:
             on_conn_params_update(p_ble_evt);
             break;
-            
+
         default:
             // No implementation needed.
            break;
@@ -311,7 +305,7 @@
             if (m_conn_params_config.evt_handler != NULL)
             {
                 ble_conn_params_evt_t evt;
-                
+
                 evt.evt_type = BLE_CONN_PARAMS_EVT_SUCCEEDED;
                 m_conn_params_config.evt_handler(&evt);
             }