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.
Dependencies: mbed Socket lwip-eth lwip-sys lwip
Fork of 6_songs-from-the-cloud by
m2mobject.h
00001 /* 00002 * Copyright (c) 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 M2M_OBJECT_H 00017 #define M2M_OBJECT_H 00018 00019 #include "mbed-client/m2mvector.h" 00020 #include "mbed-client/m2mbase.h" 00021 #include "mbed-client/m2mobjectinstance.h" 00022 00023 //FORWARD DECLARATION 00024 typedef Vector<M2MObjectInstance *> M2MObjectInstanceList; 00025 00026 /** 00027 * @brief M2MObject. 00028 * This class is the base class for the mbed Client Objects. All defined 00029 * LWM2M object models can be created based on it. This class also holds all object 00030 * instances associated with the given object. 00031 */ 00032 00033 class M2MObject : public M2MBase, 00034 public M2MObjectCallback 00035 { 00036 00037 friend class M2MInterfaceFactory; 00038 00039 protected : 00040 00041 /** 00042 * @brief Constructor 00043 * @param name, Name of the object 00044 */ 00045 M2MObject(const String &object_name); 00046 00047 // Prevents the use of default constructor. 00048 M2MObject(); 00049 00050 // Prevents the use of assignment operator. 00051 M2MObject& operator=( const M2MObject& /*other*/ ); 00052 00053 // Prevents the use of copy constructor. 00054 M2MObject( const M2MObject& /*other*/ ); 00055 00056 public: 00057 00058 /** 00059 * @brief Destructor 00060 */ 00061 virtual ~M2MObject(); 00062 00063 /** 00064 * @brief Creates a new object instance for a given mbed Client Interface object. With this, 00065 * the client can respond to server's GET methods with the provided value. 00066 * @return M2MObjectInstance, Object instance for managing other client operations. 00067 */ 00068 M2MObjectInstance* create_object_instance(uint16_t instance_id = 0); 00069 00070 /** 00071 * @brief Removes the object instance resource with the given instance id. 00072 * @param instance_id, Instance ID of the object instance to be removed, default is 0. 00073 * @return True if removed, else false. 00074 */ 00075 virtual bool remove_object_instance(uint16_t instance_id = 0); 00076 00077 /** 00078 * @brief Returns object instance with the the given instance id. 00079 * @param instance_id, Instance ID of the requested object instance id, default is 0. 00080 * @return Object instance reference if found, else NULL. 00081 */ 00082 virtual M2MObjectInstance* object_instance(uint16_t instance_id = 0) const; 00083 00084 /** 00085 * @brief Returns a list of object instances. 00086 * @return List of instances with the object. 00087 */ 00088 virtual const M2MObjectInstanceList& instances() const; 00089 00090 /** 00091 * @brief Returns the total number of instances with the object. 00092 * @return Total number of the object instances. 00093 */ 00094 virtual uint16_t instance_count() const; 00095 00096 /** 00097 * @brief Returns object type. 00098 * @return BaseType. 00099 */ 00100 virtual M2MBase::BaseType base_type() const; 00101 00102 /** 00103 * @brief Adds the observation level for the object. 00104 * @param observation_level, Level of observation. 00105 */ 00106 virtual void add_observation_level(M2MBase::Observation observation_level); 00107 00108 /** 00109 * @brief Removes the observation level from the object. 00110 * @param observation_level, Level of observation. 00111 */ 00112 virtual void remove_observation_level(M2MBase::Observation observation_level); 00113 00114 /** 00115 * @brief Handles GET request for the registered objects. 00116 * @param nsdl, NSDL handler for the CoAP library. 00117 * @param received_coap_header, CoAP message received from the server. 00118 * @param observation_handler, Handler object for sending 00119 * observation callbacks. 00120 * @return sn_coap_hdr_s, Message that needs to be sent to server. 00121 */ 00122 virtual sn_coap_hdr_s* handle_get_request(nsdl_s *nsdl, 00123 sn_coap_hdr_s *received_coap_header, 00124 M2MObservationHandler *observation_handler = NULL); 00125 /** 00126 * @brief Handles PUT request for the registered objects. 00127 * @param nsdl, NSDL handler for the CoAP library. 00128 * @param received_coap_header, CoAP message received from the server. 00129 * @param observation_handler, Handler object for sending 00130 * observation callbacks. 00131 * @return sn_coap_hdr_s, Message that needs to be sent to server. 00132 */ 00133 virtual sn_coap_hdr_s* handle_put_request(nsdl_s *nsdl, 00134 sn_coap_hdr_s *received_coap_header, 00135 M2MObservationHandler *observation_handler = NULL); 00136 00137 /** 00138 * @brief Handles GET request for the registered objects. 00139 * @param nsdl, NSDL handler for the CoAP library. 00140 * @param received_coap_header, CoAP message received from the server. 00141 * @param observation_handler, Handler object for sending 00142 * observation callbacks. 00143 * @return sn_coap_hdr_s, Message that needs to be sent to server. 00144 */ 00145 virtual sn_coap_hdr_s* handle_post_request(nsdl_s *nsdl, 00146 sn_coap_hdr_s *received_coap_header, 00147 M2MObservationHandler *observation_handler = NULL); 00148 00149 protected : 00150 00151 virtual void notification_update(); 00152 00153 private: 00154 00155 M2MObjectInstanceList _instance_list; // owned 00156 uint16_t _max_instance_count; 00157 00158 friend class Test_M2MObject; 00159 friend class Test_M2MInterfaceImpl; 00160 friend class Test_M2MNsdlInterface; 00161 friend class Test_M2MTLVSerializer; 00162 friend class Test_M2MTLVDeserializer; 00163 00164 }; 00165 00166 #endif // M2M_OBJECT_H
Generated on Tue Jul 12 2022 12:47:47 by
