I need to send a data package when radio is ON every time
but I try to send data by "sd_ble_gatts_hvx()" I find it can not work,it seems that I can't call this API to send data.
I what to know how to use SWI1_IRQHandler , if I what to prepare and send data what can I do?
void data_send_on_radio_active_evt(bool radio_active)
{
m_radio_active = radio_active;
if((radio_active == true) &&(mouse_enable == true)){
if(mouse_enable == true)
data_prepare();
else
data_send(); //call sd_ble_gatts_hvx() to send data
}
/**@brief Function for initializing the Radio Notification event.
*/
static void radio_notification_init(void)
{
uint32_t err_code;
err_code = ble_radio_notification_init(NRF_APP_PRIORITY_HIGH,
NRF_RADIO_NOTIFICATION_DISTANCE_5500US,
data_send_on_radio_active_evt);
APP_ERROR_CHECK(err_code);
}
data_send() will call
hvx_params.handle = p_hids->boot_mouse_inp_rep_handles.value_handle;
hvx_params.type = BLE_GATT_HVX_NOTIFICATION;
hvx_params.offset = 0;
hvx_params.p_len = &hvx_len;
hvx_params.p_data = buffer;
err_code = sd_ble_gatts_hvx(p_hids->conn_handle, &hvx_params);
to send data by ble.
data_prepare(); will cast about 0.3ms , and I think it's ok when I set NRF_RADIO_NOTIFICATION_DISTANCE_5500US,