Commit a88ead52 authored by Gerson Fernando Budke's avatar Gerson Fernando Budke Committed by Anas Nashif
Browse files

samples: coap_server: Refactor to use coap_get_option_int

Small clean-up to use coap_get_option_int.

Signed-off-by: default avatarGerson Fernando Budke <nandojve@gmail.com>
parent 0fb97428
Loading
Loading
Loading
Loading
+2 −20
Changes for samples/net/sockets/coap_server/src/coap-server.c: 2 added lines, 20 removed lines.
Original line number Diff line number Diff line
@@ -39,11 +39,6 @@ LOG_MODULE_REGISTER(net_coap_server_sample, LOG_LEVEL_DBG);

#define NUM_PENDINGS 3

/* block option helper */
#define GET_BLOCK_NUM(v)        ((v) >> 4)
#define GET_BLOCK_SIZE(v)       (((v) & 0x7))
#define GET_MORE(v)             (!!((v) & 0x08))

/* CoAP socket fd */
static int sock;

@@ -780,19 +775,6 @@ end:
	return r;
}

static int get_option_int(const struct coap_packet *pkt, u8_t opt)
{
	struct coap_option option;
	int r;

	r = coap_find_options(pkt, opt, &option, 1);
	if (r <= 0) {
		return -ENOENT;
	}

	return coap_option_value_to_int(&option);
}

static int large_update_put(struct coap_resource *resource,
			    struct coap_packet *request,
			    struct sockaddr *addr, socklen_t addr_len)
@@ -810,7 +792,7 @@ static int large_update_put(struct coap_resource *resource,
	int r;
	bool last_block;

	r = get_option_int(request, COAP_OPTION_BLOCK1);
	r = coap_get_option_int(request, COAP_OPTION_BLOCK1);
	if (r < 0) {
		return -EINVAL;
	}
@@ -899,7 +881,7 @@ static int large_create_post(struct coap_resource *resource,
	int r;
	bool last_block;

	r = get_option_int(request, COAP_OPTION_BLOCK1);
	r = coap_get_option_int(request, COAP_OPTION_BLOCK1);
	if (r < 0) {
		return -EINVAL;
	}