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 = 87on 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?