version of nsdl to work with lwm2m, updated RD parameters and location option handling

Dependents:   ArchPro_LWM2M_LED_Client Weather_Station_LWM2M mbedEndpointNetwork

Fork of nanoservice_client_1_12 by Zach Shelby

Committer:
michaeljkoster
Date:
Mon Apr 13 22:13:40 2015 +0000
Revision:
10:b5ecd6660d71
Parent:
0:aafd54b05111
Add error return from sn_nsdl_register_endpoint() in sn_nsdl.c

Who changed what in which revision?

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