Contiki 3.x
coap-server.h
1 #ifndef COAPSERVER_H_
2 #define COAPSERVER_H_
3 
4 #define COAP_DATA_BUFF_SIZE 300
5 
6 #include "contiki.h"
7 #include "coap-common.h"
8 
9 /*Declare process*/
10 PROCESS_NAME(coap_server);
11 
12 #define MOTE_SERVER_LISTEN_PORT 61616
13 #define MOTE_CLIENT_LISTEN_PORT 61617
14 
15 void parse_message(coap_packet_t* packet, uint8_t* buf, uint16_t size);
16 
17 uint16_t coap_get_payload(coap_packet_t* packet, uint8_t** payload);
18 int coap_set_payload(coap_packet_t* packet, uint8_t* payload, uint16_t size);
19 
20 content_type_t coap_get_header_content_type(coap_packet_t* packet);
21 int coap_set_header_content_type(coap_packet_t* packet, content_type_t content_type);
22 
23 int coap_get_header_subscription_lifetime(coap_packet_t* packet, uint32_t* lifetime);
24 int coap_set_header_subscription_lifetime(coap_packet_t* packet, uint32_t lifetime);
25 
26 int coap_get_header_block(coap_packet_t* packet, block_option_t* block);
27 int coap_set_header_block(coap_packet_t* packet, uint32_t number, uint8_t more, uint8_t size);
28 
29 int coap_set_header_uri(coap_packet_t* packet, char* uri);
30 int coap_set_header_etag(coap_packet_t* packet, uint8_t* etag, uint8_t size);
31 
32 void coap_set_code(coap_packet_t* packet, status_code_t code);
33 
34 coap_method_t coap_get_method(coap_packet_t* packet);
35 void coap_set_method(coap_packet_t* packet, coap_method_t method);
36 
37 int coap_get_query_variable(coap_packet_t* packet, const char *name, char* output, uint16_t output_size);
38 int coap_get_post_variable(coap_packet_t* packet, const char *name, char* output, uint16_t output_size);
39 
40 header_option_t* coap_get_option(coap_packet_t* packet, option_type option_type);
41 int coap_set_option(coap_packet_t* packet, option_type option_type, uint16_t len, uint8_t* value);
42 
43 /*Type definition of the service callback*/
44 typedef int (*service_callback) (coap_packet_t* request, coap_packet_t* response);
45 
46 /*
47  *Setter of the service callback, this callback will be called in case of HTTP request.
48  */
49 void coap_set_service_callback(service_callback callback);
50 
51 struct periodic_resource_t;
52 void resource_changed(struct periodic_resource_t* resource);
53 
54 #endif /* COAPSERVER_H_ */
#define PROCESS_NAME(name)
Declare the name of a process.
Definition: process.h:286