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

BLE connecting and disconnecting reset program

Hi:

SDK version: SDK 13.0

MCU: nrf52832

For the purpose of saving power, the peripheral disconnect the BLE connection in the program when there is no data transmission, and  the peripheral trigger to start advertising and build BLE connection when there is enough data for transmission. The code for disconnection and advertising is list below. 

The problem is, the code can trigger the first advertising/ble-connection and send data successfully to the central device, and after that it looks the device also successfully disconnect  from central (because BLE_GAP_EVT_DISCONNECTED is triggered.). But when the device trigger the second time advertising, it reset the main program. 

What's the possible reason for this? I search a lot similar cases on this website, but can not find solution for this.  

Thanks

static void ble_disconnect()
{
	uint32_t err_code;

	if (m_conn_handle != BLE_CONN_HANDLE_INVALID)
	{
			err_code = sd_ble_gap_disconnect(m_conn_handle, BLE_HCI_REMOTE_USER_TERMINATED_CONNECTION);
			if (err_code != NRF_ERROR_INVALID_STATE)
			{
					APP_ERROR_CHECK(err_code);
			}
	}

	err_code = sd_ble_gap_adv_stop();
	if (err_code != NRF_ERROR_INVALID_STATE)
	{
			APP_ERROR_CHECK(err_code);
	}
	
}

static void advertising_start()
{

       ret_code_t err_code, ret;
       err_code = ble_advertising_start(BLE_ADV_MODE_FAST);
			 APP_ERROR_CHECK(err_code);		
}

Parents
  • Hi,

    Just wondering if you're on right way.. if your case assumes one session, for example, in 2-3 hours, it's ok. But if your device will trigger data exchange once per 5-10 minutes, it's better to maintain connection with high slave latency, because power consumed while negotiation will whittle away the gain got by disconnecting device.

  • Hi Dmitry:

    Thanks for your kind reply. 

    We are developing some special project, which have a insufficient power driving capability. So, the sampled signal quality will be sensitive to the BLE data transmission and even BLE advertising. That's why I want to turn off BLE data transmission and even BLE advertising in the data sampling. And after a specific time when there is enough samples ready for data transmission, the code start advertising and BLE transmission.

    Best

Reply
  • Hi Dmitry:

    Thanks for your kind reply. 

    We are developing some special project, which have a insufficient power driving capability. So, the sampled signal quality will be sensitive to the BLE data transmission and even BLE advertising. That's why I want to turn off BLE data transmission and even BLE advertising in the data sampling. And after a specific time when there is enough samples ready for data transmission, the code start advertising and BLE transmission.

    Best

Children
No Data
Related