NSDL C library
Dependents: NSDL_HelloWorld_WiFi UbloxModemNanoServiceClient IOT-NSDL_HelloWorld LWM2M_NanoService_Ethernet ... more
Fork of nsdl_lib by
Note that use of this software requires acceptance of the Sensinode EULA: http://mbed.org/teams/Sensinode/code/nsdl_lib/wiki/EULA
Diff: sn_coap_protocol.h
- Revision:
- 5:da1db64e7fb9
- Parent:
- 0:58c4f13c4b9a
- Child:
- 6:1caf76131c9a
diff -r 58c4f13c4b9a -r da1db64e7fb9 sn_coap_protocol.h --- a/sn_coap_protocol.h Wed Oct 09 09:20:29 2013 +0000 +++ b/sn_coap_protocol.h Mon Oct 14 11:00:30 2013 +0000 @@ -15,76 +15,67 @@ #ifndef SN_COAP_PROTOCOL_H_ #define SN_COAP_PROTOCOL_H_ -/* * * * * * * * * * * */ -/* * * * DEFINES * * * */ -/* * * * * * * * * * * */ - -/* Maximum time in seconds of messages to be stored for Acknowledging. This time tells */ -/* how long time User of CoAP C-library have time to send Piggy-backed acknowledgement */ -/* message to Request sender. */ -#define SN_COAP_ACK_INFO_MAX_TIME_MSGS_STORED 20 -#define SN_COAP_ACK_INFO_MAX_COUNT_MESSAGES_SAVED 10 - -/* * For Message resending * */ - -/* Init value for maximum count of ongoing active resending messages */ -/* This value depends on available memory: If there is restricted count of memory, use little value e.g. 1 */ -/* Setting of this value to 0 will disable re-sending and also reduce use of ROM memory */ -#define SN_COAP_RESENDING_MAX_COUNT 0 -/* Default value for re-sending buffer size */ -#define SN_COAP_RESENDING_BUFFER_MAX_SIZE 0 - -/* These parameters sets maximum values application can set with API */ -/* Maximum allowed count of re-sending */ -#define SN_COAP_MAX_ALLOWED_RESENDING_COUNT 6 -/* Maximum allowed number of saved re-sending messages */ -#define SN_COAP_MAX_ALLOWED_RESENDING_BUFF_SIZE 6 - -/* * For Message duplication detecting * */ - -/* Init value for the maximum count of messages to be stored for duplication detection */ -/* Setting of this value to 0 will disable duplication check, also reduce use of ROM memory */ -#define SN_COAP_DUPLICATION_MAX_MSGS_COUNT 0 -/* Maximum allowed number of saved messages for duplicate searching */ -#define SN_COAP_MAX_ALLOWED_DUPLICATION_MESSAGE_COUNT 6 - -/* Maximum time in seconds of messages to be stored for duplication detection */ -#define SN_COAP_DUPLICATION_MAX_TIME_MSGS_STORED 60 /* RESPONSE_TIMEOUT * RESPONSE_RANDOM_FACTOR * (2 ^ MAX_RETRANSMIT - 1) + the expected maximum round trip time */ - -/* * For Message blockwising * */ - -/* Init value for the maximum payload size to be sent and received at one blockwise message */ -/* Setting of this value to 0 will disable this feature, and also reduce use of ROM memory */ -/* Note: Current Coap implementation supports Blockwise transfers specification version draft-ietf-core-block-03 */ -/* Note: This define is common for both received and sent Blockwise messages */ -#ifndef SN_COAP_BLOCKWISE_MAX_PAYLOAD_SIZE -#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 */ -#endif - - -/* Maximum time in seconds of data (messages and payload) to be stored for blockwising */ -#ifndef SN_COAP_BLOCKWISE_MAX_TIME_DATA_STORED -#define SN_COAP_BLOCKWISE_MAX_TIME_DATA_STORED 10 -#endif - /* * * * * * * * * * * * * * * * * * * * * * */ /* * * * EXTERNAL FUNCTION PROTOTYPES * * * */ /* * * * * * * * * * * * * * * * * * * * * * */ +/** + * \brief This function sets the memory allocation and deallocation functions and used TX callback function pointer the library will use, and must be called first. + */ extern int8_t sn_coap_protocol_init(void* (*used_malloc_func_ptr)(uint16_t), void (*used_free_func_ptr)(void*), uint8_t (*used_tx_callback_ptr)(sn_nsdl_capab_e , uint8_t *, uint16_t, sn_nsdl_addr_s *)); + +/** + * \brief Frees all allocated memory in libCoap protocol part. + */ extern int8_t sn_coap_protocol_destroy(void); + +/** + * \brief Use to build an outgoing message buffer from a CoAP header structure. + */ 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); + +/** + * \brief Use to parse an incoming message buffer to a CoAP header structure. + */ 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); + +/** + * \brief Called periodically to allow the protocol to update retransmission timers and destroy unneeded data. + */ extern int8_t sn_coap_protocol_exec(uint32_t current_time); + +/** + * \brief If block transfer is enabled, this function changes the block size. + */ extern int8_t sn_coap_protocol_set_block_size(uint16_t block_size); + +/** + * \brief If dublicate message detection is enabled, this function changes buffer size. + */ extern int8_t sn_coap_protocol_set_duplicate_buffer_size(uint8_t message_count); + +/** + * \brief If re-transmissions are enabled, this function changes resending count and buffer size. + */ extern int8_t sn_coap_protocol_set_retransmission(uint8_t resending_count, uint8_t buffer_size); -/* NSP registration functions */ +/* NSP manual registration functions */ + +/** + * \brief Create an NSP registration message. + */ extern int8_t sn_coap_register(sn_coap_hdr_s *coap_hdr_ptr, registration_info_t *endpoint_info_ptr); + +/** + * \brief Create an NSP update message. + */ extern int8_t sn_coap_register_update(sn_coap_hdr_s *coap_hdr_ptr, uint8_t *location, uint8_t length); + +/** + * \brief Create an NSP de-registration message. + */ extern int8_t sn_coap_deregister(sn_coap_hdr_s *coap_hdr_ptr, uint8_t *location, uint8_t length); #endif /* SN_COAP_PROTOCOL_H_ */