/* Attempts to transmit an SMP error response. This function consumes both supplied buffers. */
static void smp_on_err(struct smp_streamer *streamer, const struct smp_hdr *req_hdr, void *req, void *rsp, int status, const char *rsn)
/* Attempts to transmit an SMP error response. This function consumes both supplied buffers. */
static void smp_on_err(struct smp_streamer *streamer, const struct smp_hdr *req_hdr, void *req, void *rsp, int status, const char *rsn)
{
	int rc;
	if (rsp == NULL) {
		rsp = req;
		req = NULL;
	}
	cbor_nb_writer_init(streamer->writer, rsp);
	rc = smp_build_err_rsp(streamer, req_hdr, status, rsn);
	if (rc == 0) {
		streamer->smpt->functions.output(rsp);
		rsp = NULL;
	}
	smp_free_buf(req, streamer->smpt);
	smp_free_buf(rsp, streamer->smpt);
}