hello

Dependents:   nespresso_demo nespresso_endpoint EnvoyNespressoEndpointColorDetectorV2

Fork of nsdl by Robert Taylor

Committer:
GeofferyOmlette
Date:
Wed Jun 04 15:38:26 2014 +0000
Revision:
0:f6e4e1bbb3fe
hello

Who changed what in which revision?

UserRevisionLine numberNew contents of line
GeofferyOmlette 0:f6e4e1bbb3fe 1 /**
GeofferyOmlette 0:f6e4e1bbb3fe 2 * \file sn_coap_protocol_internal.h
GeofferyOmlette 0:f6e4e1bbb3fe 3 *
GeofferyOmlette 0:f6e4e1bbb3fe 4 * \brief Header file for CoAP Protocol part
GeofferyOmlette 0:f6e4e1bbb3fe 5 *
GeofferyOmlette 0:f6e4e1bbb3fe 6 * Created on: Jun 30, 2011
GeofferyOmlette 0:f6e4e1bbb3fe 7 * Author: tero
GeofferyOmlette 0:f6e4e1bbb3fe 8 *
GeofferyOmlette 0:f6e4e1bbb3fe 9 * \note Supports draft-ietf-core-coap-18
GeofferyOmlette 0:f6e4e1bbb3fe 10 */
GeofferyOmlette 0:f6e4e1bbb3fe 11
GeofferyOmlette 0:f6e4e1bbb3fe 12 #ifdef __cplusplus
GeofferyOmlette 0:f6e4e1bbb3fe 13 extern "C" {
GeofferyOmlette 0:f6e4e1bbb3fe 14 #endif
GeofferyOmlette 0:f6e4e1bbb3fe 15
GeofferyOmlette 0:f6e4e1bbb3fe 16 #ifndef SN_COAP_PROTOCOL_INTERNAL_H_
GeofferyOmlette 0:f6e4e1bbb3fe 17 #define SN_COAP_PROTOCOL_INTERNAL_H_
GeofferyOmlette 0:f6e4e1bbb3fe 18
GeofferyOmlette 0:f6e4e1bbb3fe 19 /* * * * * * * * * * * */
GeofferyOmlette 0:f6e4e1bbb3fe 20 /* * * * DEFINES * * * */
GeofferyOmlette 0:f6e4e1bbb3fe 21 /* * * * * * * * * * * */
GeofferyOmlette 0:f6e4e1bbb3fe 22
GeofferyOmlette 0:f6e4e1bbb3fe 23 /* Maximum time in seconds of messages to be stored for Acknowledging. This time tells */
GeofferyOmlette 0:f6e4e1bbb3fe 24 /* how long time User of CoAP C-library have time to send Piggy-backed acknowledgement */
GeofferyOmlette 0:f6e4e1bbb3fe 25 /* message to Request sender. */
GeofferyOmlette 0:f6e4e1bbb3fe 26 #define SN_COAP_ACK_INFO_MAX_TIME_MSGS_STORED 20
GeofferyOmlette 0:f6e4e1bbb3fe 27 #define SN_COAP_ACK_INFO_MAX_COUNT_MESSAGES_SAVED 10
GeofferyOmlette 0:f6e4e1bbb3fe 28
GeofferyOmlette 0:f6e4e1bbb3fe 29 /* * For Message resending * */
GeofferyOmlette 0:f6e4e1bbb3fe 30 #define ENABLE_RESENDINGS 0 /**< Enable / Disable resending from library in building */
GeofferyOmlette 0:f6e4e1bbb3fe 31
GeofferyOmlette 0:f6e4e1bbb3fe 32 #define SN_COAP_RESENDING_MAX_COUNT 3 /**< Default number of re-sendings */
GeofferyOmlette 0:f6e4e1bbb3fe 33 #define SN_COAP_RESENDING_QUEUE_SIZE_MSGS 2 /**< Default re-sending queue size - defines how many messages can be stored. Setting this to 0 disables feature */
GeofferyOmlette 0:f6e4e1bbb3fe 34 #define SN_COAP_RESENDING_QUEUE_SIZE_BYTES 0 /**< Default re-sending queue size - defines size of the re-sending buffer. Setting this to 0 disables feature */
GeofferyOmlette 0:f6e4e1bbb3fe 35 #define DEFAULT_RESPONSE_TIMEOUT 10 /**< Default re-sending timeout as seconds */
GeofferyOmlette 0:f6e4e1bbb3fe 36
GeofferyOmlette 0:f6e4e1bbb3fe 37 /* These parameters sets maximum values application can set with API */
GeofferyOmlette 0:f6e4e1bbb3fe 38 #define SN_COAP_MAX_ALLOWED_RESENDING_COUNT 6 /**< Maximum allowed count of re-sending */
GeofferyOmlette 0:f6e4e1bbb3fe 39 #define SN_COAP_MAX_ALLOWED_RESENDING_BUFF_SIZE_MSGS 6 /**< Maximum allowed number of saved re-sending messages */
GeofferyOmlette 0:f6e4e1bbb3fe 40 #define SN_COAP_MAX_ALLOWED_RESENDING_BUFF_SIZE_BYTES 512 /**< Maximum allowed size of re-sending buffer */
GeofferyOmlette 0:f6e4e1bbb3fe 41 #define SN_COAP_MAX_ALLOWED_RESPONSE_TIMEOUT 40 /**< Maximum allowed re-sending timeout */
GeofferyOmlette 0:f6e4e1bbb3fe 42
GeofferyOmlette 0:f6e4e1bbb3fe 43 #define RESPONSE_RANDOM_FACTOR 1 /**< Resending random factor, value is specified in IETF CoAP specification */
GeofferyOmlette 0:f6e4e1bbb3fe 44
GeofferyOmlette 0:f6e4e1bbb3fe 45 /* * For Message duplication detecting * */
GeofferyOmlette 0:f6e4e1bbb3fe 46
GeofferyOmlette 0:f6e4e1bbb3fe 47 /* Init value for the maximum count of messages to be stored for duplication detection */
GeofferyOmlette 0:f6e4e1bbb3fe 48 /* Setting of this value to 0 will disable duplication check, also reduce use of ROM memory */
GeofferyOmlette 0:f6e4e1bbb3fe 49 #define SN_COAP_DUPLICATION_MAX_MSGS_COUNT 0
GeofferyOmlette 0:f6e4e1bbb3fe 50 /* Maximum allowed number of saved messages for duplicate searching */
GeofferyOmlette 0:f6e4e1bbb3fe 51 #define SN_COAP_MAX_ALLOWED_DUPLICATION_MESSAGE_COUNT 6
GeofferyOmlette 0:f6e4e1bbb3fe 52
GeofferyOmlette 0:f6e4e1bbb3fe 53 /* Maximum time in seconds of messages to be stored for duplication detection */
GeofferyOmlette 0:f6e4e1bbb3fe 54 #define SN_COAP_DUPLICATION_MAX_TIME_MSGS_STORED 60 /* RESPONSE_TIMEOUT * RESPONSE_RANDOM_FACTOR * (2 ^ MAX_RETRANSMIT - 1) + the expected maximum round trip time */
GeofferyOmlette 0:f6e4e1bbb3fe 55
GeofferyOmlette 0:f6e4e1bbb3fe 56 /* * For Message blockwising * */
GeofferyOmlette 0:f6e4e1bbb3fe 57
GeofferyOmlette 0:f6e4e1bbb3fe 58 /* Init value for the maximum payload size to be sent and received at one blockwise message */
GeofferyOmlette 0:f6e4e1bbb3fe 59 /* Setting of this value to 0 will disable this feature, and also reduce use of ROM memory */
GeofferyOmlette 0:f6e4e1bbb3fe 60 /* Note: Current Coap implementation supports Blockwise transfers specification version draft-ietf-core-block-03 */
GeofferyOmlette 0:f6e4e1bbb3fe 61 /* Note: This define is common for both received and sent Blockwise messages */
GeofferyOmlette 0:f6e4e1bbb3fe 62 #ifndef SN_COAP_BLOCKWISE_MAX_PAYLOAD_SIZE
GeofferyOmlette 0:f6e4e1bbb3fe 63 #define SN_COAP_BLOCKWISE_MAX_PAYLOAD_SIZE 0 /**< Must be 2^x and x is at least 4. Suitable values: 0, 16, 32, 64, 128, 256, 512 and 1024 */
GeofferyOmlette 0:f6e4e1bbb3fe 64 #endif
GeofferyOmlette 0:f6e4e1bbb3fe 65
GeofferyOmlette 0:f6e4e1bbb3fe 66 #ifndef SN_COAP_BLOCKWISE_MAX_TIME_DATA_STORED
GeofferyOmlette 0:f6e4e1bbb3fe 67 #define SN_COAP_BLOCKWISE_MAX_TIME_DATA_STORED 10 /**< Maximum time in seconds of data (messages and payload) to be stored for blockwising */
GeofferyOmlette 0:f6e4e1bbb3fe 68 #endif
GeofferyOmlette 0:f6e4e1bbb3fe 69
GeofferyOmlette 0:f6e4e1bbb3fe 70
GeofferyOmlette 0:f6e4e1bbb3fe 71 /* * * * * * * * * * * * * * */
GeofferyOmlette 0:f6e4e1bbb3fe 72 /* * * * ENUMERATIONS * * * */
GeofferyOmlette 0:f6e4e1bbb3fe 73 /* * * * * * * * * * * * * * */
GeofferyOmlette 0:f6e4e1bbb3fe 74
GeofferyOmlette 0:f6e4e1bbb3fe 75 /* * * * * * * * * * * * * */
GeofferyOmlette 0:f6e4e1bbb3fe 76 /* * * * STRUCTURES * * * */
GeofferyOmlette 0:f6e4e1bbb3fe 77 /* * * * * * * * * * * * * */
GeofferyOmlette 0:f6e4e1bbb3fe 78
GeofferyOmlette 0:f6e4e1bbb3fe 79
GeofferyOmlette 0:f6e4e1bbb3fe 80 /* Structure which is stored to Linked list for message sending purposes */
GeofferyOmlette 0:f6e4e1bbb3fe 81 typedef struct coap_send_msg_
GeofferyOmlette 0:f6e4e1bbb3fe 82 {
GeofferyOmlette 0:f6e4e1bbb3fe 83 uint8_t resending_counter; /* Tells how many times message is still tried to resend */
GeofferyOmlette 0:f6e4e1bbb3fe 84 uint32_t resending_time; /* Tells next resending time */
GeofferyOmlette 0:f6e4e1bbb3fe 85
GeofferyOmlette 0:f6e4e1bbb3fe 86 sn_nsdl_transmit_s *send_msg_ptr;
GeofferyOmlette 0:f6e4e1bbb3fe 87 } coap_send_msg_s;
GeofferyOmlette 0:f6e4e1bbb3fe 88
GeofferyOmlette 0:f6e4e1bbb3fe 89 /* Structure which is stored to Linked list for message acknowledgement purposes */
GeofferyOmlette 0:f6e4e1bbb3fe 90 typedef struct coap_ack_info_
GeofferyOmlette 0:f6e4e1bbb3fe 91 {
GeofferyOmlette 0:f6e4e1bbb3fe 92 uint32_t timestamp; /* Tells when duplication information is stored to Linked list */
GeofferyOmlette 0:f6e4e1bbb3fe 93
GeofferyOmlette 0:f6e4e1bbb3fe 94 uint8_t addr_len;
GeofferyOmlette 0:f6e4e1bbb3fe 95 uint8_t *addr_ptr;
GeofferyOmlette 0:f6e4e1bbb3fe 96 uint16_t port;
GeofferyOmlette 0:f6e4e1bbb3fe 97
GeofferyOmlette 0:f6e4e1bbb3fe 98 uint16_t msg_id;
GeofferyOmlette 0:f6e4e1bbb3fe 99
GeofferyOmlette 0:f6e4e1bbb3fe 100 uint8_t token_len;
GeofferyOmlette 0:f6e4e1bbb3fe 101 uint8_t *token_ptr;
GeofferyOmlette 0:f6e4e1bbb3fe 102 } coap_ack_info_s;
GeofferyOmlette 0:f6e4e1bbb3fe 103
GeofferyOmlette 0:f6e4e1bbb3fe 104 /* Structure which is stored to Linked list for message duplication detection purposes */
GeofferyOmlette 0:f6e4e1bbb3fe 105 typedef struct coap_duplication_info_
GeofferyOmlette 0:f6e4e1bbb3fe 106 {
GeofferyOmlette 0:f6e4e1bbb3fe 107 uint32_t timestamp; /* Tells when duplication information is stored to Linked list */
GeofferyOmlette 0:f6e4e1bbb3fe 108
GeofferyOmlette 0:f6e4e1bbb3fe 109 uint8_t addr_len;
GeofferyOmlette 0:f6e4e1bbb3fe 110 uint8_t *addr_ptr;
GeofferyOmlette 0:f6e4e1bbb3fe 111 uint16_t port;
GeofferyOmlette 0:f6e4e1bbb3fe 112
GeofferyOmlette 0:f6e4e1bbb3fe 113 uint16_t msg_id;
GeofferyOmlette 0:f6e4e1bbb3fe 114 } coap_duplication_info_s;
GeofferyOmlette 0:f6e4e1bbb3fe 115
GeofferyOmlette 0:f6e4e1bbb3fe 116 /* Structure which is stored to Linked list for blockwise messages sending purposes */
GeofferyOmlette 0:f6e4e1bbb3fe 117 typedef struct coap_blockwise_msg_
GeofferyOmlette 0:f6e4e1bbb3fe 118 {
GeofferyOmlette 0:f6e4e1bbb3fe 119 uint32_t timestamp; /* Tells when Blockwise message is stored to Linked list */
GeofferyOmlette 0:f6e4e1bbb3fe 120
GeofferyOmlette 0:f6e4e1bbb3fe 121 sn_coap_hdr_s *coap_msg_ptr;
GeofferyOmlette 0:f6e4e1bbb3fe 122 } coap_blockwise_msg_s;
GeofferyOmlette 0:f6e4e1bbb3fe 123
GeofferyOmlette 0:f6e4e1bbb3fe 124 /* Structure which is stored to Linked list for blockwise messages receiving purposes */
GeofferyOmlette 0:f6e4e1bbb3fe 125 typedef struct coap_blockwise_payload_
GeofferyOmlette 0:f6e4e1bbb3fe 126 {
GeofferyOmlette 0:f6e4e1bbb3fe 127 uint32_t timestamp; /* Tells when Payload is stored to Linked list */
GeofferyOmlette 0:f6e4e1bbb3fe 128
GeofferyOmlette 0:f6e4e1bbb3fe 129 uint8_t addr_len;
GeofferyOmlette 0:f6e4e1bbb3fe 130 uint8_t *addr_ptr;
GeofferyOmlette 0:f6e4e1bbb3fe 131 uint16_t port;
GeofferyOmlette 0:f6e4e1bbb3fe 132
GeofferyOmlette 0:f6e4e1bbb3fe 133 uint16_t payload_len;
GeofferyOmlette 0:f6e4e1bbb3fe 134 uint8_t *payload_ptr;
GeofferyOmlette 0:f6e4e1bbb3fe 135 } coap_blockwise_payload_s;
GeofferyOmlette 0:f6e4e1bbb3fe 136
GeofferyOmlette 0:f6e4e1bbb3fe 137 /**
GeofferyOmlette 0:f6e4e1bbb3fe 138 * \brief Releases any memory allocated in sn_nsdl_transmit_s
GeofferyOmlette 0:f6e4e1bbb3fe 139 */
GeofferyOmlette 0:f6e4e1bbb3fe 140 extern void sn_coap_builder_release_allocated_send_msg_mem(sn_nsdl_transmit_s *freed_send_msg_ptr);
GeofferyOmlette 0:f6e4e1bbb3fe 141
GeofferyOmlette 0:f6e4e1bbb3fe 142 #endif /* SN_COAP_PROTOCOL_INTERNAL_H_ */
GeofferyOmlette 0:f6e4e1bbb3fe 143
GeofferyOmlette 0:f6e4e1bbb3fe 144 #ifdef __cplusplus
GeofferyOmlette 0:f6e4e1bbb3fe 145 }
GeofferyOmlette 0:f6e4e1bbb3fe 146 #endif