This is an example of BLE GATT Client, which receives broadcast data from BLE_Server_BME280 ( a GATT server) , then transfers values up to mbed Device Connector (cloud).

Please refer details about BLEClient_mbedDevConn below. https://github.com/soramame21/BLEClient_mbedDevConn

The location of required BLE GATT server, BLE_Server_BME280, is at here. https://developer.mbed.org/users/edamame22/code/BLE_Server_BME280/

Committer:
Ren Boting
Date:
Tue Sep 05 11:56:13 2017 +0900
Revision:
2:b894b3508057
Parent:
0:29983394c6b6
Update all libraries and reform main.cpp

Who changed what in which revision?

UserRevisionLine numberNew contents of line
edamame22 0:29983394c6b6 1 /*
edamame22 0:29983394c6b6 2 * Copyright (c) 2015 ARM Limited. All rights reserved.
edamame22 0:29983394c6b6 3 * SPDX-License-Identifier: Apache-2.0
edamame22 0:29983394c6b6 4 * Licensed under the Apache License, Version 2.0 (the License); you may
edamame22 0:29983394c6b6 5 * not use this file except in compliance with the License.
edamame22 0:29983394c6b6 6 * You may obtain a copy of the License at
edamame22 0:29983394c6b6 7 *
edamame22 0:29983394c6b6 8 * http://www.apache.org/licenses/LICENSE-2.0
edamame22 0:29983394c6b6 9 *
edamame22 0:29983394c6b6 10 * Unless required by applicable law or agreed to in writing, software
edamame22 0:29983394c6b6 11 * distributed under the License is distributed on an AS IS BASIS, WITHOUT
edamame22 0:29983394c6b6 12 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
edamame22 0:29983394c6b6 13 * See the License for the specific language governing permissions and
edamame22 0:29983394c6b6 14 * limitations under the License.
edamame22 0:29983394c6b6 15 */
edamame22 0:29983394c6b6 16 #ifndef M2MNSDLINTERFACE_H
edamame22 0:29983394c6b6 17 #define M2MNSDLINTERFACE_H
edamame22 0:29983394c6b6 18
edamame22 0:29983394c6b6 19 #include "mbed-client/m2mvector.h"
edamame22 0:29983394c6b6 20 #include "mbed-client/m2mconfig.h"
edamame22 0:29983394c6b6 21 #include "mbed-client/m2minterface.h"
edamame22 0:29983394c6b6 22 #include "mbed-client/m2mtimerobserver.h"
edamame22 0:29983394c6b6 23 #include "mbed-client/m2mobservationhandler.h"
edamame22 0:29983394c6b6 24 #include "mbed-client/m2mbase.h"
edamame22 0:29983394c6b6 25 #include "mbed-client/m2mserver.h"
edamame22 0:29983394c6b6 26 #include "include/nsdllinker.h"
edamame22 0:29983394c6b6 27
edamame22 0:29983394c6b6 28 //FORWARD DECLARARTION
edamame22 0:29983394c6b6 29 class M2MSecurity;
edamame22 0:29983394c6b6 30 class M2MObject;
edamame22 0:29983394c6b6 31 class M2MObjectInstance;
edamame22 0:29983394c6b6 32 class M2MResource;
edamame22 0:29983394c6b6 33 class M2MResourceInstance;
edamame22 0:29983394c6b6 34 class M2MNsdlObserver;
edamame22 0:29983394c6b6 35 class M2MServer;
edamame22 0:29983394c6b6 36 class M2MTimer;
edamame22 0:29983394c6b6 37
edamame22 0:29983394c6b6 38 typedef Vector<M2MObject *> M2MObjectList;
edamame22 0:29983394c6b6 39
edamame22 0:29983394c6b6 40 /**
edamame22 0:29983394c6b6 41 * @brief M2MNsdlInterface
edamame22 0:29983394c6b6 42 * Class which interacts between mbed Client C++ Library and mbed-client-c library.
edamame22 0:29983394c6b6 43 */
edamame22 0:29983394c6b6 44 class M2MNsdlInterface : public M2MTimerObserver,
edamame22 0:29983394c6b6 45 public M2MObservationHandler
edamame22 0:29983394c6b6 46 {
edamame22 0:29983394c6b6 47 private:
edamame22 0:29983394c6b6 48 // Prevents the use of assignment operator by accident.
edamame22 0:29983394c6b6 49 M2MNsdlInterface& operator=( const M2MNsdlInterface& /*other*/ );
edamame22 0:29983394c6b6 50
edamame22 0:29983394c6b6 51 // Prevents the use of copy constructor by accident
edamame22 0:29983394c6b6 52 M2MNsdlInterface( const M2MNsdlInterface& /*other*/ );
edamame22 0:29983394c6b6 53
edamame22 0:29983394c6b6 54 public:
edamame22 0:29983394c6b6 55 /**
edamame22 0:29983394c6b6 56 * @brief Constructor
edamame22 0:29983394c6b6 57 * @param observer, Observer to pass the event callbacks from nsdl library.
edamame22 0:29983394c6b6 58 */
edamame22 0:29983394c6b6 59 M2MNsdlInterface(M2MNsdlObserver &observer);
edamame22 0:29983394c6b6 60
edamame22 0:29983394c6b6 61 /**
edamame22 0:29983394c6b6 62 * @brief Destructor
edamame22 0:29983394c6b6 63 */
edamame22 0:29983394c6b6 64 virtual ~M2MNsdlInterface();
edamame22 0:29983394c6b6 65
edamame22 0:29983394c6b6 66 /**
edamame22 0:29983394c6b6 67 * @brief Creates endpoint object for the nsdl stack.
edamame22 0:29983394c6b6 68 * @param endpoint_name, Endpoint name of the client.
edamame22 0:29983394c6b6 69 * @param endpoint_type, Endpoint type of the client.
edamame22 0:29983394c6b6 70 * @param life_time, Life time of the client in seconds
edamame22 0:29983394c6b6 71 * @param domain, Domain of the client.
edamame22 0:29983394c6b6 72 * @param mode, Binding mode of the client, default is UDP
edamame22 0:29983394c6b6 73 * @param context_address, Context address default is empty.
edamame22 0:29983394c6b6 74 */
edamame22 0:29983394c6b6 75 void create_endpoint(const String &endpoint_name,
edamame22 0:29983394c6b6 76 const String &endpoint_type,
edamame22 0:29983394c6b6 77 const int32_t life_time,
edamame22 0:29983394c6b6 78 const String &domain,
edamame22 0:29983394c6b6 79 const uint8_t mode,
edamame22 0:29983394c6b6 80 const String &context_address);
edamame22 0:29983394c6b6 81
edamame22 0:29983394c6b6 82 /**
edamame22 0:29983394c6b6 83 * @brief Deletes the endpoint.
edamame22 0:29983394c6b6 84 */
edamame22 0:29983394c6b6 85 void delete_endpoint();
edamame22 0:29983394c6b6 86
edamame22 0:29983394c6b6 87 /**
edamame22 0:29983394c6b6 88 * @brief Creates the NSDL structure for the registered objectlist.
edamame22 0:29983394c6b6 89 * @param object_list, List of objects to be registered.
edamame22 0:29983394c6b6 90 * @return true if structure created successfully else false.
edamame22 0:29983394c6b6 91 */
edamame22 0:29983394c6b6 92 bool create_nsdl_list_structure(const M2MObjectList &object_list);
edamame22 0:29983394c6b6 93
edamame22 0:29983394c6b6 94 /**
edamame22 0:29983394c6b6 95 * @brief Removed the NSDL resource for the given resource.
edamame22 0:29983394c6b6 96 * @param base, Resource to be removed.
edamame22 0:29983394c6b6 97 * @return true if removed successfully else false.
edamame22 0:29983394c6b6 98 */
edamame22 0:29983394c6b6 99 bool remove_nsdl_resource(M2MBase *base);
edamame22 0:29983394c6b6 100
edamame22 0:29983394c6b6 101 /**
edamame22 0:29983394c6b6 102 * @brief Creates the bootstrap object.
edamame22 0:29983394c6b6 103 * @param address Bootstrap address.
edamame22 0:29983394c6b6 104 * @return true if created and sent successfully else false.
edamame22 0:29983394c6b6 105 */
edamame22 0:29983394c6b6 106 bool create_bootstrap_resource(sn_nsdl_addr_s *address, const String &bootstrap_endpoint_name);
edamame22 0:29983394c6b6 107
edamame22 0:29983394c6b6 108 /**
edamame22 0:29983394c6b6 109 * @brief Sends the register message to the server.
edamame22 0:29983394c6b6 110 * @param address M2MServer address.
edamame22 0:29983394c6b6 111 * @param address_length M2MServer address length.
edamame22 0:29983394c6b6 112 * @param port M2MServer port.
edamame22 0:29983394c6b6 113 * @param address_type IP Address type.
edamame22 0:29983394c6b6 114 * @return true if register sent successfully else false.
edamame22 0:29983394c6b6 115 */
edamame22 0:29983394c6b6 116 bool send_register_message(uint8_t* address,
edamame22 0:29983394c6b6 117 uint8_t address_length,
edamame22 0:29983394c6b6 118 const uint16_t port,
edamame22 0:29983394c6b6 119 sn_nsdl_addr_type_e address_type);
edamame22 0:29983394c6b6 120
edamame22 0:29983394c6b6 121 /**
edamame22 0:29983394c6b6 122 * @brief Sends the update registration message to the server.
edamame22 0:29983394c6b6 123 * @param lifetime, Updated lifetime value in seconds.
edamame22 0:29983394c6b6 124 * @return true if sent successfully else false.
edamame22 0:29983394c6b6 125 *
edamame22 0:29983394c6b6 126 */
edamame22 0:29983394c6b6 127 bool send_update_registration(const uint32_t lifetime = 0);
edamame22 0:29983394c6b6 128
edamame22 0:29983394c6b6 129 /**
edamame22 0:29983394c6b6 130 * @brief Sends unregister message to the server.
edamame22 0:29983394c6b6 131 * @return true if unregister sent successfully else false.
edamame22 0:29983394c6b6 132 */
edamame22 0:29983394c6b6 133 bool send_unregister_message();
edamame22 0:29983394c6b6 134
edamame22 0:29983394c6b6 135 /**
edamame22 0:29983394c6b6 136 * @brief Memory Allocation required for libCoap.
edamame22 0:29983394c6b6 137 * @param size, Size of memory to be reserved.
edamame22 0:29983394c6b6 138 */
edamame22 0:29983394c6b6 139 static void* memory_alloc(uint16_t size);
edamame22 0:29983394c6b6 140
edamame22 0:29983394c6b6 141 /**
edamame22 0:29983394c6b6 142 * @brief Memory free functions required for libCoap
edamame22 0:29983394c6b6 143 * @param ptr, Object whose memory needs to be freed.
edamame22 0:29983394c6b6 144 */
edamame22 0:29983394c6b6 145 static void memory_free(void *ptr);
edamame22 0:29983394c6b6 146
edamame22 0:29983394c6b6 147 /**
edamame22 0:29983394c6b6 148 * @brief Callback from nsdl library to inform the data is ready
edamame22 0:29983394c6b6 149 * to be sent to server.
edamame22 0:29983394c6b6 150 * @param nsdl_handle, Handler for the nsdl structure for this endpoint
edamame22 0:29983394c6b6 151 * @param protocol, Protocol format of the data
edamame22 0:29983394c6b6 152 * @param data, Data to be sent.
edamame22 0:29983394c6b6 153 * @param data_len, Size of the data to be sent
edamame22 0:29983394c6b6 154 * @param address, server address where data has to be sent.
edamame22 0:29983394c6b6 155 * @return 1 if successful else 0.
edamame22 0:29983394c6b6 156 */
edamame22 0:29983394c6b6 157 uint8_t send_to_server_callback(struct nsdl_s * nsdl_handle,
edamame22 0:29983394c6b6 158 sn_nsdl_capab_e protocol,
edamame22 0:29983394c6b6 159 uint8_t *data,
edamame22 0:29983394c6b6 160 uint16_t data_len,
edamame22 0:29983394c6b6 161 sn_nsdl_addr_s *address);
edamame22 0:29983394c6b6 162
edamame22 0:29983394c6b6 163 /**
edamame22 0:29983394c6b6 164 * @brief Callback from nsdl library to inform the data which is
edamame22 0:29983394c6b6 165 * received from server for the client has been converted to coap message.
edamame22 0:29983394c6b6 166 * @param nsdl_handle, Handler for the nsdl structure for this endpoint
edamame22 0:29983394c6b6 167 * @param coap_header, Coap message formed from data.
edamame22 0:29983394c6b6 168 * @param address, Server address from where the data is received.
edamame22 0:29983394c6b6 169 * @return 1 if successful else 0.
edamame22 0:29983394c6b6 170 */
edamame22 0:29983394c6b6 171 uint8_t received_from_server_callback(struct nsdl_s * nsdl_handle,
edamame22 0:29983394c6b6 172 sn_coap_hdr_s *coap_header,
edamame22 0:29983394c6b6 173 sn_nsdl_addr_s *address);
edamame22 0:29983394c6b6 174
edamame22 0:29983394c6b6 175 /**
edamame22 0:29983394c6b6 176 * @brief Callback from nsdl library to inform the data which is
edamame22 0:29983394c6b6 177 * received from server for the resources has been converted to coap message.
edamame22 0:29983394c6b6 178 * @param nsdl_handle, Handler for the nsdl resource structure for this endpoint..
edamame22 0:29983394c6b6 179 * @param coap_header, Coap message formed from data.
edamame22 0:29983394c6b6 180 * @param address, Server address from where the data is received.
edamame22 0:29983394c6b6 181 * @param nsdl_capab, Protocol for the message, currently only coap is supported.
edamame22 0:29983394c6b6 182 * @return 1 if successful else 0.
edamame22 0:29983394c6b6 183 */
edamame22 0:29983394c6b6 184 uint8_t resource_callback(struct nsdl_s *nsdl_handle, sn_coap_hdr_s *coap,
edamame22 0:29983394c6b6 185 sn_nsdl_addr_s *address,
edamame22 0:29983394c6b6 186 sn_nsdl_capab_e nsdl_capab);
edamame22 0:29983394c6b6 187
edamame22 0:29983394c6b6 188 /**
edamame22 0:29983394c6b6 189 * @brief Callback when there is data received from server and needs to be processed.
edamame22 0:29983394c6b6 190 * @param data, data received from server.
edamame22 0:29983394c6b6 191 * @param data_size, data size received from server.
edamame22 0:29983394c6b6 192 * @param addres, address structure of the server.
edamame22 0:29983394c6b6 193 * @return true if successfully processed else false.
edamame22 0:29983394c6b6 194 */
edamame22 0:29983394c6b6 195 bool process_received_data(uint8_t *data,
edamame22 0:29983394c6b6 196 uint16_t data_size,
edamame22 0:29983394c6b6 197 sn_nsdl_addr_s *address);
edamame22 0:29983394c6b6 198
edamame22 0:29983394c6b6 199 /**
edamame22 0:29983394c6b6 200 * @brief Stops all the timers in case there is any errors.
edamame22 0:29983394c6b6 201 */
edamame22 0:29983394c6b6 202 void stop_timers();
edamame22 0:29983394c6b6 203
edamame22 0:29983394c6b6 204 /**
edamame22 0:29983394c6b6 205 * @brief Returns nsdl handle.
edamame22 0:29983394c6b6 206 * @return ndsl handle
edamame22 0:29983394c6b6 207 */
edamame22 0:29983394c6b6 208 nsdl_s* get_nsdl_handle();
edamame22 0:29983394c6b6 209
edamame22 0:29983394c6b6 210 /**
edamame22 0:29983394c6b6 211 * @brief Get endpoint name
edamame22 0:29983394c6b6 212 * @return endpoint name
edamame22 0:29983394c6b6 213 */
edamame22 0:29983394c6b6 214 const String& endpoint_name() const;
edamame22 0:29983394c6b6 215
edamame22 0:29983394c6b6 216 protected: // from M2MTimerObserver
edamame22 0:29983394c6b6 217
edamame22 0:29983394c6b6 218 virtual void timer_expired(M2MTimerObserver::Type type);
edamame22 0:29983394c6b6 219
edamame22 0:29983394c6b6 220 protected: // from M2MObservationHandler
edamame22 0:29983394c6b6 221
edamame22 0:29983394c6b6 222 virtual void observation_to_be_sent(M2MBase *object,
edamame22 0:29983394c6b6 223 uint16_t obs_number,
edamame22 0:29983394c6b6 224 m2m::Vector<uint16_t> changed_instance_ids,
edamame22 0:29983394c6b6 225 bool send_object = false);
edamame22 0:29983394c6b6 226
edamame22 0:29983394c6b6 227 virtual void resource_to_be_deleted(M2MBase* base);
edamame22 0:29983394c6b6 228
edamame22 0:29983394c6b6 229 virtual void value_updated(M2MBase *base, const String &object_name);
edamame22 0:29983394c6b6 230
edamame22 0:29983394c6b6 231 virtual void remove_object(M2MBase *object);
edamame22 0:29983394c6b6 232
edamame22 0:29983394c6b6 233 virtual void send_delayed_response(M2MBase *base);
edamame22 0:29983394c6b6 234
edamame22 0:29983394c6b6 235 private:
edamame22 0:29983394c6b6 236
edamame22 0:29983394c6b6 237 /**
edamame22 0:29983394c6b6 238 * @brief Initializes all the nsdl library component to be usable.
edamame22 0:29983394c6b6 239 * @return true if initialization is successful else false.
edamame22 0:29983394c6b6 240 */
edamame22 0:29983394c6b6 241 bool initialize();
edamame22 0:29983394c6b6 242
edamame22 0:29983394c6b6 243 bool add_object_to_list(M2MObject *object);
edamame22 0:29983394c6b6 244
edamame22 0:29983394c6b6 245 bool create_nsdl_object_structure(M2MObject *object);
edamame22 0:29983394c6b6 246
edamame22 0:29983394c6b6 247 bool create_nsdl_object_instance_structure(M2MObjectInstance *object_instance);
edamame22 0:29983394c6b6 248
edamame22 0:29983394c6b6 249 bool create_nsdl_resource_structure(M2MResource *resource,
edamame22 0:29983394c6b6 250 bool multiple_instances = false);
edamame22 0:29983394c6b6 251
edamame22 0:29983394c6b6 252 bool create_nsdl_resource(M2MBase *base);
edamame22 0:29983394c6b6 253
edamame22 0:29983394c6b6 254 String coap_to_string(uint8_t *coap_data_ptr,
edamame22 0:29983394c6b6 255 int coap_data_ptr_length);
edamame22 0:29983394c6b6 256
edamame22 0:29983394c6b6 257 void execute_nsdl_process_loop();
edamame22 0:29983394c6b6 258
edamame22 0:29983394c6b6 259 uint64_t registration_time();
edamame22 0:29983394c6b6 260
edamame22 0:29983394c6b6 261 M2MBase* find_resource(const String &object,
edamame22 0:29983394c6b6 262 uint8_t *token = NULL,
edamame22 0:29983394c6b6 263 uint8_t token_len = 0);
edamame22 0:29983394c6b6 264
edamame22 0:29983394c6b6 265 M2MBase* find_resource(const M2MObject *object,
edamame22 0:29983394c6b6 266 const String &object_instance,
edamame22 0:29983394c6b6 267 uint8_t *token = NULL,
edamame22 0:29983394c6b6 268 uint8_t token_len = 0);
edamame22 0:29983394c6b6 269
edamame22 0:29983394c6b6 270 M2MBase* find_resource(const M2MObjectInstance *object_instance,
edamame22 0:29983394c6b6 271 const String &resource_instance,
edamame22 0:29983394c6b6 272 uint8_t *token = NULL,
edamame22 0:29983394c6b6 273 uint8_t token_len = 0);
edamame22 0:29983394c6b6 274
edamame22 0:29983394c6b6 275 M2MBase* find_resource(const M2MResource *resource,
edamame22 0:29983394c6b6 276 const String &object_name,
edamame22 0:29983394c6b6 277 const String &resource_instance,
edamame22 0:29983394c6b6 278 uint8_t *token = NULL,
edamame22 0:29983394c6b6 279 uint8_t token_len = 0);
edamame22 0:29983394c6b6 280
edamame22 0:29983394c6b6 281 bool object_present(M2MObject * object) const;
edamame22 0:29983394c6b6 282
edamame22 0:29983394c6b6 283 M2MInterface::Error interface_error(sn_coap_hdr_s *coap_header);
edamame22 0:29983394c6b6 284
edamame22 0:29983394c6b6 285 void send_object_observation(M2MObject *object,
edamame22 0:29983394c6b6 286 uint16_t obs_number,
edamame22 0:29983394c6b6 287 m2m::Vector<uint16_t> changed_instance_ids,
edamame22 0:29983394c6b6 288 bool send_object);
edamame22 0:29983394c6b6 289
edamame22 0:29983394c6b6 290 void send_object_instance_observation(M2MObjectInstance *object_instance,
edamame22 0:29983394c6b6 291 uint16_t obs_number);
edamame22 0:29983394c6b6 292
edamame22 0:29983394c6b6 293 void send_resource_observation(M2MResource *resource, uint16_t obs_number);
edamame22 0:29983394c6b6 294
edamame22 0:29983394c6b6 295 void send_notification(uint8_t *token,
edamame22 0:29983394c6b6 296 uint8_t token_length,
edamame22 0:29983394c6b6 297 uint8_t *value,
edamame22 0:29983394c6b6 298 uint32_t value_length,
edamame22 0:29983394c6b6 299 uint16_t observation,
edamame22 0:29983394c6b6 300 uint32_t max_age,
edamame22 0:29983394c6b6 301 uint8_t coap_content_type);
edamame22 0:29983394c6b6 302
edamame22 0:29983394c6b6 303 /**
edamame22 0:29983394c6b6 304 * @brief Allocate (size + 1) amount of memory, copy size bytes into
edamame22 0:29983394c6b6 305 * it and add zero termination.
edamame22 0:29983394c6b6 306 * @param source Source string to copy, may not be NULL.
edamame22 0:29983394c6b6 307 * @param size The size of memory to be reserved.
edamame22 0:29983394c6b6 308 */
edamame22 0:29983394c6b6 309 static uint8_t* alloc_string_copy(const uint8_t* source, uint16_t size);
edamame22 0:29983394c6b6 310
edamame22 0:29983394c6b6 311 /**
edamame22 0:29983394c6b6 312 * @brief Utility method to convert given lifetime int to ascii
edamame22 0:29983394c6b6 313 * and allocate a buffer for it and set it to _endpoint->lifetime_ptr.
edamame22 0:29983394c6b6 314 * @param lifetime A new value for lifetime.
edamame22 0:29983394c6b6 315 */
edamame22 0:29983394c6b6 316 void set_endpoint_lifetime_buffer(int lifetime);
edamame22 0:29983394c6b6 317
edamame22 0:29983394c6b6 318 /**
edamame22 0:29983394c6b6 319 * @brief Handle incoming bootstrap PUT message.
edamame22 0:29983394c6b6 320 * @param coap_header, Received CoAP message
edamame22 0:29983394c6b6 321 * @param address, Server address
edamame22 0:29983394c6b6 322 */
edamame22 0:29983394c6b6 323 void handle_bootstrap_put_message(sn_coap_hdr_s *coap_header, sn_nsdl_addr_s *address);
edamame22 0:29983394c6b6 324
edamame22 0:29983394c6b6 325 /**
edamame22 0:29983394c6b6 326 * @brief Handle bootstrap finished message.
edamame22 0:29983394c6b6 327 * @param coap_header, Received CoAP message
edamame22 0:29983394c6b6 328 * @param address, Server address
edamame22 0:29983394c6b6 329 */
edamame22 0:29983394c6b6 330 void handle_bootstrap_finished(sn_coap_hdr_s *coap_header,sn_nsdl_addr_s *address);
edamame22 0:29983394c6b6 331
edamame22 0:29983394c6b6 332 /**
edamame22 0:29983394c6b6 333 * @brief Handle bootstrap delete message.
edamame22 0:29983394c6b6 334 * @param coap_header, Received CoAP message
edamame22 0:29983394c6b6 335 * @param address, Server address
edamame22 0:29983394c6b6 336 */
edamame22 0:29983394c6b6 337 void handle_bootstrap_delete(sn_coap_hdr_s *coap_header,sn_nsdl_addr_s *address);
edamame22 0:29983394c6b6 338
edamame22 0:29983394c6b6 339 /**
edamame22 0:29983394c6b6 340 * @brief Parse bootstrap TLV message.
edamame22 0:29983394c6b6 341 * @param coap_header, Received CoAP message
edamame22 0:29983394c6b6 342 * @return True if parsing was succesful else false
edamame22 0:29983394c6b6 343 */
edamame22 0:29983394c6b6 344 bool parse_bootstrap_message(sn_coap_hdr_s *coap_header, bool is_security_object);
edamame22 0:29983394c6b6 345
edamame22 0:29983394c6b6 346 /**
edamame22 0:29983394c6b6 347 * @brief Parse bootstrap TLV message.
edamame22 0:29983394c6b6 348 * @param coap_header, Received CoAP message
edamame22 0:29983394c6b6 349 * @return True if parsing was succesful else false
edamame22 0:29983394c6b6 350 */
edamame22 0:29983394c6b6 351 bool validate_security_object();
edamame22 0:29983394c6b6 352
edamame22 0:29983394c6b6 353 /**
edamame22 0:29983394c6b6 354 * @brief Handle bootstrap errors.
edamame22 0:29983394c6b6 355 */
edamame22 0:29983394c6b6 356 void handle_bootstrap_error();
edamame22 0:29983394c6b6 357
edamame22 0:29983394c6b6 358 private:
edamame22 0:29983394c6b6 359
edamame22 0:29983394c6b6 360 M2MNsdlObserver &_observer;
edamame22 0:29983394c6b6 361 M2MObjectList _object_list;
edamame22 0:29983394c6b6 362 sn_nsdl_ep_parameters_s *_endpoint;
edamame22 0:29983394c6b6 363 nsdl_s *_nsdl_handle;
edamame22 0:29983394c6b6 364 M2MSecurity *_security; // Not owned
edamame22 0:29983394c6b6 365 M2MServer _server;
edamame22 0:29983394c6b6 366 M2MTimer *_nsdl_exceution_timer;
edamame22 0:29983394c6b6 367 M2MTimer *_registration_timer;
edamame22 0:29983394c6b6 368 sn_nsdl_addr_s _sn_nsdl_address;
edamame22 0:29983394c6b6 369 String _endpoint_name;
edamame22 0:29983394c6b6 370 uint32_t _counter_for_nsdl;
edamame22 0:29983394c6b6 371 uint16_t _bootstrap_id;
edamame22 0:29983394c6b6 372 bool _unregister_ongoing;
edamame22 0:29983394c6b6 373 bool _identity_accepted;
edamame22 0:29983394c6b6 374
edamame22 0:29983394c6b6 375 friend class Test_M2MNsdlInterface;
edamame22 0:29983394c6b6 376
edamame22 0:29983394c6b6 377 };
edamame22 0:29983394c6b6 378
edamame22 0:29983394c6b6 379 #endif // M2MNSDLINTERFACE_H
edamame22 0:29983394c6b6 380