IoT - Kubus
/
Kubus
JNP3 16/17
cantcoap/cantcoap.h@31:413ba83b8c0b, 2017-01-17 (annotated)
- Committer:
- Bartosz Stebel
- Date:
- Tue Jan 17 11:05:46 2017 +0100
- Revision:
- 31:413ba83b8c0b
coap patches
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
Bartosz Stebel |
31:413ba83b8c0b | 1 | /** |
Bartosz Stebel |
31:413ba83b8c0b | 2 | Copyright (c) 2013, Ashley Mills. |
Bartosz Stebel |
31:413ba83b8c0b | 3 | All rights reserved. |
Bartosz Stebel |
31:413ba83b8c0b | 4 | |
Bartosz Stebel |
31:413ba83b8c0b | 5 | Redistribution and use in source and binary forms, with or without |
Bartosz Stebel |
31:413ba83b8c0b | 6 | modification, are permitted provided that the following conditions are met: |
Bartosz Stebel |
31:413ba83b8c0b | 7 | |
Bartosz Stebel |
31:413ba83b8c0b | 8 | 1. Redistributions of source code must retain the above copyright notice, this |
Bartosz Stebel |
31:413ba83b8c0b | 9 | list of conditions and the following disclaimer. |
Bartosz Stebel |
31:413ba83b8c0b | 10 | 2. Redistributions in binary form must reproduce the above copyright notice, |
Bartosz Stebel |
31:413ba83b8c0b | 11 | this list of conditions and the following disclaimer in the documentation |
Bartosz Stebel |
31:413ba83b8c0b | 12 | and/or other materials provided with the distribution. |
Bartosz Stebel |
31:413ba83b8c0b | 13 | |
Bartosz Stebel |
31:413ba83b8c0b | 14 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND |
Bartosz Stebel |
31:413ba83b8c0b | 15 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED |
Bartosz Stebel |
31:413ba83b8c0b | 16 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
Bartosz Stebel |
31:413ba83b8c0b | 17 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR |
Bartosz Stebel |
31:413ba83b8c0b | 18 | ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES |
Bartosz Stebel |
31:413ba83b8c0b | 19 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; |
Bartosz Stebel |
31:413ba83b8c0b | 20 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND |
Bartosz Stebel |
31:413ba83b8c0b | 21 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
Bartosz Stebel |
31:413ba83b8c0b | 22 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS |
Bartosz Stebel |
31:413ba83b8c0b | 23 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
Bartosz Stebel |
31:413ba83b8c0b | 24 | */ |
Bartosz Stebel |
31:413ba83b8c0b | 25 | |
Bartosz Stebel |
31:413ba83b8c0b | 26 | #pragma once |
Bartosz Stebel |
31:413ba83b8c0b | 27 | |
Bartosz Stebel |
31:413ba83b8c0b | 28 | #include <stdint.h> |
Bartosz Stebel |
31:413ba83b8c0b | 29 | |
Bartosz Stebel |
31:413ba83b8c0b | 30 | #define COAP_HDR_SIZE 4 |
Bartosz Stebel |
31:413ba83b8c0b | 31 | #define COAP_OPTION_HDR_BYTE 1 |
Bartosz Stebel |
31:413ba83b8c0b | 32 | |
Bartosz Stebel |
31:413ba83b8c0b | 33 | // CoAP PDU format |
Bartosz Stebel |
31:413ba83b8c0b | 34 | |
Bartosz Stebel |
31:413ba83b8c0b | 35 | // 0 1 2 3 |
Bartosz Stebel |
31:413ba83b8c0b | 36 | // 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 |
Bartosz Stebel |
31:413ba83b8c0b | 37 | // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |
Bartosz Stebel |
31:413ba83b8c0b | 38 | // |Ver| T | TKL | Code | Message ID | |
Bartosz Stebel |
31:413ba83b8c0b | 39 | // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |
Bartosz Stebel |
31:413ba83b8c0b | 40 | // | Token (if any, TKL bytes) ... |
Bartosz Stebel |
31:413ba83b8c0b | 41 | // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |
Bartosz Stebel |
31:413ba83b8c0b | 42 | // | Options (if any) ... |
Bartosz Stebel |
31:413ba83b8c0b | 43 | // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |
Bartosz Stebel |
31:413ba83b8c0b | 44 | // |1 1 1 1 1 1 1 1| Payload (if any) ... |
Bartosz Stebel |
31:413ba83b8c0b | 45 | // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |
Bartosz Stebel |
31:413ba83b8c0b | 46 | |
Bartosz Stebel |
31:413ba83b8c0b | 47 | class CoapPDU { |
Bartosz Stebel |
31:413ba83b8c0b | 48 | |
Bartosz Stebel |
31:413ba83b8c0b | 49 | |
Bartosz Stebel |
31:413ba83b8c0b | 50 | public: |
Bartosz Stebel |
31:413ba83b8c0b | 51 | /// CoAP message types. Note, values only work as enum. |
Bartosz Stebel |
31:413ba83b8c0b | 52 | enum Type { |
Bartosz Stebel |
31:413ba83b8c0b | 53 | COAP_CONFIRMABLE=0x00, |
Bartosz Stebel |
31:413ba83b8c0b | 54 | COAP_NON_CONFIRMABLE=0x10, |
Bartosz Stebel |
31:413ba83b8c0b | 55 | COAP_ACKNOWLEDGEMENT=0x20, |
Bartosz Stebel |
31:413ba83b8c0b | 56 | COAP_RESET=0x30 |
Bartosz Stebel |
31:413ba83b8c0b | 57 | }; |
Bartosz Stebel |
31:413ba83b8c0b | 58 | |
Bartosz Stebel |
31:413ba83b8c0b | 59 | // CoAP response codes. |
Bartosz Stebel |
31:413ba83b8c0b | 60 | enum Code { |
Bartosz Stebel |
31:413ba83b8c0b | 61 | COAP_EMPTY=0x00, |
Bartosz Stebel |
31:413ba83b8c0b | 62 | COAP_GET, |
Bartosz Stebel |
31:413ba83b8c0b | 63 | COAP_POST, |
Bartosz Stebel |
31:413ba83b8c0b | 64 | COAP_PUT, |
Bartosz Stebel |
31:413ba83b8c0b | 65 | COAP_DELETE, |
Bartosz Stebel |
31:413ba83b8c0b | 66 | COAP_CREATED=0x41, |
Bartosz Stebel |
31:413ba83b8c0b | 67 | COAP_DELETED, |
Bartosz Stebel |
31:413ba83b8c0b | 68 | COAP_VALID, |
Bartosz Stebel |
31:413ba83b8c0b | 69 | COAP_CHANGED, |
Bartosz Stebel |
31:413ba83b8c0b | 70 | COAP_CONTENT, |
Bartosz Stebel |
31:413ba83b8c0b | 71 | COAP_BAD_REQUEST=0x80, |
Bartosz Stebel |
31:413ba83b8c0b | 72 | COAP_UNAUTHORIZED, |
Bartosz Stebel |
31:413ba83b8c0b | 73 | COAP_BAD_OPTION, |
Bartosz Stebel |
31:413ba83b8c0b | 74 | COAP_FORBIDDEN, |
Bartosz Stebel |
31:413ba83b8c0b | 75 | COAP_NOT_FOUND, |
Bartosz Stebel |
31:413ba83b8c0b | 76 | COAP_METHOD_NOT_ALLOWED, |
Bartosz Stebel |
31:413ba83b8c0b | 77 | COAP_NOT_ACCEPTABLE, |
Bartosz Stebel |
31:413ba83b8c0b | 78 | COAP_PRECONDITION_FAILED=0x8C, |
Bartosz Stebel |
31:413ba83b8c0b | 79 | COAP_REQUEST_ENTITY_TOO_LARGE=0x8D, |
Bartosz Stebel |
31:413ba83b8c0b | 80 | COAP_UNSUPPORTED_CONTENT_FORMAT=0x8F, |
Bartosz Stebel |
31:413ba83b8c0b | 81 | COAP_INTERNAL_SERVER_ERROR=0xA0, |
Bartosz Stebel |
31:413ba83b8c0b | 82 | COAP_NOT_IMPLEMENTED, |
Bartosz Stebel |
31:413ba83b8c0b | 83 | COAP_BAD_GATEWAY, |
Bartosz Stebel |
31:413ba83b8c0b | 84 | COAP_SERVICE_UNAVAILABLE, |
Bartosz Stebel |
31:413ba83b8c0b | 85 | COAP_GATEWAY_TIMEOUT, |
Bartosz Stebel |
31:413ba83b8c0b | 86 | COAP_PROXYING_NOT_SUPPORTED, |
Bartosz Stebel |
31:413ba83b8c0b | 87 | COAP_UNDEFINED_CODE=0xFF |
Bartosz Stebel |
31:413ba83b8c0b | 88 | }; |
Bartosz Stebel |
31:413ba83b8c0b | 89 | |
Bartosz Stebel |
31:413ba83b8c0b | 90 | /// CoAP option numbers. |
Bartosz Stebel |
31:413ba83b8c0b | 91 | enum Option { |
Bartosz Stebel |
31:413ba83b8c0b | 92 | COAP_OPTION_IF_MATCH=1, |
Bartosz Stebel |
31:413ba83b8c0b | 93 | COAP_OPTION_URI_HOST=3, |
Bartosz Stebel |
31:413ba83b8c0b | 94 | COAP_OPTION_ETAG, |
Bartosz Stebel |
31:413ba83b8c0b | 95 | COAP_OPTION_IF_NONE_MATCH, |
Bartosz Stebel |
31:413ba83b8c0b | 96 | COAP_OPTION_OBSERVE, |
Bartosz Stebel |
31:413ba83b8c0b | 97 | COAP_OPTION_URI_PORT, |
Bartosz Stebel |
31:413ba83b8c0b | 98 | COAP_OPTION_LOCATION_PATH, |
Bartosz Stebel |
31:413ba83b8c0b | 99 | COAP_OPTION_URI_PATH=11, |
Bartosz Stebel |
31:413ba83b8c0b | 100 | COAP_OPTION_CONTENT_FORMAT, |
Bartosz Stebel |
31:413ba83b8c0b | 101 | COAP_OPTION_MAX_AGE=14, |
Bartosz Stebel |
31:413ba83b8c0b | 102 | COAP_OPTION_URI_QUERY, |
Bartosz Stebel |
31:413ba83b8c0b | 103 | COAP_OPTION_ACCEPT=17, |
Bartosz Stebel |
31:413ba83b8c0b | 104 | COAP_OPTION_LOCATION_QUERY=20, |
Bartosz Stebel |
31:413ba83b8c0b | 105 | COAP_OPTION_BLOCK2=23, |
Bartosz Stebel |
31:413ba83b8c0b | 106 | COAP_OPTION_BLOCK1=27, |
Bartosz Stebel |
31:413ba83b8c0b | 107 | COAP_OPTION_SIZE2, |
Bartosz Stebel |
31:413ba83b8c0b | 108 | COAP_OPTION_PROXY_URI=35, |
Bartosz Stebel |
31:413ba83b8c0b | 109 | COAP_OPTION_PROXY_SCHEME=39, |
Bartosz Stebel |
31:413ba83b8c0b | 110 | COAP_OPTION_SIZE1=60 |
Bartosz Stebel |
31:413ba83b8c0b | 111 | }; |
Bartosz Stebel |
31:413ba83b8c0b | 112 | |
Bartosz Stebel |
31:413ba83b8c0b | 113 | /// CoAP content-formats. |
Bartosz Stebel |
31:413ba83b8c0b | 114 | enum ContentFormat { |
Bartosz Stebel |
31:413ba83b8c0b | 115 | COAP_CONTENT_FORMAT_TEXT_PLAIN = 0, |
Bartosz Stebel |
31:413ba83b8c0b | 116 | COAP_CONTENT_FORMAT_APP_LINK = 40, |
Bartosz Stebel |
31:413ba83b8c0b | 117 | COAP_CONTENT_FORMAT_APP_XML, |
Bartosz Stebel |
31:413ba83b8c0b | 118 | COAP_CONTENT_FORMAT_APP_OCTET, |
Bartosz Stebel |
31:413ba83b8c0b | 119 | COAP_CONTENT_FORMAT_APP_EXI = 47, |
Bartosz Stebel |
31:413ba83b8c0b | 120 | COAP_CONTENT_FORMAT_APP_JSON = 50 |
Bartosz Stebel |
31:413ba83b8c0b | 121 | }; |
Bartosz Stebel |
31:413ba83b8c0b | 122 | |
Bartosz Stebel |
31:413ba83b8c0b | 123 | /// Sequence of these is returned by CoapPDU::getOptions() |
Bartosz Stebel |
31:413ba83b8c0b | 124 | struct CoapOption { |
Bartosz Stebel |
31:413ba83b8c0b | 125 | uint16_t optionDelta; |
Bartosz Stebel |
31:413ba83b8c0b | 126 | uint16_t optionNumber; |
Bartosz Stebel |
31:413ba83b8c0b | 127 | uint16_t optionValueLength; |
Bartosz Stebel |
31:413ba83b8c0b | 128 | int totalLength; |
Bartosz Stebel |
31:413ba83b8c0b | 129 | uint8_t *optionPointer; |
Bartosz Stebel |
31:413ba83b8c0b | 130 | uint8_t *optionValuePointer; |
Bartosz Stebel |
31:413ba83b8c0b | 131 | }; |
Bartosz Stebel |
31:413ba83b8c0b | 132 | |
Bartosz Stebel |
31:413ba83b8c0b | 133 | // construction and destruction |
Bartosz Stebel |
31:413ba83b8c0b | 134 | CoapPDU(); |
Bartosz Stebel |
31:413ba83b8c0b | 135 | CoapPDU(uint8_t *pdu, int pduLength); |
Bartosz Stebel |
31:413ba83b8c0b | 136 | CoapPDU(uint8_t *buffer, int bufferLength, int pduLength); |
Bartosz Stebel |
31:413ba83b8c0b | 137 | ~CoapPDU(); |
Bartosz Stebel |
31:413ba83b8c0b | 138 | int reset(); |
Bartosz Stebel |
31:413ba83b8c0b | 139 | int validate(); |
Bartosz Stebel |
31:413ba83b8c0b | 140 | |
Bartosz Stebel |
31:413ba83b8c0b | 141 | // version |
Bartosz Stebel |
31:413ba83b8c0b | 142 | int setVersion(uint8_t version); |
Bartosz Stebel |
31:413ba83b8c0b | 143 | uint8_t getVersion(); |
Bartosz Stebel |
31:413ba83b8c0b | 144 | |
Bartosz Stebel |
31:413ba83b8c0b | 145 | // message type |
Bartosz Stebel |
31:413ba83b8c0b | 146 | void setType(CoapPDU::Type type); |
Bartosz Stebel |
31:413ba83b8c0b | 147 | CoapPDU::Type getType(); |
Bartosz Stebel |
31:413ba83b8c0b | 148 | |
Bartosz Stebel |
31:413ba83b8c0b | 149 | // tokens |
Bartosz Stebel |
31:413ba83b8c0b | 150 | int setTokenLength(uint8_t tokenLength); |
Bartosz Stebel |
31:413ba83b8c0b | 151 | int getTokenLength(); |
Bartosz Stebel |
31:413ba83b8c0b | 152 | uint8_t* getTokenPointer(); |
Bartosz Stebel |
31:413ba83b8c0b | 153 | int setToken(uint8_t *token, uint8_t tokenLength); |
Bartosz Stebel |
31:413ba83b8c0b | 154 | |
Bartosz Stebel |
31:413ba83b8c0b | 155 | // message code |
Bartosz Stebel |
31:413ba83b8c0b | 156 | void setCode(CoapPDU::Code code); |
Bartosz Stebel |
31:413ba83b8c0b | 157 | CoapPDU::Code getCode(); |
Bartosz Stebel |
31:413ba83b8c0b | 158 | CoapPDU::Code httpStatusToCode(int httpStatus); |
Bartosz Stebel |
31:413ba83b8c0b | 159 | |
Bartosz Stebel |
31:413ba83b8c0b | 160 | // message ID |
Bartosz Stebel |
31:413ba83b8c0b | 161 | int setMessageID(uint16_t messageID); |
Bartosz Stebel |
31:413ba83b8c0b | 162 | uint16_t getMessageID(); |
Bartosz Stebel |
31:413ba83b8c0b | 163 | |
Bartosz Stebel |
31:413ba83b8c0b | 164 | // options |
Bartosz Stebel |
31:413ba83b8c0b | 165 | int addOption(uint16_t optionNumber, uint16_t optionLength, uint8_t *optionValue); |
Bartosz Stebel |
31:413ba83b8c0b | 166 | // gets a list of all options |
Bartosz Stebel |
31:413ba83b8c0b | 167 | CoapOption* getOptions(); |
Bartosz Stebel |
31:413ba83b8c0b | 168 | int getNumOptions(); |
Bartosz Stebel |
31:413ba83b8c0b | 169 | // shorthand helpers |
Bartosz Stebel |
31:413ba83b8c0b | 170 | int setURI(char *uri); |
Bartosz Stebel |
31:413ba83b8c0b | 171 | int setURI(char *uri, int urilen); |
Bartosz Stebel |
31:413ba83b8c0b | 172 | int getURI(char *dst, int dstlen, int *outLen); |
Bartosz Stebel |
31:413ba83b8c0b | 173 | int addURIQuery(char *query); |
Bartosz Stebel |
31:413ba83b8c0b | 174 | |
Bartosz Stebel |
31:413ba83b8c0b | 175 | // content format helper |
Bartosz Stebel |
31:413ba83b8c0b | 176 | int setContentFormat(CoapPDU::ContentFormat format); |
Bartosz Stebel |
31:413ba83b8c0b | 177 | |
Bartosz Stebel |
31:413ba83b8c0b | 178 | // payload |
Bartosz Stebel |
31:413ba83b8c0b | 179 | uint8_t* mallocPayload(int bytes); |
Bartosz Stebel |
31:413ba83b8c0b | 180 | int setPayload(uint8_t *value, int len); |
Bartosz Stebel |
31:413ba83b8c0b | 181 | uint8_t* getPayloadPointer(); |
Bartosz Stebel |
31:413ba83b8c0b | 182 | int getPayloadLength(); |
Bartosz Stebel |
31:413ba83b8c0b | 183 | uint8_t* getPayloadCopy(); |
Bartosz Stebel |
31:413ba83b8c0b | 184 | |
Bartosz Stebel |
31:413ba83b8c0b | 185 | // pdu |
Bartosz Stebel |
31:413ba83b8c0b | 186 | int getPDULength(); |
Bartosz Stebel |
31:413ba83b8c0b | 187 | uint8_t* getPDUPointer(); |
Bartosz Stebel |
31:413ba83b8c0b | 188 | void setPDULength(int len); |
Bartosz Stebel |
31:413ba83b8c0b | 189 | |
Bartosz Stebel |
31:413ba83b8c0b | 190 | // debugging |
Bartosz Stebel |
31:413ba83b8c0b | 191 | static void printBinary(uint8_t b); |
Bartosz Stebel |
31:413ba83b8c0b | 192 | void print(); |
Bartosz Stebel |
31:413ba83b8c0b | 193 | void printBin(); |
Bartosz Stebel |
31:413ba83b8c0b | 194 | void printHex(); |
Bartosz Stebel |
31:413ba83b8c0b | 195 | void printOptionHuman(uint8_t *option); |
Bartosz Stebel |
31:413ba83b8c0b | 196 | void printHuman(); |
Bartosz Stebel |
31:413ba83b8c0b | 197 | void printPDUAsCArray(); |
Bartosz Stebel |
31:413ba83b8c0b | 198 | |
Bartosz Stebel |
31:413ba83b8c0b | 199 | private: |
Bartosz Stebel |
31:413ba83b8c0b | 200 | // variables |
Bartosz Stebel |
31:413ba83b8c0b | 201 | uint8_t *_pdu; |
Bartosz Stebel |
31:413ba83b8c0b | 202 | int _pduLength; |
Bartosz Stebel |
31:413ba83b8c0b | 203 | |
Bartosz Stebel |
31:413ba83b8c0b | 204 | int _constructedFromBuffer; |
Bartosz Stebel |
31:413ba83b8c0b | 205 | int _bufferLength; |
Bartosz Stebel |
31:413ba83b8c0b | 206 | |
Bartosz Stebel |
31:413ba83b8c0b | 207 | uint8_t *_payloadPointer; |
Bartosz Stebel |
31:413ba83b8c0b | 208 | int _payloadLength; |
Bartosz Stebel |
31:413ba83b8c0b | 209 | |
Bartosz Stebel |
31:413ba83b8c0b | 210 | int _numOptions; |
Bartosz Stebel |
31:413ba83b8c0b | 211 | uint16_t _maxAddedOptionNumber; |
Bartosz Stebel |
31:413ba83b8c0b | 212 | |
Bartosz Stebel |
31:413ba83b8c0b | 213 | // functions |
Bartosz Stebel |
31:413ba83b8c0b | 214 | void shiftPDUUp(int shiftOffset, int shiftAmount); |
Bartosz Stebel |
31:413ba83b8c0b | 215 | void shiftPDUDown(int startLocation, int shiftOffset, int shiftAmount); |
Bartosz Stebel |
31:413ba83b8c0b | 216 | uint8_t codeToValue(CoapPDU::Code c); |
Bartosz Stebel |
31:413ba83b8c0b | 217 | |
Bartosz Stebel |
31:413ba83b8c0b | 218 | // option stuff |
Bartosz Stebel |
31:413ba83b8c0b | 219 | int findInsertionPosition(uint16_t optionNumber, uint16_t *prevOptionNumber); |
Bartosz Stebel |
31:413ba83b8c0b | 220 | int computeExtraBytes(uint16_t n); |
Bartosz Stebel |
31:413ba83b8c0b | 221 | int insertOption(int insertionPosition, uint16_t optionDelta, uint16_t optionValueLength, uint8_t *optionValue); |
Bartosz Stebel |
31:413ba83b8c0b | 222 | uint16_t getOptionDelta(uint8_t *option); |
Bartosz Stebel |
31:413ba83b8c0b | 223 | void setOptionDelta(int optionPosition, uint16_t optionDelta); |
Bartosz Stebel |
31:413ba83b8c0b | 224 | uint16_t getOptionValueLength(uint8_t *option); |
Bartosz Stebel |
31:413ba83b8c0b | 225 | |
Bartosz Stebel |
31:413ba83b8c0b | 226 | }; |
Bartosz Stebel |
31:413ba83b8c0b | 227 | |
Bartosz Stebel |
31:413ba83b8c0b | 228 | /* |
Bartosz Stebel |
31:413ba83b8c0b | 229 | #define COAP_CODE_EMPTY 0x00 |
Bartosz Stebel |
31:413ba83b8c0b | 230 | |
Bartosz Stebel |
31:413ba83b8c0b | 231 | // method codes 0.01-0.31 |
Bartosz Stebel |
31:413ba83b8c0b | 232 | #define COAP_CODE_GET 0x01 |
Bartosz Stebel |
31:413ba83b8c0b | 233 | #define COAP_CODE_POST 0x02 |
Bartosz Stebel |
31:413ba83b8c0b | 234 | #define COAP_CODE_PUT 0x03 |
Bartosz Stebel |
31:413ba83b8c0b | 235 | #define COAP_CODE_DELETE 0x04 |
Bartosz Stebel |
31:413ba83b8c0b | 236 | |
Bartosz Stebel |
31:413ba83b8c0b | 237 | // Response codes 2.00 - 5.31 |
Bartosz Stebel |
31:413ba83b8c0b | 238 | // 2.00 - 2.05 |
Bartosz Stebel |
31:413ba83b8c0b | 239 | #define COAP_CODE_CREATED 0x41 |
Bartosz Stebel |
31:413ba83b8c0b | 240 | #define COAP_CODE_DELETED 0x42 |
Bartosz Stebel |
31:413ba83b8c0b | 241 | #define COAP_CODE_VALID 0x43 |
Bartosz Stebel |
31:413ba83b8c0b | 242 | #define COAP_CODE_CHANGED 0x44 |
Bartosz Stebel |
31:413ba83b8c0b | 243 | #define COAP_CODE_CONTENT 0x45 |
Bartosz Stebel |
31:413ba83b8c0b | 244 | |
Bartosz Stebel |
31:413ba83b8c0b | 245 | // 4.00 - 4.15 |
Bartosz Stebel |
31:413ba83b8c0b | 246 | #define COAP_CODE_BAD_REQUEST 0x80 |
Bartosz Stebel |
31:413ba83b8c0b | 247 | #define COAP_CODE_UNAUTHORIZED 0x81 |
Bartosz Stebel |
31:413ba83b8c0b | 248 | #define COAP_CODE_BAD_OPTION 0x82 |
Bartosz Stebel |
31:413ba83b8c0b | 249 | #define COAP_CODE_FORBIDDEN 0x83 |
Bartosz Stebel |
31:413ba83b8c0b | 250 | #define COAP_CODE_NOT_FOUND 0x84 |
Bartosz Stebel |
31:413ba83b8c0b | 251 | #define COAP_CODE_METHOD_NOT_ALLOWED 0x85 |
Bartosz Stebel |
31:413ba83b8c0b | 252 | #define COAP_CODE_NOT_ACCEPTABLE 0x86 |
Bartosz Stebel |
31:413ba83b8c0b | 253 | #define COAP_CODE_PRECONDITION_FAILED 0x8C |
Bartosz Stebel |
31:413ba83b8c0b | 254 | #define COAP_CODE_REQUEST_ENTITY_TOO_LARGE 0x8D |
Bartosz Stebel |
31:413ba83b8c0b | 255 | #define COAP_CODE_UNSUPPORTED_CONTENT_FORMAT 0x8F |
Bartosz Stebel |
31:413ba83b8c0b | 256 | |
Bartosz Stebel |
31:413ba83b8c0b | 257 | // 5.00 - 5.05 |
Bartosz Stebel |
31:413ba83b8c0b | 258 | #define COAP_CODE_INTERNAL_SERVER_ERROR 0xA0 |
Bartosz Stebel |
31:413ba83b8c0b | 259 | #define COAP_CODE_NOT_IMPLEMENTED 0xA1 |
Bartosz Stebel |
31:413ba83b8c0b | 260 | #define COAP_CODE_BAD_GATEWAY 0xA2 |
Bartosz Stebel |
31:413ba83b8c0b | 261 | #define COAP_CODE_SERVICE_UNAVAILABLE 0xA3 |
Bartosz Stebel |
31:413ba83b8c0b | 262 | #define COAP_CODE_GATEWAY_TIMEOUT 0xA4 |
Bartosz Stebel |
31:413ba83b8c0b | 263 | #define COAP_CODE_PROXYING_NOT_SUPPORTED 0xA5 |
Bartosz Stebel |
31:413ba83b8c0b | 264 | */ |