diff --git a/sys/include/net/coap.h b/sys/include/net/coap.h index dca1f4bae0fd..7da367af581f 100644 --- a/sys/include/net/coap.h +++ b/sys/include/net/coap.h @@ -163,14 +163,20 @@ extern "C" { * @name CoAP method codes used in header * @{ */ -#define COAP_CLASS_REQ (0) -#define COAP_METHOD_GET (1) -#define COAP_METHOD_POST (2) -#define COAP_METHOD_PUT (3) -#define COAP_METHOD_DELETE (4) -#define COAP_METHOD_FETCH (5) -#define COAP_METHOD_PATCH (6) -#define COAP_METHOD_IPATCH (7) +#define COAP_CLASS_REQ (0) /**< Code Class for Request */ + +/** + * @brief CoAP method codes used in request + */ +typedef enum { + COAP_METHOD_GET = 1, /**< GET request (no paylod) */ + COAP_METHOD_POST = 2, /**< POST request (resource processes payload) */ + COAP_METHOD_PUT = 3, /**< PUT request (update resource with payload) */ + COAP_METHOD_DELETE = 4, /**< DELETE request (no payload, remove resource)*/ + COAP_METHOD_FETCH = 5, /**< FETCH request (RFC 8132) */ + COAP_METHOD_PATCH = 6, /**< PATCH request (RFC 8132) */ + COAP_METHOD_IPATCH = 7, /**< iPATCH request (RFC 8132) */ +} coap_method_t; /** @} */ /** diff --git a/sys/include/net/nanocoap_sock.h b/sys/include/net/nanocoap_sock.h index aee225d2c472..9917996df885 100644 --- a/sys/include/net/nanocoap_sock.h +++ b/sys/include/net/nanocoap_sock.h @@ -205,7 +205,7 @@ typedef struct { nanocoap_sock_t *sock; /**< socket used for the request */ const char *path; /**< path on the server */ uint32_t blknum; /**< current block number */ - uint8_t method; /**< request method (GET, POST, PUT) */ + coap_method_t method; /**< request method (GET, POST, PUT) */ uint8_t blksize; /**< CoAP blocksize exponent */ } coap_block_request_t; @@ -580,7 +580,7 @@ ssize_t nanocoap_request(coap_pkt_t *pkt, const sock_udp_ep_t *local, static inline int nanocoap_block_request_connect_url(coap_block_request_t *ctx, nanocoap_sock_t *sock, const char *url, - uint8_t method, + coap_method_t method, coap_blksize_t blksize) { ctx->sock = sock;