Skip to content

Commit e0fd876

Browse files
committed
app: coapc: Fix socket collision with nRF Cloud and provisioning
sm_coap_client is zero-initialized, so fd=0. Since Zephyr's ZVFS allocates FDs from index 0, the first socket opened by nRF Cloud or provisioning also gets FD 0. coap_client's get_client() then finds sm_coap_client first in the registered clients array and misroutes responses to it. Initialize sm_coap_client.fd=-1 at init and reset it to -1 in coap_close_request(), matching the pattern used by the nRF Cloud and provisioning CoAP transports. Signed-off-by: Juha Ylinen <juha.ylinen@nordicsemi.no>
1 parent dde7101 commit e0fd876

1 file changed

Lines changed: 3 additions & 0 deletions

File tree

app/src/sm_at_coap.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,8 @@ static void coap_close_request(struct coap_request *req)
134134
coap_pending_req = NULL;
135135
}
136136

137+
sm_coap_client.fd = -1;
138+
137139
free(req->staging);
138140
free(req->rx_buf);
139141
free(req);
@@ -946,6 +948,7 @@ STATIC int handle_at_coap_data(enum at_parser_cmd_type cmd_type, struct at_parse
946948

947949
static int sm_at_coap_init(void)
948950
{
951+
sm_coap_client.fd = -1;
949952
return coap_client_init(&sm_coap_client, "sm_coap");
950953
}
951954

0 commit comments

Comments
 (0)