NSDL C library

Dependents:   NSDL_HelloWorld_WiFi UbloxModemNanoServiceClient IOT-NSDL_HelloWorld LWM2M_NanoService_Ethernet ... more

Fork of nsdl_lib by Tero Heinonen

Note that use of this software requires acceptance of the Sensinode EULA: http://mbed.org/teams/Sensinode/code/nsdl_lib/wiki/EULA

Committer:
terohoo
Date:
Wed Oct 09 09:20:29 2013 +0000
Revision:
0:58c4f13c4b9a
Child:
1:01d723824294
Child:
5:da1db64e7fb9
Adding nsdl_lib

Who changed what in which revision?

UserRevisionLine numberNew contents of line
terohoo 0:58c4f13c4b9a 1 /**
terohoo 0:58c4f13c4b9a 2 * \file sn_coap_protocol.h
terohoo 0:58c4f13c4b9a 3 *
terohoo 0:58c4f13c4b9a 4 * \brief CoAP C-library User protocol interface header file
terohoo 0:58c4f13c4b9a 5 *
terohoo 0:58c4f13c4b9a 6 * Created on: Jun 30, 2011
terohoo 0:58c4f13c4b9a 7 * Author: tero
terohoo 0:58c4f13c4b9a 8 *
terohoo 0:58c4f13c4b9a 9 */
terohoo 0:58c4f13c4b9a 10
terohoo 0:58c4f13c4b9a 11 #ifdef __cplusplus
terohoo 0:58c4f13c4b9a 12 extern "C" {
terohoo 0:58c4f13c4b9a 13 #endif
terohoo 0:58c4f13c4b9a 14
terohoo 0:58c4f13c4b9a 15 #ifndef SN_COAP_PROTOCOL_H_
terohoo 0:58c4f13c4b9a 16 #define SN_COAP_PROTOCOL_H_
terohoo 0:58c4f13c4b9a 17
terohoo 0:58c4f13c4b9a 18 /* * * * * * * * * * * */
terohoo 0:58c4f13c4b9a 19 /* * * * DEFINES * * * */
terohoo 0:58c4f13c4b9a 20 /* * * * * * * * * * * */
terohoo 0:58c4f13c4b9a 21
terohoo 0:58c4f13c4b9a 22 /* Maximum time in seconds of messages to be stored for Acknowledging. This time tells */
terohoo 0:58c4f13c4b9a 23 /* how long time User of CoAP C-library have time to send Piggy-backed acknowledgement */
terohoo 0:58c4f13c4b9a 24 /* message to Request sender. */
terohoo 0:58c4f13c4b9a 25 #define SN_COAP_ACK_INFO_MAX_TIME_MSGS_STORED 20
terohoo 0:58c4f13c4b9a 26 #define SN_COAP_ACK_INFO_MAX_COUNT_MESSAGES_SAVED 10
terohoo 0:58c4f13c4b9a 27
terohoo 0:58c4f13c4b9a 28 /* * For Message resending * */
terohoo 0:58c4f13c4b9a 29
terohoo 0:58c4f13c4b9a 30 /* Init value for maximum count of ongoing active resending messages */
terohoo 0:58c4f13c4b9a 31 /* This value depends on available memory: If there is restricted count of memory, use little value e.g. 1 */
terohoo 0:58c4f13c4b9a 32 /* Setting of this value to 0 will disable re-sending and also reduce use of ROM memory */
terohoo 0:58c4f13c4b9a 33 #define SN_COAP_RESENDING_MAX_COUNT 0
terohoo 0:58c4f13c4b9a 34 /* Default value for re-sending buffer size */
terohoo 0:58c4f13c4b9a 35 #define SN_COAP_RESENDING_BUFFER_MAX_SIZE 0
terohoo 0:58c4f13c4b9a 36
terohoo 0:58c4f13c4b9a 37 /* These parameters sets maximum values application can set with API */
terohoo 0:58c4f13c4b9a 38 /* Maximum allowed count of re-sending */
terohoo 0:58c4f13c4b9a 39 #define SN_COAP_MAX_ALLOWED_RESENDING_COUNT 6
terohoo 0:58c4f13c4b9a 40 /* Maximum allowed number of saved re-sending messages */
terohoo 0:58c4f13c4b9a 41 #define SN_COAP_MAX_ALLOWED_RESENDING_BUFF_SIZE 6
terohoo 0:58c4f13c4b9a 42
terohoo 0:58c4f13c4b9a 43 /* * For Message duplication detecting * */
terohoo 0:58c4f13c4b9a 44
terohoo 0:58c4f13c4b9a 45 /* Init value for the maximum count of messages to be stored for duplication detection */
terohoo 0:58c4f13c4b9a 46 /* Setting of this value to 0 will disable duplication check, also reduce use of ROM memory */
terohoo 0:58c4f13c4b9a 47 #define SN_COAP_DUPLICATION_MAX_MSGS_COUNT 0
terohoo 0:58c4f13c4b9a 48 /* Maximum allowed number of saved messages for duplicate searching */
terohoo 0:58c4f13c4b9a 49 #define SN_COAP_MAX_ALLOWED_DUPLICATION_MESSAGE_COUNT 6
terohoo 0:58c4f13c4b9a 50
terohoo 0:58c4f13c4b9a 51 /* Maximum time in seconds of messages to be stored for duplication detection */
terohoo 0:58c4f13c4b9a 52 #define SN_COAP_DUPLICATION_MAX_TIME_MSGS_STORED 60 /* RESPONSE_TIMEOUT * RESPONSE_RANDOM_FACTOR * (2 ^ MAX_RETRANSMIT - 1) + the expected maximum round trip time */
terohoo 0:58c4f13c4b9a 53
terohoo 0:58c4f13c4b9a 54 /* * For Message blockwising * */
terohoo 0:58c4f13c4b9a 55
terohoo 0:58c4f13c4b9a 56 /* Init value for the maximum payload size to be sent and received at one blockwise message */
terohoo 0:58c4f13c4b9a 57 /* Setting of this value to 0 will disable this feature, and also reduce use of ROM memory */
terohoo 0:58c4f13c4b9a 58 /* Note: Current Coap implementation supports Blockwise transfers specification version draft-ietf-core-block-03 */
terohoo 0:58c4f13c4b9a 59 /* Note: This define is common for both received and sent Blockwise messages */
terohoo 0:58c4f13c4b9a 60 #ifndef SN_COAP_BLOCKWISE_MAX_PAYLOAD_SIZE
terohoo 0:58c4f13c4b9a 61 #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 */
terohoo 0:58c4f13c4b9a 62 #endif
terohoo 0:58c4f13c4b9a 63
terohoo 0:58c4f13c4b9a 64
terohoo 0:58c4f13c4b9a 65 /* Maximum time in seconds of data (messages and payload) to be stored for blockwising */
terohoo 0:58c4f13c4b9a 66 #ifndef SN_COAP_BLOCKWISE_MAX_TIME_DATA_STORED
terohoo 0:58c4f13c4b9a 67 #define SN_COAP_BLOCKWISE_MAX_TIME_DATA_STORED 10
terohoo 0:58c4f13c4b9a 68 #endif
terohoo 0:58c4f13c4b9a 69
terohoo 0:58c4f13c4b9a 70
terohoo 0:58c4f13c4b9a 71 /* * * * * * * * * * * * * * * * * * * * * * */
terohoo 0:58c4f13c4b9a 72 /* * * * EXTERNAL FUNCTION PROTOTYPES * * * */
terohoo 0:58c4f13c4b9a 73 /* * * * * * * * * * * * * * * * * * * * * * */
terohoo 0:58c4f13c4b9a 74
terohoo 0:58c4f13c4b9a 75 extern int8_t sn_coap_protocol_init(void* (*used_malloc_func_ptr)(uint16_t), void (*used_free_func_ptr)(void*),
terohoo 0:58c4f13c4b9a 76 uint8_t (*used_tx_callback_ptr)(sn_nsdl_capab_e , uint8_t *, uint16_t, sn_nsdl_addr_s *));
terohoo 0:58c4f13c4b9a 77 extern int8_t sn_coap_protocol_destroy(void);
terohoo 0:58c4f13c4b9a 78 extern int16_t sn_coap_protocol_build(sn_nsdl_addr_s *dst_addr_ptr, uint8_t *dst_packet_data_ptr, sn_coap_hdr_s *src_coap_msg_ptr);
terohoo 0:58c4f13c4b9a 79 extern sn_coap_hdr_s *sn_coap_protocol_parse(sn_nsdl_addr_s *src_addr_ptr, uint16_t packet_data_len, uint8_t *packet_data_ptr);
terohoo 0:58c4f13c4b9a 80 extern int8_t sn_coap_protocol_exec(uint32_t current_time);
terohoo 0:58c4f13c4b9a 81 extern int8_t sn_coap_protocol_set_block_size(uint16_t block_size);
terohoo 0:58c4f13c4b9a 82 extern int8_t sn_coap_protocol_set_duplicate_buffer_size(uint8_t message_count);
terohoo 0:58c4f13c4b9a 83 extern int8_t sn_coap_protocol_set_retransmission(uint8_t resending_count, uint8_t buffer_size);
terohoo 0:58c4f13c4b9a 84
terohoo 0:58c4f13c4b9a 85 /* NSP registration functions */
terohoo 0:58c4f13c4b9a 86 extern int8_t sn_coap_register(sn_coap_hdr_s *coap_hdr_ptr, registration_info_t *endpoint_info_ptr);
terohoo 0:58c4f13c4b9a 87 extern int8_t sn_coap_register_update(sn_coap_hdr_s *coap_hdr_ptr, uint8_t *location, uint8_t length);
terohoo 0:58c4f13c4b9a 88 extern int8_t sn_coap_deregister(sn_coap_hdr_s *coap_hdr_ptr, uint8_t *location, uint8_t length);
terohoo 0:58c4f13c4b9a 89
terohoo 0:58c4f13c4b9a 90 #endif /* SN_COAP_PROTOCOL_H_ */
terohoo 0:58c4f13c4b9a 91
terohoo 0:58c4f13c4b9a 92 #ifdef __cplusplus
terohoo 0:58c4f13c4b9a 93 }
terohoo 0:58c4f13c4b9a 94 #endif