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