Hi,
I want to write Bluetooth ON and OFF functions for the project purpose,
what are all the steps needs to follow while creating ON function and same for OFF function.
Thanks in advance
Kind Regards,
Thiru.
Hi,
I want to write Bluetooth ON and OFF functions for the project purpose,
what are all the steps needs to follow while creating ON function and same for OFF function.
Thanks in advance
Kind Regards,
Thiru.
Define two command "BT ON"&"BT OFF"
if client get nus_data_handler()
static void nus_data_handler(ble_nus_evt_t * p_evt)
{
char* str_cmp;
if (p_evt->type == BLE_NUS_EVT_RX_DATA)
{
uint32_t err_code;
NRF_LOG_DEBUG("Received data from BLE NUS. Writing data on UART.");
NRF_LOG_HEXDUMP_DEBUG(p_evt->params.rx_data.p_data, p_evt->params.rx_data.length);
str_cmp =strstr(p_evt->params.rx_data.p_data,""BT ON");
if (str_cmp!=NULL) do_on_func();
str_cmp =strstr(p_evt->params.rx_data.p_data,""BT OFF");
if (str_cmp!=NULL) do_off_func();
}
}
Define two command "BT ON"&"BT OFF"
if client get nus_data_handler()
static void nus_data_handler(ble_nus_evt_t * p_evt)
{
char* str_cmp;
if (p_evt->type == BLE_NUS_EVT_RX_DATA)
{
uint32_t err_code;
NRF_LOG_DEBUG("Received data from BLE NUS. Writing data on UART.");
NRF_LOG_HEXDUMP_DEBUG(p_evt->params.rx_data.p_data, p_evt->params.rx_data.length);
str_cmp =strstr(p_evt->params.rx_data.p_data,""BT ON");
if (str_cmp!=NULL) do_on_func();
str_cmp =strstr(p_evt->params.rx_data.p_data,""BT OFF");
if (str_cmp!=NULL) do_off_func();
}
}
Hi,
Thank you for the response,
I have done seding BLE_ON & BLE_OFF command via UART under "uart_event_handle" function.
But i need to control the Bluetooth ON/OFF state via UART, so when i call the function (do_on_func()) the bluetooth should be ON and when i call do_off_func(), BLE discovery needs to be OFF.
If you have some idea, please help to achieve this.
Thank you.
What i mean is,
I need function definition for bluetooth ON and OFF functionality.
Thank you.
You can start and stop advertisement, or you disconnect the connection if you are already connected. There is api that can handle this:
You may then enter system off state to save current, for instance while waiting for the user to press a button to wakeup the device again.
Kenneth
HI Kenneth,
Thank you for the reply,
sd_ble_gap_disconnect(m_conn_handle, BLE_GAP_EVT_ADV_SET_TERMINATED);
sd_ble_gap_adv_stop(m_advertising.adv_handle);
I have tried both calls, but the bluetooth discovery is not stoped
Need to follow any sequence?
Thank you for the support.