hello

Dependents:   nespresso_demo nespresso_endpoint EnvoyNespressoEndpointColorDetectorV2

Fork of nsdl by Robert Taylor

Committer:
bjblazkowicz
Date:
Mon Jul 14 12:33:59 2014 +0000
Revision:
2:05e4cd1a1542
Parent:
1:c9d755d3429a
WIP - registration is broken in this commit.

Who changed what in which revision?

UserRevisionLine numberNew contents of line
GeofferyOmlette 0:f6e4e1bbb3fe 1 /**
GeofferyOmlette 0:f6e4e1bbb3fe 2 * \file sn_nsdl_lib.h
GeofferyOmlette 0:f6e4e1bbb3fe 3 *
GeofferyOmlette 0:f6e4e1bbb3fe 4 * \brief NanoService Devices Library header file
GeofferyOmlette 0:f6e4e1bbb3fe 5 *
GeofferyOmlette 0:f6e4e1bbb3fe 6 * Created on: Aug 23, 2011
GeofferyOmlette 0:f6e4e1bbb3fe 7 * Author: tero
GeofferyOmlette 0:f6e4e1bbb3fe 8 *
GeofferyOmlette 0:f6e4e1bbb3fe 9 */
GeofferyOmlette 0:f6e4e1bbb3fe 10
GeofferyOmlette 0:f6e4e1bbb3fe 11 #ifdef __cplusplus
GeofferyOmlette 0:f6e4e1bbb3fe 12 extern "C" {
GeofferyOmlette 0:f6e4e1bbb3fe 13 #endif
GeofferyOmlette 0:f6e4e1bbb3fe 14
GeofferyOmlette 0:f6e4e1bbb3fe 15 #ifndef SN_NSDL_LIB_H_
GeofferyOmlette 0:f6e4e1bbb3fe 16 #define SN_NSDL_LIB_H_
GeofferyOmlette 0:f6e4e1bbb3fe 17
GeofferyOmlette 0:f6e4e1bbb3fe 18 #define SN_NSDL_CONST_MEMORY_ATTRIBUTE
GeofferyOmlette 0:f6e4e1bbb3fe 19
GeofferyOmlette 0:f6e4e1bbb3fe 20 #define SN_NSDL_ENDPOINT_NOT_REGISTERED 0
GeofferyOmlette 0:f6e4e1bbb3fe 21 #define SN_NSDL_ENDPOINT_IS_REGISTERED 1
GeofferyOmlette 0:f6e4e1bbb3fe 22
GeofferyOmlette 0:f6e4e1bbb3fe 23 /**
GeofferyOmlette 0:f6e4e1bbb3fe 24 * \brief Endpoint registration parameters
GeofferyOmlette 0:f6e4e1bbb3fe 25 */
GeofferyOmlette 0:f6e4e1bbb3fe 26 typedef struct sn_nsdl_ep_parameters_
GeofferyOmlette 0:f6e4e1bbb3fe 27 {
GeofferyOmlette 0:f6e4e1bbb3fe 28 uint8_t *endpoint_name_ptr; /**< Endpoint name */
GeofferyOmlette 0:f6e4e1bbb3fe 29 uint8_t endpoint_name_len;
GeofferyOmlette 0:f6e4e1bbb3fe 30
GeofferyOmlette 0:f6e4e1bbb3fe 31 uint8_t *domain_name_ptr; /**< Domain to register. If null, NSP uses default domain */
GeofferyOmlette 0:f6e4e1bbb3fe 32 uint8_t domain_name_len;
GeofferyOmlette 0:f6e4e1bbb3fe 33
GeofferyOmlette 0:f6e4e1bbb3fe 34 uint8_t *type_ptr; /**< Endpoint type */
GeofferyOmlette 0:f6e4e1bbb3fe 35 uint8_t type_len;
GeofferyOmlette 0:f6e4e1bbb3fe 36
GeofferyOmlette 0:f6e4e1bbb3fe 37 uint8_t *lifetime_ptr; /**< Endpoint lifetime in seconds. eg. "1200" = 1200 seconds */
GeofferyOmlette 0:f6e4e1bbb3fe 38 uint8_t lifetime_len;
bjblazkowicz 1:c9d755d3429a 39
bjblazkowicz 2:05e4cd1a1542 40 uint8_t *binding_type_ptr; /**< Binding type parameter */
bjblazkowicz 2:05e4cd1a1542 41 uint8_t binding_type_len;
bjblazkowicz 2:05e4cd1a1542 42
GeofferyOmlette 0:f6e4e1bbb3fe 43 } sn_nsdl_ep_parameters_s;
GeofferyOmlette 0:f6e4e1bbb3fe 44
GeofferyOmlette 0:f6e4e1bbb3fe 45 /**
GeofferyOmlette 0:f6e4e1bbb3fe 46 * \brief For internal use
GeofferyOmlette 0:f6e4e1bbb3fe 47 */
GeofferyOmlette 0:f6e4e1bbb3fe 48 typedef struct sn_nsdl_sent_messages_
GeofferyOmlette 0:f6e4e1bbb3fe 49 {
GeofferyOmlette 0:f6e4e1bbb3fe 50 uint16_t msg_id_number;
GeofferyOmlette 0:f6e4e1bbb3fe 51 uint8_t message_type;
GeofferyOmlette 0:f6e4e1bbb3fe 52 } sn_nsdl_sent_messages_s;
GeofferyOmlette 0:f6e4e1bbb3fe 53
GeofferyOmlette 0:f6e4e1bbb3fe 54 /**
GeofferyOmlette 0:f6e4e1bbb3fe 55 * \brief Function pointers used for memory allocation and freeing
GeofferyOmlette 0:f6e4e1bbb3fe 56 */
GeofferyOmlette 0:f6e4e1bbb3fe 57 typedef struct sn_nsdl_mem_
GeofferyOmlette 0:f6e4e1bbb3fe 58 {
GeofferyOmlette 0:f6e4e1bbb3fe 59 void *(*sn_nsdl_alloc)(uint16_t);
GeofferyOmlette 0:f6e4e1bbb3fe 60 void (*sn_nsdl_free)(void *);
GeofferyOmlette 0:f6e4e1bbb3fe 61 } sn_nsdl_mem_s;
GeofferyOmlette 0:f6e4e1bbb3fe 62
GeofferyOmlette 0:f6e4e1bbb3fe 63 /**
GeofferyOmlette 0:f6e4e1bbb3fe 64 * \brief Includes resource path
GeofferyOmlette 0:f6e4e1bbb3fe 65 */
GeofferyOmlette 0:f6e4e1bbb3fe 66 typedef struct sn_grs_resource_
GeofferyOmlette 0:f6e4e1bbb3fe 67 {
GeofferyOmlette 0:f6e4e1bbb3fe 68 uint8_t pathlen;
GeofferyOmlette 0:f6e4e1bbb3fe 69 uint8_t *path;
GeofferyOmlette 0:f6e4e1bbb3fe 70 } sn_grs_resource_s;
GeofferyOmlette 0:f6e4e1bbb3fe 71
GeofferyOmlette 0:f6e4e1bbb3fe 72 /**
GeofferyOmlette 0:f6e4e1bbb3fe 73 * \brief Table of created resources
GeofferyOmlette 0:f6e4e1bbb3fe 74 */
GeofferyOmlette 0:f6e4e1bbb3fe 75 typedef struct sn_grs_resource_list_
GeofferyOmlette 0:f6e4e1bbb3fe 76 {
GeofferyOmlette 0:f6e4e1bbb3fe 77 uint8_t res_count; /**< Number of resources */
GeofferyOmlette 0:f6e4e1bbb3fe 78 sn_grs_resource_s *res;
GeofferyOmlette 0:f6e4e1bbb3fe 79 } sn_grs_resource_list_s;
GeofferyOmlette 0:f6e4e1bbb3fe 80
GeofferyOmlette 0:f6e4e1bbb3fe 81 /**
GeofferyOmlette 0:f6e4e1bbb3fe 82 * \brief Resource access rights
GeofferyOmlette 0:f6e4e1bbb3fe 83 */
GeofferyOmlette 0:f6e4e1bbb3fe 84 typedef enum sn_grs_resource_acl_
GeofferyOmlette 0:f6e4e1bbb3fe 85 {
GeofferyOmlette 0:f6e4e1bbb3fe 86 SN_GRS_GET_ALLOWED = 0x01 ,
GeofferyOmlette 0:f6e4e1bbb3fe 87 SN_GRS_PUT_ALLOWED = 0x02,
GeofferyOmlette 0:f6e4e1bbb3fe 88 SN_GRS_POST_ALLOWED = 0x04,
GeofferyOmlette 0:f6e4e1bbb3fe 89 SN_GRS_DELETE_ALLOWED = 0x08
GeofferyOmlette 0:f6e4e1bbb3fe 90 } sn_grs_resource_acl_e;
GeofferyOmlette 0:f6e4e1bbb3fe 91
GeofferyOmlette 0:f6e4e1bbb3fe 92 /**
GeofferyOmlette 0:f6e4e1bbb3fe 93 * \brief Used protocol
GeofferyOmlette 0:f6e4e1bbb3fe 94 */
GeofferyOmlette 0:f6e4e1bbb3fe 95 typedef struct sn_proto_info_
GeofferyOmlette 0:f6e4e1bbb3fe 96 {
GeofferyOmlette 0:f6e4e1bbb3fe 97 sn_nsdl_capab_e proto; /**< Only COAP is supported */
GeofferyOmlette 0:f6e4e1bbb3fe 98 } sn_proto_info_s;
GeofferyOmlette 0:f6e4e1bbb3fe 99
GeofferyOmlette 0:f6e4e1bbb3fe 100 /**
GeofferyOmlette 0:f6e4e1bbb3fe 101 * \brief Defines the resource mode
GeofferyOmlette 0:f6e4e1bbb3fe 102 */
GeofferyOmlette 0:f6e4e1bbb3fe 103 typedef enum sn_nsdl_resource_mode_
GeofferyOmlette 0:f6e4e1bbb3fe 104 {
GeofferyOmlette 0:f6e4e1bbb3fe 105 SN_GRS_STATIC, /**< Static resources have some value that doesn't change */
GeofferyOmlette 0:f6e4e1bbb3fe 106 SN_GRS_DYNAMIC, /**< Dynamic resources are handled in application. Therefore one must give function callback pointer to them */
GeofferyOmlette 0:f6e4e1bbb3fe 107 SN_GRS_DIRECTORY /**< Directory resources are unused and unsupported */
GeofferyOmlette 0:f6e4e1bbb3fe 108 } sn_nsdl_resource_mode_e;
GeofferyOmlette 0:f6e4e1bbb3fe 109
GeofferyOmlette 0:f6e4e1bbb3fe 110 /**
GeofferyOmlette 0:f6e4e1bbb3fe 111 * \brief Resource registration parameters
GeofferyOmlette 0:f6e4e1bbb3fe 112 */
GeofferyOmlette 0:f6e4e1bbb3fe 113 typedef struct sn_nsdl_resource_parameters_
GeofferyOmlette 0:f6e4e1bbb3fe 114 {
GeofferyOmlette 0:f6e4e1bbb3fe 115 uint8_t *resource_type_ptr;
GeofferyOmlette 0:f6e4e1bbb3fe 116 uint16_t resource_type_len;
GeofferyOmlette 0:f6e4e1bbb3fe 117
GeofferyOmlette 0:f6e4e1bbb3fe 118 uint8_t *interface_description_ptr;
GeofferyOmlette 0:f6e4e1bbb3fe 119 uint16_t interface_description_len;
GeofferyOmlette 0:f6e4e1bbb3fe 120
GeofferyOmlette 0:f6e4e1bbb3fe 121 uint8_t coap_content_type;
GeofferyOmlette 0:f6e4e1bbb3fe 122
GeofferyOmlette 0:f6e4e1bbb3fe 123 uint8_t mime_content_type;
GeofferyOmlette 0:f6e4e1bbb3fe 124
GeofferyOmlette 0:f6e4e1bbb3fe 125 uint8_t observable;
GeofferyOmlette 0:f6e4e1bbb3fe 126
GeofferyOmlette 0:f6e4e1bbb3fe 127 uint8_t registered;
GeofferyOmlette 0:f6e4e1bbb3fe 128
GeofferyOmlette 0:f6e4e1bbb3fe 129 }sn_nsdl_resource_parameters_s;
GeofferyOmlette 0:f6e4e1bbb3fe 130
GeofferyOmlette 0:f6e4e1bbb3fe 131 /**
GeofferyOmlette 0:f6e4e1bbb3fe 132 * \brief Defines parameters for the resource.
GeofferyOmlette 0:f6e4e1bbb3fe 133 */
GeofferyOmlette 0:f6e4e1bbb3fe 134 typedef struct sn_nsdl_resource_info_
GeofferyOmlette 0:f6e4e1bbb3fe 135 {
GeofferyOmlette 0:f6e4e1bbb3fe 136 sn_nsdl_resource_parameters_s *resource_parameters_ptr;
GeofferyOmlette 0:f6e4e1bbb3fe 137
GeofferyOmlette 0:f6e4e1bbb3fe 138 sn_nsdl_resource_mode_e mode; /**< STATIC etc.. */
GeofferyOmlette 0:f6e4e1bbb3fe 139
GeofferyOmlette 0:f6e4e1bbb3fe 140 uint16_t pathlen; /**< Address */
GeofferyOmlette 0:f6e4e1bbb3fe 141 uint8_t *path;
GeofferyOmlette 0:f6e4e1bbb3fe 142
GeofferyOmlette 0:f6e4e1bbb3fe 143 uint16_t resourcelen; /**< 0 if dynamic resource, resource information in static resource */
GeofferyOmlette 0:f6e4e1bbb3fe 144 uint8_t *resource; /**< NULL if dynamic resource */
GeofferyOmlette 0:f6e4e1bbb3fe 145
GeofferyOmlette 0:f6e4e1bbb3fe 146 sn_grs_resource_acl_e access;
GeofferyOmlette 0:f6e4e1bbb3fe 147
GeofferyOmlette 0:f6e4e1bbb3fe 148 uint8_t (*sn_grs_dyn_res_callback)(sn_coap_hdr_s *, sn_nsdl_addr_s *, sn_proto_info_s *);
GeofferyOmlette 0:f6e4e1bbb3fe 149
GeofferyOmlette 0:f6e4e1bbb3fe 150 } sn_nsdl_resource_info_s;
GeofferyOmlette 0:f6e4e1bbb3fe 151
GeofferyOmlette 0:f6e4e1bbb3fe 152 /**
GeofferyOmlette 0:f6e4e1bbb3fe 153 * \fn extern int8_t sn_nsdl_init (uint8_t (*sn_nsdl_tx_cb)(sn_nsdl_capab_e , uint8_t *, uint16_t, sn_nsdl_addr_s *),
GeofferyOmlette 0:f6e4e1bbb3fe 154 * uint8_t (*sn_nsdl_rx_cb)(sn_coap_hdr_s *, sn_nsdl_addr_s *),
GeofferyOmlette 0:f6e4e1bbb3fe 155 * sn_nsdl_mem_s *sn_memory)
GeofferyOmlette 0:f6e4e1bbb3fe 156 *
GeofferyOmlette 0:f6e4e1bbb3fe 157 * \brief Initialization function for NSDL library. Initializes NSDL, GRS, HTTP and CoAP.
GeofferyOmlette 0:f6e4e1bbb3fe 158 *
GeofferyOmlette 0:f6e4e1bbb3fe 159 * \param *sn_nsdl_tx_callback A callback function for sending messages.
GeofferyOmlette 0:f6e4e1bbb3fe 160 *
GeofferyOmlette 0:f6e4e1bbb3fe 161 * \param *sn_nsdl_rx_callback A callback function for parsed messages. If received message is not CoAP protocol message (eg. ACK), message for GRS (GET, PUT, POST, DELETE) or
GeofferyOmlette 0:f6e4e1bbb3fe 162 * reply for some NSDL message (register message etc.), rx callback will be called.
GeofferyOmlette 0:f6e4e1bbb3fe 163 *
GeofferyOmlette 0:f6e4e1bbb3fe 164 * \param *sn_memory Memory structure which includes function pointers to the allocation and free functions.
GeofferyOmlette 0:f6e4e1bbb3fe 165 *
GeofferyOmlette 0:f6e4e1bbb3fe 166 * \return 0 Success
GeofferyOmlette 0:f6e4e1bbb3fe 167 * \return -1 Failure
GeofferyOmlette 0:f6e4e1bbb3fe 168 */
GeofferyOmlette 0:f6e4e1bbb3fe 169 extern int8_t sn_nsdl_init(uint8_t (*sn_nsdl_tx_cb)(sn_nsdl_capab_e , uint8_t *, uint16_t, sn_nsdl_addr_s *),
GeofferyOmlette 0:f6e4e1bbb3fe 170 uint8_t (*sn_nsdl_rx_cb)(sn_coap_hdr_s *, sn_nsdl_addr_s *),
GeofferyOmlette 0:f6e4e1bbb3fe 171 sn_nsdl_mem_s *sn_memory);
GeofferyOmlette 0:f6e4e1bbb3fe 172
GeofferyOmlette 0:f6e4e1bbb3fe 173 /**
GeofferyOmlette 0:f6e4e1bbb3fe 174 * \fn extern uint8_t sn_nsdl_register_endpoint(sn_nsdl_ep_parameters_s *endpoint_info_ptr)
GeofferyOmlette 0:f6e4e1bbb3fe 175 *
GeofferyOmlette 0:f6e4e1bbb3fe 176 * \brief Registers endpoint to NSP server.
GeofferyOmlette 0:f6e4e1bbb3fe 177 *
GeofferyOmlette 0:f6e4e1bbb3fe 178 * \param *endpoint_info_ptr Contains endpoint information.
GeofferyOmlette 0:f6e4e1bbb3fe 179 *
GeofferyOmlette 0:f6e4e1bbb3fe 180 * \return 0 Success
GeofferyOmlette 0:f6e4e1bbb3fe 181 * \return -1 Failure
GeofferyOmlette 0:f6e4e1bbb3fe 182 */
GeofferyOmlette 0:f6e4e1bbb3fe 183 extern int8_t sn_nsdl_register_endpoint(sn_nsdl_ep_parameters_s *endpoint_info_ptr);
GeofferyOmlette 0:f6e4e1bbb3fe 184
GeofferyOmlette 0:f6e4e1bbb3fe 185 /**
GeofferyOmlette 0:f6e4e1bbb3fe 186 * \fn extern int8_t sn_nsdl_unregister_endpoint(void)
GeofferyOmlette 0:f6e4e1bbb3fe 187 *
GeofferyOmlette 0:f6e4e1bbb3fe 188 * \brief Sends unregister-message to NSP server.
GeofferyOmlette 0:f6e4e1bbb3fe 189 *
GeofferyOmlette 0:f6e4e1bbb3fe 190 * \return 0 Success
GeofferyOmlette 0:f6e4e1bbb3fe 191 * \return -1 Failure
GeofferyOmlette 0:f6e4e1bbb3fe 192 */
GeofferyOmlette 0:f6e4e1bbb3fe 193 extern int8_t sn_nsdl_unregister_endpoint(void);
GeofferyOmlette 0:f6e4e1bbb3fe 194
GeofferyOmlette 0:f6e4e1bbb3fe 195 /**
GeofferyOmlette 0:f6e4e1bbb3fe 196 * \fn extern int8_t sn_nsdl_update_registration(sn_nsdl_ep_parameters_s *endpoint_parameters_ptr);
GeofferyOmlette 0:f6e4e1bbb3fe 197 *
GeofferyOmlette 0:f6e4e1bbb3fe 198 * \brief Update the registration with NSP.
GeofferyOmlette 0:f6e4e1bbb3fe 199 *
GeofferyOmlette 0:f6e4e1bbb3fe 200 * \param *endpoint_info_ptr Contains endpoint information.
GeofferyOmlette 0:f6e4e1bbb3fe 201 *
GeofferyOmlette 0:f6e4e1bbb3fe 202 * \return 0 Success
GeofferyOmlette 0:f6e4e1bbb3fe 203 * \return -1 Failure
GeofferyOmlette 0:f6e4e1bbb3fe 204 */
GeofferyOmlette 0:f6e4e1bbb3fe 205 extern int8_t sn_nsdl_update_registration(sn_nsdl_ep_parameters_s *endpoint_parameters_ptr);
GeofferyOmlette 0:f6e4e1bbb3fe 206
GeofferyOmlette 0:f6e4e1bbb3fe 207 /**
GeofferyOmlette 0:f6e4e1bbb3fe 208 * \fn extern int8_t sn_nsdl_is_ep_registered(void)
GeofferyOmlette 0:f6e4e1bbb3fe 209 *
GeofferyOmlette 0:f6e4e1bbb3fe 210 * \brief Checks if endpoint is registered.
GeofferyOmlette 0:f6e4e1bbb3fe 211 *
GeofferyOmlette 0:f6e4e1bbb3fe 212 * \return 1 Endpoint registration is done successfully
GeofferyOmlette 0:f6e4e1bbb3fe 213 * \return 0 Endpoint is not registered
GeofferyOmlette 0:f6e4e1bbb3fe 214 */
GeofferyOmlette 0:f6e4e1bbb3fe 215 extern int8_t sn_nsdl_is_ep_registered(void);
GeofferyOmlette 0:f6e4e1bbb3fe 216
GeofferyOmlette 0:f6e4e1bbb3fe 217 /**
GeofferyOmlette 0:f6e4e1bbb3fe 218 * \fn extern void sn_nsdl_nsp_lost(void);
GeofferyOmlette 0:f6e4e1bbb3fe 219 *
GeofferyOmlette 0:f6e4e1bbb3fe 220 * \brief A function to inform NSDL-C library if application detects a fault in NSP registration.
GeofferyOmlette 0:f6e4e1bbb3fe 221 *
GeofferyOmlette 0:f6e4e1bbb3fe 222 * After calling this function sn_nsdl_is_ep_registered() will return "not registered".
GeofferyOmlette 0:f6e4e1bbb3fe 223 */
GeofferyOmlette 0:f6e4e1bbb3fe 224 extern void sn_nsdl_nsp_lost(void);
GeofferyOmlette 0:f6e4e1bbb3fe 225
GeofferyOmlette 0:f6e4e1bbb3fe 226 /**
GeofferyOmlette 0:f6e4e1bbb3fe 227 * \fn extern uint16_t sn_nsdl_send_observation_notification(uint8_t *token_ptr, uint8_t token_len,
GeofferyOmlette 0:f6e4e1bbb3fe 228 * uint8_t *payload_ptr, uint16_t payload_len,
GeofferyOmlette 0:f6e4e1bbb3fe 229 * uint8_t *observe_ptr, uint8_t observe_len,
GeofferyOmlette 0:f6e4e1bbb3fe 230 * sn_coap_msg_type_e message_type, uint8_t content_type)
GeofferyOmlette 0:f6e4e1bbb3fe 231 *
GeofferyOmlette 0:f6e4e1bbb3fe 232 *
GeofferyOmlette 0:f6e4e1bbb3fe 233 * \brief Sends observation message to NSP server
GeofferyOmlette 0:f6e4e1bbb3fe 234 *
GeofferyOmlette 0:f6e4e1bbb3fe 235 * \param *token_ptr Pointer to token to be used
GeofferyOmlette 0:f6e4e1bbb3fe 236 * \param token_len Token length
GeofferyOmlette 0:f6e4e1bbb3fe 237 * \param *payload_ptr Pointer to payload to be sent
GeofferyOmlette 0:f6e4e1bbb3fe 238 * \param payload_len Payload length
GeofferyOmlette 0:f6e4e1bbb3fe 239 * \param *observe_ptr Pointer to observe number to be sent
GeofferyOmlette 0:f6e4e1bbb3fe 240 * \param observe_len Observe number len
GeofferyOmlette 0:f6e4e1bbb3fe 241 * \param message_type Observation message type (confirmable or non-confirmable)
GeofferyOmlette 0:f6e4e1bbb3fe 242 * \param contetnt_type Observation message payload contetnt type
GeofferyOmlette 0:f6e4e1bbb3fe 243 *
GeofferyOmlette 0:f6e4e1bbb3fe 244 * \return !0 Success, observation messages message ID
GeofferyOmlette 0:f6e4e1bbb3fe 245 * \return 0 Failure
GeofferyOmlette 0:f6e4e1bbb3fe 246 */
GeofferyOmlette 0:f6e4e1bbb3fe 247 extern uint16_t sn_nsdl_send_observation_notification(uint8_t *token_ptr, uint8_t token_len,
GeofferyOmlette 0:f6e4e1bbb3fe 248 uint8_t *payload_ptr, uint16_t payload_len,
GeofferyOmlette 0:f6e4e1bbb3fe 249 uint8_t *observe_ptr, uint8_t observe_len,
GeofferyOmlette 0:f6e4e1bbb3fe 250 sn_coap_msg_type_e message_type, uint8_t content_type);
GeofferyOmlette 0:f6e4e1bbb3fe 251
GeofferyOmlette 0:f6e4e1bbb3fe 252 /**
GeofferyOmlette 0:f6e4e1bbb3fe 253 * \fn extern int16_t sn_nsdl_get_capability(void)
GeofferyOmlette 0:f6e4e1bbb3fe 254 *
GeofferyOmlette 0:f6e4e1bbb3fe 255 * \brief Capability query function.
GeofferyOmlette 0:f6e4e1bbb3fe 256 *
GeofferyOmlette 0:f6e4e1bbb3fe 257 * Used to retrieve the list of supported protocols from the NSDL module.
GeofferyOmlette 0:f6e4e1bbb3fe 258 *
GeofferyOmlette 0:f6e4e1bbb3fe 259 * \return >0 Success, supported capabilities reported using bitmask with definitions from sn_nsdl_capab_t
GeofferyOmlette 0:f6e4e1bbb3fe 260 * \return 0 Success, no supported capabilities
GeofferyOmlette 0:f6e4e1bbb3fe 261 */
GeofferyOmlette 0:f6e4e1bbb3fe 262 extern int16_t sn_nsdl_get_capability(void);
GeofferyOmlette 0:f6e4e1bbb3fe 263
GeofferyOmlette 0:f6e4e1bbb3fe 264 /**
GeofferyOmlette 0:f6e4e1bbb3fe 265 * \fn extern uint32_t sn_nsdl_get_version(void)
GeofferyOmlette 0:f6e4e1bbb3fe 266 *
GeofferyOmlette 0:f6e4e1bbb3fe 267 * \brief Version query function.
GeofferyOmlette 0:f6e4e1bbb3fe 268 *
GeofferyOmlette 0:f6e4e1bbb3fe 269 * Used to retrieve the version information structure from the NSDL library.
GeofferyOmlette 0:f6e4e1bbb3fe 270 *
GeofferyOmlette 0:f6e4e1bbb3fe 271 * \return !0 MSB 2 bytes major version, LSB 2 bytes minor version.
GeofferyOmlette 0:f6e4e1bbb3fe 272 * \return 0 Failure
GeofferyOmlette 0:f6e4e1bbb3fe 273 */
GeofferyOmlette 0:f6e4e1bbb3fe 274 extern uint32_t sn_nsdl_get_version(void);
GeofferyOmlette 0:f6e4e1bbb3fe 275
GeofferyOmlette 0:f6e4e1bbb3fe 276 /**
GeofferyOmlette 0:f6e4e1bbb3fe 277 * \fn extern int8_t sn_nsdl_process_http(uint8_t *packet, uint16_t *packet_len, sn_nsdl_addr_s *src)
GeofferyOmlette 0:f6e4e1bbb3fe 278 *
GeofferyOmlette 0:f6e4e1bbb3fe 279 * \brief Currently HTTP is not supported
GeofferyOmlette 0:f6e4e1bbb3fe 280 *
GeofferyOmlette 0:f6e4e1bbb3fe 281 * \return -1 Failure
GeofferyOmlette 0:f6e4e1bbb3fe 282 */
GeofferyOmlette 0:f6e4e1bbb3fe 283 extern int8_t sn_nsdl_process_http(uint8_t *packet, uint16_t *packet_len, sn_nsdl_addr_s *src);
GeofferyOmlette 0:f6e4e1bbb3fe 284
GeofferyOmlette 0:f6e4e1bbb3fe 285 /**
GeofferyOmlette 0:f6e4e1bbb3fe 286 * \fn extern int8_t sn_nsdl_process_coap(uint8_t *packet, uint16_t packet_len, sn_nsdl_addr_s *src)
GeofferyOmlette 0:f6e4e1bbb3fe 287 *
GeofferyOmlette 0:f6e4e1bbb3fe 288 * \brief To push CoAP packet to NSDL library
GeofferyOmlette 0:f6e4e1bbb3fe 289 *
GeofferyOmlette 0:f6e4e1bbb3fe 290 * Used to push an CoAP packet to NSDL library for processing.
GeofferyOmlette 0:f6e4e1bbb3fe 291 *
GeofferyOmlette 0:f6e4e1bbb3fe 292 * \param *packet Pointer to a uint8_t array containing the packet (including the CoAP headers).
GeofferyOmlette 0:f6e4e1bbb3fe 293 * After successful execution this array may contain the response packet.
GeofferyOmlette 0:f6e4e1bbb3fe 294 *
GeofferyOmlette 0:f6e4e1bbb3fe 295 * \param *packet_len Pointer to length of the packet. After successful execution this array may contain the length
GeofferyOmlette 0:f6e4e1bbb3fe 296 * of the response packet.
GeofferyOmlette 0:f6e4e1bbb3fe 297 *
GeofferyOmlette 0:f6e4e1bbb3fe 298 * \param *src Pointer to packet source address information. After successful execution this array may contain
GeofferyOmlette 0:f6e4e1bbb3fe 299 * the destination address of the response packet.
GeofferyOmlette 0:f6e4e1bbb3fe 300 *
GeofferyOmlette 0:f6e4e1bbb3fe 301 * \return 0 Success
GeofferyOmlette 0:f6e4e1bbb3fe 302 * \return -1 Failure
GeofferyOmlette 0:f6e4e1bbb3fe 303 */
GeofferyOmlette 0:f6e4e1bbb3fe 304 extern int8_t sn_nsdl_process_coap(uint8_t *packet, uint16_t packet_len, sn_nsdl_addr_s *src);
GeofferyOmlette 0:f6e4e1bbb3fe 305
GeofferyOmlette 0:f6e4e1bbb3fe 306 /**
GeofferyOmlette 0:f6e4e1bbb3fe 307 * \fn extern int8_t sn_nsdl_exec(uint32_t time);
GeofferyOmlette 0:f6e4e1bbb3fe 308 *
GeofferyOmlette 0:f6e4e1bbb3fe 309 * \brief CoAP retransmission function.
GeofferyOmlette 0:f6e4e1bbb3fe 310 *
GeofferyOmlette 0:f6e4e1bbb3fe 311 * Used to give execution time for the NSDL (CoAP) library for retransmissions. The NSDL library
GeofferyOmlette 0:f6e4e1bbb3fe 312 * will call the exec functions of all enabled protocol modules.
GeofferyOmlette 0:f6e4e1bbb3fe 313 *
GeofferyOmlette 0:f6e4e1bbb3fe 314 * \param time Time in seconds.
GeofferyOmlette 0:f6e4e1bbb3fe 315 *
GeofferyOmlette 0:f6e4e1bbb3fe 316 * \return 0 Success
GeofferyOmlette 0:f6e4e1bbb3fe 317 * \return -1 Failure
GeofferyOmlette 0:f6e4e1bbb3fe 318 */
GeofferyOmlette 0:f6e4e1bbb3fe 319 extern int8_t sn_nsdl_exec(uint32_t time);
GeofferyOmlette 0:f6e4e1bbb3fe 320
GeofferyOmlette 0:f6e4e1bbb3fe 321 /**
GeofferyOmlette 0:f6e4e1bbb3fe 322 * \fn extern int8_t sn_nsdl_create_resource(sn_nsdl_resource_info_s *res)
GeofferyOmlette 0:f6e4e1bbb3fe 323 *
GeofferyOmlette 0:f6e4e1bbb3fe 324 * \brief Resource creating function.
GeofferyOmlette 0:f6e4e1bbb3fe 325 *
GeofferyOmlette 0:f6e4e1bbb3fe 326 * Used to create a static or dynamic HTTP(S) or CoAP resource.
GeofferyOmlette 0:f6e4e1bbb3fe 327 *
GeofferyOmlette 0:f6e4e1bbb3fe 328 * \param *res Pointer to a structure of type sn_nsdl_resource_info_t that contains the information
GeofferyOmlette 0:f6e4e1bbb3fe 329 * about the resource.
GeofferyOmlette 0:f6e4e1bbb3fe 330 *
GeofferyOmlette 0:f6e4e1bbb3fe 331 * \return 0 Success
GeofferyOmlette 0:f6e4e1bbb3fe 332 * \return -1 Failure
GeofferyOmlette 0:f6e4e1bbb3fe 333 * \return -2 Resource already exists
GeofferyOmlette 0:f6e4e1bbb3fe 334 * \return -3 Invalid path
GeofferyOmlette 0:f6e4e1bbb3fe 335 * \return -4 List adding failure
GeofferyOmlette 0:f6e4e1bbb3fe 336 */
GeofferyOmlette 0:f6e4e1bbb3fe 337 extern int8_t sn_nsdl_create_resource(sn_nsdl_resource_info_s *res);
GeofferyOmlette 0:f6e4e1bbb3fe 338
GeofferyOmlette 0:f6e4e1bbb3fe 339 /**
GeofferyOmlette 0:f6e4e1bbb3fe 340 * \fn extern int8_t sn_nsdl_update_resource(sn_nsdl_resource_info_s *res)
GeofferyOmlette 0:f6e4e1bbb3fe 341 *
GeofferyOmlette 0:f6e4e1bbb3fe 342 * \brief Resource updating function.
GeofferyOmlette 0:f6e4e1bbb3fe 343 *
GeofferyOmlette 0:f6e4e1bbb3fe 344 * Used to update the direct value of a static resource, the callback function pointer of a dynamic resource
GeofferyOmlette 0:f6e4e1bbb3fe 345 * and access rights of the recource.
GeofferyOmlette 0:f6e4e1bbb3fe 346 *
GeofferyOmlette 0:f6e4e1bbb3fe 347 * \param *res Pointer to a structure of type sn_nsdl_resource_info_t that contains the information
GeofferyOmlette 0:f6e4e1bbb3fe 348 * about the resource. Only the pathlen and path elements are evaluated along with
GeofferyOmlette 0:f6e4e1bbb3fe 349 * either resourcelen and resource or the function pointer.
GeofferyOmlette 0:f6e4e1bbb3fe 350 *
GeofferyOmlette 0:f6e4e1bbb3fe 351 * \return 0 Success
GeofferyOmlette 0:f6e4e1bbb3fe 352 * \return -1 Failure
GeofferyOmlette 0:f6e4e1bbb3fe 353 */
GeofferyOmlette 0:f6e4e1bbb3fe 354 extern int8_t sn_nsdl_update_resource(sn_nsdl_resource_info_s *res);
GeofferyOmlette 0:f6e4e1bbb3fe 355
GeofferyOmlette 0:f6e4e1bbb3fe 356 /**
GeofferyOmlette 0:f6e4e1bbb3fe 357 * \fn extern int8_t sn_nsdl_delete_resource(uint8_t pathlen, uint8_t *path)
GeofferyOmlette 0:f6e4e1bbb3fe 358 *
GeofferyOmlette 0:f6e4e1bbb3fe 359 * \brief Resource delete function.
GeofferyOmlette 0:f6e4e1bbb3fe 360 *
GeofferyOmlette 0:f6e4e1bbb3fe 361 * Used to delete a resource. If resource has a subresources, these all must also be removed.
GeofferyOmlette 0:f6e4e1bbb3fe 362 *
GeofferyOmlette 0:f6e4e1bbb3fe 363 * \param pathlen Contains the length of the path that is to be deleted (excluding possible trailing "\0").
GeofferyOmlette 0:f6e4e1bbb3fe 364 *
GeofferyOmlette 0:f6e4e1bbb3fe 365 * \param *path_ptr A pointer to an array containing the path.
GeofferyOmlette 0:f6e4e1bbb3fe 366 *
GeofferyOmlette 0:f6e4e1bbb3fe 367 * \return 0 Success
GeofferyOmlette 0:f6e4e1bbb3fe 368 * \return -1 Failure (No such resource)
GeofferyOmlette 0:f6e4e1bbb3fe 369 */
GeofferyOmlette 0:f6e4e1bbb3fe 370 extern int8_t sn_nsdl_delete_resource(uint8_t pathlen, uint8_t *path);
GeofferyOmlette 0:f6e4e1bbb3fe 371
GeofferyOmlette 0:f6e4e1bbb3fe 372 /**
GeofferyOmlette 0:f6e4e1bbb3fe 373 * \fn extern sn_nsdl_resource_info_s *sn_nsdl_get_resource(uint16_t pathlen, uint8_t *path)
GeofferyOmlette 0:f6e4e1bbb3fe 374 *
GeofferyOmlette 0:f6e4e1bbb3fe 375 * \brief Resource get function.
GeofferyOmlette 0:f6e4e1bbb3fe 376 *
GeofferyOmlette 0:f6e4e1bbb3fe 377 * Used to get a resource.
GeofferyOmlette 0:f6e4e1bbb3fe 378 *
GeofferyOmlette 0:f6e4e1bbb3fe 379 * \param pathlen Contains the length of the path that is to be returned (excluding possible trailing '\0').
GeofferyOmlette 0:f6e4e1bbb3fe 380 *
GeofferyOmlette 0:f6e4e1bbb3fe 381 * \param *path A pointer to an array containing the path.
GeofferyOmlette 0:f6e4e1bbb3fe 382 *
GeofferyOmlette 0:f6e4e1bbb3fe 383 * \return !NULL Success, pointer to a sn_nsdl_resource_info_s that contains the resource information\n
GeofferyOmlette 0:f6e4e1bbb3fe 384 * \return NULL Failure
GeofferyOmlette 0:f6e4e1bbb3fe 385 */
GeofferyOmlette 0:f6e4e1bbb3fe 386 extern sn_nsdl_resource_info_s *sn_nsdl_get_resource(uint16_t pathlen, uint8_t *path);
GeofferyOmlette 0:f6e4e1bbb3fe 387
GeofferyOmlette 0:f6e4e1bbb3fe 388 /**
GeofferyOmlette 0:f6e4e1bbb3fe 389 * \fn extern sn_grs_resource_list_s *sn_nsdl_list_resource(uint16_t pathlen, uint8_t *path)
GeofferyOmlette 0:f6e4e1bbb3fe 390 *
GeofferyOmlette 0:f6e4e1bbb3fe 391 * \brief Resource list function.
GeofferyOmlette 0:f6e4e1bbb3fe 392 *
GeofferyOmlette 0:f6e4e1bbb3fe 393 * \param pathlen Contains the length of the target path (excluding possible trailing '\0').
GeofferyOmlette 0:f6e4e1bbb3fe 394 * The length value is not examined if the path itself is a NULL pointer.
GeofferyOmlette 0:f6e4e1bbb3fe 395 *
GeofferyOmlette 0:f6e4e1bbb3fe 396 * \param *path A pointer to an array containing the path or a NULL pointer.
GeofferyOmlette 0:f6e4e1bbb3fe 397 *
GeofferyOmlette 0:f6e4e1bbb3fe 398 * \return !NULL A pointer to a sn_grs_resource_list_s structure containing the resource listing.
GeofferyOmlette 0:f6e4e1bbb3fe 399 * \return NULL Failure with an unspecified error
GeofferyOmlette 0:f6e4e1bbb3fe 400 */
GeofferyOmlette 0:f6e4e1bbb3fe 401 extern sn_grs_resource_list_s *sn_nsdl_list_resource(uint16_t pathlen, uint8_t *path);
GeofferyOmlette 0:f6e4e1bbb3fe 402
GeofferyOmlette 0:f6e4e1bbb3fe 403 /**
GeofferyOmlette 0:f6e4e1bbb3fe 404 * \fn extern int8_t sn_nsdl_send_coap_message(sn_nsdl_addr_s *address_ptr, sn_coap_hdr_s *coap_hdr_ptr);
GeofferyOmlette 0:f6e4e1bbb3fe 405 *
GeofferyOmlette 0:f6e4e1bbb3fe 406 * \brief Send an outgoing CoAP request.
GeofferyOmlette 0:f6e4e1bbb3fe 407 *
GeofferyOmlette 0:f6e4e1bbb3fe 408 * \param *address_ptr Pointer to source address struct
GeofferyOmlette 0:f6e4e1bbb3fe 409 *
GeofferyOmlette 0:f6e4e1bbb3fe 410 * \param *coap_hdr_ptr Pointer to CoAP message to be sent
GeofferyOmlette 0:f6e4e1bbb3fe 411 *
GeofferyOmlette 0:f6e4e1bbb3fe 412 * \return 0 Success
GeofferyOmlette 0:f6e4e1bbb3fe 413 * \return -1 Failure
GeofferyOmlette 0:f6e4e1bbb3fe 414 */
GeofferyOmlette 0:f6e4e1bbb3fe 415 extern int8_t sn_nsdl_send_coap_message(sn_nsdl_addr_s *address_ptr, sn_coap_hdr_s *coap_hdr_ptr);
GeofferyOmlette 0:f6e4e1bbb3fe 416
GeofferyOmlette 0:f6e4e1bbb3fe 417 /**
GeofferyOmlette 0:f6e4e1bbb3fe 418 * \fn extern int8_t set_NSP_address(uint8_t *NSP_address, uint16_t port, sn_nsdl_addr_type_e address_type);
GeofferyOmlette 0:f6e4e1bbb3fe 419 *
GeofferyOmlette 0:f6e4e1bbb3fe 420 * \brief This function is used to set the NSP address given by an application.
GeofferyOmlette 0:f6e4e1bbb3fe 421 *
GeofferyOmlette 0:f6e4e1bbb3fe 422 * \return 0 Success
GeofferyOmlette 0:f6e4e1bbb3fe 423 * \return -1 Failed to indicate that NSDL internal address pointer is not allocated (call nsdl_init() first).
GeofferyOmlette 0:f6e4e1bbb3fe 424 */
GeofferyOmlette 0:f6e4e1bbb3fe 425 extern int8_t set_NSP_address(uint8_t *NSP_address, uint16_t port, sn_nsdl_addr_type_e address_type);
GeofferyOmlette 0:f6e4e1bbb3fe 426
GeofferyOmlette 0:f6e4e1bbb3fe 427 /**
GeofferyOmlette 0:f6e4e1bbb3fe 428 * \fn extern int8_t sn_nsdl_destroy(void);
GeofferyOmlette 0:f6e4e1bbb3fe 429 *
GeofferyOmlette 0:f6e4e1bbb3fe 430 * \brief This function releases all allocated memory in nsdl and grs modules.
GeofferyOmlette 0:f6e4e1bbb3fe 431 */
GeofferyOmlette 0:f6e4e1bbb3fe 432 extern int8_t sn_nsdl_destroy(void);
GeofferyOmlette 0:f6e4e1bbb3fe 433
GeofferyOmlette 0:f6e4e1bbb3fe 434 #endif /* SN_NSDL_LIB_H_ */
GeofferyOmlette 0:f6e4e1bbb3fe 435
GeofferyOmlette 0:f6e4e1bbb3fe 436 #ifdef __cplusplus
GeofferyOmlette 0:f6e4e1bbb3fe 437 }
GeofferyOmlette 0:f6e4e1bbb3fe 438 #endif