NSDL C library
Dependents: NSDL_HelloWorld_WiFi UbloxModemNanoServiceClient IOT-NSDL_HelloWorld LWM2M_NanoService_Ethernet ... more
Fork of nsdl_lib by
sn_nsdl_lib.h File Reference
NanoService Devices Library header file. More...
Go to the source code of this file.
Data Structures | |
struct | sn_nsdl_ep_parameters_ |
Endpoint registration parameters. More... | |
struct | sn_nsdl_sent_messages_ |
For internal use. More... | |
struct | sn_nsdl_mem_ |
Function pointers used for memory allocation and freeing. More... | |
struct | sn_grs_resource_ |
Includes resource path. More... | |
struct | sn_grs_resource_list_ |
Table of created resources. More... | |
struct | sn_proto_info_ |
Used protocol. More... | |
struct | sn_nsdl_resource_parameters_ |
Resource registration parameters. More... | |
struct | sn_nsdl_resource_info_ |
Defines parameters for the resource. More... | |
Typedefs | |
typedef struct sn_nsdl_ep_parameters_ | sn_nsdl_ep_parameters_s |
Endpoint registration parameters. | |
typedef struct sn_nsdl_sent_messages_ | sn_nsdl_sent_messages_s |
For internal use. | |
typedef struct sn_nsdl_mem_ | sn_nsdl_mem_s |
Function pointers used for memory allocation and freeing. | |
typedef struct sn_grs_resource_ | sn_grs_resource_s |
Includes resource path. | |
typedef struct sn_grs_resource_list_ | sn_grs_resource_list_s |
Table of created resources. | |
typedef enum sn_grs_resource_acl_ | sn_grs_resource_acl_e |
Resource access rights. | |
typedef struct sn_proto_info_ | sn_proto_info_s |
Used protocol. | |
typedef enum sn_nsdl_resource_mode_ | sn_nsdl_resource_mode_e |
Defines the resource mode. | |
typedef struct sn_nsdl_resource_parameters_ | sn_nsdl_resource_parameters_s |
Resource registration parameters. | |
typedef struct sn_nsdl_resource_info_ | sn_nsdl_resource_info_s |
Defines parameters for the resource. | |
Enumerations | |
enum | sn_grs_resource_acl_ |
Resource access rights. More... | |
enum | sn_nsdl_resource_mode_ { SN_GRS_STATIC, SN_GRS_DYNAMIC, SN_GRS_DIRECTORY } |
Defines the resource mode. More... | |
Functions | |
int8_t | sn_nsdl_init (uint8_t(*sn_nsdl_tx_cb)(sn_nsdl_capab_e, uint8_t *, uint16_t, sn_nsdl_addr_s *), uint8_t(*sn_nsdl_rx_cb)(sn_coap_hdr_s *, sn_nsdl_addr_s *), sn_nsdl_mem_s *sn_memory) |
Initialization function for NSDL library. | |
int8_t | sn_nsdl_register_endpoint (sn_nsdl_ep_parameters_s *endpoint_info_ptr) |
Registers endpoint to NSP server. | |
int8_t | sn_nsdl_unregister_endpoint (void) |
Sends unregister-message to NSP server. | |
int8_t | sn_nsdl_update_registration (sn_nsdl_ep_parameters_s *endpoint_parameters_ptr) |
Update the registration with NSP. | |
int8_t | sn_nsdl_is_ep_registered (void) |
Checks if endpoint is registered. | |
void | sn_nsdl_nsp_lost (void) |
A function to inform NSDL-C library if application detects a fault in NSP registration. | |
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) |
Sends observation message to NSP server. | |
int16_t | sn_nsdl_get_capability (void) |
Capability query function. | |
uint32_t | sn_nsdl_get_version (void) |
Version query function. | |
int8_t | sn_nsdl_process_http (uint8_t *packet, uint16_t *packet_len, sn_nsdl_addr_s *src) |
Currently HTTP is not supported. | |
int8_t | sn_nsdl_process_coap (uint8_t *packet, uint16_t packet_len, sn_nsdl_addr_s *src) |
To push CoAP packet to NSDL library. | |
int8_t | sn_nsdl_exec (uint32_t time) |
CoAP retransmission function. | |
int8_t | sn_nsdl_create_resource (sn_nsdl_resource_info_s *res) |
Resource creating function. | |
int8_t | sn_nsdl_update_resource (sn_nsdl_resource_info_s *res) |
Resource updating function. | |
int8_t | sn_nsdl_delete_resource (uint8_t pathlen, uint8_t *path) |
Resource delete function. | |
sn_nsdl_resource_info_s * | sn_nsdl_get_resource (uint16_t pathlen, uint8_t *path) |
Resource get function. | |
sn_grs_resource_list_s * | sn_nsdl_list_resource (uint16_t pathlen, uint8_t *path) |
Resource list function. | |
int8_t | sn_nsdl_send_coap_message (sn_nsdl_addr_s *address_ptr, sn_coap_hdr_s *coap_hdr_ptr) |
Send an outgoing CoAP request. | |
int8_t | set_NSP_address (uint8_t *NSP_address, uint16_t port, sn_nsdl_addr_type_e address_type) |
This function is used to set the NSP address given by an application. | |
int8_t | sn_nsdl_destroy (void) |
This function releases all allocated memory in nsdl and grs modules. |
Detailed Description
NanoService Devices Library header file.
Created on: Aug 23, 2011 Author: tero
Definition in file sn_nsdl_lib.h.
Typedef Documentation
typedef enum sn_grs_resource_acl_ sn_grs_resource_acl_e |
Resource access rights.
typedef struct sn_grs_resource_list_ sn_grs_resource_list_s |
Table of created resources.
typedef struct sn_grs_resource_ sn_grs_resource_s |
Includes resource path.
typedef struct sn_nsdl_ep_parameters_ sn_nsdl_ep_parameters_s |
Endpoint registration parameters.
typedef struct sn_nsdl_mem_ sn_nsdl_mem_s |
Function pointers used for memory allocation and freeing.
typedef struct sn_nsdl_resource_info_ sn_nsdl_resource_info_s |
Defines parameters for the resource.
typedef enum sn_nsdl_resource_mode_ sn_nsdl_resource_mode_e |
Defines the resource mode.
typedef struct sn_nsdl_resource_parameters_ sn_nsdl_resource_parameters_s |
Resource registration parameters.
typedef struct sn_nsdl_sent_messages_ sn_nsdl_sent_messages_s |
For internal use.
typedef struct sn_proto_info_ sn_proto_info_s |
Used protocol.
Enumeration Type Documentation
enum sn_grs_resource_acl_ |
Resource access rights.
Definition at line 81 of file sn_nsdl_lib.h.
Defines the resource mode.
- Enumerator:
Definition at line 100 of file sn_nsdl_lib.h.
Function Documentation
int8_t set_NSP_address | ( | uint8_t * | NSP_address, |
uint16_t | port, | ||
sn_nsdl_addr_type_e | address_type | ||
) |
This function is used to set the NSP address given by an application.
- Returns:
- 0 Success
- -1 Failed to indicate that NSDL internal address pointer is not allocated (call nsdl_init() first).
int8_t sn_nsdl_create_resource | ( | sn_nsdl_resource_info_s * | res ) |
Resource creating function.
Used to create a static or dynamic HTTP(S) or CoAP resource.
- Parameters:
-
*res Pointer to a structure of type sn_nsdl_resource_info_t that contains the information about the resource.
- Returns:
- 0 Success
- -1 Failure
- -2 Resource already exists
- -3 Invalid path
- -4 List adding failure
int8_t sn_nsdl_delete_resource | ( | uint8_t | pathlen, |
uint8_t * | path | ||
) |
Resource delete function.
Used to delete a resource. If resource has a subresources, these all must also be removed.
- Parameters:
-
pathlen Contains the length of the path that is to be deleted (excluding possible trailing "\0"). *path_ptr A pointer to an array containing the path.
- Returns:
- 0 Success
- -1 Failure (No such resource)
int8_t sn_nsdl_destroy | ( | void | ) |
This function releases all allocated memory in nsdl and grs modules.
int8_t sn_nsdl_exec | ( | uint32_t | time ) |
CoAP retransmission function.
Used to give execution time for the NSDL (CoAP) library for retransmissions. The NSDL library will call the exec functions of all enabled protocol modules.
- Parameters:
-
time Time in seconds.
- Returns:
- 0 Success
- -1 Failure
int16_t sn_nsdl_get_capability | ( | void | ) |
Capability query function.
Used to retrieve the list of supported protocols from the NSDL module.
- Returns:
- >0 Success, supported capabilities reported using bitmask with definitions from sn_nsdl_capab_t
- 0 Success, no supported capabilities
sn_nsdl_resource_info_s * sn_nsdl_get_resource | ( | uint16_t | pathlen, |
uint8_t * | path | ||
) |
Resource get function.
Used to get a resource.
- Parameters:
-
pathlen Contains the length of the path that is to be returned (excluding possible trailing '\0'). *path A pointer to an array containing the path.
- Returns:
- !NULL Success, pointer to a sn_nsdl_resource_info_s that contains the resource information
- NULL Failure
uint32_t sn_nsdl_get_version | ( | void | ) |
Version query function.
Used to retrieve the version information structure from the NSDL library.
- Returns:
- !0 MSB 2 bytes major version, LSB 2 bytes minor version.
- 0 Failure
int8_t sn_nsdl_init | ( | uint8_t(*)(sn_nsdl_capab_e, uint8_t *, uint16_t, sn_nsdl_addr_s *) | sn_nsdl_tx_cb, |
uint8_t(*)(sn_coap_hdr_s *, sn_nsdl_addr_s *) | sn_nsdl_rx_cb, | ||
sn_nsdl_mem_s * | sn_memory | ||
) |
Initialization function for NSDL library.
Initializes NSDL, GRS, HTTP and CoAP.
- Parameters:
-
*sn_nsdl_tx_callback A callback function for sending messages. *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 reply for some NSDL message (register message etc.), rx callback will be called. *sn_memory Memory structure which includes function pointers to the allocation and free functions.
- Returns:
- 0 Success
- -1 Failure
int8_t sn_nsdl_is_ep_registered | ( | void | ) |
Checks if endpoint is registered.
- Returns:
- 1 Endpoint registration is done successfully
- 0 Endpoint is not registered
sn_grs_resource_list_s * sn_nsdl_list_resource | ( | uint16_t | pathlen, |
uint8_t * | path | ||
) |
Resource list function.
- Parameters:
-
pathlen Contains the length of the target path (excluding possible trailing '\0'). The length value is not examined if the path itself is a NULL pointer. *path A pointer to an array containing the path or a NULL pointer.
- Returns:
- !NULL A pointer to a sn_grs_resource_list_s structure containing the resource listing.
- NULL Failure with an unspecified error
void sn_nsdl_nsp_lost | ( | void | ) |
A function to inform NSDL-C library if application detects a fault in NSP registration.
After calling this function sn_nsdl_is_ep_registered() will return "not registered".
int8_t sn_nsdl_process_coap | ( | uint8_t * | packet, |
uint16_t | packet_len, | ||
sn_nsdl_addr_s * | src | ||
) |
To push CoAP packet to NSDL library.
Used to push an CoAP packet to NSDL library for processing.
- Parameters:
-
*packet Pointer to a uint8_t array containing the packet (including the CoAP headers). After successful execution this array may contain the response packet. *packet_len Pointer to length of the packet. After successful execution this array may contain the length of the response packet. *src Pointer to packet source address information. After successful execution this array may contain the destination address of the response packet.
- Returns:
- 0 Success
- -1 Failure
int8_t sn_nsdl_process_http | ( | uint8_t * | packet, |
uint16_t * | packet_len, | ||
sn_nsdl_addr_s * | src | ||
) |
Currently HTTP is not supported.
- Returns:
- -1 Failure
uint8_t sn_nsdl_register_endpoint | ( | sn_nsdl_ep_parameters_s * | endpoint_info_ptr ) |
Registers endpoint to NSP server.
- Parameters:
-
*endpoint_info_ptr Contains endpoint information.
- Returns:
- 0 Success
- -1 Failure
int8_t sn_nsdl_send_coap_message | ( | sn_nsdl_addr_s * | address_ptr, |
sn_coap_hdr_s * | coap_hdr_ptr | ||
) |
Send an outgoing CoAP request.
- Parameters:
-
*address_ptr Pointer to source address struct *coap_hdr_ptr Pointer to CoAP message to be sent
- Returns:
- 0 Success
- -1 Failure
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 | ||
) |
Sends observation message to NSP server.
- Parameters:
-
*token_ptr Pointer to token to be used token_len Token length *payload_ptr Pointer to payload to be sent payload_len Payload length *observe_ptr Pointer to observe number to be sent observe_len Observe number len message_type Observation message type (confirmable or non-confirmable) contetnt_type Observation message payload contetnt type
- Returns:
- !0 Success, observation messages message ID
- 0 Failure
int8_t sn_nsdl_unregister_endpoint | ( | void | ) |
Sends unregister-message to NSP server.
- Returns:
- 0 Success
- -1 Failure
int8_t sn_nsdl_update_registration | ( | sn_nsdl_ep_parameters_s * | endpoint_parameters_ptr ) |
Update the registration with NSP.
- Parameters:
-
*endpoint_info_ptr Contains endpoint information.
- Returns:
- 0 Success
- -1 Failure
int8_t sn_nsdl_update_resource | ( | sn_nsdl_resource_info_s * | res ) |
Resource updating function.
Used to update the direct value of a static resource, the callback function pointer of a dynamic resource and access rights of the recource.
- Parameters:
-
*res Pointer to a structure of type sn_nsdl_resource_info_t that contains the information about the resource. Only the pathlen and path elements are evaluated along with either resourcelen and resource or the function pointer.
- Returns:
- 0 Success
- -1 Failure
Generated on Tue Jul 12 2022 18:09:19 by 1.7.2