Skip to content

Commit 174e2cf

Browse files
juhaylinenSeppoTakalo
authored andcommitted
net: nrf_provisioning: Add block2 option to a CoAP request
Add block2 option to a CoAP GET request. This suggests the maximum block size to the server when blockwise transfer is required. Signed-off-by: Juha Ylinen <juha.ylinen@nordicsemi.no>
1 parent e133c72 commit 174e2cf

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

subsys/net/lib/nrf_provisioning/src/nrf_provisioning_coap.c

+8
Original file line numberDiff line numberDiff line change
@@ -306,6 +306,7 @@ static int send_coap_request(struct coap_client *client, uint8_t method, const c
306306
{
307307
int retries = 0;
308308
struct coap_transmission_parameters params = coap_get_transmission_parameters();
309+
static struct coap_client_option block2_option;
309310

310311
struct coap_client_request client_request = {
311312
.method = method,
@@ -323,6 +324,13 @@ static int send_coap_request(struct coap_client *client, uint8_t method, const c
323324
client_request.len = len;
324325
}
325326

327+
/* Suggest the maximum block size CONFIG_COAP_CLIENT_BLOCK_SIZE to the server */
328+
if (method == COAP_METHOD_GET) {
329+
block2_option = coap_client_option_initial_block2();
330+
client_request.options = &block2_option;
331+
client_request.num_options = 1;
332+
}
333+
326334
while (coap_client_req(client, coap_ctx->connect_socket, NULL, &client_request, NULL) ==
327335
-EAGAIN) {
328336
if (retries > RETRY_AMOUNT) {

0 commit comments

Comments
 (0)