Skip to content

Commit cf0b606

Browse files
rluboskartben
authored andcommitted
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: Robert Lubos <[email protected]>
1 parent 0875499 commit cf0b606

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

subsys/net/lib/coap/coap_client.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1139,6 +1139,10 @@ bool coap_client_has_ongoing_exchange(struct coap_client *client)
11391139
return has_ongoing_exchange(client);
11401140
}
11411141

1142+
#define COAP_CLIENT_THREAD_PRIORITY CLAMP(CONFIG_COAP_CLIENT_THREAD_PRIORITY, \
1143+
K_HIGHEST_APPLICATION_THREAD_PRIO, \
1144+
K_LOWEST_APPLICATION_THREAD_PRIO)
1145+
11421146
K_THREAD_DEFINE(coap_client_recv_thread, CONFIG_COAP_CLIENT_STACK_SIZE,
11431147
coap_client_recv, NULL, NULL, NULL,
1144-
CONFIG_COAP_CLIENT_THREAD_PRIORITY, 0, 0);
1148+
COAP_CLIENT_THREAD_PRIORITY, 0, 0);

0 commit comments

Comments
 (0)