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

ble service characteristic read authorization completion notify

I have configure a authorized read from a service's characteristic as below .

void ble_band_ble_evt(ble_evt_t const * p_ble_evt, void * p_context)
{
ble_band_t * p_band = (ble_band_t *)p_context;
ble_gatts_evt_read_t const * p_evt_read = &p_ble_evt->evt.gatts_evt.params.authorize_request ;


switch (p_ble_evt->header.evt_id)
{
case BLE_GATTS_EVT_WRITE:
on_band_on_off_write(p_band, p_ble_evt);
break;

case BLE_GATTS_EVT_RW_AUTHORIZE_REQUEST:


get_log_data();
break;
default:
// No implementation needed.
break;
}
}

and  get_log_data() has ,

void get_log_data(void){

ble_gatts_rw_authorize_reply_params_t test_param ;
test_param.type = BLE_GATTS_AUTHORIZE_TYPE_READ ;
test_param.params.read.gatt_status = BLE_GATT_STATUS_SUCCESS ;
test_param.params.read.update = 1 ;
test_param.params.read.offset = 0 ;

test_param.params.read.len = sizeof(log_read_buf_display);
test_param.params.read.p_data = log_read_buf_display ;

uint32_t ret = sd_ble_gatts_rw_authorize_reply(m_conn_handle, &test_param);

printf("error code  = %d \r\n",ret );

}

The read authorization works fine but "case BLE_GATTS_EVT_RW_AUTHORIZE_REQUEST:" gets called multiple times( more then five) ,(for one request ) every time I send read request from nrf app( If I press read button from nrfconnect once , above case executes more then five times ) .

So , is there any flag which can be monitor to check whether the read request from peer device has completed ??  or Can we stop this multiple calling because every time I press read button from nrf app , I have to update log_read_buf_display  array  , and  with this behavior ,I am unable to distinguish the request  .

Parents
  • Hi

    You say that you put your debug inside the case, but I don't see anything log files in your initial case. Can you upload a log file of your debug log so I can get a better view of what's going on? Can you also tell me where this event comes from?

    I'm not aware of anything like that the number of bytes you try to read should trig multiple requests. Can you try reducing the amount of data you try to read to see if that reduces the number of requests?

    Best regards,

    Simon

Reply
  • Hi

    You say that you put your debug inside the case, but I don't see anything log files in your initial case. Can you upload a log file of your debug log so I can get a better view of what's going on? Can you also tell me where this event comes from?

    I'm not aware of anything like that the number of bytes you try to read should trig multiple requests. Can you try reducing the amount of data you try to read to see if that reduces the number of requests?

    Best regards,

    Simon

Children
No Data
Related