Beware that this post is related to an SDK in maintenance mode
More Info: Consider nRF Connect SDK for new designs
This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

ble_app_multirole_lesc on SDK17.1.0 vs SDK15.2.0

Hi,

I want to use a single firmware to be flashed on two devices that can be used as a ble peripheral with DK Button 3 and as a central with DK Button 4.

I chose ble_app_multirole_lesc for this purpose. I made the following changes:

diff --git a/examples/ble_central_and_peripheral/experimental/ble_app_multirole_lesc/main.c b/examples/ble_central_and_peripheral/experimental/ble_app_multirole_lesc/main.c
index e384712..84442ed 100644
--- a/examples/ble_central_and_peripheral/experimental/ble_app_multirole_lesc/main.c
+++ b/examples/ble_central_and_peripheral/experimental/ble_app_multirole_lesc/main.c
@@ -280,25 +280,6 @@ static void scan_start(void)
 }
 
 
-/**@brief Function for initializing the advertising and the scanning.
- */
-static void adv_scan_start(void)
-{
-    ret_code_t err_code;
-
-    scan_start();
-
-    // Turn on the LED to signal scanning.
-    bsp_board_led_on(CENTRAL_SCANNING_LED);
-
-    // Start advertising.
-    err_code = ble_advertising_start(&m_advertising, BLE_ADV_MODE_FAST);
-    APP_ERROR_CHECK(err_code);
-
-    NRF_LOG_INFO("Advertising");
-}
-
-
 /**@brief Function for handling Peer Manager events.
  *
  * @param[in] p_evt  Peer Manager event.
@@ -312,7 +293,6 @@ static void pm_evt_handler(pm_evt_t const * p_evt)
     switch (p_evt->evt_id)
     {
         case PM_EVT_PEERS_DELETE_SUCCEEDED:
-            adv_scan_start();
             break;
 
         default:
@@ -588,8 +568,6 @@ static void on_ble_central_evt(ble_evt_t const * p_ble_evt)
                                                    &target_uuid);
                 APP_ERROR_CHECK(err_code);
             }
-            
-            scan_start();
         } break; // BLE_GAP_EVT_DISCONNECTED
 
         case BLE_GAP_EVT_TIMEOUT:
@@ -693,8 +671,6 @@ static void on_adv_evt(ble_adv_evt_t ble_adv_evt)
 
         case BLE_ADV_EVT_IDLE:
         {
-            ret_code_t err_code = ble_advertising_start(&m_advertising, BLE_ADV_MODE_FAST);
-            APP_ERROR_CHECK(err_code);
         } break;
 
         default:
@@ -897,6 +873,21 @@ static void bsp_event_handler(bsp_event_t event)
             on_num_comp_button_press(false);
             break;
 
+      case BSP_EVENT_KEY_2:
+            // Start advertising.
+            err_code = ble_advertising_start(&m_advertising, BLE_ADV_MODE_FAST);
+            APP_ERROR_CHECK(err_code);
+
+            NRF_LOG_INFO("Advertising");
+            break;
+
+      case BSP_EVENT_KEY_3:
+            scan_start();
+
+            // Turn on the LED to signal scanning.
+            bsp_board_led_on(CENTRAL_SCANNING_LED);
+            break;
+
         default:
             break;
     }
@@ -1161,6 +1152,7 @@ int main(void)
     // Start execution.
     NRF_LOG_INFO("LE Secure Connections example started.");
 
+    erase_bonds = true;
     if (erase_bonds == true)
     {
         delete_bonds();
@@ -1168,7 +1160,6 @@ int main(void)
     }
     else
     {
-        adv_scan_start();
     }
 
     // Enter main loop.

After bonding, it used to work on SDK15.2.0 such that pressing Button 1 on the peripheral side would print 

<info> app: CENTRAL: Heart Rate = 87
on the central side.

But on SDK17.1.0 it does not print anything! What other changes do I need to make it work on the latest SDK?

Parents
  • Hi

    The function in the default versions of the multirole example seems to be the same for v15.2.0 and 17.1.0 of the SDK, so there shouldn't be a difference between the two. Can you confirm that you still have the following handling of the BSP_EVENT_KEY_0 on your application?

            case BSP_EVENT_KEY_0:
                err_code = ble_hrs_heart_rate_measurement_send(&m_hrs, 87);
                if ((err_code != NRF_SUCCESS) &&
                    (err_code != NRF_ERROR_INVALID_STATE) &&
                    (err_code != NRF_ERROR_RESOURCES) &&
                    (err_code != NRF_ERROR_BUSY) &&
                    (err_code != BLE_ERROR_GATTS_SYS_ATTR_MISSING)
                    )
                {
                    APP_ERROR_HANDLER(err_code);
                }
    
                on_num_comp_button_press(true);
                break;

    Can you confirm that the two devices both use UART as the backend for logging and that UART is enabled in the sdk_config.h header file. 

    Best regards,

    Simon

  • Hi Simon,

    The above diffs are the only changes I made, so BSP_EVENT_KEY_0 and sd_config.h are untouched.

    Both devices use UART and UART backend for logging is set:

    #define NRF_LOG_BACKEND_UART_ENABLED 1

Reply Children
No Data
Related