FRDM K64F Metronome

Committer:
ram54288
Date:
Sun May 14 18:35:07 2017 +0000
Revision:
0:a2cb7295a1f7
Initial commit

Who changed what in which revision?

UserRevisionLine numberNew 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 #include "mbed-client/m2mconstants.h"
ram54288 0:a2cb7295a1f7 17 #include "mbed-client/m2mresource.h"
ram54288 0:a2cb7295a1f7 18 #include "mbed-client/m2mobservationhandler.h"
ram54288 0:a2cb7295a1f7 19 #include "include/m2mreporthandler.h"
ram54288 0:a2cb7295a1f7 20 #include "include/m2mtlvserializer.h"
ram54288 0:a2cb7295a1f7 21 #include "include/m2mtlvdeserializer.h"
ram54288 0:a2cb7295a1f7 22 #include "mbed-trace/mbed_trace.h"
ram54288 0:a2cb7295a1f7 23
ram54288 0:a2cb7295a1f7 24 #include <stdlib.h>
ram54288 0:a2cb7295a1f7 25
ram54288 0:a2cb7295a1f7 26 #define TRACE_GROUP "mClt"
ram54288 0:a2cb7295a1f7 27
ram54288 0:a2cb7295a1f7 28 M2MResource::M2MResource(M2MObjectInstance &parent,
ram54288 0:a2cb7295a1f7 29 const String &resource_name,
ram54288 0:a2cb7295a1f7 30 const String &resource_type,
ram54288 0:a2cb7295a1f7 31 M2MResourceInstance::ResourceType type,
ram54288 0:a2cb7295a1f7 32 const uint8_t *value,
ram54288 0:a2cb7295a1f7 33 const uint8_t value_length,
ram54288 0:a2cb7295a1f7 34 char *path,
ram54288 0:a2cb7295a1f7 35 const uint16_t object_instance_id,
ram54288 0:a2cb7295a1f7 36 bool multiple_instance,
ram54288 0:a2cb7295a1f7 37 bool external_blockwise_store)
ram54288 0:a2cb7295a1f7 38 : M2MResourceInstance(*this, resource_name, resource_type, type, value, value_length,
ram54288 0:a2cb7295a1f7 39 object_instance_id,
ram54288 0:a2cb7295a1f7 40 path, external_blockwise_store),
ram54288 0:a2cb7295a1f7 41 _parent(parent),
ram54288 0:a2cb7295a1f7 42 _delayed_token(NULL),
ram54288 0:a2cb7295a1f7 43 _delayed_token_len(0),
ram54288 0:a2cb7295a1f7 44 _has_multiple_instances(multiple_instance),
ram54288 0:a2cb7295a1f7 45 _delayed_response(false)
ram54288 0:a2cb7295a1f7 46 {
ram54288 0:a2cb7295a1f7 47 M2MBase::set_base_type(M2MBase::Resource);
ram54288 0:a2cb7295a1f7 48 M2MBase::set_operation(M2MBase::GET_ALLOWED);
ram54288 0:a2cb7295a1f7 49 M2MBase::set_observable(false);
ram54288 0:a2cb7295a1f7 50
ram54288 0:a2cb7295a1f7 51 }
ram54288 0:a2cb7295a1f7 52
ram54288 0:a2cb7295a1f7 53 M2MResource::M2MResource(M2MObjectInstance &parent,
ram54288 0:a2cb7295a1f7 54 const lwm2m_parameters_s* s,
ram54288 0:a2cb7295a1f7 55 M2MResourceInstance::ResourceType type,
ram54288 0:a2cb7295a1f7 56 const uint16_t object_instance_id)
ram54288 0:a2cb7295a1f7 57 : M2MResourceInstance(*this, s, type, object_instance_id),
ram54288 0:a2cb7295a1f7 58 _parent(parent),
ram54288 0:a2cb7295a1f7 59 _delayed_token(NULL),
ram54288 0:a2cb7295a1f7 60 _delayed_token_len(0),
ram54288 0:a2cb7295a1f7 61 _has_multiple_instances(false),
ram54288 0:a2cb7295a1f7 62 _delayed_response(false)
ram54288 0:a2cb7295a1f7 63 {
ram54288 0:a2cb7295a1f7 64 // tbd: _has_multiple_instances could be in flash, but no real benefit, because of current alignment.
ram54288 0:a2cb7295a1f7 65 }
ram54288 0:a2cb7295a1f7 66
ram54288 0:a2cb7295a1f7 67 M2MResource::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 bool observable,
ram54288 0:a2cb7295a1f7 72 char *path,
ram54288 0:a2cb7295a1f7 73 const uint16_t object_instance_id,
ram54288 0:a2cb7295a1f7 74 bool multiple_instance,
ram54288 0:a2cb7295a1f7 75 bool external_blockwise_store)
ram54288 0:a2cb7295a1f7 76 : M2MResourceInstance(*this, resource_name, resource_type, type,
ram54288 0:a2cb7295a1f7 77 object_instance_id,
ram54288 0:a2cb7295a1f7 78 path,
ram54288 0:a2cb7295a1f7 79 external_blockwise_store),
ram54288 0:a2cb7295a1f7 80 _parent(parent),
ram54288 0:a2cb7295a1f7 81 _delayed_token(NULL),
ram54288 0:a2cb7295a1f7 82 _delayed_token_len(0),
ram54288 0:a2cb7295a1f7 83 _has_multiple_instances(multiple_instance),
ram54288 0:a2cb7295a1f7 84 _delayed_response(false)
ram54288 0:a2cb7295a1f7 85 {
ram54288 0:a2cb7295a1f7 86 M2MBase::set_base_type(M2MBase::Resource);
ram54288 0:a2cb7295a1f7 87 M2MBase::set_operation(M2MBase::GET_PUT_ALLOWED);
ram54288 0:a2cb7295a1f7 88 M2MBase::set_observable(observable);
ram54288 0:a2cb7295a1f7 89 }
ram54288 0:a2cb7295a1f7 90
ram54288 0:a2cb7295a1f7 91
ram54288 0:a2cb7295a1f7 92 M2MResource::~M2MResource()
ram54288 0:a2cb7295a1f7 93 {
ram54288 0:a2cb7295a1f7 94 if(!_resource_instance_list.empty()) {
ram54288 0:a2cb7295a1f7 95 M2MResourceInstance* res = NULL;
ram54288 0:a2cb7295a1f7 96 M2MResourceInstanceList::const_iterator it;
ram54288 0:a2cb7295a1f7 97 it = _resource_instance_list.begin();
ram54288 0:a2cb7295a1f7 98 for (; it!=_resource_instance_list.end(); it++ ) {
ram54288 0:a2cb7295a1f7 99 //Free allocated memory for resources.
ram54288 0:a2cb7295a1f7 100 res = *it;
ram54288 0:a2cb7295a1f7 101 delete res;
ram54288 0:a2cb7295a1f7 102 }
ram54288 0:a2cb7295a1f7 103 _resource_instance_list.clear();
ram54288 0:a2cb7295a1f7 104 }
ram54288 0:a2cb7295a1f7 105 free(_delayed_token);
ram54288 0:a2cb7295a1f7 106 }
ram54288 0:a2cb7295a1f7 107
ram54288 0:a2cb7295a1f7 108 bool M2MResource::supports_multiple_instances() const
ram54288 0:a2cb7295a1f7 109 {
ram54288 0:a2cb7295a1f7 110 return _has_multiple_instances;
ram54288 0:a2cb7295a1f7 111 }
ram54288 0:a2cb7295a1f7 112
ram54288 0:a2cb7295a1f7 113 void M2MResource::set_delayed_response(bool delayed_response)
ram54288 0:a2cb7295a1f7 114 {
ram54288 0:a2cb7295a1f7 115 _delayed_response = delayed_response;
ram54288 0:a2cb7295a1f7 116 }
ram54288 0:a2cb7295a1f7 117
ram54288 0:a2cb7295a1f7 118 bool M2MResource::send_delayed_post_response()
ram54288 0:a2cb7295a1f7 119 {
ram54288 0:a2cb7295a1f7 120 bool success = false;
ram54288 0:a2cb7295a1f7 121 if(_delayed_response) {
ram54288 0:a2cb7295a1f7 122 success = true;
ram54288 0:a2cb7295a1f7 123 observation_handler()->send_delayed_response(this);
ram54288 0:a2cb7295a1f7 124 }
ram54288 0:a2cb7295a1f7 125 return success;
ram54288 0:a2cb7295a1f7 126 }
ram54288 0:a2cb7295a1f7 127
ram54288 0:a2cb7295a1f7 128 void M2MResource::get_delayed_token(uint8_t *&token, uint8_t &token_length)
ram54288 0:a2cb7295a1f7 129 {
ram54288 0:a2cb7295a1f7 130 token_length = 0;
ram54288 0:a2cb7295a1f7 131 if(token) {
ram54288 0:a2cb7295a1f7 132 free(token);
ram54288 0:a2cb7295a1f7 133 token = NULL;
ram54288 0:a2cb7295a1f7 134 }
ram54288 0:a2cb7295a1f7 135 if(_delayed_token && _delayed_token_len > 0) {
ram54288 0:a2cb7295a1f7 136 token = alloc_copy(_delayed_token, _delayed_token_len);
ram54288 0:a2cb7295a1f7 137 if(token) {
ram54288 0:a2cb7295a1f7 138 token_length = _delayed_token_len;
ram54288 0:a2cb7295a1f7 139 }
ram54288 0:a2cb7295a1f7 140 }
ram54288 0:a2cb7295a1f7 141 }
ram54288 0:a2cb7295a1f7 142
ram54288 0:a2cb7295a1f7 143 bool M2MResource::remove_resource_instance(uint16_t inst_id)
ram54288 0:a2cb7295a1f7 144 {
ram54288 0:a2cb7295a1f7 145 tr_debug("M2MResource::remove_resource(inst_id %d)", inst_id);
ram54288 0:a2cb7295a1f7 146 bool success = false;
ram54288 0:a2cb7295a1f7 147 if(!_resource_instance_list.empty()) {
ram54288 0:a2cb7295a1f7 148 M2MResourceInstance* res = NULL;
ram54288 0:a2cb7295a1f7 149 M2MResourceInstanceList::const_iterator it;
ram54288 0:a2cb7295a1f7 150 it = _resource_instance_list.begin();
ram54288 0:a2cb7295a1f7 151 int pos = 0;
ram54288 0:a2cb7295a1f7 152 for ( ; it != _resource_instance_list.end(); it++, pos++ ) {
ram54288 0:a2cb7295a1f7 153 if(((*it)->instance_id() == inst_id)) {
ram54288 0:a2cb7295a1f7 154 // Resource found and deleted.
ram54288 0:a2cb7295a1f7 155 res = *it;
ram54288 0:a2cb7295a1f7 156 delete res;
ram54288 0:a2cb7295a1f7 157 _resource_instance_list.erase(pos);
ram54288 0:a2cb7295a1f7 158 success = true;
ram54288 0:a2cb7295a1f7 159 break;
ram54288 0:a2cb7295a1f7 160 }
ram54288 0:a2cb7295a1f7 161 }
ram54288 0:a2cb7295a1f7 162 }
ram54288 0:a2cb7295a1f7 163 return success;
ram54288 0:a2cb7295a1f7 164 }
ram54288 0:a2cb7295a1f7 165
ram54288 0:a2cb7295a1f7 166 M2MResourceInstance* M2MResource::resource_instance(uint16_t inst_id) const
ram54288 0:a2cb7295a1f7 167 {
ram54288 0:a2cb7295a1f7 168 tr_debug("M2MResource::resource(resource_name inst_id %d)", inst_id);
ram54288 0:a2cb7295a1f7 169 M2MResourceInstance *res = NULL;
ram54288 0:a2cb7295a1f7 170 if(!_resource_instance_list.empty()) {
ram54288 0:a2cb7295a1f7 171 M2MResourceInstanceList::const_iterator it;
ram54288 0:a2cb7295a1f7 172 it = _resource_instance_list.begin();
ram54288 0:a2cb7295a1f7 173 for ( ; it != _resource_instance_list.end(); it++ ) {
ram54288 0:a2cb7295a1f7 174 if(((*it)->instance_id() == inst_id)) {
ram54288 0:a2cb7295a1f7 175 // Resource found.
ram54288 0:a2cb7295a1f7 176 res = *it;
ram54288 0:a2cb7295a1f7 177 break;
ram54288 0:a2cb7295a1f7 178 }
ram54288 0:a2cb7295a1f7 179 }
ram54288 0:a2cb7295a1f7 180 }
ram54288 0:a2cb7295a1f7 181 return res;
ram54288 0:a2cb7295a1f7 182 }
ram54288 0:a2cb7295a1f7 183
ram54288 0:a2cb7295a1f7 184 const M2MResourceInstanceList& M2MResource::resource_instances() const
ram54288 0:a2cb7295a1f7 185 {
ram54288 0:a2cb7295a1f7 186 return _resource_instance_list;
ram54288 0:a2cb7295a1f7 187 }
ram54288 0:a2cb7295a1f7 188
ram54288 0:a2cb7295a1f7 189 uint16_t M2MResource::resource_instance_count() const
ram54288 0:a2cb7295a1f7 190 {
ram54288 0:a2cb7295a1f7 191 return (uint16_t)_resource_instance_list.size();
ram54288 0:a2cb7295a1f7 192 }
ram54288 0:a2cb7295a1f7 193
ram54288 0:a2cb7295a1f7 194 bool M2MResource::delayed_response() const
ram54288 0:a2cb7295a1f7 195 {
ram54288 0:a2cb7295a1f7 196 return _delayed_response;
ram54288 0:a2cb7295a1f7 197 }
ram54288 0:a2cb7295a1f7 198
ram54288 0:a2cb7295a1f7 199 bool M2MResource::handle_observation_attribute(const char *query)
ram54288 0:a2cb7295a1f7 200 {
ram54288 0:a2cb7295a1f7 201 tr_debug("M2MResource::handle_observation_attribute - is_under_observation(%d)", is_under_observation());
ram54288 0:a2cb7295a1f7 202 bool success = false;
ram54288 0:a2cb7295a1f7 203 M2MReportHandler *handler = M2MBase::report_handler();
ram54288 0:a2cb7295a1f7 204 if (!handler) {
ram54288 0:a2cb7295a1f7 205 handler = M2MBase::create_report_handler();
ram54288 0:a2cb7295a1f7 206 }
ram54288 0:a2cb7295a1f7 207
ram54288 0:a2cb7295a1f7 208 if (handler) {
ram54288 0:a2cb7295a1f7 209 success = handler->parse_notification_attribute(query,
ram54288 0:a2cb7295a1f7 210 M2MBase::base_type(), _resource_type);
ram54288 0:a2cb7295a1f7 211 if (success) {
ram54288 0:a2cb7295a1f7 212 if (is_under_observation()) {
ram54288 0:a2cb7295a1f7 213 handler->set_under_observation(true);
ram54288 0:a2cb7295a1f7 214 }
ram54288 0:a2cb7295a1f7 215 }
ram54288 0:a2cb7295a1f7 216 else {
ram54288 0:a2cb7295a1f7 217 handler->set_default_values();
ram54288 0:a2cb7295a1f7 218 }
ram54288 0:a2cb7295a1f7 219
ram54288 0:a2cb7295a1f7 220 if (success) {
ram54288 0:a2cb7295a1f7 221 if(!_resource_instance_list.empty()) {
ram54288 0:a2cb7295a1f7 222 M2MResourceInstanceList::const_iterator it;
ram54288 0:a2cb7295a1f7 223 it = _resource_instance_list.begin();
ram54288 0:a2cb7295a1f7 224 for ( ; it != _resource_instance_list.end(); it++ ) {
ram54288 0:a2cb7295a1f7 225 M2MReportHandler *report_handler = (*it)->report_handler();
ram54288 0:a2cb7295a1f7 226 if(report_handler && is_under_observation()) {
ram54288 0:a2cb7295a1f7 227 report_handler->set_notification_trigger();
ram54288 0:a2cb7295a1f7 228 }
ram54288 0:a2cb7295a1f7 229 }
ram54288 0:a2cb7295a1f7 230 }
ram54288 0:a2cb7295a1f7 231 }
ram54288 0:a2cb7295a1f7 232 }
ram54288 0:a2cb7295a1f7 233 return success;
ram54288 0:a2cb7295a1f7 234 }
ram54288 0:a2cb7295a1f7 235
ram54288 0:a2cb7295a1f7 236 void M2MResource::add_observation_level(M2MBase::Observation observation_level)
ram54288 0:a2cb7295a1f7 237 {
ram54288 0:a2cb7295a1f7 238 M2MBase::add_observation_level(observation_level);
ram54288 0:a2cb7295a1f7 239 if(!_resource_instance_list.empty()) {
ram54288 0:a2cb7295a1f7 240 M2MResourceInstanceList::const_iterator inst;
ram54288 0:a2cb7295a1f7 241 inst = _resource_instance_list.begin();
ram54288 0:a2cb7295a1f7 242 for ( ; inst != _resource_instance_list.end(); inst++ ) {
ram54288 0:a2cb7295a1f7 243 (*inst)->add_observation_level(observation_level);
ram54288 0:a2cb7295a1f7 244 }
ram54288 0:a2cb7295a1f7 245 }
ram54288 0:a2cb7295a1f7 246 }
ram54288 0:a2cb7295a1f7 247
ram54288 0:a2cb7295a1f7 248 void M2MResource::remove_observation_level(M2MBase::Observation observation_level)
ram54288 0:a2cb7295a1f7 249 {
ram54288 0:a2cb7295a1f7 250 M2MBase::remove_observation_level(observation_level);
ram54288 0:a2cb7295a1f7 251 if(!_resource_instance_list.empty()) {
ram54288 0:a2cb7295a1f7 252 M2MResourceInstanceList::const_iterator inst;
ram54288 0:a2cb7295a1f7 253 inst = _resource_instance_list.begin();
ram54288 0:a2cb7295a1f7 254 for ( ; inst != _resource_instance_list.end(); inst++ ) {
ram54288 0:a2cb7295a1f7 255 (*inst)->remove_observation_level(observation_level);
ram54288 0:a2cb7295a1f7 256 }
ram54288 0:a2cb7295a1f7 257 }
ram54288 0:a2cb7295a1f7 258 }
ram54288 0:a2cb7295a1f7 259
ram54288 0:a2cb7295a1f7 260 void M2MResource::add_resource_instance(M2MResourceInstance *res)
ram54288 0:a2cb7295a1f7 261 {
ram54288 0:a2cb7295a1f7 262 tr_debug("M2MResource::add_resource_instance()");
ram54288 0:a2cb7295a1f7 263 if(res) {
ram54288 0:a2cb7295a1f7 264 _resource_instance_list.push_back(res);
ram54288 0:a2cb7295a1f7 265 }
ram54288 0:a2cb7295a1f7 266 }
ram54288 0:a2cb7295a1f7 267
ram54288 0:a2cb7295a1f7 268 sn_coap_hdr_s* M2MResource::handle_get_request(nsdl_s *nsdl,
ram54288 0:a2cb7295a1f7 269 sn_coap_hdr_s *received_coap_header,
ram54288 0:a2cb7295a1f7 270 M2MObservationHandler *observation_handler)
ram54288 0:a2cb7295a1f7 271 {
ram54288 0:a2cb7295a1f7 272 tr_debug("M2MResource::handle_get_request()");
ram54288 0:a2cb7295a1f7 273 sn_coap_msg_code_e msg_code = COAP_MSG_CODE_RESPONSE_CONTENT;
ram54288 0:a2cb7295a1f7 274 sn_coap_hdr_s * coap_response = NULL;
ram54288 0:a2cb7295a1f7 275 if(_has_multiple_instances) {
ram54288 0:a2cb7295a1f7 276 coap_response = sn_nsdl_build_response(nsdl,
ram54288 0:a2cb7295a1f7 277 received_coap_header,
ram54288 0:a2cb7295a1f7 278 msg_code);
ram54288 0:a2cb7295a1f7 279 if(received_coap_header) {
ram54288 0:a2cb7295a1f7 280 // process the GET if we have registered a callback for it
ram54288 0:a2cb7295a1f7 281 if ((operation() & SN_GRS_GET_ALLOWED) != 0) {
ram54288 0:a2cb7295a1f7 282 if(coap_response) {
ram54288 0:a2cb7295a1f7 283 uint16_t coap_content_type = 0;
ram54288 0:a2cb7295a1f7 284 bool content_type_present = false;
ram54288 0:a2cb7295a1f7 285 if(received_coap_header->content_format != COAP_CT_NONE){
ram54288 0:a2cb7295a1f7 286 content_type_present = true;
ram54288 0:a2cb7295a1f7 287 coap_content_type = received_coap_header->content_format;
ram54288 0:a2cb7295a1f7 288 }
ram54288 0:a2cb7295a1f7 289
ram54288 0:a2cb7295a1f7 290 if(!content_type_present &&
ram54288 0:a2cb7295a1f7 291 M2MBase::coap_content_type() == COAP_CONTENT_OMA_TLV_TYPE) {
ram54288 0:a2cb7295a1f7 292 coap_content_type = COAP_CONTENT_OMA_TLV_TYPE;
ram54288 0:a2cb7295a1f7 293 }
ram54288 0:a2cb7295a1f7 294
ram54288 0:a2cb7295a1f7 295 tr_debug("M2MResource::handle_get_request() - Request Content-Type %d", coap_content_type);
ram54288 0:a2cb7295a1f7 296 if (coap_response->content_format == COAP_CT_NONE) {
ram54288 0:a2cb7295a1f7 297 coap_response->content_format = sn_coap_content_format_e(coap_content_type);
ram54288 0:a2cb7295a1f7 298 if (coap_response->content_format != COAP_CT_NONE) {
ram54288 0:a2cb7295a1f7 299 set_coap_content_type(coap_content_type);
ram54288 0:a2cb7295a1f7 300 }
ram54288 0:a2cb7295a1f7 301 }
ram54288 0:a2cb7295a1f7 302 uint8_t *data = NULL;
ram54288 0:a2cb7295a1f7 303 uint32_t data_length = 0;
ram54288 0:a2cb7295a1f7 304 // fill in the CoAP response payload
ram54288 0:a2cb7295a1f7 305 if(COAP_CONTENT_OMA_TLV_TYPE == coap_content_type) {
ram54288 0:a2cb7295a1f7 306 M2MTLVSerializer serializer;
ram54288 0:a2cb7295a1f7 307 data = serializer.serialize(this, data_length);
ram54288 0:a2cb7295a1f7 308 } else {
ram54288 0:a2cb7295a1f7 309 msg_code = COAP_MSG_CODE_RESPONSE_UNSUPPORTED_CONTENT_FORMAT; // Content format not supported
ram54288 0:a2cb7295a1f7 310 }
ram54288 0:a2cb7295a1f7 311
ram54288 0:a2cb7295a1f7 312 coap_response->payload_len = data_length;
ram54288 0:a2cb7295a1f7 313 coap_response->payload_ptr = data;
ram54288 0:a2cb7295a1f7 314
ram54288 0:a2cb7295a1f7 315 coap_response->options_list_ptr = sn_nsdl_alloc_options_list(nsdl, coap_response);
ram54288 0:a2cb7295a1f7 316
ram54288 0:a2cb7295a1f7 317 coap_response->options_list_ptr->max_age = max_age();
ram54288 0:a2cb7295a1f7 318
ram54288 0:a2cb7295a1f7 319 if(received_coap_header->options_list_ptr) {
ram54288 0:a2cb7295a1f7 320 if(received_coap_header->options_list_ptr->observe != -1) {
ram54288 0:a2cb7295a1f7 321 if (is_observable()) {
ram54288 0:a2cb7295a1f7 322 uint32_t number = 0;
ram54288 0:a2cb7295a1f7 323 uint8_t observe_option = 0;
ram54288 0:a2cb7295a1f7 324 observe_option = received_coap_header->options_list_ptr->observe;
ram54288 0:a2cb7295a1f7 325 if(START_OBSERVATION == observe_option) {
ram54288 0:a2cb7295a1f7 326 tr_debug("M2MResource::handle_get_request - Starts Observation");
ram54288 0:a2cb7295a1f7 327 // If the observe length is 0 means register for observation.
ram54288 0:a2cb7295a1f7 328 if(received_coap_header->options_list_ptr->observe != -1) {
ram54288 0:a2cb7295a1f7 329 number = received_coap_header->options_list_ptr->observe;
ram54288 0:a2cb7295a1f7 330 }
ram54288 0:a2cb7295a1f7 331 if(received_coap_header->token_ptr) {
ram54288 0:a2cb7295a1f7 332 tr_debug("M2MResource::handle_get_request - Sets Observation Token to resource");
ram54288 0:a2cb7295a1f7 333 set_observation_token(received_coap_header->token_ptr,
ram54288 0:a2cb7295a1f7 334 received_coap_header->token_len);
ram54288 0:a2cb7295a1f7 335 }
ram54288 0:a2cb7295a1f7 336
ram54288 0:a2cb7295a1f7 337 // If the observe value is 0 means register for observation.
ram54288 0:a2cb7295a1f7 338 if(number == 0) {
ram54288 0:a2cb7295a1f7 339 tr_debug("M2MResource::handle_get_request - Put Resource under Observation");
ram54288 0:a2cb7295a1f7 340 M2MResourceInstanceList::const_iterator it;
ram54288 0:a2cb7295a1f7 341 it = _resource_instance_list.begin();
ram54288 0:a2cb7295a1f7 342 for (; it!=_resource_instance_list.end(); it++ ) {
ram54288 0:a2cb7295a1f7 343 tr_debug("M2MResource::handle_get_request - set_resource_observer");
ram54288 0:a2cb7295a1f7 344 (*it)->set_resource_observer(this);
ram54288 0:a2cb7295a1f7 345 (*it)->add_observation_level(M2MBase::R_Attribute);
ram54288 0:a2cb7295a1f7 346 }
ram54288 0:a2cb7295a1f7 347 set_under_observation(true,observation_handler);
ram54288 0:a2cb7295a1f7 348 M2MBase::add_observation_level(M2MBase::R_Attribute);
ram54288 0:a2cb7295a1f7 349 coap_response->options_list_ptr->observe = observation_number();
ram54288 0:a2cb7295a1f7 350 }
ram54288 0:a2cb7295a1f7 351 } else if (STOP_OBSERVATION == observe_option) {
ram54288 0:a2cb7295a1f7 352 tr_debug("M2MResource::handle_get_request - Stops Observation");
ram54288 0:a2cb7295a1f7 353 set_under_observation(false,NULL);
ram54288 0:a2cb7295a1f7 354 M2MBase::remove_observation_level(M2MBase::R_Attribute);
ram54288 0:a2cb7295a1f7 355 M2MResourceInstanceList::const_iterator it;
ram54288 0:a2cb7295a1f7 356 it = _resource_instance_list.begin();
ram54288 0:a2cb7295a1f7 357 for (; it!=_resource_instance_list.end(); it++ ) {
ram54288 0:a2cb7295a1f7 358 (*it)->set_resource_observer(NULL);
ram54288 0:a2cb7295a1f7 359 }
ram54288 0:a2cb7295a1f7 360 }
ram54288 0:a2cb7295a1f7 361 msg_code = COAP_MSG_CODE_RESPONSE_CONTENT;
ram54288 0:a2cb7295a1f7 362 }
ram54288 0:a2cb7295a1f7 363 else {
ram54288 0:a2cb7295a1f7 364 msg_code = COAP_MSG_CODE_RESPONSE_METHOD_NOT_ALLOWED;
ram54288 0:a2cb7295a1f7 365 }
ram54288 0:a2cb7295a1f7 366 }
ram54288 0:a2cb7295a1f7 367 }
ram54288 0:a2cb7295a1f7 368 }
ram54288 0:a2cb7295a1f7 369 } else {
ram54288 0:a2cb7295a1f7 370 tr_error("M2MResource::handle_get_request - Return COAP_MSG_CODE_RESPONSE_METHOD_NOT_ALLOWED");
ram54288 0:a2cb7295a1f7 371 // Operation is not allowed.
ram54288 0:a2cb7295a1f7 372 msg_code = COAP_MSG_CODE_RESPONSE_METHOD_NOT_ALLOWED;
ram54288 0:a2cb7295a1f7 373 }
ram54288 0:a2cb7295a1f7 374 }
ram54288 0:a2cb7295a1f7 375 if(coap_response) {
ram54288 0:a2cb7295a1f7 376 coap_response->msg_code = msg_code;
ram54288 0:a2cb7295a1f7 377 }
ram54288 0:a2cb7295a1f7 378 } else {
ram54288 0:a2cb7295a1f7 379 coap_response = M2MResourceInstance::handle_get_request(nsdl,
ram54288 0:a2cb7295a1f7 380 received_coap_header,
ram54288 0:a2cb7295a1f7 381 observation_handler);
ram54288 0:a2cb7295a1f7 382 }
ram54288 0:a2cb7295a1f7 383 return coap_response;
ram54288 0:a2cb7295a1f7 384 }
ram54288 0:a2cb7295a1f7 385
ram54288 0:a2cb7295a1f7 386 sn_coap_hdr_s* M2MResource::handle_put_request(nsdl_s *nsdl,
ram54288 0:a2cb7295a1f7 387 sn_coap_hdr_s *received_coap_header,
ram54288 0:a2cb7295a1f7 388 M2MObservationHandler *observation_handler,
ram54288 0:a2cb7295a1f7 389 bool &execute_value_updated)
ram54288 0:a2cb7295a1f7 390 {
ram54288 0:a2cb7295a1f7 391 tr_debug("M2MResource::handle_put_request()");
ram54288 0:a2cb7295a1f7 392 sn_coap_msg_code_e msg_code = COAP_MSG_CODE_RESPONSE_CHANGED; // 2.04
ram54288 0:a2cb7295a1f7 393 sn_coap_hdr_s * coap_response = NULL;
ram54288 0:a2cb7295a1f7 394 if(_has_multiple_instances) {
ram54288 0:a2cb7295a1f7 395 coap_response = sn_nsdl_build_response(nsdl,
ram54288 0:a2cb7295a1f7 396 received_coap_header,
ram54288 0:a2cb7295a1f7 397 msg_code);
ram54288 0:a2cb7295a1f7 398 // process the PUT if we have registered a callback for it
ram54288 0:a2cb7295a1f7 399 if(received_coap_header) {
ram54288 0:a2cb7295a1f7 400 uint16_t coap_content_type = 0;
ram54288 0:a2cb7295a1f7 401 bool content_type_present = false;
ram54288 0:a2cb7295a1f7 402 if(received_coap_header->content_format != COAP_CT_NONE && coap_response) {
ram54288 0:a2cb7295a1f7 403 content_type_present = true;
ram54288 0:a2cb7295a1f7 404 coap_content_type = received_coap_header->content_format;
ram54288 0:a2cb7295a1f7 405 }
ram54288 0:a2cb7295a1f7 406 if(received_coap_header->options_list_ptr &&
ram54288 0:a2cb7295a1f7 407 received_coap_header->options_list_ptr->uri_query_ptr) {
ram54288 0:a2cb7295a1f7 408 char *query = (char*)alloc_string_copy(received_coap_header->options_list_ptr->uri_query_ptr,
ram54288 0:a2cb7295a1f7 409 received_coap_header->options_list_ptr->uri_query_len);
ram54288 0:a2cb7295a1f7 410 if (query){
ram54288 0:a2cb7295a1f7 411 msg_code = COAP_MSG_CODE_RESPONSE_CHANGED;
ram54288 0:a2cb7295a1f7 412 tr_debug("M2MResource::handle_put_request() - Query %s", query);
ram54288 0:a2cb7295a1f7 413 // if anything was updated, re-initialize the stored notification attributes
ram54288 0:a2cb7295a1f7 414 if (!handle_observation_attribute(query)){
ram54288 0:a2cb7295a1f7 415 tr_debug("M2MResource::handle_put_request() - Invalid query");
ram54288 0:a2cb7295a1f7 416 msg_code = COAP_MSG_CODE_RESPONSE_BAD_REQUEST; // 4.00
ram54288 0:a2cb7295a1f7 417 }
ram54288 0:a2cb7295a1f7 418 free(query);
ram54288 0:a2cb7295a1f7 419 }
ram54288 0:a2cb7295a1f7 420 } else if ((operation() & SN_GRS_PUT_ALLOWED) != 0) {
ram54288 0:a2cb7295a1f7 421 if(!content_type_present &&
ram54288 0:a2cb7295a1f7 422 M2MBase::coap_content_type() == COAP_CONTENT_OMA_TLV_TYPE) {
ram54288 0:a2cb7295a1f7 423 coap_content_type = COAP_CONTENT_OMA_TLV_TYPE;
ram54288 0:a2cb7295a1f7 424 }
ram54288 0:a2cb7295a1f7 425
ram54288 0:a2cb7295a1f7 426 tr_debug("M2MResource::handle_put_request() - Request Content-Type %d", coap_content_type);
ram54288 0:a2cb7295a1f7 427
ram54288 0:a2cb7295a1f7 428 if(COAP_CONTENT_OMA_TLV_TYPE == coap_content_type) {
ram54288 0:a2cb7295a1f7 429 M2MTLVDeserializer deserializer;
ram54288 0:a2cb7295a1f7 430 M2MTLVDeserializer::Error error = M2MTLVDeserializer::None;
ram54288 0:a2cb7295a1f7 431 error = deserializer.deserialize_resource_instances(received_coap_header->payload_ptr,
ram54288 0:a2cb7295a1f7 432 received_coap_header->payload_len,
ram54288 0:a2cb7295a1f7 433 *this,
ram54288 0:a2cb7295a1f7 434 M2MTLVDeserializer::Put);
ram54288 0:a2cb7295a1f7 435 switch(error) {
ram54288 0:a2cb7295a1f7 436 case M2MTLVDeserializer::None:
ram54288 0:a2cb7295a1f7 437 if(observation_handler) {
ram54288 0:a2cb7295a1f7 438 String value = "";
ram54288 0:a2cb7295a1f7 439 if (received_coap_header->uri_path_ptr != NULL &&
ram54288 0:a2cb7295a1f7 440 received_coap_header->uri_path_len > 0) {
ram54288 0:a2cb7295a1f7 441
ram54288 0:a2cb7295a1f7 442 value.append_raw((char*)received_coap_header->uri_path_ptr,received_coap_header->uri_path_len);
ram54288 0:a2cb7295a1f7 443 }
ram54288 0:a2cb7295a1f7 444 execute_value_updated = true;
ram54288 0:a2cb7295a1f7 445 }
ram54288 0:a2cb7295a1f7 446 msg_code = COAP_MSG_CODE_RESPONSE_CHANGED;
ram54288 0:a2cb7295a1f7 447 break;
ram54288 0:a2cb7295a1f7 448 case M2MTLVDeserializer::NotFound:
ram54288 0:a2cb7295a1f7 449 msg_code = COAP_MSG_CODE_RESPONSE_NOT_FOUND;
ram54288 0:a2cb7295a1f7 450 break;
ram54288 0:a2cb7295a1f7 451 case M2MTLVDeserializer::NotAllowed:
ram54288 0:a2cb7295a1f7 452 msg_code = COAP_MSG_CODE_RESPONSE_METHOD_NOT_ALLOWED;
ram54288 0:a2cb7295a1f7 453 break;
ram54288 0:a2cb7295a1f7 454 case M2MTLVDeserializer::NotValid:
ram54288 0:a2cb7295a1f7 455 msg_code = COAP_MSG_CODE_RESPONSE_BAD_REQUEST;
ram54288 0:a2cb7295a1f7 456 break;
ram54288 0:a2cb7295a1f7 457 }
ram54288 0:a2cb7295a1f7 458 } else {
ram54288 0:a2cb7295a1f7 459 msg_code =COAP_MSG_CODE_RESPONSE_UNSUPPORTED_CONTENT_FORMAT;
ram54288 0:a2cb7295a1f7 460 } // if(COAP_CONTENT_OMA_TLV_TYPE == coap_content_type)
ram54288 0:a2cb7295a1f7 461 } else {
ram54288 0:a2cb7295a1f7 462 // Operation is not allowed.
ram54288 0:a2cb7295a1f7 463 tr_error("M2MResource::handle_put_request() - COAP_MSG_CODE_RESPONSE_METHOD_NOT_ALLOWED");
ram54288 0:a2cb7295a1f7 464 msg_code = COAP_MSG_CODE_RESPONSE_METHOD_NOT_ALLOWED;
ram54288 0:a2cb7295a1f7 465 }
ram54288 0:a2cb7295a1f7 466 } else {
ram54288 0:a2cb7295a1f7 467 msg_code = COAP_MSG_CODE_RESPONSE_METHOD_NOT_ALLOWED;
ram54288 0:a2cb7295a1f7 468 }
ram54288 0:a2cb7295a1f7 469 if(coap_response) {
ram54288 0:a2cb7295a1f7 470 coap_response->msg_code = msg_code;
ram54288 0:a2cb7295a1f7 471 }
ram54288 0:a2cb7295a1f7 472 } else {
ram54288 0:a2cb7295a1f7 473 coap_response = M2MResourceInstance::handle_put_request(nsdl,
ram54288 0:a2cb7295a1f7 474 received_coap_header,
ram54288 0:a2cb7295a1f7 475 observation_handler,
ram54288 0:a2cb7295a1f7 476 execute_value_updated);
ram54288 0:a2cb7295a1f7 477 }
ram54288 0:a2cb7295a1f7 478 return coap_response;
ram54288 0:a2cb7295a1f7 479 }
ram54288 0:a2cb7295a1f7 480
ram54288 0:a2cb7295a1f7 481 sn_coap_hdr_s* M2MResource::handle_post_request(nsdl_s *nsdl,
ram54288 0:a2cb7295a1f7 482 sn_coap_hdr_s *received_coap_header,
ram54288 0:a2cb7295a1f7 483 M2MObservationHandler */*observation_handler*/,
ram54288 0:a2cb7295a1f7 484 bool &/*execute_value_updated*/,
ram54288 0:a2cb7295a1f7 485 sn_nsdl_addr_s *address)
ram54288 0:a2cb7295a1f7 486 {
ram54288 0:a2cb7295a1f7 487 tr_debug("M2MResource::handle_post_request()");
ram54288 0:a2cb7295a1f7 488 sn_coap_msg_code_e msg_code = COAP_MSG_CODE_RESPONSE_CHANGED; // 2.04
ram54288 0:a2cb7295a1f7 489 sn_coap_hdr_s * coap_response = sn_nsdl_build_response(nsdl,
ram54288 0:a2cb7295a1f7 490 received_coap_header,
ram54288 0:a2cb7295a1f7 491 msg_code);
ram54288 0:a2cb7295a1f7 492 // process the POST if we have registered a callback for it
ram54288 0:a2cb7295a1f7 493 if(received_coap_header) {
ram54288 0:a2cb7295a1f7 494 if ((operation() & SN_GRS_POST_ALLOWED) != 0) {
ram54288 0:a2cb7295a1f7 495 M2MResource::M2MExecuteParameter *exec_params = new M2MResource::M2MExecuteParameter();
ram54288 0:a2cb7295a1f7 496 if (exec_params) {
ram54288 0:a2cb7295a1f7 497 exec_params->_object_name = object_name();
ram54288 0:a2cb7295a1f7 498 exec_params->_resource_name = name();
ram54288 0:a2cb7295a1f7 499 exec_params->_object_instance_id = object_instance_id();
ram54288 0:a2cb7295a1f7 500 }
ram54288 0:a2cb7295a1f7 501 uint16_t coap_content_type = 0;
ram54288 0:a2cb7295a1f7 502 if(received_coap_header->payload_ptr) {
ram54288 0:a2cb7295a1f7 503 if(received_coap_header->content_format != COAP_CT_NONE) {
ram54288 0:a2cb7295a1f7 504 coap_content_type = received_coap_header->content_format;
ram54288 0:a2cb7295a1f7 505 }
ram54288 0:a2cb7295a1f7 506 if(coap_content_type == 0) {
ram54288 0:a2cb7295a1f7 507 if (exec_params){
ram54288 0:a2cb7295a1f7 508 exec_params->_value = alloc_string_copy(received_coap_header->payload_ptr,
ram54288 0:a2cb7295a1f7 509 received_coap_header->payload_len);
ram54288 0:a2cb7295a1f7 510 if (exec_params->_value) {
ram54288 0:a2cb7295a1f7 511 exec_params->_value_length = received_coap_header->payload_len;
ram54288 0:a2cb7295a1f7 512 }
ram54288 0:a2cb7295a1f7 513 }
ram54288 0:a2cb7295a1f7 514 } else {
ram54288 0:a2cb7295a1f7 515 msg_code = COAP_MSG_CODE_RESPONSE_UNSUPPORTED_CONTENT_FORMAT;
ram54288 0:a2cb7295a1f7 516 }
ram54288 0:a2cb7295a1f7 517 }
ram54288 0:a2cb7295a1f7 518 if(COAP_MSG_CODE_RESPONSE_CHANGED == msg_code) {
ram54288 0:a2cb7295a1f7 519 tr_debug("M2MResource::handle_post_request - Execute resource function");
ram54288 0:a2cb7295a1f7 520 if(_delayed_response) {
ram54288 0:a2cb7295a1f7 521 msg_code = COAP_MSG_CODE_EMPTY;
ram54288 0:a2cb7295a1f7 522 coap_response->msg_type = COAP_MSG_TYPE_ACKNOWLEDGEMENT;
ram54288 0:a2cb7295a1f7 523 coap_response->msg_code = msg_code;
ram54288 0:a2cb7295a1f7 524 coap_response->msg_id = received_coap_header->msg_id;
ram54288 0:a2cb7295a1f7 525 if(received_coap_header->token_len) {
ram54288 0:a2cb7295a1f7 526 free(_delayed_token);
ram54288 0:a2cb7295a1f7 527 _delayed_token = NULL;
ram54288 0:a2cb7295a1f7 528 _delayed_token_len = 0;
ram54288 0:a2cb7295a1f7 529 _delayed_token = alloc_copy(received_coap_header->token_ptr, received_coap_header->token_len);
ram54288 0:a2cb7295a1f7 530 if(_delayed_token) {
ram54288 0:a2cb7295a1f7 531 _delayed_token_len = received_coap_header->token_len;
ram54288 0:a2cb7295a1f7 532 }
ram54288 0:a2cb7295a1f7 533 sn_nsdl_send_coap_message(nsdl, address, coap_response);
ram54288 0:a2cb7295a1f7 534 }
ram54288 0:a2cb7295a1f7 535 } else {
ram54288 0:a2cb7295a1f7 536 uint32_t length = 0;
ram54288 0:a2cb7295a1f7 537 get_value(coap_response->payload_ptr, length);
ram54288 0:a2cb7295a1f7 538 coap_response->payload_len = length;
ram54288 0:a2cb7295a1f7 539 }
ram54288 0:a2cb7295a1f7 540 execute(exec_params);
ram54288 0:a2cb7295a1f7 541 }
ram54288 0:a2cb7295a1f7 542 delete exec_params;
ram54288 0:a2cb7295a1f7 543 } else { // if ((object->operation() & SN_GRS_POST_ALLOWED) != 0)
ram54288 0:a2cb7295a1f7 544 tr_error("M2MResource::handle_post_request - COAP_MSG_CODE_RESPONSE_METHOD_NOT_ALLOWED");
ram54288 0:a2cb7295a1f7 545 msg_code = COAP_MSG_CODE_RESPONSE_METHOD_NOT_ALLOWED; // 4.05
ram54288 0:a2cb7295a1f7 546 }
ram54288 0:a2cb7295a1f7 547 } else { //if(object && received_coap_header)
ram54288 0:a2cb7295a1f7 548 tr_error("M2MResource::handle_post_request - COAP_MSG_CODE_RESPONSE_METHOD_NOT_ALLOWED");
ram54288 0:a2cb7295a1f7 549 msg_code = COAP_MSG_CODE_RESPONSE_METHOD_NOT_ALLOWED; // 4.01
ram54288 0:a2cb7295a1f7 550 }
ram54288 0:a2cb7295a1f7 551 if(coap_response) {
ram54288 0:a2cb7295a1f7 552 coap_response->msg_code = msg_code;
ram54288 0:a2cb7295a1f7 553 }
ram54288 0:a2cb7295a1f7 554 return coap_response;
ram54288 0:a2cb7295a1f7 555 }
ram54288 0:a2cb7295a1f7 556
ram54288 0:a2cb7295a1f7 557 void M2MResource::notification_update()
ram54288 0:a2cb7295a1f7 558 {
ram54288 0:a2cb7295a1f7 559 tr_debug("M2MResource::notification_update()");
ram54288 0:a2cb7295a1f7 560 M2MReportHandler *report_handler = M2MBase::report_handler();
ram54288 0:a2cb7295a1f7 561 if(report_handler && is_observable()) {
ram54288 0:a2cb7295a1f7 562 report_handler->set_notification_trigger();
ram54288 0:a2cb7295a1f7 563 }
ram54288 0:a2cb7295a1f7 564 }
ram54288 0:a2cb7295a1f7 565
ram54288 0:a2cb7295a1f7 566 M2MObjectInstance& M2MResource::get_parent_object_instance() const
ram54288 0:a2cb7295a1f7 567 {
ram54288 0:a2cb7295a1f7 568 return _parent;
ram54288 0:a2cb7295a1f7 569 }
ram54288 0:a2cb7295a1f7 570
ram54288 0:a2cb7295a1f7 571 const char* M2MResource::object_name() const
ram54288 0:a2cb7295a1f7 572 {
ram54288 0:a2cb7295a1f7 573 const M2MObjectInstance& parent_object_instance = _parent;
ram54288 0:a2cb7295a1f7 574 const M2MObject& parent_object = parent_object_instance.get_parent_object();
ram54288 0:a2cb7295a1f7 575
ram54288 0:a2cb7295a1f7 576 return parent_object.name();
ram54288 0:a2cb7295a1f7 577 }
ram54288 0:a2cb7295a1f7 578
ram54288 0:a2cb7295a1f7 579
ram54288 0:a2cb7295a1f7 580 M2MResource::M2MExecuteParameter::M2MExecuteParameter()
ram54288 0:a2cb7295a1f7 581 {
ram54288 0:a2cb7295a1f7 582 _value = NULL;
ram54288 0:a2cb7295a1f7 583 _value_length = 0;
ram54288 0:a2cb7295a1f7 584 _object_name = "";
ram54288 0:a2cb7295a1f7 585 _resource_name = "";
ram54288 0:a2cb7295a1f7 586 _object_instance_id = 0;
ram54288 0:a2cb7295a1f7 587 }
ram54288 0:a2cb7295a1f7 588
ram54288 0:a2cb7295a1f7 589 M2MResource::M2MExecuteParameter::~M2MExecuteParameter()
ram54288 0:a2cb7295a1f7 590 {
ram54288 0:a2cb7295a1f7 591 free(_value);
ram54288 0:a2cb7295a1f7 592 }
ram54288 0:a2cb7295a1f7 593
ram54288 0:a2cb7295a1f7 594 uint8_t *M2MResource::M2MExecuteParameter::get_argument_value() const
ram54288 0:a2cb7295a1f7 595 {
ram54288 0:a2cb7295a1f7 596 return _value;
ram54288 0:a2cb7295a1f7 597 }
ram54288 0:a2cb7295a1f7 598
ram54288 0:a2cb7295a1f7 599 uint16_t M2MResource::M2MExecuteParameter::get_argument_value_length() const
ram54288 0:a2cb7295a1f7 600 {
ram54288 0:a2cb7295a1f7 601 return _value_length;
ram54288 0:a2cb7295a1f7 602 }
ram54288 0:a2cb7295a1f7 603
ram54288 0:a2cb7295a1f7 604 const String& M2MResource::M2MExecuteParameter::get_argument_object_name() const
ram54288 0:a2cb7295a1f7 605 {
ram54288 0:a2cb7295a1f7 606 return _object_name;
ram54288 0:a2cb7295a1f7 607 }
ram54288 0:a2cb7295a1f7 608
ram54288 0:a2cb7295a1f7 609 const String& M2MResource::M2MExecuteParameter::get_argument_resource_name() const
ram54288 0:a2cb7295a1f7 610 {
ram54288 0:a2cb7295a1f7 611 return _resource_name;
ram54288 0:a2cb7295a1f7 612 }
ram54288 0:a2cb7295a1f7 613
ram54288 0:a2cb7295a1f7 614 uint16_t M2MResource::M2MExecuteParameter::get_argument_object_instance_id() const
ram54288 0:a2cb7295a1f7 615 {
ram54288 0:a2cb7295a1f7 616 return _object_instance_id;
ram54288 0:a2cb7295a1f7 617 }
ram54288 0:a2cb7295a1f7 618
ram54288 0:a2cb7295a1f7 619