This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

Completely Switch off BLE and restart it again

Hi,

We are developing a device which should have a power save mode where no BLE connection is possible (switch off the BLE to a minimum power consumption) and restart the BLE connection when leaving the power safe mode the BLE should get enabled again. In the power safe mode all other functionality shall be available.

Now we have the problem that we can't switch off the BLE. We configured the advertizing to restart at disconnection (as this is needed when losing the connection while usage).

We use the following code to stop the connection:

void vFsmBldExitActive(void)
{
/** START_PROTECTED {EAID_DA649126_9521_45db_83DB_337FCF9A0291} */

	// If you are a peripheral, the radio is "disabled" or not used,
	// as long as you are not in a connection and you are not advertising.

	uint32_t err_code;

	// If connected -> disconnect
	if (u16ConnectionHandle != BLE_CONN_HANDLE_INVALID)
	{
		err_code = sd_ble_gap_disconnect(u16ConnectionHandle,  BLE_HCI_REMOTE_USER_TERMINATED_CONNECTION);
		APP_ERROR_CHECK(err_code);
	}

	// Stop advertising
	err_code = ble_advertising_start(&m_advertising, BLE_ADV_MODE_IDLE);
	APP_ERROR_CHECK(err_code);

	sd_ble_gap_adv_stop(m_advertising.adv_handle);

	// Disable the radio tasks as scytulip suggested
	// devzone.nordicsemi.com/.../
	//NRF_RADIO->TASKS_DISABLE;
	//NRF_RADIO->TASKS_DISABLE = 1;

	// Inform power management about shutdown
	POM_vHandlePowerStateChange(POM_CALL_SOURCE_BLE, POM_CALL_INFO_DOWN_OK);

/** END_PROTECTED */
}

Enabling the “NRF_RADIO->TASK_DISABLE” doesn’t help…

We also tried to use change the advertizing configuration configuration as followed:

void vFsmBldExitActive(void)
{
/** START_PROTECTED {EAID_DA649126_9521_45db_83DB_337FCF9A0291} */

	// If you are a peripheral, the radio is "disabled" or not used,
	// as long as you are not in a connection and you are not advertising.

	uint32_t err_code;
	
	// If connected -> disconnect
	if (u16ConnectionHandle != BLE_CONN_HANDLE_INVALID)
	{
		err_code = sd_ble_gap_disconnect(u16ConnectionHandle,  BLE_HCI_REMOTE_USER_TERMINATED_CONNECTION);
		APP_ERROR_CHECK(err_code);
	}

	// Stop advertising
	err_code = ble_advertising_start(&m_advertising, BLE_ADV_MODE_IDLE);
	APP_ERROR_CHECK(err_code);

	// reconfigure the advertizing
    ble_adv_modes_config_t config;
	
    config.ble_adv_on_disconnect_disabled = true;

    ble_advertising_modes_config_set(&m_advertising , &config);

	sd_ble_gap_adv_stop(m_advertising.adv_handle);

	// Disable the radio tasks as scytulip suggested
	// devzone.nordicsemi.com/.../
	//NRF_RADIO->TASKS_DISABLE;
//	NRF_RADIO->TASKS_DISABLE = 1;

	// Inform power management about shutdown
	POM_vHandlePowerStateChange(POM_CALL_SOURCE_BLE, POM_CALL_INFO_DOWN_OK);

/** END_PROTECTED */
}

But this didn't helped either...

And for starting / re-starting the connection we use:

void vFsmBldEnterActive(void)
{
/** START_PROTECTED {EAID_148B7F83_5C8F_4288_8ED1_2B0F0306760C} */

	uint32_t err_code;

	err_code = ble_advertising_start(&m_advertising, BLE_ADV_MODE_FAST);

	APP_ERROR_CHECK(err_code);

/** END_PROTECTED */
}

The BLE works fine in active mode.

Could anyone help me on how to disable and re-enable the BLE connection?

Would be great

Br, Simon

Parents Reply Children
No Data
Related