
FRDM K64F Metronome
mbed-client/mbed-client/m2mresource.h@0:a2cb7295a1f7, 2017-05-14 (annotated)
- Committer:
- ram54288
- Date:
- Sun May 14 18:35:07 2017 +0000
- Revision:
- 0:a2cb7295a1f7
Initial commit
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
ram54288 | 0:a2cb7295a1f7 | 1 | /* |
ram54288 | 0:a2cb7295a1f7 | 2 | * Copyright (c) 2015 ARM Limited. All rights reserved. |
ram54288 | 0:a2cb7295a1f7 | 3 | * SPDX-License-Identifier: Apache-2.0 |
ram54288 | 0:a2cb7295a1f7 | 4 | * Licensed under the Apache License, Version 2.0 (the License); you may |
ram54288 | 0:a2cb7295a1f7 | 5 | * not use this file except in compliance with the License. |
ram54288 | 0:a2cb7295a1f7 | 6 | * You may obtain a copy of the License at |
ram54288 | 0:a2cb7295a1f7 | 7 | * |
ram54288 | 0:a2cb7295a1f7 | 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
ram54288 | 0:a2cb7295a1f7 | 9 | * |
ram54288 | 0:a2cb7295a1f7 | 10 | * Unless required by applicable law or agreed to in writing, software |
ram54288 | 0:a2cb7295a1f7 | 11 | * distributed under the License is distributed on an AS IS BASIS, WITHOUT |
ram54288 | 0:a2cb7295a1f7 | 12 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
ram54288 | 0:a2cb7295a1f7 | 13 | * See the License for the specific language governing permissions and |
ram54288 | 0:a2cb7295a1f7 | 14 | * limitations under the License. |
ram54288 | 0:a2cb7295a1f7 | 15 | */ |
ram54288 | 0:a2cb7295a1f7 | 16 | #ifndef M2M_RESOURCE_H |
ram54288 | 0:a2cb7295a1f7 | 17 | #define M2M_RESOURCE_H |
ram54288 | 0:a2cb7295a1f7 | 18 | |
ram54288 | 0:a2cb7295a1f7 | 19 | #include "mbed-client/m2mvector.h" |
ram54288 | 0:a2cb7295a1f7 | 20 | #include "mbed-client/m2mresourceinstance.h" |
ram54288 | 0:a2cb7295a1f7 | 21 | |
ram54288 | 0:a2cb7295a1f7 | 22 | //FORWARD DECLARATION |
ram54288 | 0:a2cb7295a1f7 | 23 | class M2MObjectInstance; |
ram54288 | 0:a2cb7295a1f7 | 24 | typedef Vector<M2MResourceInstance *> M2MResourceInstanceList; |
ram54288 | 0:a2cb7295a1f7 | 25 | |
ram54288 | 0:a2cb7295a1f7 | 26 | class M2MResourceCallback { |
ram54288 | 0:a2cb7295a1f7 | 27 | public: |
ram54288 | 0:a2cb7295a1f7 | 28 | virtual void notification_update() = 0; |
ram54288 | 0:a2cb7295a1f7 | 29 | }; |
ram54288 | 0:a2cb7295a1f7 | 30 | |
ram54288 | 0:a2cb7295a1f7 | 31 | /*! \file m2mresource.h |
ram54288 | 0:a2cb7295a1f7 | 32 | * \brief M2MResource. |
ram54288 | 0:a2cb7295a1f7 | 33 | * This class is the base class for mbed Client Resources. All defined |
ram54288 | 0:a2cb7295a1f7 | 34 | * LWM2M object models can be created using it. This class will also hold all resources |
ram54288 | 0:a2cb7295a1f7 | 35 | * instances associated with the given object. |
ram54288 | 0:a2cb7295a1f7 | 36 | */ |
ram54288 | 0:a2cb7295a1f7 | 37 | |
ram54288 | 0:a2cb7295a1f7 | 38 | class M2MResource : public M2MResourceInstance, M2MResourceCallback { |
ram54288 | 0:a2cb7295a1f7 | 39 | |
ram54288 | 0:a2cb7295a1f7 | 40 | friend class M2MObjectInstance; |
ram54288 | 0:a2cb7295a1f7 | 41 | |
ram54288 | 0:a2cb7295a1f7 | 42 | public: |
ram54288 | 0:a2cb7295a1f7 | 43 | class M2MExecuteParameter; |
ram54288 | 0:a2cb7295a1f7 | 44 | |
ram54288 | 0:a2cb7295a1f7 | 45 | private: // Constructor and destructor are private, |
ram54288 | 0:a2cb7295a1f7 | 46 | // which means that these objects can be created or |
ram54288 | 0:a2cb7295a1f7 | 47 | // deleted only through a function provided by the M2MObjectInstance. |
ram54288 | 0:a2cb7295a1f7 | 48 | |
ram54288 | 0:a2cb7295a1f7 | 49 | M2MResource(M2MObjectInstance &_parent, |
ram54288 | 0:a2cb7295a1f7 | 50 | const lwm2m_parameters_s* s, |
ram54288 | 0:a2cb7295a1f7 | 51 | M2MResourceInstance::ResourceType type, |
ram54288 | 0:a2cb7295a1f7 | 52 | const uint16_t object_instance_id); |
ram54288 | 0:a2cb7295a1f7 | 53 | /** |
ram54288 | 0:a2cb7295a1f7 | 54 | * \brief Constructor |
ram54288 | 0:a2cb7295a1f7 | 55 | * \param resource_name The resource name of the object. |
ram54288 | 0:a2cb7295a1f7 | 56 | * \param resource_type The resource type of the object. |
ram54288 | 0:a2cb7295a1f7 | 57 | * \param type The resource data type of the object. |
ram54288 | 0:a2cb7295a1f7 | 58 | * \param value The value pointer of the object. |
ram54288 | 0:a2cb7295a1f7 | 59 | * \param value_length The length of the value pointer. |
ram54288 | 0:a2cb7295a1f7 | 60 | * \param path Full path of the resource, eg. 1/2/3. Ownership of the memory is transferred. |
ram54288 | 0:a2cb7295a1f7 | 61 | * \param object_instance_id The instance ID of the object where the resource exists. |
ram54288 | 0:a2cb7295a1f7 | 62 | * \param object_name The name of the object where the resource exists. |
ram54288 | 0:a2cb7295a1f7 | 63 | * \param multiple_instance True if the resource supports instances. |
ram54288 | 0:a2cb7295a1f7 | 64 | * \param external_blockwise_store If true CoAP blocks are passed to application through callbacks |
ram54288 | 0:a2cb7295a1f7 | 65 | * otherwise handled in mbed-client-c. |
ram54288 | 0:a2cb7295a1f7 | 66 | */ |
ram54288 | 0:a2cb7295a1f7 | 67 | M2MResource(M2MObjectInstance &_parent, |
ram54288 | 0:a2cb7295a1f7 | 68 | const String &resource_name, |
ram54288 | 0:a2cb7295a1f7 | 69 | const String &resource_type, |
ram54288 | 0:a2cb7295a1f7 | 70 | M2MResourceInstance::ResourceType type, |
ram54288 | 0:a2cb7295a1f7 | 71 | const uint8_t *value, |
ram54288 | 0:a2cb7295a1f7 | 72 | const uint8_t value_length, |
ram54288 | 0:a2cb7295a1f7 | 73 | char *path, |
ram54288 | 0:a2cb7295a1f7 | 74 | const uint16_t object_instance_id = 0, |
ram54288 | 0:a2cb7295a1f7 | 75 | bool multiple_instance = false, |
ram54288 | 0:a2cb7295a1f7 | 76 | bool external_blockwise_store = false); |
ram54288 | 0:a2cb7295a1f7 | 77 | |
ram54288 | 0:a2cb7295a1f7 | 78 | /** |
ram54288 | 0:a2cb7295a1f7 | 79 | * \brief Constructor |
ram54288 | 0:a2cb7295a1f7 | 80 | * \param resource_name The resource name of the object. |
ram54288 | 0:a2cb7295a1f7 | 81 | * \param resource_type The resource type of the object. |
ram54288 | 0:a2cb7295a1f7 | 82 | * \param type The resource data type of the object. |
ram54288 | 0:a2cb7295a1f7 | 83 | * \param observable Indicates whether the resource is observable or not. |
ram54288 | 0:a2cb7295a1f7 | 84 | * \param path Full path of the resource, eg. 1/2/3. Ownership of the memory is transferred. |
ram54288 | 0:a2cb7295a1f7 | 85 | * \param object_instance_id The ID of the object instance where the resource exists. |
ram54288 | 0:a2cb7295a1f7 | 86 | * \param object_name The name of the object where the resource exists. |
ram54288 | 0:a2cb7295a1f7 | 87 | * \param multiple_instance True if the resource supports instances. |
ram54288 | 0:a2cb7295a1f7 | 88 | * \param external_blockwise_store If true CoAP blocks are passed to application through callbacks |
ram54288 | 0:a2cb7295a1f7 | 89 | * otherwise handled in mbed-client-c. |
ram54288 | 0:a2cb7295a1f7 | 90 | */ |
ram54288 | 0:a2cb7295a1f7 | 91 | M2MResource(M2MObjectInstance &_parent, |
ram54288 | 0:a2cb7295a1f7 | 92 | const String &resource_name, |
ram54288 | 0:a2cb7295a1f7 | 93 | const String &resource_type, |
ram54288 | 0:a2cb7295a1f7 | 94 | M2MResourceInstance::ResourceType type, |
ram54288 | 0:a2cb7295a1f7 | 95 | bool observable, |
ram54288 | 0:a2cb7295a1f7 | 96 | char *path, |
ram54288 | 0:a2cb7295a1f7 | 97 | const uint16_t object_instance_id = 0, |
ram54288 | 0:a2cb7295a1f7 | 98 | bool multiple_instance = false, |
ram54288 | 0:a2cb7295a1f7 | 99 | bool external_blockwise_store = false); |
ram54288 | 0:a2cb7295a1f7 | 100 | |
ram54288 | 0:a2cb7295a1f7 | 101 | // Prevents the use of a default constructor. |
ram54288 | 0:a2cb7295a1f7 | 102 | M2MResource(); |
ram54288 | 0:a2cb7295a1f7 | 103 | |
ram54288 | 0:a2cb7295a1f7 | 104 | // Prevents the use of an assignment operator. |
ram54288 | 0:a2cb7295a1f7 | 105 | M2MResource& operator=( const M2MResource& /*other*/ ); |
ram54288 | 0:a2cb7295a1f7 | 106 | |
ram54288 | 0:a2cb7295a1f7 | 107 | // Prevents the use of a copy constructor |
ram54288 | 0:a2cb7295a1f7 | 108 | M2MResource( const M2MResource& /*other*/ ); |
ram54288 | 0:a2cb7295a1f7 | 109 | |
ram54288 | 0:a2cb7295a1f7 | 110 | /** |
ram54288 | 0:a2cb7295a1f7 | 111 | * Destructor |
ram54288 | 0:a2cb7295a1f7 | 112 | */ |
ram54288 | 0:a2cb7295a1f7 | 113 | virtual ~M2MResource(); |
ram54288 | 0:a2cb7295a1f7 | 114 | |
ram54288 | 0:a2cb7295a1f7 | 115 | public: |
ram54288 | 0:a2cb7295a1f7 | 116 | |
ram54288 | 0:a2cb7295a1f7 | 117 | /** |
ram54288 | 0:a2cb7295a1f7 | 118 | * \brief Adds resource instances to a M2MResource. |
ram54288 | 0:a2cb7295a1f7 | 119 | * \param resource_instance The resource instance to be added. |
ram54288 | 0:a2cb7295a1f7 | 120 | */ |
ram54288 | 0:a2cb7295a1f7 | 121 | void add_resource_instance(M2MResourceInstance *resource_instance); |
ram54288 | 0:a2cb7295a1f7 | 122 | |
ram54288 | 0:a2cb7295a1f7 | 123 | /** |
ram54288 | 0:a2cb7295a1f7 | 124 | * \brief Returns whether the resource has multiple |
ram54288 | 0:a2cb7295a1f7 | 125 | * resource instances or not. |
ram54288 | 0:a2cb7295a1f7 | 126 | * \return True if the resource base has multiple instances, |
ram54288 | 0:a2cb7295a1f7 | 127 | * else false. |
ram54288 | 0:a2cb7295a1f7 | 128 | */ |
ram54288 | 0:a2cb7295a1f7 | 129 | bool supports_multiple_instances() const; |
ram54288 | 0:a2cb7295a1f7 | 130 | |
ram54288 | 0:a2cb7295a1f7 | 131 | /** |
ram54288 | 0:a2cb7295a1f7 | 132 | * \brief Sets whether the resource should send a delayed response for a POST request. |
ram54288 | 0:a2cb7295a1f7 | 133 | * \param delayed_response A boolean value to set the delayed response. |
ram54288 | 0:a2cb7295a1f7 | 134 | */ |
ram54288 | 0:a2cb7295a1f7 | 135 | void set_delayed_response(bool delayed_response); |
ram54288 | 0:a2cb7295a1f7 | 136 | |
ram54288 | 0:a2cb7295a1f7 | 137 | /** |
ram54288 | 0:a2cb7295a1f7 | 138 | * \brief A trigger to send the delayed response for the POST request. |
ram54288 | 0:a2cb7295a1f7 | 139 | * The delayed_response flag must be set before receiving the POST request |
ram54288 | 0:a2cb7295a1f7 | 140 | * and the value of the resource must be updated before calling this function. |
ram54288 | 0:a2cb7295a1f7 | 141 | * \return True if a response is sent, else false. |
ram54288 | 0:a2cb7295a1f7 | 142 | */ |
ram54288 | 0:a2cb7295a1f7 | 143 | bool send_delayed_post_response(); |
ram54288 | 0:a2cb7295a1f7 | 144 | |
ram54288 | 0:a2cb7295a1f7 | 145 | /** |
ram54288 | 0:a2cb7295a1f7 | 146 | * \brief Provides the value of the given token. |
ram54288 | 0:a2cb7295a1f7 | 147 | * \param value[OUT] A pointer to the token value. |
ram54288 | 0:a2cb7295a1f7 | 148 | * \param value_length[OUT] The length of the token pointer. |
ram54288 | 0:a2cb7295a1f7 | 149 | */ |
ram54288 | 0:a2cb7295a1f7 | 150 | void get_delayed_token(uint8_t *&token, uint8_t &token_length); |
ram54288 | 0:a2cb7295a1f7 | 151 | |
ram54288 | 0:a2cb7295a1f7 | 152 | /** |
ram54288 | 0:a2cb7295a1f7 | 153 | * \brief Removes a resource with a given name. |
ram54288 | 0:a2cb7295a1f7 | 154 | * \param name The name of the resource to be removed. |
ram54288 | 0:a2cb7295a1f7 | 155 | * \param instance_id The instance ID of the resource to be removed, default is 0. |
ram54288 | 0:a2cb7295a1f7 | 156 | * \return True if removed, else false. |
ram54288 | 0:a2cb7295a1f7 | 157 | */ |
ram54288 | 0:a2cb7295a1f7 | 158 | virtual bool remove_resource_instance(uint16_t instance_id = 0); |
ram54288 | 0:a2cb7295a1f7 | 159 | |
ram54288 | 0:a2cb7295a1f7 | 160 | /** |
ram54288 | 0:a2cb7295a1f7 | 161 | * \brief Returns a resource instance with a given name. |
ram54288 | 0:a2cb7295a1f7 | 162 | * \param instance_id The instance ID of the requested resource, default is 0 |
ram54288 | 0:a2cb7295a1f7 | 163 | * \return M2MResourceInstance object if found, else NULL. |
ram54288 | 0:a2cb7295a1f7 | 164 | */ |
ram54288 | 0:a2cb7295a1f7 | 165 | virtual M2MResourceInstance* resource_instance(uint16_t instance_id = 0) const; |
ram54288 | 0:a2cb7295a1f7 | 166 | |
ram54288 | 0:a2cb7295a1f7 | 167 | /** |
ram54288 | 0:a2cb7295a1f7 | 168 | * \brief Returns a list of resources. |
ram54288 | 0:a2cb7295a1f7 | 169 | * \return A list of resources. |
ram54288 | 0:a2cb7295a1f7 | 170 | */ |
ram54288 | 0:a2cb7295a1f7 | 171 | virtual const M2MResourceInstanceList& resource_instances() const; |
ram54288 | 0:a2cb7295a1f7 | 172 | |
ram54288 | 0:a2cb7295a1f7 | 173 | /** |
ram54288 | 0:a2cb7295a1f7 | 174 | * \brief Returns the total number of resources. |
ram54288 | 0:a2cb7295a1f7 | 175 | * \return The total number of resources. |
ram54288 | 0:a2cb7295a1f7 | 176 | */ |
ram54288 | 0:a2cb7295a1f7 | 177 | virtual uint16_t resource_instance_count() const; |
ram54288 | 0:a2cb7295a1f7 | 178 | |
ram54288 | 0:a2cb7295a1f7 | 179 | /** |
ram54288 | 0:a2cb7295a1f7 | 180 | * \brief Returns the value set for delayed response. |
ram54288 | 0:a2cb7295a1f7 | 181 | * \return The value for delayed response. |
ram54288 | 0:a2cb7295a1f7 | 182 | */ |
ram54288 | 0:a2cb7295a1f7 | 183 | bool delayed_response() const; |
ram54288 | 0:a2cb7295a1f7 | 184 | |
ram54288 | 0:a2cb7295a1f7 | 185 | /** |
ram54288 | 0:a2cb7295a1f7 | 186 | * \brief Parses the received query for a notification |
ram54288 | 0:a2cb7295a1f7 | 187 | * attribute. |
ram54288 | 0:a2cb7295a1f7 | 188 | * \return True if required attributes are present, else false. |
ram54288 | 0:a2cb7295a1f7 | 189 | */ |
ram54288 | 0:a2cb7295a1f7 | 190 | virtual bool handle_observation_attribute(const char *query); |
ram54288 | 0:a2cb7295a1f7 | 191 | |
ram54288 | 0:a2cb7295a1f7 | 192 | /** |
ram54288 | 0:a2cb7295a1f7 | 193 | * \brief Adds the observation level for the object. |
ram54288 | 0:a2cb7295a1f7 | 194 | * \param observation_level The level of observation. |
ram54288 | 0:a2cb7295a1f7 | 195 | */ |
ram54288 | 0:a2cb7295a1f7 | 196 | virtual void add_observation_level(M2MBase::Observation observation_level); |
ram54288 | 0:a2cb7295a1f7 | 197 | |
ram54288 | 0:a2cb7295a1f7 | 198 | /** |
ram54288 | 0:a2cb7295a1f7 | 199 | * \brief Removes the observation level from an object. |
ram54288 | 0:a2cb7295a1f7 | 200 | * \param observation_level The level of observation. |
ram54288 | 0:a2cb7295a1f7 | 201 | */ |
ram54288 | 0:a2cb7295a1f7 | 202 | virtual void remove_observation_level(M2MBase::Observation observation_level); |
ram54288 | 0:a2cb7295a1f7 | 203 | |
ram54288 | 0:a2cb7295a1f7 | 204 | /** |
ram54288 | 0:a2cb7295a1f7 | 205 | * \brief Handles the GET request for registered objects. |
ram54288 | 0:a2cb7295a1f7 | 206 | * \param nsdl An NSDL handler for the CoAP library. |
ram54288 | 0:a2cb7295a1f7 | 207 | * \param received_coap_header The CoAP message received from the server. |
ram54288 | 0:a2cb7295a1f7 | 208 | * \param observation_handler A handler object for sending |
ram54288 | 0:a2cb7295a1f7 | 209 | * observation callbacks. |
ram54288 | 0:a2cb7295a1f7 | 210 | * \return sn_coap_hdr_s The message that needs to be sent to the server. |
ram54288 | 0:a2cb7295a1f7 | 211 | */ |
ram54288 | 0:a2cb7295a1f7 | 212 | virtual sn_coap_hdr_s* handle_get_request(nsdl_s *nsdl, |
ram54288 | 0:a2cb7295a1f7 | 213 | sn_coap_hdr_s *received_coap_header, |
ram54288 | 0:a2cb7295a1f7 | 214 | M2MObservationHandler *observation_handler = NULL); |
ram54288 | 0:a2cb7295a1f7 | 215 | /** |
ram54288 | 0:a2cb7295a1f7 | 216 | * \brief Handles the PUT request for registered objects. |
ram54288 | 0:a2cb7295a1f7 | 217 | * \param nsdl An NSDL handler for the CoAP library. |
ram54288 | 0:a2cb7295a1f7 | 218 | * \param received_coap_header The CoAP message received from the server. |
ram54288 | 0:a2cb7295a1f7 | 219 | * \param observation_handler A handler object for sending |
ram54288 | 0:a2cb7295a1f7 | 220 | * observation callbacks. |
ram54288 | 0:a2cb7295a1f7 | 221 | * \param execute_value_updated True executes the "value_updated" callback. |
ram54288 | 0:a2cb7295a1f7 | 222 | * \return sn_coap_hdr_s The message that needs to be sent to the server. |
ram54288 | 0:a2cb7295a1f7 | 223 | */ |
ram54288 | 0:a2cb7295a1f7 | 224 | virtual sn_coap_hdr_s* handle_put_request(nsdl_s *nsdl, |
ram54288 | 0:a2cb7295a1f7 | 225 | sn_coap_hdr_s *received_coap_header, |
ram54288 | 0:a2cb7295a1f7 | 226 | M2MObservationHandler *observation_handler, |
ram54288 | 0:a2cb7295a1f7 | 227 | bool &execute_value_updated); |
ram54288 | 0:a2cb7295a1f7 | 228 | /** |
ram54288 | 0:a2cb7295a1f7 | 229 | * \brief Handles the POST request for registered objects. |
ram54288 | 0:a2cb7295a1f7 | 230 | * \param nsdl An NSDL handler for the CoAP library. |
ram54288 | 0:a2cb7295a1f7 | 231 | * \param received_coap_header The CoAP message received from the server. |
ram54288 | 0:a2cb7295a1f7 | 232 | * \param observation_handler A handler object for sending |
ram54288 | 0:a2cb7295a1f7 | 233 | * observation callbacks. |
ram54288 | 0:a2cb7295a1f7 | 234 | * \param execute_value_updated True executes the "value_updated" callback. |
ram54288 | 0:a2cb7295a1f7 | 235 | * \return sn_coap_hdr_s The message that needs to be sent to the server. |
ram54288 | 0:a2cb7295a1f7 | 236 | */ |
ram54288 | 0:a2cb7295a1f7 | 237 | virtual sn_coap_hdr_s* handle_post_request(nsdl_s *nsdl, |
ram54288 | 0:a2cb7295a1f7 | 238 | sn_coap_hdr_s *received_coap_header, |
ram54288 | 0:a2cb7295a1f7 | 239 | M2MObservationHandler *observation_handler, |
ram54288 | 0:a2cb7295a1f7 | 240 | bool &execute_value_updated, |
ram54288 | 0:a2cb7295a1f7 | 241 | sn_nsdl_addr_s *address = NULL); |
ram54288 | 0:a2cb7295a1f7 | 242 | |
ram54288 | 0:a2cb7295a1f7 | 243 | M2MObjectInstance& get_parent_object_instance() const; |
ram54288 | 0:a2cb7295a1f7 | 244 | |
ram54288 | 0:a2cb7295a1f7 | 245 | /** |
ram54288 | 0:a2cb7295a1f7 | 246 | * \brief Returns the name of the object where the resource exists. |
ram54288 | 0:a2cb7295a1f7 | 247 | * \return Object name. |
ram54288 | 0:a2cb7295a1f7 | 248 | */ |
ram54288 | 0:a2cb7295a1f7 | 249 | virtual const char* object_name() const; |
ram54288 | 0:a2cb7295a1f7 | 250 | |
ram54288 | 0:a2cb7295a1f7 | 251 | protected: |
ram54288 | 0:a2cb7295a1f7 | 252 | virtual void notification_update(); |
ram54288 | 0:a2cb7295a1f7 | 253 | |
ram54288 | 0:a2cb7295a1f7 | 254 | |
ram54288 | 0:a2cb7295a1f7 | 255 | private: |
ram54288 | 0:a2cb7295a1f7 | 256 | M2MObjectInstance &_parent; |
ram54288 | 0:a2cb7295a1f7 | 257 | |
ram54288 | 0:a2cb7295a1f7 | 258 | M2MResourceInstanceList _resource_instance_list; // owned |
ram54288 | 0:a2cb7295a1f7 | 259 | uint8_t *_delayed_token; |
ram54288 | 0:a2cb7295a1f7 | 260 | uint8_t _delayed_token_len; |
ram54288 | 0:a2cb7295a1f7 | 261 | bool _has_multiple_instances; |
ram54288 | 0:a2cb7295a1f7 | 262 | bool _delayed_response; |
ram54288 | 0:a2cb7295a1f7 | 263 | |
ram54288 | 0:a2cb7295a1f7 | 264 | friend class Test_M2MResource; |
ram54288 | 0:a2cb7295a1f7 | 265 | friend class Test_M2MObjectInstance; |
ram54288 | 0:a2cb7295a1f7 | 266 | friend class Test_M2MObject; |
ram54288 | 0:a2cb7295a1f7 | 267 | friend class Test_M2MDevice; |
ram54288 | 0:a2cb7295a1f7 | 268 | friend class Test_M2MSecurity; |
ram54288 | 0:a2cb7295a1f7 | 269 | friend class Test_M2MServer; |
ram54288 | 0:a2cb7295a1f7 | 270 | friend class Test_M2MNsdlInterface; |
ram54288 | 0:a2cb7295a1f7 | 271 | friend class Test_M2MFirmware; |
ram54288 | 0:a2cb7295a1f7 | 272 | friend class Test_M2MTLVSerializer; |
ram54288 | 0:a2cb7295a1f7 | 273 | friend class Test_M2MTLVDeserializer; |
ram54288 | 0:a2cb7295a1f7 | 274 | friend class Test_M2MBase; |
ram54288 | 0:a2cb7295a1f7 | 275 | friend class Test_M2MResourceInstance; |
ram54288 | 0:a2cb7295a1f7 | 276 | }; |
ram54288 | 0:a2cb7295a1f7 | 277 | |
ram54288 | 0:a2cb7295a1f7 | 278 | /** |
ram54288 | 0:a2cb7295a1f7 | 279 | * \brief M2MResource::M2MExecuteParameter. |
ram54288 | 0:a2cb7295a1f7 | 280 | * This class handles the "Execute" operation arguments. |
ram54288 | 0:a2cb7295a1f7 | 281 | */ |
ram54288 | 0:a2cb7295a1f7 | 282 | class M2MResource::M2MExecuteParameter { |
ram54288 | 0:a2cb7295a1f7 | 283 | |
ram54288 | 0:a2cb7295a1f7 | 284 | private: |
ram54288 | 0:a2cb7295a1f7 | 285 | |
ram54288 | 0:a2cb7295a1f7 | 286 | /** |
ram54288 | 0:a2cb7295a1f7 | 287 | * \brief Constructor |
ram54288 | 0:a2cb7295a1f7 | 288 | */ |
ram54288 | 0:a2cb7295a1f7 | 289 | M2MExecuteParameter(); |
ram54288 | 0:a2cb7295a1f7 | 290 | |
ram54288 | 0:a2cb7295a1f7 | 291 | /** |
ram54288 | 0:a2cb7295a1f7 | 292 | * Destructor |
ram54288 | 0:a2cb7295a1f7 | 293 | */ |
ram54288 | 0:a2cb7295a1f7 | 294 | ~M2MExecuteParameter(); |
ram54288 | 0:a2cb7295a1f7 | 295 | |
ram54288 | 0:a2cb7295a1f7 | 296 | public: |
ram54288 | 0:a2cb7295a1f7 | 297 | |
ram54288 | 0:a2cb7295a1f7 | 298 | /** |
ram54288 | 0:a2cb7295a1f7 | 299 | * \brief Returns the value of an argument. |
ram54288 | 0:a2cb7295a1f7 | 300 | * \return uint8_t * The argument value. |
ram54288 | 0:a2cb7295a1f7 | 301 | */ |
ram54288 | 0:a2cb7295a1f7 | 302 | uint8_t *get_argument_value() const; |
ram54288 | 0:a2cb7295a1f7 | 303 | |
ram54288 | 0:a2cb7295a1f7 | 304 | /** |
ram54288 | 0:a2cb7295a1f7 | 305 | * \brief Returns the length of the value argument. |
ram54288 | 0:a2cb7295a1f7 | 306 | * \return uint8_t The argument value length. |
ram54288 | 0:a2cb7295a1f7 | 307 | */ |
ram54288 | 0:a2cb7295a1f7 | 308 | uint16_t get_argument_value_length() const; |
ram54288 | 0:a2cb7295a1f7 | 309 | |
ram54288 | 0:a2cb7295a1f7 | 310 | /** |
ram54288 | 0:a2cb7295a1f7 | 311 | * \brief Returns the name of the object where the resource exists. |
ram54288 | 0:a2cb7295a1f7 | 312 | * \return Object name. |
ram54288 | 0:a2cb7295a1f7 | 313 | */ |
ram54288 | 0:a2cb7295a1f7 | 314 | const String& get_argument_object_name() const; |
ram54288 | 0:a2cb7295a1f7 | 315 | |
ram54288 | 0:a2cb7295a1f7 | 316 | /** |
ram54288 | 0:a2cb7295a1f7 | 317 | * \brief Returns the resource name. |
ram54288 | 0:a2cb7295a1f7 | 318 | * \return Resource name. |
ram54288 | 0:a2cb7295a1f7 | 319 | */ |
ram54288 | 0:a2cb7295a1f7 | 320 | const String& get_argument_resource_name() const; |
ram54288 | 0:a2cb7295a1f7 | 321 | |
ram54288 | 0:a2cb7295a1f7 | 322 | /** |
ram54288 | 0:a2cb7295a1f7 | 323 | * \brief Returns the instance ID of the object where the resource exists. |
ram54288 | 0:a2cb7295a1f7 | 324 | * \return Object instance ID. |
ram54288 | 0:a2cb7295a1f7 | 325 | */ |
ram54288 | 0:a2cb7295a1f7 | 326 | uint16_t get_argument_object_instance_id() const; |
ram54288 | 0:a2cb7295a1f7 | 327 | |
ram54288 | 0:a2cb7295a1f7 | 328 | private: |
ram54288 | 0:a2cb7295a1f7 | 329 | |
ram54288 | 0:a2cb7295a1f7 | 330 | String _object_name; |
ram54288 | 0:a2cb7295a1f7 | 331 | String _resource_name; |
ram54288 | 0:a2cb7295a1f7 | 332 | uint8_t * _value; |
ram54288 | 0:a2cb7295a1f7 | 333 | uint16_t _value_length; |
ram54288 | 0:a2cb7295a1f7 | 334 | uint16_t _object_instance_id; |
ram54288 | 0:a2cb7295a1f7 | 335 | |
ram54288 | 0:a2cb7295a1f7 | 336 | |
ram54288 | 0:a2cb7295a1f7 | 337 | friend class Test_M2MResource; |
ram54288 | 0:a2cb7295a1f7 | 338 | friend class M2MResource; |
ram54288 | 0:a2cb7295a1f7 | 339 | }; |
ram54288 | 0:a2cb7295a1f7 | 340 | |
ram54288 | 0:a2cb7295a1f7 | 341 | #endif // M2M_RESOURCE_H |