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@3:d8cb1afd7285, 2013-10-10 (annotated)
- Committer:
- screamer
- Date:
- Thu Oct 10 10:24:59 2013 +0000
- Revision:
- 3:d8cb1afd7285
- Parent:
- 2:ab50a2ab6ec9
- Child:
- 4:0f845ba8adff
More doxygen markup #3
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 | |
terohoo | 0:58c4f13c4b9a | 83 | typedef struct sn_nsdl_sent_messages_ |
terohoo | 0:58c4f13c4b9a | 84 | { |
terohoo | 0:58c4f13c4b9a | 85 | uint16_t msg_id_number; |
terohoo | 0:58c4f13c4b9a | 86 | uint8_t message_type; |
screamer | 3:d8cb1afd7285 | 87 | } sn_nsdl_sent_messages_s; |
terohoo | 0:58c4f13c4b9a | 88 | |
terohoo | 0:58c4f13c4b9a | 89 | typedef struct sn_nsdl_mem_ |
terohoo | 0:58c4f13c4b9a | 90 | { |
terohoo | 0:58c4f13c4b9a | 91 | void *(*sn_nsdl_alloc)(uint16_t); |
terohoo | 0:58c4f13c4b9a | 92 | void (*sn_nsdl_free)(void *); |
screamer | 3:d8cb1afd7285 | 93 | } sn_nsdl_mem_s; |
terohoo | 0:58c4f13c4b9a | 94 | |
terohoo | 0:58c4f13c4b9a | 95 | typedef struct sn_grs_resource_ |
terohoo | 0:58c4f13c4b9a | 96 | { |
terohoo | 0:58c4f13c4b9a | 97 | uint8_t pathlen; |
terohoo | 0:58c4f13c4b9a | 98 | uint8_t *path; |
screamer | 3:d8cb1afd7285 | 99 | } sn_grs_resource_s; |
terohoo | 0:58c4f13c4b9a | 100 | |
terohoo | 0:58c4f13c4b9a | 101 | typedef struct sn_grs_resource_list_ |
terohoo | 0:58c4f13c4b9a | 102 | { |
screamer | 3:d8cb1afd7285 | 103 | uint8_t res_count; /**< Number of resources */ |
terohoo | 0:58c4f13c4b9a | 104 | sn_grs_resource_s *res; |
screamer | 3:d8cb1afd7285 | 105 | } sn_grs_resource_list_s; |
terohoo | 0:58c4f13c4b9a | 106 | |
screamer | 3:d8cb1afd7285 | 107 | /** |
screamer | 3:d8cb1afd7285 | 108 | * \brief Resource access rights |
screamer | 3:d8cb1afd7285 | 109 | */ |
terohoo | 0:58c4f13c4b9a | 110 | typedef enum sn_grs_resource_acl_ |
terohoo | 0:58c4f13c4b9a | 111 | { |
terohoo | 0:58c4f13c4b9a | 112 | SN_GRS_GET_ALLOWED = 0x01 , |
terohoo | 0:58c4f13c4b9a | 113 | SN_GRS_PUT_ALLOWED = 0x02, |
terohoo | 0:58c4f13c4b9a | 114 | SN_GRS_POST_ALLOWED = 0x04, |
terohoo | 0:58c4f13c4b9a | 115 | SN_GRS_DELETE_ALLOWED = 0x08 |
screamer | 3:d8cb1afd7285 | 116 | } sn_grs_resource_acl_e; |
terohoo | 0:58c4f13c4b9a | 117 | |
terohoo | 0:58c4f13c4b9a | 118 | typedef struct sn_proto_info_ |
terohoo | 0:58c4f13c4b9a | 119 | { |
terohoo | 0:58c4f13c4b9a | 120 | sn_nsdl_capab_e proto; |
screamer | 3:d8cb1afd7285 | 121 | } sn_proto_info_s; |
terohoo | 0:58c4f13c4b9a | 122 | |
screamer | 3:d8cb1afd7285 | 123 | /** |
screamer | 3:d8cb1afd7285 | 124 | * \brief Defines the resource mode |
screamer | 3:d8cb1afd7285 | 125 | */ |
screamer | 3:d8cb1afd7285 | 126 | typedef enum sn_nsdl_resource_mode_ |
screamer | 3:d8cb1afd7285 | 127 | { |
screamer | 3:d8cb1afd7285 | 128 | SN_GRS_STATIC, /**< Static resources have some value that does not change. */ |
screamer | 3:d8cb1afd7285 | 129 | SN_GRS_DYNAMIC, /**< Dynamic resources are handled in application. Therefore one must give function callback pointer to them. */ |
screamer | 3:d8cb1afd7285 | 130 | SN_GRS_DIRECTORY /**< Directory resources are unused and unsupported. */ |
screamer | 3:d8cb1afd7285 | 131 | } sn_nsdl_resource_mode_e; |
screamer | 3:d8cb1afd7285 | 132 | |
screamer | 3:d8cb1afd7285 | 133 | /** |
screamer | 3:d8cb1afd7285 | 134 | * \brief Resource registration parameters |
screamer | 3:d8cb1afd7285 | 135 | */ |
terohoo | 0:58c4f13c4b9a | 136 | typedef struct sn_nsdl_resource_parameters_ |
terohoo | 0:58c4f13c4b9a | 137 | { |
terohoo | 0:58c4f13c4b9a | 138 | uint8_t *resource_type_ptr; |
terohoo | 0:58c4f13c4b9a | 139 | uint16_t resource_type_len; |
terohoo | 0:58c4f13c4b9a | 140 | |
terohoo | 0:58c4f13c4b9a | 141 | uint8_t *interface_description_ptr; |
terohoo | 0:58c4f13c4b9a | 142 | uint16_t interface_description_len; |
terohoo | 0:58c4f13c4b9a | 143 | |
terohoo | 0:58c4f13c4b9a | 144 | uint8_t coap_content_type; |
terohoo | 0:58c4f13c4b9a | 145 | |
terohoo | 0:58c4f13c4b9a | 146 | uint8_t mime_content_type; |
terohoo | 0:58c4f13c4b9a | 147 | |
terohoo | 0:58c4f13c4b9a | 148 | uint8_t observable; |
terohoo | 0:58c4f13c4b9a | 149 | |
terohoo | 0:58c4f13c4b9a | 150 | uint8_t registered; |
terohoo | 0:58c4f13c4b9a | 151 | |
terohoo | 0:58c4f13c4b9a | 152 | }sn_nsdl_resource_parameters_s; |
terohoo | 0:58c4f13c4b9a | 153 | |
screamer | 3:d8cb1afd7285 | 154 | /** |
screamer | 3:d8cb1afd7285 | 155 | * \brief Defines parameters for the resource. |
screamer | 3:d8cb1afd7285 | 156 | */ |
terohoo | 0:58c4f13c4b9a | 157 | typedef struct sn_nsdl_resource_info_ |
terohoo | 0:58c4f13c4b9a | 158 | { |
terohoo | 0:58c4f13c4b9a | 159 | sn_nsdl_resource_parameters_s *resource_parameters_ptr; |
terohoo | 0:58c4f13c4b9a | 160 | |
screamer | 3:d8cb1afd7285 | 161 | sn_nsdl_resource_mode_e mode; /**< STATIC etc.. */ |
terohoo | 0:58c4f13c4b9a | 162 | |
screamer | 3:d8cb1afd7285 | 163 | uint16_t pathlen; /**< Address */ |
terohoo | 0:58c4f13c4b9a | 164 | uint8_t *path; |
terohoo | 0:58c4f13c4b9a | 165 | |
screamer | 3:d8cb1afd7285 | 166 | uint16_t resourcelen; /**< 0 if dynamic resource, resource information in static resource */ |
screamer | 3:d8cb1afd7285 | 167 | uint8_t *resource; /**< NULL if dynamic resource */ |
terohoo | 0:58c4f13c4b9a | 168 | |
terohoo | 0:58c4f13c4b9a | 169 | sn_grs_resource_acl_e access; |
terohoo | 0:58c4f13c4b9a | 170 | |
terohoo | 0:58c4f13c4b9a | 171 | uint8_t (*sn_grs_dyn_res_callback)(sn_coap_hdr_s *, sn_nsdl_addr_s *, sn_proto_info_s *); |
terohoo | 0:58c4f13c4b9a | 172 | |
terohoo | 0:58c4f13c4b9a | 173 | } sn_nsdl_resource_info_s; |
terohoo | 0:58c4f13c4b9a | 174 | |
terohoo | 0:58c4f13c4b9a | 175 | /** |
terohoo | 0:58c4f13c4b9a | 176 | * \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 | 177 | * uint8_t (*sn_nsdl_rx_cb)(sn_coap_hdr_s *, sn_nsdl_addr_s *), |
terohoo | 0:58c4f13c4b9a | 178 | * sn_nsdl_mem_s *sn_memory) |
terohoo | 0:58c4f13c4b9a | 179 | * |
terohoo | 0:58c4f13c4b9a | 180 | * \brief Initialization function for NSDL library. Initializes NSDL, GRS, HTTP and CoAP. |
terohoo | 0:58c4f13c4b9a | 181 | * |
terohoo | 0:58c4f13c4b9a | 182 | * \param *sn_nsdl_tx_callback A callback function for sending messages. |
terohoo | 0:58c4f13c4b9a | 183 | * |
terohoo | 0:58c4f13c4b9a | 184 | * \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 | 185 | * reply for some NSDL message (register message etc.), rx callback will be called. |
terohoo | 0:58c4f13c4b9a | 186 | * |
terohoo | 0:58c4f13c4b9a | 187 | * \param *sn_memory Memory structure which includes function pointers to the allocation and free functions. |
terohoo | 0:58c4f13c4b9a | 188 | * |
screamer | 2:ab50a2ab6ec9 | 189 | * \return Success = 0 |
screamer | 2:ab50a2ab6ec9 | 190 | * \return Failed = -1 |
terohoo | 0:58c4f13c4b9a | 191 | */ |
terohoo | 0:58c4f13c4b9a | 192 | 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 | 193 | uint8_t (*sn_nsdl_rx_cb)(sn_coap_hdr_s *, sn_nsdl_addr_s *), |
terohoo | 0:58c4f13c4b9a | 194 | sn_nsdl_mem_s *sn_memory); |
terohoo | 0:58c4f13c4b9a | 195 | |
terohoo | 0:58c4f13c4b9a | 196 | /** |
terohoo | 0:58c4f13c4b9a | 197 | * \fn extern uint8_t sn_nsdl_register_endpoint(sn_nsdl_ep_parameters_s *endpoint_info_ptr) |
terohoo | 0:58c4f13c4b9a | 198 | * |
terohoo | 0:58c4f13c4b9a | 199 | * \brief Registers endpoint to NSP server. |
terohoo | 0:58c4f13c4b9a | 200 | * |
terohoo | 0:58c4f13c4b9a | 201 | * \param *endpoint_info_ptr Contains endpoint information. |
terohoo | 0:58c4f13c4b9a | 202 | * |
screamer | 2:ab50a2ab6ec9 | 203 | * \return Success = 0 |
screamer | 2:ab50a2ab6ec9 | 204 | * \return Failed = -1 |
terohoo | 0:58c4f13c4b9a | 205 | */ |
terohoo | 0:58c4f13c4b9a | 206 | int8_t sn_nsdl_register_endpoint(sn_nsdl_ep_parameters_s *endpoint_info_ptr); |
terohoo | 0:58c4f13c4b9a | 207 | |
terohoo | 0:58c4f13c4b9a | 208 | /** |
terohoo | 0:58c4f13c4b9a | 209 | * \fn extern int8_t sn_nsdl_unregister_endpoint(void) |
terohoo | 0:58c4f13c4b9a | 210 | * |
terohoo | 0:58c4f13c4b9a | 211 | * \brief Sends unregister-message to NSP server. |
terohoo | 0:58c4f13c4b9a | 212 | * |
screamer | 2:ab50a2ab6ec9 | 213 | * \return Success = 0 |
screamer | 2:ab50a2ab6ec9 | 214 | * \return Failed = -1 |
terohoo | 0:58c4f13c4b9a | 215 | */ |
terohoo | 0:58c4f13c4b9a | 216 | int8_t sn_nsdl_unregister_endpoint(void); |
screamer | 2:ab50a2ab6ec9 | 217 | |
screamer | 2:ab50a2ab6ec9 | 218 | /** |
screamer | 2:ab50a2ab6ec9 | 219 | * Update the registration with NSP. |
screamer | 2:ab50a2ab6ec9 | 220 | */ |
terohoo | 0:58c4f13c4b9a | 221 | int8_t sn_nsdl_update_registration (sn_nsdl_ep_parameters_s *endpoint_parameters_ptr); |
screamer | 2:ab50a2ab6ec9 | 222 | |
screamer | 2:ab50a2ab6ec9 | 223 | /** |
screamer | 2:ab50a2ab6ec9 | 224 | * |
screamer | 2:ab50a2ab6ec9 | 225 | */ |
terohoo | 0:58c4f13c4b9a | 226 | int8_t sn_nsdl_send_eventing_message (uint8_t *event_name_ptr, uint16_t event_name_len, uint8_t *message_body_ptr, uint16_t message_body_len); |
terohoo | 0:58c4f13c4b9a | 227 | |
terohoo | 0:58c4f13c4b9a | 228 | /** |
terohoo | 0:58c4f13c4b9a | 229 | * \fn extern int8_t sn_nsdl_is_ep_registered(void) |
terohoo | 0:58c4f13c4b9a | 230 | * |
terohoo | 0:58c4f13c4b9a | 231 | * \brief Checks if endpoint is registered. |
terohoo | 0:58c4f13c4b9a | 232 | * |
screamer | 2:ab50a2ab6ec9 | 233 | * \return 1 if endpointi registration is done successfully |
screamer | 2:ab50a2ab6ec9 | 234 | * \return 0 if endpoint is not registered |
terohoo | 0:58c4f13c4b9a | 235 | */ |
terohoo | 0:58c4f13c4b9a | 236 | int8_t sn_nsdl_is_ep_registered(void); |
terohoo | 0:58c4f13c4b9a | 237 | |
screamer | 1:01d723824294 | 238 | /** |
screamer | 2:ab50a2ab6ec9 | 239 | * \fn void sn_nsdl_nsp_lost(void); |
screamer | 2:ab50a2ab6ec9 | 240 | * |
screamer | 2:ab50a2ab6ec9 | 241 | * \brief A function to inform NSDL-C library if application detects a fault in NSP registration. After calling this function |
terohoo | 0:58c4f13c4b9a | 242 | * , sn_nsdl_is_ep_registered() will return "not registered". |
terohoo | 0:58c4f13c4b9a | 243 | */ |
screamer | 2:ab50a2ab6ec9 | 244 | void sn_nsdl_nsp_lost(void); |
screamer | 2:ab50a2ab6ec9 | 245 | |
terohoo | 0:58c4f13c4b9a | 246 | /** |
terohoo | 0:58c4f13c4b9a | 247 | * \fn extern int8_t sn_nsdl_send_observation_notification(uint8_t *token_ptr, uint8_t token_len, |
terohoo | 0:58c4f13c4b9a | 248 | * uint8_t *payload_ptr, uint16_t payload_len, |
terohoo | 0:58c4f13c4b9a | 249 | * uint8_t *observe_ptr, uint8_t observe_len) |
terohoo | 0:58c4f13c4b9a | 250 | * |
terohoo | 0:58c4f13c4b9a | 251 | * |
terohoo | 0:58c4f13c4b9a | 252 | * \brief Sends observation message to NSP server |
terohoo | 0:58c4f13c4b9a | 253 | * |
terohoo | 0:58c4f13c4b9a | 254 | * \param *token_ptr Pointer to token to be used |
terohoo | 0:58c4f13c4b9a | 255 | * \param token_len Token length |
terohoo | 0:58c4f13c4b9a | 256 | * \param *payload_ptr Pointer to payload to be sent |
terohoo | 0:58c4f13c4b9a | 257 | * \param payload_len Payload length |
terohoo | 0:58c4f13c4b9a | 258 | * \param *observe_ptr Pointer to observe number to be sent |
terohoo | 0:58c4f13c4b9a | 259 | * \param observe_len Observe number len |
terohoo | 0:58c4f13c4b9a | 260 | * |
screamer | 2:ab50a2ab6ec9 | 261 | * \return Success = 0 |
screamer | 2:ab50a2ab6ec9 | 262 | * \return Failed = -1 |
terohoo | 0:58c4f13c4b9a | 263 | */ |
terohoo | 0:58c4f13c4b9a | 264 | extern uint16_t sn_nsdl_send_observation_notification(uint8_t *token_ptr, uint8_t token_len, uint8_t *payload_ptr, uint16_t payload_len, uint8_t *observe_ptr, uint8_t observe_len, sn_coap_msg_type_e message_type, uint8_t content_type); |
screamer | 2:ab50a2ab6ec9 | 265 | |
terohoo | 0:58c4f13c4b9a | 266 | int16_t sn_nsdl_get_capability(void); |
terohoo | 0:58c4f13c4b9a | 267 | uint32_t sn_nsdl_get_version(void); |
terohoo | 0:58c4f13c4b9a | 268 | int8_t sn_nsdl_process_http(uint8_t *packet, uint16_t *packet_len, sn_nsdl_addr_s *src); |
screamer | 2:ab50a2ab6ec9 | 269 | |
screamer | 2:ab50a2ab6ec9 | 270 | /** |
screamer | 3:d8cb1afd7285 | 271 | * \brief Process an incoming CoAP message. |
screamer | 2:ab50a2ab6ec9 | 272 | */ |
terohoo | 0:58c4f13c4b9a | 273 | int8_t sn_nsdl_process_coap(uint8_t *packet, uint16_t packet_len, sn_nsdl_addr_s *src); |
screamer | 2:ab50a2ab6ec9 | 274 | |
screamer | 2:ab50a2ab6ec9 | 275 | /** |
screamer | 3:d8cb1afd7285 | 276 | * \brief Must be called periodically for the library to update retransmissions. |
screamer | 2:ab50a2ab6ec9 | 277 | */ |
terohoo | 0:58c4f13c4b9a | 278 | int8_t sn_nsdl_exec(uint32_t time); |
screamer | 2:ab50a2ab6ec9 | 279 | |
screamer | 2:ab50a2ab6ec9 | 280 | /** |
screamer | 3:d8cb1afd7285 | 281 | * \brief Adds a resource to the server. |
screamer | 2:ab50a2ab6ec9 | 282 | */ |
terohoo | 0:58c4f13c4b9a | 283 | int8_t sn_nsdl_create_resource(sn_nsdl_resource_info_s *res); |
screamer | 2:ab50a2ab6ec9 | 284 | |
screamer | 2:ab50a2ab6ec9 | 285 | /** |
screamer | 3:d8cb1afd7285 | 286 | * \brief Updates a resource on the server. |
screamer | 2:ab50a2ab6ec9 | 287 | */ |
terohoo | 0:58c4f13c4b9a | 288 | int8_t sn_nsdl_update_resource(sn_nsdl_resource_info_s *res); |
screamer | 2:ab50a2ab6ec9 | 289 | |
screamer | 2:ab50a2ab6ec9 | 290 | /** |
screamer | 3:d8cb1afd7285 | 291 | * \brief Removes a resource from the resource server. |
screamer | 2:ab50a2ab6ec9 | 292 | */ |
terohoo | 0:58c4f13c4b9a | 293 | int8_t sn_nsdl_delete_resource(uint8_t pathlen, uint8_t *path); |
screamer | 2:ab50a2ab6ec9 | 294 | |
screamer | 2:ab50a2ab6ec9 | 295 | |
terohoo | 0:58c4f13c4b9a | 296 | sn_nsdl_resource_info_s *sn_nsdl_get_resource(uint8_t pathlen, uint8_t *path); |
terohoo | 0:58c4f13c4b9a | 297 | sn_grs_resource_list_s *sn_nsdl_list_resource(uint8_t pathlen, uint8_t *path); |
screamer | 2:ab50a2ab6ec9 | 298 | |
screamer | 2:ab50a2ab6ec9 | 299 | /** |
screamer | 3:d8cb1afd7285 | 300 | * \brief Send an outgoing CoAP request. |
screamer | 2:ab50a2ab6ec9 | 301 | */ |
terohoo | 0:58c4f13c4b9a | 302 | int8_t sn_nsdl_send_coap_message(sn_nsdl_addr_s *address_ptr, sn_coap_hdr_s *coap_hdr_ptr); |
screamer | 2:ab50a2ab6ec9 | 303 | |
terohoo | 0:58c4f13c4b9a | 304 | /** |
screamer | 2:ab50a2ab6ec9 | 305 | * \fn int8_t set_NSP_address(uint8_t *NSP_address, uint16_t port, sn_nsdl_addr_type_e address_type); |
screamer | 2:ab50a2ab6ec9 | 306 | * |
terohoo | 0:58c4f13c4b9a | 307 | * \brief This function is used to set the NSP address given by an application. |
screamer | 2:ab50a2ab6ec9 | 308 | * |
screamer | 2:ab50a2ab6ec9 | 309 | * \return 0 on success, |
screamer | 2:ab50a2ab6ec9 | 310 | * \return -1 on false to indicate that NSDL internal address pointer is not allocated (call nsdl_init() first). |
terohoo | 0:58c4f13c4b9a | 311 | */ |
terohoo | 0:58c4f13c4b9a | 312 | int8_t set_NSP_address(uint8_t *NSP_address, uint16_t port, sn_nsdl_addr_type_e address_type); |
terohoo | 0:58c4f13c4b9a | 313 | |
terohoo | 0:58c4f13c4b9a | 314 | /** |
screamer | 2:ab50a2ab6ec9 | 315 | * \fn extern int8_t sn_nsdl_destroy(void); |
screamer | 2:ab50a2ab6ec9 | 316 | * |
terohoo | 0:58c4f13c4b9a | 317 | * \brief This function releases all allocated memory in nsdl and grs modules. |
terohoo | 0:58c4f13c4b9a | 318 | */ |
terohoo | 0:58c4f13c4b9a | 319 | extern int8_t sn_nsdl_destroy(void); |
terohoo | 0:58c4f13c4b9a | 320 | |
terohoo | 0:58c4f13c4b9a | 321 | /* |
screamer | 2:ab50a2ab6ec9 | 322 | * \fn extern const char __code * sn_nsdl_get_library_version_info(void); |
screamer | 2:ab50a2ab6ec9 | 323 | * |
terohoo | 0:58c4f13c4b9a | 324 | * \brief A function to request SN internal version information out of NSDL library in case of "error reporting" or similar. |
screamer | 2:ab50a2ab6ec9 | 325 | * |
screamer | 2:ab50a2ab6ec9 | 326 | * \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 | 327 | */ |
terohoo | 0:58c4f13c4b9a | 328 | //extern const char __code * sn_nsdl_get_library_version_info(void); |
terohoo | 0:58c4f13c4b9a | 329 | |
terohoo | 0:58c4f13c4b9a | 330 | #ifdef __cplusplus |
terohoo | 0:58c4f13c4b9a | 331 | } |
terohoo | 0:58c4f13c4b9a | 332 | #endif |