Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependents: mbed-TFT-example-NCS36510 mbed-Accelerometer-example-NCS36510 mbed-Accelerometer-example-NCS36510
sn_nsdl2.c File Reference
Nano service device library. More...
Go to the source code of this file.
Functions | |
| static uint16_t | sn_nsdl_internal_coap_send (struct nsdl_s *handle, sn_coap_hdr_s *coap_header_ptr, sn_nsdl_addr_s *dst_addr_ptr, uint8_t message_description) |
| To send NSDL messages. | |
| static void | sn_nsdl_resolve_nsp_address (struct nsdl_s *handle) |
| Resolves NSP server address. | |
| int8_t | sn_nsdl_build_registration_body (struct nsdl_s *handle, sn_coap_hdr_s *message_ptr, uint8_t updating_registeration) |
| To build GRS resources to registration message payload. | |
| static uint16_t | sn_nsdl_calculate_registration_body_size (struct nsdl_s *handle, uint8_t updating_registeration, int8_t *error) |
| Calculates registration message payload size. | |
| static uint8_t | sn_nsdl_calculate_uri_query_option_len (sn_nsdl_ep_parameters_s *endpoint_info_ptr, uint8_t msg_type) |
| Calculates needed uri query option length. | |
| static int8_t | sn_nsdl_fill_uri_query_options (struct nsdl_s *handle, sn_nsdl_ep_parameters_s *parameter_ptr, sn_coap_hdr_s *source_msg_ptr, uint8_t msg_type) |
| Fills uri-query options to message header struct. | |
| static int8_t | sn_nsdl_local_rx_function (struct nsdl_s *handle, sn_coap_hdr_s *coap_packet_ptr, sn_nsdl_addr_s *address_ptr) |
| If received message is reply for the message that NSDL has been sent, it is processed here. | |
| static int8_t | sn_nsdl_resolve_ep_information (struct nsdl_s *handle, sn_coap_hdr_s *coap_packet_ptr) |
| Resolves endpoint information from received CoAP message. | |
| int8_t | sn_nsdl_destroy (struct nsdl_s *handle) |
| This function releases all allocated memory in mbed Device C Client library. | |
| uint16_t | sn_nsdl_register_endpoint (struct nsdl_s *handle, sn_nsdl_ep_parameters_s *endpoint_info_ptr) |
| Registers endpoint to mbed Device Server. | |
| uint16_t | sn_nsdl_unregister_endpoint (struct nsdl_s *handle) |
| Sends unregister-message to mbed Device Server. | |
| uint16_t | sn_nsdl_update_registration (struct nsdl_s *handle, uint8_t *lt_ptr, uint8_t lt_len) |
| Update the registration with mbed Device Server. | |
| int8_t | sn_nsdl_set_endpoint_location (struct nsdl_s *handle, uint8_t *location_ptr, uint8_t location_len) |
| Sets the location receievd from Device Server. | |
| void | sn_nsdl_nsp_lost (struct nsdl_s *handle) |
| A function to inform mbed Device C client library if application detects a fault in mbed Device Server registration. | |
| int8_t | sn_nsdl_is_ep_registered (struct nsdl_s *handle) |
| Checks if endpoint is registered. | |
| uint16_t | sn_nsdl_send_observation_notification (struct nsdl_s *handle, uint8_t *token_ptr, uint8_t token_len, uint8_t *payload_ptr, uint16_t payload_len, sn_coap_observe_e observe, sn_coap_msg_type_e message_type, sn_coap_content_format_e content_format) |
| Sends observation message to mbed Device Server. | |
| uint16_t | sn_nsdl_oma_bootstrap (struct nsdl_s *handle, sn_nsdl_addr_s *bootstrap_address_ptr, sn_nsdl_ep_parameters_s *endpoint_info_ptr, sn_nsdl_bs_ep_info_t *bootstrap_endpoint_info_ptr) |
| Starts OMA bootstrap process. | |
| char * | sn_nsdl_get_version (void) |
| Version query function. | |
| int8_t | sn_nsdl_process_coap (struct nsdl_s *handle, uint8_t *packet_ptr, uint16_t packet_len, sn_nsdl_addr_s *src_ptr) |
| To push CoAP packet to mbed Device C Client library. | |
| int8_t | sn_nsdl_exec (struct nsdl_s *handle, uint32_t time) |
| CoAP retransmission function. | |
| sn_nsdl_dynamic_resource_parameters_s * | sn_nsdl_get_resource (struct nsdl_s *handle, uint16_t pathlen, uint8_t *path_ptr) |
| Resource get function. | |
| int8_t | set_NSP_address (struct nsdl_s *handle, uint8_t *NSP_address, uint8_t address_length, uint16_t port, sn_nsdl_addr_type_e address_type) |
| This function is used to set the mbed Device Server address given by an application. | |
| sn_grs_resource_list_s * | sn_nsdl_list_resource (struct nsdl_s *handle, uint16_t pathlen, uint8_t *path) |
| Resource list function. | |
| void | sn_nsdl_free_resource_list (struct nsdl_s *handle, sn_grs_resource_list_s *list) |
| Free a resource list obtained from sn_nsdl_list_resource() | |
| int8_t | sn_nsdl_update_resource (struct nsdl_s *handle, sn_nsdl_dynamic_resource_parameters_s *res) |
| Resource updating function. | |
| int8_t | sn_nsdl_send_coap_message (struct nsdl_s *handle, sn_nsdl_addr_s *address_ptr, sn_coap_hdr_s *coap_hdr_ptr) |
| Send an outgoing CoAP request. | |
| sn_coap_hdr_s * | sn_nsdl_build_response (struct nsdl_s *handle, sn_coap_hdr_s *coap_packet_ptr, uint8_t msg_code) |
| Prepares generic response packet from a request packet. | |
| sn_coap_options_list_s * | sn_nsdl_alloc_options_list (struct nsdl_s *handle, sn_coap_hdr_s *coap_msg_ptr) |
| Allocates and initializes options list structure. | |
| void | sn_nsdl_release_allocated_coap_msg_mem (struct nsdl_s *handle, sn_coap_hdr_s *freed_coap_msg_ptr) |
| Releases memory of given CoAP message. | |
| int8_t | sn_nsdl_set_retransmission_parameters (struct nsdl_s *handle, uint8_t resending_count, uint8_t resending_interval) |
| If re-transmissions are enabled, this function changes resending count and interval. | |
| int8_t | sn_nsdl_set_retransmission_buffer (struct nsdl_s *handle, uint8_t buffer_size_messages, uint16_t buffer_size_bytes) |
| If re-transmissions are enabled, this function changes message retransmission queue size. | |
| int8_t | sn_nsdl_set_block_size (struct nsdl_s *handle, uint16_t block_size) |
| If block transfer is enabled, this function changes the block size. | |
| int8_t | sn_nsdl_set_duplicate_buffer_size (struct nsdl_s *handle, uint8_t message_count) |
| If dublicate message detection is enabled, this function changes buffer size. | |
| void * | sn_nsdl_get_context (const struct nsdl_s *const handle) |
| Get the application defined context parameter for given handle. | |
Detailed Description
Nano service device library.
Definition in file sn_nsdl2.c.
Function Documentation
| int8_t set_NSP_address | ( | struct nsdl_s * | handle, |
| uint8_t * | NSP_address, | ||
| uint8_t | address_length, | ||
| uint16_t | port, | ||
| sn_nsdl_addr_type_e | address_type | ||
| ) |
This function is used to set the mbed Device Server address given by an application.
- Parameters:
-
*handle Pointer to nsdl-library handle
- Returns:
- 0 Success
- -1 Failed to indicate that internal address pointer is not allocated (call nsdl_init() first).
Definition at line 1446 of file sn_nsdl2.c.
| sn_coap_options_list_s* sn_nsdl_alloc_options_list | ( | struct nsdl_s * | handle, |
| sn_coap_hdr_s * | coap_msg_ptr | ||
| ) |
Allocates and initializes options list structure.
- Parameters:
-
*handle Pointer to library handle *coap_msg_ptr is pointer to CoAP message that will contain the options
If the message already has a pointer to an option structure, that pointer is returned, rather than a new structure being allocated.
- Returns:
- Return value is pointer to the CoAP options structure.
In following failure cases NULL is returned:
-Failure in given pointer (= NULL)
-Failure in memory allocation (malloc() returns NULL)
Definition at line 1674 of file sn_nsdl2.c.
| int8_t sn_nsdl_build_registration_body | ( | struct nsdl_s * | handle, |
| sn_coap_hdr_s * | message_ptr, | ||
| uint8_t | updating_registeration | ||
| ) |
| sn_coap_hdr_s* sn_nsdl_build_response | ( | struct nsdl_s * | handle, |
| sn_coap_hdr_s * | coap_packet_ptr, | ||
| uint8_t | msg_code | ||
| ) |
Prepares generic response packet from a request packet.
This function allocates memory for the resulting sn_coap_hdr_s
- Parameters:
-
*handle Pointer to library handle *coap_packet_ptr The request packet pointer msg_code response messages code
- Returns:
- *coap_packet_ptr The allocated and pre-filled response packet pointer NULL Error in parsing the request
Definition at line 1665 of file sn_nsdl2.c.
| static uint16_t sn_nsdl_calculate_registration_body_size | ( | struct nsdl_s * | handle, |
| uint8_t | updating_registeration, | ||
| int8_t * | error | ||
| ) | [static] |
Calculates registration message payload size.
- Parameters:
-
*handle Pointer to nsdl-library handle *updating_registeration Pointer to list of GRS resources *error Error code, SN_NSDL_SUCCESS or SN_NSDL_FAILURE
- Returns:
- Needed payload size
Definition at line 989 of file sn_nsdl2.c.
| static uint8_t sn_nsdl_calculate_uri_query_option_len | ( | sn_nsdl_ep_parameters_s * | endpoint_info_ptr, |
| uint8_t | msg_type | ||
| ) | [static] |
Calculates needed uri query option length.
- Parameters:
-
*endpoint_info_ptr Pointer to endpoint info structure msg_type Message type
- Returns:
- number of parameters in uri query
Definition at line 1101 of file sn_nsdl2.c.
| int8_t sn_nsdl_destroy | ( | struct nsdl_s * | handle ) |
This function releases all allocated memory in mbed Device C Client library.
- Parameters:
-
*handle Pointer to nsdl-library handle
Definition at line 107 of file sn_nsdl2.c.
| int8_t sn_nsdl_exec | ( | struct nsdl_s * | handle, |
| uint32_t | time | ||
| ) |
CoAP retransmission function.
Used to give execution time for the mbed Device C Client library for retransmissions.
- Parameters:
-
*handle Pointer to nsdl-library handle time Time in seconds.
- Returns:
- 0 Success
- -1 Failure
Definition at line 741 of file sn_nsdl2.c.
| static int8_t sn_nsdl_fill_uri_query_options | ( | struct nsdl_s * | handle, |
| sn_nsdl_ep_parameters_s * | parameter_ptr, | ||
| sn_coap_hdr_s * | source_msg_ptr, | ||
| uint8_t | msg_type | ||
| ) | [static] |
Fills uri-query options to message header struct.
- Parameters:
-
*handle Pointer to nsdl-library handle *parameter_ptr Pointer to endpoint parameters struct *source_msg_ptr Pointer to CoAP header struct msg_type Message type
- Returns:
- SN_NSDL_SUCCESS = 0, Failed = -1
Definition at line 1166 of file sn_nsdl2.c.
| void sn_nsdl_free_resource_list | ( | struct nsdl_s * | handle, |
| sn_grs_resource_list_s * | list | ||
| ) |
Free a resource list obtained from sn_nsdl_list_resource()
- Parameters:
-
list The list to free, or NULL.
Definition at line 1577 of file sn_nsdl2.c.
| void* sn_nsdl_get_context | ( | const struct nsdl_s *const | handle ) |
Get the application defined context parameter for given handle.
This is useful for example when interfacing with c++ objects where a pointer to object is set as the context, and in the callback functions the context pointer can be used to call methods for the correct instance of the c++ object.
- Parameters:
-
*handle Pointer to library handle
- Returns:
- Pointer to the application defined context
Definition at line 1751 of file sn_nsdl2.c.
| sn_nsdl_dynamic_resource_parameters_s* sn_nsdl_get_resource | ( | struct nsdl_s * | handle, |
| uint16_t | pathlen, | ||
| uint8_t * | path_ptr | ||
| ) |
Resource get function.
Used to get a resource.
- Parameters:
-
*handle Pointer to nsdl-library handle 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
Used to get a resource.
- Parameters:
-
*handle Pointer to nsdl-library handle 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_dynamic_resource_parameters_s that contains the resource information
- NULL Failure
Definition at line 750 of file sn_nsdl2.c.
| char* sn_nsdl_get_version | ( | void | ) |
Version query function.
Used to retrieve the version information from the mbed Device C Client library.
- Returns:
- Pointer to library version string
Definition at line 640 of file sn_nsdl2.c.
| static uint16_t sn_nsdl_internal_coap_send | ( | struct nsdl_s * | handle, |
| sn_coap_hdr_s * | coap_header_ptr, | ||
| sn_nsdl_addr_s * | dst_addr_ptr, | ||
| uint8_t | message_description | ||
| ) | [static] |
To send NSDL messages.
Stores message id?s and message description to catch response from NSP server
- Parameters:
-
*handle Pointer to nsdl-library handle *coap_header_ptr Pointer to the CoAP message header to be sent *dst_addr_ptr Pointer to the address structure that contains destination address information message_description Message description to be stored to list for waiting response
- Returns:
- message id, 0 if failed
Definition at line 773 of file sn_nsdl2.c.
| int8_t sn_nsdl_is_ep_registered | ( | struct nsdl_s * | handle ) |
Checks if endpoint is registered.
- Parameters:
-
*handle Pointer to nsdl-library handle
Definition at line 499 of file sn_nsdl2.c.
| sn_grs_resource_list_s* sn_nsdl_list_resource | ( | struct nsdl_s * | handle, |
| uint16_t | pathlen, | ||
| uint8_t * | path | ||
| ) |
Resource list function.
- Parameters:
-
*handle Pointer to nsdl-library handle 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
Definition at line 1567 of file sn_nsdl2.c.
| static int8_t sn_nsdl_local_rx_function | ( | struct nsdl_s * | handle, |
| sn_coap_hdr_s * | coap_packet_ptr, | ||
| sn_nsdl_addr_s * | address_ptr | ||
| ) | [static] |
If received message is reply for the message that NSDL has been sent, it is processed here.
Else, packet will be sent to application.
- Parameters:
-
*handle Pointer to nsdl-library handle *coap_packet_ptr Pointer to received CoAP packet *address_ptr Pointer to source address struct
- Returns:
- SN_NSDL_SUCCESS = 0, Failed = -1
Definition at line 1316 of file sn_nsdl2.c.
| void sn_nsdl_nsp_lost | ( | struct nsdl_s * | handle ) |
A function to inform mbed Device C client library if application detects a fault in mbed Device Server registration.
- Parameters:
-
*handle Pointer to nsdl-library handle
After calling this function sn_nsdl_is_ep_registered() will return "not registered".
Definition at line 489 of file sn_nsdl2.c.
| uint16_t sn_nsdl_oma_bootstrap | ( | struct nsdl_s * | handle, |
| sn_nsdl_addr_s * | bootstrap_address_ptr, | ||
| sn_nsdl_ep_parameters_s * | endpoint_info_ptr, | ||
| sn_nsdl_bs_ep_info_t * | bootstrap_endpoint_info_ptr | ||
| ) |
Starts OMA bootstrap process.
- Parameters:
-
*handle Pointer to nsdl-library handle
- Returns:
- bootstrap message ID, 0 if failed
Definition at line 571 of file sn_nsdl2.c.
| int8_t sn_nsdl_process_coap | ( | struct nsdl_s * | handle, |
| uint8_t * | packet_ptr, | ||
| uint16_t | packet_len, | ||
| sn_nsdl_addr_s * | src_ptr | ||
| ) |
To push CoAP packet to mbed Device C Client library.
Used to push an CoAP packet to mbed Device C Client library for processing.
- Parameters:
-
*handle Pointer to nsdl-library handle *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
Definition at line 651 of file sn_nsdl2.c.
| uint16_t sn_nsdl_register_endpoint | ( | struct nsdl_s * | handle, |
| sn_nsdl_ep_parameters_s * | endpoint_info_ptr | ||
| ) |
Registers endpoint to mbed Device Server.
- Parameters:
-
*handle Pointer to nsdl-library handle *endpoint_info_ptr Contains endpoint information.
- Returns:
- registration message ID, 0 if failed
Definition at line 223 of file sn_nsdl2.c.
| void sn_nsdl_release_allocated_coap_msg_mem | ( | struct nsdl_s * | handle, |
| sn_coap_hdr_s * | freed_coap_msg_ptr | ||
| ) |
Releases memory of given CoAP message.
Note!!! Does not release Payload part
- Parameters:
-
*handle Pointer to library handle *freed_coap_msg_ptr is pointer to released CoAP message
Definition at line 1682 of file sn_nsdl2.c.
| static int8_t sn_nsdl_resolve_ep_information | ( | struct nsdl_s * | handle, |
| sn_coap_hdr_s * | coap_packet_ptr | ||
| ) | [static] |
Resolves endpoint information from received CoAP message.
- Parameters:
-
*handle Pointer to nsdl-library handle *coap_packet_ptr Pointer to received CoAP message
- Returns:
- SN_NSDL_SUCCESS = 0, Failed = -1
Definition at line 1390 of file sn_nsdl2.c.
| static void sn_nsdl_resolve_nsp_address | ( | struct nsdl_s * | handle ) | [static] |
Resolves NSP server address.
- Parameters:
-
*handle Pointer to nsdl-library handle
- Note:
- Application must set NSP address with set_nsp_address
Definition at line 838 of file sn_nsdl2.c.
| int8_t sn_nsdl_send_coap_message | ( | struct nsdl_s * | handle, |
| sn_nsdl_addr_s * | address_ptr, | ||
| sn_coap_hdr_s * | coap_hdr_ptr | ||
| ) |
Send an outgoing CoAP request.
- Parameters:
-
*handle Pointer to nsdl-library handle *address_ptr Pointer to source address struct *coap_hdr_ptr Pointer to CoAP message to be sent
- Returns:
- 0 Success
- -1 Failure
Definition at line 1609 of file sn_nsdl2.c.
| uint16_t sn_nsdl_send_observation_notification | ( | struct nsdl_s * | handle, |
| uint8_t * | token_ptr, | ||
| uint8_t | token_len, | ||
| uint8_t * | payload_ptr, | ||
| uint16_t | payload_len, | ||
| sn_coap_observe_e | observe, | ||
| sn_coap_msg_type_e | message_type, | ||
| sn_coap_content_format_e | content_format | ||
| ) |
Sends observation message to mbed Device Server.
- Parameters:
-
*handle Pointer to nsdl-library handle *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 Observe option value to be sent message_type Observation message type (confirmable or non-confirmable) content_format Observation message payload content format
- Returns:
- !0 Success, observation messages message ID
- 0 Failure
Definition at line 509 of file sn_nsdl2.c.
| int8_t sn_nsdl_set_block_size | ( | struct nsdl_s * | handle, |
| uint16_t | block_size | ||
| ) |
If block transfer is enabled, this function changes the block size.
- Parameters:
-
*handle Pointer to library handle uint16_t block_size maximum size of CoAP payload. Valid sizes are 16, 32, 64, 128, 256, 512 and 1024 bytes
- Returns:
- 0 = success, -1 = failure
Definition at line 1711 of file sn_nsdl2.c.
| int8_t sn_nsdl_set_duplicate_buffer_size | ( | struct nsdl_s * | handle, |
| uint8_t | message_count | ||
| ) |
If dublicate message detection is enabled, this function changes buffer size.
- Parameters:
-
*handle Pointer to library handle uint8_t message_count max number of messages saved for duplicate control
- Returns:
- 0 = success, -1 = failure
Definition at line 1719 of file sn_nsdl2.c.
| int8_t sn_nsdl_set_endpoint_location | ( | struct nsdl_s * | handle, |
| uint8_t * | location_ptr, | ||
| uint8_t | location_len | ||
| ) |
Sets the location receievd from Device Server.
- Parameters:
-
*handle Pointer to nsdl-library handle *lt_ptr Pointer to location value string , eg. "s322j4k" lt_len Length of the location string
- Returns:
- success, 0 if failed -1
Definition at line 475 of file sn_nsdl2.c.
| int8_t sn_nsdl_set_retransmission_buffer | ( | struct nsdl_s * | handle, |
| uint8_t | buffer_size_messages, | ||
| uint16_t | buffer_size_bytes | ||
| ) |
If re-transmissions are enabled, this function changes message retransmission queue size.
Set size to '0' to disable feature. If both are set to '0', then re-sendings are disabled.
- Parameters:
-
*handle Pointer to library handle uint8_t buffer_size_messages queue size - maximum number of messages to be saved to queue uint8_t buffer_size_bytes queue size - maximum size of messages saved to queue
- Returns:
- 0 = success, -1 = failure
Definition at line 1701 of file sn_nsdl2.c.
| int8_t sn_nsdl_set_retransmission_parameters | ( | struct nsdl_s * | handle, |
| uint8_t | resending_count, | ||
| uint8_t | resending_interval | ||
| ) |
If re-transmissions are enabled, this function changes resending count and interval.
- Parameters:
-
*handle Pointer to library handle uint8_t resending_count max number of resendings for message uint8_t resending_intervall message resending intervall in seconds
- Returns:
- 0 = success, -1 = failure
Definition at line 1691 of file sn_nsdl2.c.
| uint16_t sn_nsdl_unregister_endpoint | ( | struct nsdl_s * | handle ) |
Sends unregister-message to mbed Device Server.
- Parameters:
-
*handle Pointer to nsdl-library handle
- Returns:
- unregistration message ID, 0 if failed
Definition at line 304 of file sn_nsdl2.c.
| uint16_t sn_nsdl_update_registration | ( | struct nsdl_s * | handle, |
| uint8_t * | lt_ptr, | ||
| uint8_t | lt_len | ||
| ) |
Update the registration with mbed Device Server.
- Parameters:
-
*handle Pointer to nsdl-library handle *lt_ptr Pointer to lifetime value string in ascii form, eg. "1200" lt_len Length of the lifetime string
- Returns:
- registration update message ID, 0 if failed
Definition at line 374 of file sn_nsdl2.c.
| int8_t sn_nsdl_update_resource | ( | struct nsdl_s * | handle, |
| sn_nsdl_dynamic_resource_parameters_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:
-
*handle Pointer to nsdl-library handle *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
Definition at line 1588 of file sn_nsdl2.c.
Generated on Tue Jul 12 2022 11:03:05 by
1.7.2