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