Hello all,
Please help!
I am using nrf52480 with SDK15.
I have been developing this application for quite some time now and this is a new problem. I am using BLE_GATTS_EVT_RW_AUTHORIZE_REQUESTs for all of my characteristics. When I send a request_write the length is correct but only the first 2 bytes of data are correct. The rest is the same value of 020000000000000000000000000000000000000000000000980604001996 every time on any characteristic. I am assuming that I am somehow overwriting the write request data value but I don't know how to debug this. The part that confuses me even more is that the application is receiving the correct values and my application works find until I read from the characteristic again, then the data is garbage. If my application is getting the right value then why would the value of the characteristic be garbage? Or am I just not able to access the data in the request data value before replying with success? Here is how I handle rw_request.
ret_code_t err_code;
ble_gatts_evt_rw_authorize_request_t req;
ble_gatts_rw_authorize_reply_params_t auth_reply;
memset(&auth_reply, 0, sizeof(auth_reply));
req = p_ble_evt->evt.gatts_evt.params.authorize_request;
if (req.type != BLE_GATTS_AUTHORIZE_TYPE_INVALID)
{
if (req.type == BLE_GATTS_AUTHORIZE_TYPE_WRITE)
{
auth_reply.type = BLE_GATTS_AUTHORIZE_TYPE_WRITE;
NRF_LOG_RAW_INFO("REQUEST WRITE VALUE: ");
for(int i = 0; i < req.request.write.len; i++)
NRF_LOG_RAW_INFO("%02x",*(req.request.write.data+i));
}
else
{
auth_reply.type = BLE_GATTS_AUTHORIZE_TYPE_READ;
}
}
if (is_secure_characteristic_hash_valid)
{
NRF_LOG_INFO("Connection is SECURE");
if (req.type == BLE_GATTS_AUTHORIZE_TYPE_WRITE)
{
auth_reply.params.write.gatt_status = BLE_GATT_STATUS_SUCCESS;
auth_reply.params.write.len = req.request.write.len;
auth_reply.params.write.p_data = req.request.write.data;
auth_reply.params.write.update = 1;
auth_reply.params.write.offset = 0;
}
else
{
NRF_LOG_RAW_INFO("READ VALUE: ");
auth_reply.params.read.gatt_status = BLE_GATT_STATUS_SUCCESS;
auth_reply.params.read.update = 0;
//auth_reply.params.read.offset = 0;
}
err_code = sd_ble_gatts_rw_authorize_reply(p_ble_evt->evt.gatts_evt.conn_handle,
&auth_reply);
APP_ERROR_CHECK(err_code);
}
This is a new problem and did not exist in the old versions of my firmware. Now that it is occurring even when I step back to older versions is seems to be occurring. Did I permanently overwrite something on my device? I have done "nrfjprog -e" and reflashed everything numerous times, reinstalled the lightblue app on my phone, and stepped back to older versions of my code. I am at a total loss and will take any advice.
Thanks in advanced,
Bloq