/**@brief Command response callback function for @ref sd_ble_gatts_hvx BLE command. * * Callback for decoding the command response return code. * * @param[in] p_buffer Pointer to begin of command response buffer. * @param[in] length Length of data in bytes. * * @return Decoded command response return code. */ static uint32_t gatts_hvx_rsp_dec(const uint8_t * p_buffer, uint16_t length) { uint32_t result_code; const uint32_t err_code = ble_gatts_hvx_rsp_dec(p_buffer, length, &result_code, (uint16_t * *)&mp_out_params[0]); APP_ERROR_CHECK(err_code); return result_code; }
uint32_t sd_ble_gatts_hvx(adapter_t *adapter, uint16_t conn_handle, ble_gatts_hvx_params_t const *p_hvx_params) { encode_function_t encode_function = [&] (uint8_t *buffer, uint32_t *length) -> uint32_t { return ble_gatts_hvx_req_enc(conn_handle, p_hvx_params, buffer, length); }; decode_function_t decode_function = [&] (uint8_t *buffer, uint32_t length, uint32_t *result) -> uint32_t { uint16_t *out_length = p_hvx_params->p_len; return ble_gatts_hvx_rsp_dec(buffer, length, result, &out_length); }; return encode_decode(adapter, encode_function, decode_function); }