mikroSDK Reference Manual
coap_message.h
Go to the documentation of this file.
1
31#ifndef _COAP_MESSAGE_H
32#define _COAP_MESSAGE_H
33
34//Dependencies
35#include "core/net.h"
36#include "coap/coap_common.h"
37
38//Maximum size of CoAP messages
39#ifndef COAP_MAX_MSG_SIZE
40 #define COAP_MAX_MSG_SIZE 1152
41#elif (COAP_MAX_MSG_SIZE < 16)
42 #error COAP_MAX_MSG_SIZE parameter is not valid
43#endif
44
45//C++ guard
46#ifdef __cplusplus
47extern "C" {
48#endif
49
50
55typedef struct
56{
57 uint8_t buffer[COAP_MAX_MSG_SIZE];
58 size_t length;
59 size_t pos;
61
62
63//CoAP related functions
64error_t coapParseMessage(const CoapMessage *message);
65
66error_t coapParseMessageHeader(const uint8_t *p, size_t length,
67 size_t *consumed);
68
69error_t coapSetType(CoapMessage *message, CoapMessageType type);
70error_t coapGetType(const CoapMessage *message, CoapMessageType *type);
71
72error_t coapSetCode(CoapMessage *message, CoapCode code);
73error_t coapGetCode(const CoapMessage *message, CoapCode *code);
74
75error_t coapSetPayload(CoapMessage *message, const void *payload,
76 size_t payloadLen);
77
78error_t coapGetPayload(const CoapMessage *message, const uint8_t **payload,
79 size_t *payloadLen);
80
81error_t coapWritePayload(CoapMessage *message, const void *data,
82 size_t length);
83
84error_t coapReadPayload(CoapMessage *message, void *data, size_t size,
85 size_t *length);
86
87bool_t coapCompareToken(const CoapMessageHeader *header1,
88 const CoapMessageHeader *header2);
89
90//C++ guard
91#ifdef __cplusplus
92}
93#endif
94
95#endif
Definitions common to CoAP client and server.
CoapMessageType
CoAP message types.
Definition coap_common.h:88
CoapCode
CoAP method and response codes.
Definition coap_common.h:113
error_t
Error codes.
Definition error.h:43
TCP/IP stack core.
CoAP message.
Definition coap_message.h:56