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_grs2.h
00001 /* 00002 * Copyright (c) 2011-2015 ARM Limited. All rights reserved. 00003 * SPDX-License-Identifier: Apache-2.0 00004 * Licensed under the Apache License, Version 2.0 (the License); you may 00005 * not use this file except in compliance with the License. 00006 * You may obtain a copy of the License at 00007 * 00008 * http://www.apache.org/licenses/LICENSE-2.0 00009 * 00010 * Unless required by applicable law or agreed to in writing, software 00011 * distributed under the License is distributed on an AS IS BASIS, WITHOUT 00012 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 00013 * See the License for the specific language governing permissions and 00014 * limitations under the License. 00015 */ 00016 #ifndef GRS_2_H_ 00017 #define GRS_2_H_ 00018 00019 #ifdef MBED_CLIENT_C_NEW_API 00020 00021 #ifdef __cplusplus 00022 extern "C" { 00023 #endif 00024 00025 00026 #define SN_GRS_RESOURCE_ALREADY_EXISTS -2 00027 #define SN_GRS_INVALID_PATH -3 00028 #define SN_GRS_LIST_ADDING_FAILURE -4 00029 #define SN_GRS_RESOURCE_UPDATED -5 00030 00031 #define ACCESS_DENIED -6 00032 00033 #define SN_GRS_DELETE_METHOD 0 00034 #define SN_GRS_SEARCH_METHOD 1 00035 00036 #define SN_GRS_DEFAULT_ACCESS 0x0F 00037 00038 #define SN_NDSL_RESOURCE_NOT_REGISTERED 0 00039 #define SN_NDSL_RESOURCE_REGISTERING 1 00040 #define SN_NDSL_RESOURCE_REGISTERED 2 00041 00042 /***** Structs *****/ 00043 00044 typedef struct sn_grs_version_ { 00045 uint8_t major_version; 00046 uint8_t minor_version; 00047 uint8_t build; 00048 } sn_grs_version_s; 00049 00050 typedef NS_LIST_HEAD(sn_nsdl_dynamic_resource_parameters_s, link) resource_list_t; 00051 00052 struct grs_s { 00053 struct coap_s *coap; 00054 00055 void *(*sn_grs_alloc)(uint16_t); 00056 void (*sn_grs_free)(void *); 00057 uint8_t (*sn_grs_tx_callback)(struct nsdl_s *, sn_nsdl_capab_e , uint8_t *, uint16_t, sn_nsdl_addr_s *); 00058 int8_t (*sn_grs_rx_callback)(struct nsdl_s *, sn_coap_hdr_s *, sn_nsdl_addr_s *); 00059 00060 uint16_t resource_root_count; 00061 resource_list_t resource_root_list; 00062 }; 00063 00064 00065 struct nsdl_s { 00066 uint16_t update_register_msg_id; 00067 uint16_t register_msg_len; 00068 uint16_t update_register_msg_len; 00069 00070 uint16_t register_msg_id; 00071 uint16_t unregister_msg_id; 00072 00073 uint16_t bootstrap_msg_id; 00074 uint16_t oma_bs_port; /* Bootstrap port */ 00075 uint8_t oma_bs_address_len; /* Bootstrap address length */ 00076 unsigned int sn_nsdl_endpoint_registered:1; 00077 00078 struct grs_s *grs; 00079 uint8_t *oma_bs_address_ptr; /* Bootstrap address pointer. If null, no bootstrap in use */ 00080 sn_nsdl_ep_parameters_s *ep_information_ptr; // Endpoint parameters, Name, Domain etc.. 00081 sn_nsdl_oma_server_info_t *nsp_address_ptr; // NSP server address information 00082 /* Application definable context. This is useful for example when interfacing with c++ objects where a pointer to object is set as the 00083 * context, and in the callback functions the context pointer can be used to call methods for the correct instance of the c++ object. */ 00084 void *context; 00085 00086 void (*sn_nsdl_oma_bs_done_cb)(sn_nsdl_oma_server_info_t *server_info_ptr); /* Callback to inform application when bootstrap is done */ 00087 void *(*sn_nsdl_alloc)(uint16_t); 00088 void (*sn_nsdl_free)(void *); 00089 uint8_t (*sn_nsdl_tx_callback)(struct nsdl_s *, sn_nsdl_capab_e , uint8_t *, uint16_t, sn_nsdl_addr_s *); 00090 uint8_t (*sn_nsdl_rx_callback)(struct nsdl_s *, sn_coap_hdr_s *, sn_nsdl_addr_s *); 00091 void (*sn_nsdl_oma_bs_done_cb_handle)(sn_nsdl_oma_server_info_t *server_info_ptr, 00092 struct nsdl_s *handle); /* Callback to inform application when bootstrap is done with nsdl handle */ 00093 }; 00094 00095 /***** Function prototypes *****/ 00096 /** 00097 * \fn extern grs_s *sn_grs_init (uint8_t (*sn_grs_tx_callback_ptr)(sn_nsdl_capab_e , uint8_t *, uint16_t, 00098 * sn_nsdl_addr_s *), uint8_t (*sn_grs_rx_callback_ptr)(sn_coap_hdr_s *, sn_nsdl_addr_s *), 00099 * sn_grs_mem_s *sn_memory) 00100 * 00101 * \brief GRS library initialize function. 00102 * 00103 * This function initializes GRS and CoAP. 00104 * 00105 * \param sn_grs_tx_callback A function pointer to a transmit callback function. Should return 1 when succeed, 0 when failed 00106 * \param *sn_grs_rx_callback_ptr A function pointer to a receiving callback function. If received packet is not for GRS, it will be passed to 00107 * upper level (NSDL) to be proceed. 00108 * \param sn_memory A pointer to a structure containing the platform specific functions for memory allocation and free. 00109 * 00110 * \return success pointer to handle, failure = NULL 00111 * 00112 */ 00113 extern struct grs_s *sn_grs_init(uint8_t (*sn_grs_tx_callback_ptr)(struct nsdl_s *, sn_nsdl_capab_e , uint8_t *, uint16_t, 00114 sn_nsdl_addr_s *), 00115 int8_t (*sn_grs_rx_callback_ptr)(struct nsdl_s *, sn_coap_hdr_s *, sn_nsdl_addr_s *), 00116 void *(*sn_grs_alloc)(uint16_t), 00117 void (*sn_grs_free)(void *)); 00118 00119 extern sn_nsdl_dynamic_resource_parameters_s *sn_grs_get_first_resource(struct grs_s *handle); 00120 extern sn_nsdl_dynamic_resource_parameters_s *sn_grs_get_next_resource(struct grs_s *handle, 00121 const sn_nsdl_dynamic_resource_parameters_s *sn_grs_current_resource); 00122 extern int8_t sn_grs_process_coap(struct nsdl_s *handle, 00123 sn_coap_hdr_s *coap_packet_ptr, 00124 sn_nsdl_addr_s *src); 00125 extern sn_nsdl_dynamic_resource_parameters_s *sn_grs_search_resource(struct grs_s *handle, 00126 uint16_t pathlen, 00127 uint8_t *path, 00128 uint8_t search_method); 00129 extern int8_t sn_grs_destroy(struct grs_s *handle); 00130 extern sn_grs_resource_list_s *sn_grs_list_resource(struct grs_s *handle, uint16_t pathlen, uint8_t *path); 00131 extern void sn_grs_free_resource_list(struct grs_s *handle, sn_grs_resource_list_s *list); 00132 extern int8_t sn_grs_send_coap_message(struct nsdl_s *handle, 00133 sn_nsdl_addr_s *address_ptr, 00134 sn_coap_hdr_s *coap_hdr_ptr); 00135 extern int8_t sn_grs_put_resource(struct grs_s *handle, sn_nsdl_dynamic_resource_parameters_s *res); 00136 extern int8_t sn_grs_pop_resource(struct grs_s *handle, sn_nsdl_dynamic_resource_parameters_s *res); 00137 extern int8_t sn_grs_delete_resource(struct grs_s *handle, uint16_t pathlen, uint8_t *path); 00138 extern void sn_grs_mark_resources_as_registered(struct nsdl_s *handle); 00139 #ifndef MEMORY_OPTIMIZED_API 00140 extern int8_t sn_grs_create_resource(struct grs_s *handle, sn_nsdl_dynamic_resource_parameters_s *res); 00141 extern int8_t sn_grs_update_resource(struct grs_s *handle, sn_nsdl_dynamic_resource_parameters_s *res); 00142 #endif 00143 00144 #ifdef __cplusplus 00145 } 00146 #endif 00147 00148 #endif /* MBED_CLIENT_C_NEW_API */ 00149 00150 #endif /* GRS_H_ */
Generated on Tue Jul 12 2022 11:02:51 by
