1 #ifndef COAP_CONFIG_H_ 2 #define COAP_CONFIG_H_ 3 4 #include "contiki.h" 5 #include "contiki-lib.h" 6 #include "contiki-net.h" 7 8 #define WITH_CONTIKI 1 9 10 #ifndef COAP_CONSTRAINED_STACK 11 #define COAP_CONSTRAINED_STACK 1 12 #endif 13 14 #define PACKAGE_STRING "libcoap" 15 #define PACKAGE_NAME "libcoap" 16 17 #ifndef COAP_DEFAULT_PDU_SIZE 18 #define COAP_DEFAULT_PDU_SIZE 64 19 #endif /* COAP_DEFAULT_PDU_SIZE */ 20 #ifndef COAP_RXBUFFER_SIZE 21 #define COAP_RXBUFFER_SIZE 64 22 #endif /* COAP_RXBUFFER_SIZE */ 23 24 /** Number of resources that can be handled by a CoAP server in addition to 25 * @c /.well-known/core */ 26 #ifndef COAP_MAX_RESOURCES 27 #define COAP_MAX_RESOURCES 3 28 #endif /* COAP_MAX_RESOURCES */ 29 30 /** Number of attributes that can be handled (should be at least 31 * @c 2 * COAP_MAX_RESOURCES. to carry the content type and the 32 * resource type. */ 33 #ifndef COAP_MAX_ATTRIBUTES 34 #define COAP_MAX_ATTRIBUTES 4 35 #endif /* COAP_MAX_ATTRIBUTES */ 36 37 /** 38 * Number of PDUs that can be stored simultaneously. This number 39 * includes both, the PDUs stored for retransmission as well as the 40 * PDUs received. Beware that choosing a too small value can lead to 41 * many retransmissions to be dealt with. 42 */ 43 #ifndef COAP_PDU_MAXCNT 44 #define COAP_PDU_MAXCNT 4 45 #endif /* COAP_PDU_MAXCNT */ 46 47 /** 48 * Maximum number of sessions. 49 */ 50 #ifndef COAP_MAX_SESSIONS 51 #define COAP_MAX_SESSIONS 2 52 #endif /* COAP_MAX_SESSIONS */ 53 54 /** 55 * Maximum number of subscriptions. Every additional subscriber costs 56 * 36 B. 57 */ 58 #ifndef COAP_MAX_SUBSCRIBERS 59 #define COAP_MAX_SUBSCRIBERS 3 60 #endif /* COAP_MAX_SUBSCRIBERS */ 61 62 /** 63 * Number of notifications that may be sent non-confirmable before a 64 * confirmable message is sent to detect if observers are alive. The 65 * maximum allowed value here is @c 15. 66 */ 67 #ifndef COAP_OBS_MAX_NON 68 #define COAP_OBS_MAX_NON 5 69 #endif /* COAP_OBS_MAX_NON */ 70 71 /** 72 * Number of confirmable notifications that may fail (i.e. time out 73 * without being ACKed) before an observer is removed. The maximum 74 * value for COAP_OBS_MAX_FAIL is @c 3. 75 */ 76 #ifndef COAP_OBS_MAX_FAIL 77 #define COAP_OBS_MAX_FAIL 3 78 #endif /* COAP_OBS_MAX_FAIL */ 79 80 #ifndef DEBUG 81 # define DEBUG DEBUG_PRINT 82 #endif 83 84 #define HAVE_STRNLEN 1 85 #define HAVE_SNPRINTF 1 86 #define HAVE_STRINGS_H 1 87 88 /* there is no file-oriented output */ 89 #define COAP_DEBUG_FD NULL 90 #define COAP_ERR_FD NULL 91 92 #include "contiki-conf.h" 93 94 #if (defined(PLATFORM) && PLATFORM == PLATFORM_MC1322X) || defined(CONTIKI_TARGET_ECONOTAG) 95 /* Redbee econotags get a special treatment here: endianness is set 96 * explicitly, and 97 */ 98 99 #define BYTE_ORDER UIP_LITTLE_ENDIAN 100 101 #define HAVE_ASSERT_H 102 #define HAVE_UNISTD_H 103 #define HAVE_SYS_TYPES_H 104 #define HAVE_LIMITS_H 105 #endif /* PLATFORM_MC1322X || CONTIKI_TARGET_ECONOTAG */ 106 107 #if defined(TMOTE_SKY) || defined(CONTIKI_TARGET_SKY) || defined(CONTIKI_TARGET_WISMOTE) 108 /* Need to set the byte order for TMote Sky explicitely */ 109 110 #define BYTE_ORDER UIP_LITTLE_ENDIAN 111 #undef COAP_DEFAULT_PDU_SIZE 112 #undef COAP_RXBUFFER_SIZE 113 #define COAP_DEFAULT_PDU_SIZE 100 114 #define COAP_RXBUFFER_SIZE 100 115 116 #define COAP_MAX_BLOCK_SZX 2 117 118 typedef int ssize_t; 119 typedef void FILE; 120 121 #define HAVE_LIMITS_H 1 122 #undef HAVE_ASSERT_H 123 #define HAVE_VPRINTF 1 124 #endif /* defined(TMOTE_SKY) */ 125 126 #ifdef CONTIKI_TARGET_MINIMAL_NET 127 #undef COAP_DEFAULT_PDU_SIZE 128 #undef COAP_RXBUFFER_SIZE 129 #define COAP_DEFAULT_PDU_SIZE 1152 130 #define COAP_RXBUFFER_SIZE 1472 131 #define HAVE_ASSERT_H 1 132 #define HAVE_VPRINTF 1 133 #define HAVE_SYS_TYPES_H 1 134 #endif /* CONTIKI_TARGET_MINIMAL_NET */ 135 136 #ifdef CONTIKI_TARGET_CC2538DK 137 #define BYTE_ORDER UIP_LITTLE_ENDIAN 138 #undef COAP_DEFAULT_PDU_SIZE 139 #undef COAP_RXBUFFER_SIZE 140 #define COAP_DEFAULT_PDU_SIZE 100 141 #define COAP_RXBUFFER_SIZE 100 142 143 #undef COAP_MAX_BLOCK_SZX 144 #define COAP_MAX_BLOCK_SZX 2 145 146 #define HAVE_LIMITS_H 1 147 #endif /* CONTIKI_TARGET_CC2538DK */ 148 149 #ifndef BYTE_ORDER 150 # ifdef UIP_CONF_BYTE_ORDER 151 # define BYTE_ORDER UIP_CONF_BYTE_ORDER 152 # else 153 # error "UIP_CONF_BYTE_ORDER not defined" 154 # endif /* UIP_CONF_BYTE_ORDER */ 155 #endif /* BYTE_ORDER */ 156 157 /* Define assert() as empty directive unless HAVE_ASSERT_H is given. */ 158 #ifndef HAVE_ASSERT_H 159 # define assert(x) 160 #endif 161 162 #define ntohs uip_ntohs 163 164 #include <stdio.h> 165 #define coap_log(fd, ...) printf(__VA_ARGS__) 166 167 #endif /* COAP_CONFIG_H_ */ 168 169