mbed client on ethernet with LWIP

Dependencies:   mbed Socket lwip-eth lwip-sys lwip

Fork of mbed-client-classic-example-lwip by sandbox

Committer:
mbedAustin
Date:
Thu Jun 09 17:08:36 2016 +0000
Revision:
11:cada08fc8a70
Commit for public Consumption

Who changed what in which revision?

UserRevisionLine numberNew contents of line
mbedAustin 11:cada08fc8a70 1 /*
mbedAustin 11:cada08fc8a70 2 * Copyright (c) 2015 ARM Limited. All rights reserved.
mbedAustin 11:cada08fc8a70 3 * SPDX-License-Identifier: Apache-2.0
mbedAustin 11:cada08fc8a70 4 * Licensed under the Apache License, Version 2.0 (the License); you may
mbedAustin 11:cada08fc8a70 5 * not use this file except in compliance with the License.
mbedAustin 11:cada08fc8a70 6 * You may obtain a copy of the License at
mbedAustin 11:cada08fc8a70 7 *
mbedAustin 11:cada08fc8a70 8 * http://www.apache.org/licenses/LICENSE-2.0
mbedAustin 11:cada08fc8a70 9 *
mbedAustin 11:cada08fc8a70 10 * Unless required by applicable law or agreed to in writing, software
mbedAustin 11:cada08fc8a70 11 * distributed under the License is distributed on an AS IS BASIS, WITHOUT
mbedAustin 11:cada08fc8a70 12 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
mbedAustin 11:cada08fc8a70 13 * See the License for the specific language governing permissions and
mbedAustin 11:cada08fc8a70 14 * limitations under the License.
mbedAustin 11:cada08fc8a70 15 */
mbedAustin 11:cada08fc8a70 16 #ifndef M2M_OBJECT_H
mbedAustin 11:cada08fc8a70 17 #define M2M_OBJECT_H
mbedAustin 11:cada08fc8a70 18
mbedAustin 11:cada08fc8a70 19 #include "mbed-client/m2mvector.h"
mbedAustin 11:cada08fc8a70 20 #include "mbed-client/m2mbase.h"
mbedAustin 11:cada08fc8a70 21 #include "mbed-client/m2mobjectinstance.h"
mbedAustin 11:cada08fc8a70 22
mbedAustin 11:cada08fc8a70 23 //FORWARD DECLARATION
mbedAustin 11:cada08fc8a70 24 typedef Vector<M2MObjectInstance *> M2MObjectInstanceList;
mbedAustin 11:cada08fc8a70 25
mbedAustin 11:cada08fc8a70 26 /**
mbedAustin 11:cada08fc8a70 27 * @brief M2MObject.
mbedAustin 11:cada08fc8a70 28 * This class is the base class for the mbed Client Objects. All defined
mbedAustin 11:cada08fc8a70 29 * LWM2M object models can be created based on it. This class also holds all object
mbedAustin 11:cada08fc8a70 30 * instances associated with the given object.
mbedAustin 11:cada08fc8a70 31 */
mbedAustin 11:cada08fc8a70 32
mbedAustin 11:cada08fc8a70 33 class M2MObject : public M2MBase,
mbedAustin 11:cada08fc8a70 34 public M2MObjectCallback
mbedAustin 11:cada08fc8a70 35 {
mbedAustin 11:cada08fc8a70 36
mbedAustin 11:cada08fc8a70 37 friend class M2MInterfaceFactory;
mbedAustin 11:cada08fc8a70 38
mbedAustin 11:cada08fc8a70 39 protected :
mbedAustin 11:cada08fc8a70 40
mbedAustin 11:cada08fc8a70 41 /**
mbedAustin 11:cada08fc8a70 42 * @brief Constructor
mbedAustin 11:cada08fc8a70 43 * @param name, Name of the object
mbedAustin 11:cada08fc8a70 44 */
mbedAustin 11:cada08fc8a70 45 M2MObject(const String &object_name);
mbedAustin 11:cada08fc8a70 46
mbedAustin 11:cada08fc8a70 47 // Prevents the use of default constructor.
mbedAustin 11:cada08fc8a70 48 M2MObject();
mbedAustin 11:cada08fc8a70 49
mbedAustin 11:cada08fc8a70 50 // Prevents the use of assignment operator.
mbedAustin 11:cada08fc8a70 51 M2MObject& operator=( const M2MObject& /*other*/ );
mbedAustin 11:cada08fc8a70 52
mbedAustin 11:cada08fc8a70 53 // Prevents the use of copy constructor.
mbedAustin 11:cada08fc8a70 54 M2MObject( const M2MObject& /*other*/ );
mbedAustin 11:cada08fc8a70 55
mbedAustin 11:cada08fc8a70 56 public:
mbedAustin 11:cada08fc8a70 57
mbedAustin 11:cada08fc8a70 58 /**
mbedAustin 11:cada08fc8a70 59 * @brief Destructor
mbedAustin 11:cada08fc8a70 60 */
mbedAustin 11:cada08fc8a70 61 virtual ~M2MObject();
mbedAustin 11:cada08fc8a70 62
mbedAustin 11:cada08fc8a70 63 /**
mbedAustin 11:cada08fc8a70 64 * @brief Creates a new object instance for a given mbed Client Interface object. With this,
mbedAustin 11:cada08fc8a70 65 * the client can respond to server's GET methods with the provided value.
mbedAustin 11:cada08fc8a70 66 * @return M2MObjectInstance, Object instance for managing other client operations.
mbedAustin 11:cada08fc8a70 67 */
mbedAustin 11:cada08fc8a70 68 M2MObjectInstance* create_object_instance(uint16_t instance_id = 0);
mbedAustin 11:cada08fc8a70 69
mbedAustin 11:cada08fc8a70 70 /**
mbedAustin 11:cada08fc8a70 71 * @brief Removes the object instance resource with the given instance id.
mbedAustin 11:cada08fc8a70 72 * @param instance_id, Instance ID of the object instance to be removed, default is 0.
mbedAustin 11:cada08fc8a70 73 * @return True if removed, else false.
mbedAustin 11:cada08fc8a70 74 */
mbedAustin 11:cada08fc8a70 75 virtual bool remove_object_instance(uint16_t instance_id = 0);
mbedAustin 11:cada08fc8a70 76
mbedAustin 11:cada08fc8a70 77 /**
mbedAustin 11:cada08fc8a70 78 * @brief Returns object instance with the the given instance id.
mbedAustin 11:cada08fc8a70 79 * @param instance_id, Instance ID of the requested object instance id, default is 0.
mbedAustin 11:cada08fc8a70 80 * @return Object instance reference if found, else NULL.
mbedAustin 11:cada08fc8a70 81 */
mbedAustin 11:cada08fc8a70 82 virtual M2MObjectInstance* object_instance(uint16_t instance_id = 0) const;
mbedAustin 11:cada08fc8a70 83
mbedAustin 11:cada08fc8a70 84 /**
mbedAustin 11:cada08fc8a70 85 * @brief Returns a list of object instances.
mbedAustin 11:cada08fc8a70 86 * @return List of instances with the object.
mbedAustin 11:cada08fc8a70 87 */
mbedAustin 11:cada08fc8a70 88 virtual const M2MObjectInstanceList& instances() const;
mbedAustin 11:cada08fc8a70 89
mbedAustin 11:cada08fc8a70 90 /**
mbedAustin 11:cada08fc8a70 91 * @brief Returns the total number of instances with the object.
mbedAustin 11:cada08fc8a70 92 * @return Total number of the object instances.
mbedAustin 11:cada08fc8a70 93 */
mbedAustin 11:cada08fc8a70 94 virtual uint16_t instance_count() const;
mbedAustin 11:cada08fc8a70 95
mbedAustin 11:cada08fc8a70 96 /**
mbedAustin 11:cada08fc8a70 97 * @brief Returns object type.
mbedAustin 11:cada08fc8a70 98 * @return BaseType.
mbedAustin 11:cada08fc8a70 99 */
mbedAustin 11:cada08fc8a70 100 virtual M2MBase::BaseType base_type() const;
mbedAustin 11:cada08fc8a70 101
mbedAustin 11:cada08fc8a70 102 /**
mbedAustin 11:cada08fc8a70 103 * @brief Adds the observation level for the object.
mbedAustin 11:cada08fc8a70 104 * @param observation_level, Level of observation.
mbedAustin 11:cada08fc8a70 105 */
mbedAustin 11:cada08fc8a70 106 virtual void add_observation_level(M2MBase::Observation observation_level);
mbedAustin 11:cada08fc8a70 107
mbedAustin 11:cada08fc8a70 108 /**
mbedAustin 11:cada08fc8a70 109 * @brief Removes the observation level from the object.
mbedAustin 11:cada08fc8a70 110 * @param observation_level, Level of observation.
mbedAustin 11:cada08fc8a70 111 */
mbedAustin 11:cada08fc8a70 112 virtual void remove_observation_level(M2MBase::Observation observation_level);
mbedAustin 11:cada08fc8a70 113
mbedAustin 11:cada08fc8a70 114 /**
mbedAustin 11:cada08fc8a70 115 * @brief Handles GET request for the registered objects.
mbedAustin 11:cada08fc8a70 116 * @param nsdl, NSDL handler for the CoAP library.
mbedAustin 11:cada08fc8a70 117 * @param received_coap_header, CoAP message received from the server.
mbedAustin 11:cada08fc8a70 118 * @param observation_handler, Handler object for sending
mbedAustin 11:cada08fc8a70 119 * observation callbacks.
mbedAustin 11:cada08fc8a70 120 * @return sn_coap_hdr_s, Message that needs to be sent to server.
mbedAustin 11:cada08fc8a70 121 */
mbedAustin 11:cada08fc8a70 122 virtual sn_coap_hdr_s* handle_get_request(nsdl_s *nsdl,
mbedAustin 11:cada08fc8a70 123 sn_coap_hdr_s *received_coap_header,
mbedAustin 11:cada08fc8a70 124 M2MObservationHandler *observation_handler = NULL);
mbedAustin 11:cada08fc8a70 125 /**
mbedAustin 11:cada08fc8a70 126 * @brief Handles PUT request for the registered objects.
mbedAustin 11:cada08fc8a70 127 * @param nsdl, NSDL handler for the CoAP library.
mbedAustin 11:cada08fc8a70 128 * @param received_coap_header, CoAP message received from the server.
mbedAustin 11:cada08fc8a70 129 * @param observation_handler, Handler object for sending
mbedAustin 11:cada08fc8a70 130 * observation callbacks.
mbedAustin 11:cada08fc8a70 131 * @return sn_coap_hdr_s, Message that needs to be sent to server.
mbedAustin 11:cada08fc8a70 132 */
mbedAustin 11:cada08fc8a70 133 virtual sn_coap_hdr_s* handle_put_request(nsdl_s *nsdl,
mbedAustin 11:cada08fc8a70 134 sn_coap_hdr_s *received_coap_header,
mbedAustin 11:cada08fc8a70 135 M2MObservationHandler *observation_handler = NULL);
mbedAustin 11:cada08fc8a70 136
mbedAustin 11:cada08fc8a70 137 /**
mbedAustin 11:cada08fc8a70 138 * @brief Handles GET request for the registered objects.
mbedAustin 11:cada08fc8a70 139 * @param nsdl, NSDL handler for the CoAP library.
mbedAustin 11:cada08fc8a70 140 * @param received_coap_header, CoAP message received from the server.
mbedAustin 11:cada08fc8a70 141 * @param observation_handler, Handler object for sending
mbedAustin 11:cada08fc8a70 142 * observation callbacks.
mbedAustin 11:cada08fc8a70 143 * @return sn_coap_hdr_s, Message that needs to be sent to server.
mbedAustin 11:cada08fc8a70 144 */
mbedAustin 11:cada08fc8a70 145 virtual sn_coap_hdr_s* handle_post_request(nsdl_s *nsdl,
mbedAustin 11:cada08fc8a70 146 sn_coap_hdr_s *received_coap_header,
mbedAustin 11:cada08fc8a70 147 M2MObservationHandler *observation_handler = NULL);
mbedAustin 11:cada08fc8a70 148
mbedAustin 11:cada08fc8a70 149 protected :
mbedAustin 11:cada08fc8a70 150
mbedAustin 11:cada08fc8a70 151 virtual void notification_update();
mbedAustin 11:cada08fc8a70 152
mbedAustin 11:cada08fc8a70 153 private:
mbedAustin 11:cada08fc8a70 154
mbedAustin 11:cada08fc8a70 155 M2MObjectInstanceList _instance_list; // owned
mbedAustin 11:cada08fc8a70 156 uint16_t _max_instance_count;
mbedAustin 11:cada08fc8a70 157
mbedAustin 11:cada08fc8a70 158 friend class Test_M2MObject;
mbedAustin 11:cada08fc8a70 159 friend class Test_M2MInterfaceImpl;
mbedAustin 11:cada08fc8a70 160 friend class Test_M2MNsdlInterface;
mbedAustin 11:cada08fc8a70 161 friend class Test_M2MTLVSerializer;
mbedAustin 11:cada08fc8a70 162 friend class Test_M2MTLVDeserializer;
mbedAustin 11:cada08fc8a70 163
mbedAustin 11:cada08fc8a70 164 };
mbedAustin 11:cada08fc8a70 165
mbedAustin 11:cada08fc8a70 166 #endif // M2M_OBJECT_H