This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts
This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Writing peripheral characteristic value

Hello,

I established a connection between my central and peripheral module. Now i want to write characteristic value on peripheral. I tried with sd_ble_gattc_write function. First time, function doesn't return error, but value on my peripheral doesnt change. If i write again, i get error 0x11 (BUSY).

My function to write characteristic:

static uint32_t writeChar (uint16_t peripheral_id,uint8_t vrednost)
{
    uint32_t                 error_code   = NRF_ERROR_NOT_FOUND;
    ble_gattc_write_params_t write_params = {0};
    uint8_t                 write_value  = vrednost;

	
write_params.write_op = BLE_GATT_OP_WRITE_REQ;
write_params.handle = gs_peripheral[peripheral_id].read_handle;
write_params.offset = 0;
write_params.len = sizeof(write_value);
write_params.p_value = (uint8_t *)&write_value;


	LOG_DEBUG("vrednost: 0x%02x\r\n",vrednost);
if ((error_code = sd_ble_gattc_write(gs_peripheral[peripheral_id].conn_handle, &write_params)) != NRF_SUCCESS)
{
		LOG_DEBUG("(Peripheral %i) Error: 0x%x", peripheral_id, error_code);
    return error_code;
}
	else
	{
		LOG_DEBUG("Success\r\n");
	}
return error_code;
}
Related