@@ -115,43 +115,49 @@ enum coap_msgtype {
115
115
COAP_TYPE_RESET = 3
116
116
};
117
117
118
- #define coap_make_response_code (class , det ) ((class << 5) | (det))
118
+ /**
119
+ * Utility macro to create a CoAP response code.
120
+ * @param class Class of the response code (ex. 2, 4, 5, ...)
121
+ * @param det Detail of the response code
122
+ * @return Response code literal
123
+ */
124
+ #define COAP_MAKE_RESPONSE_CODE (class , det ) ((class << 5) | (det))
119
125
120
126
/**
121
127
* @brief Set of response codes available for a response packet.
122
128
*
123
129
* To be used when creating a response.
124
130
*/
125
131
enum coap_response_code {
126
- COAP_RESPONSE_CODE_OK = coap_make_response_code (2 , 0 ),
127
- COAP_RESPONSE_CODE_CREATED = coap_make_response_code (2 , 1 ),
128
- COAP_RESPONSE_CODE_DELETED = coap_make_response_code (2 , 2 ),
129
- COAP_RESPONSE_CODE_VALID = coap_make_response_code (2 , 3 ),
130
- COAP_RESPONSE_CODE_CHANGED = coap_make_response_code (2 , 4 ),
131
- COAP_RESPONSE_CODE_CONTENT = coap_make_response_code (2 , 5 ),
132
- COAP_RESPONSE_CODE_CONTINUE = coap_make_response_code (2 , 31 ),
133
- COAP_RESPONSE_CODE_BAD_REQUEST = coap_make_response_code (4 , 0 ),
134
- COAP_RESPONSE_CODE_UNAUTHORIZED = coap_make_response_code (4 , 1 ),
135
- COAP_RESPONSE_CODE_BAD_OPTION = coap_make_response_code (4 , 2 ),
136
- COAP_RESPONSE_CODE_FORBIDDEN = coap_make_response_code (4 , 3 ),
137
- COAP_RESPONSE_CODE_NOT_FOUND = coap_make_response_code (4 , 4 ),
138
- COAP_RESPONSE_CODE_NOT_ALLOWED = coap_make_response_code (4 , 5 ),
139
- COAP_RESPONSE_CODE_NOT_ACCEPTABLE = coap_make_response_code (4 , 6 ),
140
- COAP_RESPONSE_CODE_INCOMPLETE = coap_make_response_code (4 , 8 ),
141
- COAP_RESPONSE_CODE_CONFLICT = coap_make_response_code (4 , 9 ),
142
- COAP_RESPONSE_CODE_PRECONDITION_FAILED = coap_make_response_code (4 , 12 ),
143
- COAP_RESPONSE_CODE_REQUEST_TOO_LARGE = coap_make_response_code (4 , 13 ),
132
+ COAP_RESPONSE_CODE_OK = COAP_MAKE_RESPONSE_CODE (2 , 0 ),
133
+ COAP_RESPONSE_CODE_CREATED = COAP_MAKE_RESPONSE_CODE (2 , 1 ),
134
+ COAP_RESPONSE_CODE_DELETED = COAP_MAKE_RESPONSE_CODE (2 , 2 ),
135
+ COAP_RESPONSE_CODE_VALID = COAP_MAKE_RESPONSE_CODE (2 , 3 ),
136
+ COAP_RESPONSE_CODE_CHANGED = COAP_MAKE_RESPONSE_CODE (2 , 4 ),
137
+ COAP_RESPONSE_CODE_CONTENT = COAP_MAKE_RESPONSE_CODE (2 , 5 ),
138
+ COAP_RESPONSE_CODE_CONTINUE = COAP_MAKE_RESPONSE_CODE (2 , 31 ),
139
+ COAP_RESPONSE_CODE_BAD_REQUEST = COAP_MAKE_RESPONSE_CODE (4 , 0 ),
140
+ COAP_RESPONSE_CODE_UNAUTHORIZED = COAP_MAKE_RESPONSE_CODE (4 , 1 ),
141
+ COAP_RESPONSE_CODE_BAD_OPTION = COAP_MAKE_RESPONSE_CODE (4 , 2 ),
142
+ COAP_RESPONSE_CODE_FORBIDDEN = COAP_MAKE_RESPONSE_CODE (4 , 3 ),
143
+ COAP_RESPONSE_CODE_NOT_FOUND = COAP_MAKE_RESPONSE_CODE (4 , 4 ),
144
+ COAP_RESPONSE_CODE_NOT_ALLOWED = COAP_MAKE_RESPONSE_CODE (4 , 5 ),
145
+ COAP_RESPONSE_CODE_NOT_ACCEPTABLE = COAP_MAKE_RESPONSE_CODE (4 , 6 ),
146
+ COAP_RESPONSE_CODE_INCOMPLETE = COAP_MAKE_RESPONSE_CODE (4 , 8 ),
147
+ COAP_RESPONSE_CODE_CONFLICT = COAP_MAKE_RESPONSE_CODE (4 , 9 ),
148
+ COAP_RESPONSE_CODE_PRECONDITION_FAILED = COAP_MAKE_RESPONSE_CODE (4 , 12 ),
149
+ COAP_RESPONSE_CODE_REQUEST_TOO_LARGE = COAP_MAKE_RESPONSE_CODE (4 , 13 ),
144
150
COAP_RESPONSE_CODE_UNSUPPORTED_CONTENT_FORMAT =
145
- coap_make_response_code (4 , 15 ),
146
- COAP_RESPONSE_CODE_UNPROCESSABLE_ENTITY = coap_make_response_code (4 , 22 ),
147
- COAP_RESPONSE_CODE_TOO_MANY_REQUESTS = coap_make_response_code (4 , 29 ),
148
- COAP_RESPONSE_CODE_INTERNAL_ERROR = coap_make_response_code (5 , 0 ),
149
- COAP_RESPONSE_CODE_NOT_IMPLEMENTED = coap_make_response_code (5 , 1 ),
150
- COAP_RESPONSE_CODE_BAD_GATEWAY = coap_make_response_code (5 , 2 ),
151
- COAP_RESPONSE_CODE_SERVICE_UNAVAILABLE = coap_make_response_code (5 , 3 ),
152
- COAP_RESPONSE_CODE_GATEWAY_TIMEOUT = coap_make_response_code (5 , 4 ),
151
+ COAP_MAKE_RESPONSE_CODE (4 , 15 ),
152
+ COAP_RESPONSE_CODE_UNPROCESSABLE_ENTITY = COAP_MAKE_RESPONSE_CODE (4 , 22 ),
153
+ COAP_RESPONSE_CODE_TOO_MANY_REQUESTS = COAP_MAKE_RESPONSE_CODE (4 , 29 ),
154
+ COAP_RESPONSE_CODE_INTERNAL_ERROR = COAP_MAKE_RESPONSE_CODE (5 , 0 ),
155
+ COAP_RESPONSE_CODE_NOT_IMPLEMENTED = COAP_MAKE_RESPONSE_CODE (5 , 1 ),
156
+ COAP_RESPONSE_CODE_BAD_GATEWAY = COAP_MAKE_RESPONSE_CODE (5 , 2 ),
157
+ COAP_RESPONSE_CODE_SERVICE_UNAVAILABLE = COAP_MAKE_RESPONSE_CODE (5 , 3 ),
158
+ COAP_RESPONSE_CODE_GATEWAY_TIMEOUT = COAP_MAKE_RESPONSE_CODE (5 , 4 ),
153
159
COAP_RESPONSE_CODE_PROXYING_NOT_SUPPORTED =
154
- coap_make_response_code (5 , 5 )
160
+ COAP_MAKE_RESPONSE_CODE (5 , 5 )
155
161
};
156
162
157
163
#define COAP_CODE_EMPTY (0)
0 commit comments