Commit f6a55c96 authored by Robert Lubos's avatar Robert Lubos Committed by Benjamin Cabé
Browse files

net: coap_client: Fix CoAP client thread priority

The default thread priority for the CoAP client thread is set to
NUM_PREEMPT_PRIORITIES which is not a valid thread priority, as the
lowest application thread priority is actually
NUM_PREEMPT_PRIORITIES - 1. Because of this, CoAP client library gave an
assert on boot if assertions were enabled.

Kconfig does not allow for arithmetics when setting integer defaults,
therefore handle this at the preprocessor stage by limiting the actual
priority assigned to the CoAP client thread to a valid range.

Signed-off-by: default avatarRobert Lubos <robert.lubos@nordicsemi.no>
parent 5601c18b
Loading
Loading
Loading
Loading
+5 −1
Changes for subsys/net/lib/coap/coap_client.c: 5 added lines, 1 removed line.
Original line number Diff line number Diff line
@@ -1121,6 +1121,10 @@ struct coap_client_option coap_client_option_initial_block2(void)
	return block2;
}

#define COAP_CLIENT_THREAD_PRIORITY CLAMP(CONFIG_COAP_CLIENT_THREAD_PRIORITY, \
					  K_HIGHEST_APPLICATION_THREAD_PRIO, \
					  K_LOWEST_APPLICATION_THREAD_PRIO)

K_THREAD_DEFINE(coap_client_recv_thread, CONFIG_COAP_CLIENT_STACK_SIZE,
		coap_client_recv, NULL, NULL, NULL,
		CONFIG_COAP_CLIENT_THREAD_PRIORITY, 0, 0);
		COAP_CLIENT_THREAD_PRIORITY, 0, 0);