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.
m2mresource.cpp
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 #include "mbed-client/m2mconstants.h" 00017 #include "mbed-client/m2mresource.h" 00018 #include "mbed-client/m2mobservationhandler.h" 00019 #include "include/m2mreporthandler.h" 00020 #include "include/m2mtlvserializer.h" 00021 #include "include/m2mtlvdeserializer.h" 00022 #include "include/nsdllinker.h" 00023 #include "mbed-trace/mbed_trace.h" 00024 00025 #define TRACE_GROUP "mClt" 00026 00027 M2MResource& M2MResource::operator=(const M2MResource& other) 00028 { 00029 if (this != &other) { // protect against invalid self-assignment 00030 _has_multiple_instances = other._has_multiple_instances; 00031 if(!other._resource_instance_list.empty()){ 00032 M2MResourceInstance* ins = NULL; 00033 M2MResourceInstanceList::const_iterator it; 00034 it = other._resource_instance_list.begin(); 00035 for (; it!=other._resource_instance_list.end(); it++ ) { 00036 ins = *it; 00037 _resource_instance_list.push_back(new M2MResourceInstance(*ins)); 00038 } 00039 } 00040 if(other._delayed_token) { 00041 _delayed_token = (uint8_t*)alloc_copy(other._delayed_token,other._delayed_token_len); 00042 if(_delayed_token) { 00043 _delayed_token_len = other._delayed_token_len; 00044 } 00045 } 00046 } 00047 return *this; 00048 } 00049 00050 M2MResource::M2MResource(const M2MResource& other) 00051 : M2MResourceInstance(other), 00052 _delayed_token(NULL), 00053 _delayed_token_len(0), 00054 _delayed_response(false) 00055 { 00056 this->operator=(other); 00057 } 00058 00059 M2MResource::M2MResource(M2MObjectInstanceCallback &object_instance_callback, 00060 const String &resource_name, 00061 const String &resource_type, 00062 M2MResourceInstance::ResourceType type, 00063 const uint8_t *value, 00064 const uint8_t value_length, 00065 const uint16_t object_instance_id, 00066 const String &object_name, 00067 bool multiple_instance) 00068 : M2MResourceInstance(resource_name, resource_type, type, value, value_length, 00069 object_instance_callback, object_instance_id, object_name), 00070 _delayed_token(NULL), 00071 _delayed_token_len(0), 00072 _has_multiple_instances(multiple_instance), 00073 _delayed_response(false) 00074 { 00075 M2MBase::set_base_type(M2MBase::Resource); 00076 M2MBase::set_operation(M2MBase::GET_ALLOWED); 00077 M2MBase::set_observable(false); 00078 } 00079 00080 M2MResource::M2MResource(M2MObjectInstanceCallback &object_instance_callback, 00081 const String &resource_name, 00082 const String &resource_type, 00083 M2MResourceInstance::ResourceType type, 00084 bool observable, 00085 const uint16_t object_instance_id, 00086 const String &object_name, 00087 bool multiple_instance) 00088 : M2MResourceInstance(resource_name, resource_type, type, 00089 object_instance_callback, object_instance_id, object_name), 00090 _delayed_token(NULL), 00091 _delayed_token_len(0), 00092 _has_multiple_instances(multiple_instance), 00093 _delayed_response(false) 00094 { 00095 M2MBase::set_base_type(M2MBase::Resource); 00096 M2MBase::set_operation(M2MBase::GET_PUT_ALLOWED); 00097 M2MBase::set_observable(observable); 00098 } 00099 00100 M2MResource::~M2MResource() 00101 { 00102 if(!_resource_instance_list.empty()) { 00103 M2MResourceInstance* res = NULL; 00104 M2MResourceInstanceList::const_iterator it; 00105 it = _resource_instance_list.begin(); 00106 for (; it!=_resource_instance_list.end(); it++ ) { 00107 //Free allocated memory for resources. 00108 res = *it; 00109 delete res; 00110 } 00111 _resource_instance_list.clear(); 00112 } 00113 free(_delayed_token); 00114 } 00115 00116 bool M2MResource::supports_multiple_instances() const 00117 { 00118 return _has_multiple_instances; 00119 } 00120 00121 void M2MResource::set_delayed_response(bool delayed_response) 00122 { 00123 _delayed_response = delayed_response; 00124 } 00125 00126 bool M2MResource::send_delayed_post_response() 00127 { 00128 bool success = false; 00129 if(_delayed_response) { 00130 success = true; 00131 observation_handler()->send_delayed_response(this); 00132 } 00133 return success; 00134 } 00135 00136 void M2MResource::get_delayed_token(uint8_t *&token, uint8_t &token_length) 00137 { 00138 token = _delayed_token; 00139 token_length = _delayed_token_len; 00140 } 00141 00142 bool M2MResource::remove_resource_instance(uint16_t inst_id) 00143 { 00144 tr_debug("M2MResource::remove_resource(inst_id %d)", inst_id); 00145 bool success = false; 00146 if(!_resource_instance_list.empty()) { 00147 M2MResourceInstance* res = NULL; 00148 M2MResourceInstanceList::const_iterator it; 00149 it = _resource_instance_list.begin(); 00150 int pos = 0; 00151 for ( ; it != _resource_instance_list.end(); it++, pos++ ) { 00152 if(((*it)->instance_id() == inst_id)) { 00153 // Resource found and deleted. 00154 res = *it; 00155 delete res; 00156 _resource_instance_list.erase(pos); 00157 success = true; 00158 break; 00159 } 00160 } 00161 } 00162 return success; 00163 } 00164 00165 M2MResourceInstance* M2MResource::resource_instance(uint16_t inst_id) const 00166 { 00167 tr_debug("M2MResource::resource(resource_name inst_id %d)", inst_id); 00168 M2MResourceInstance *res = NULL; 00169 if(!_resource_instance_list.empty()) { 00170 M2MResourceInstanceList::const_iterator it; 00171 it = _resource_instance_list.begin(); 00172 for ( ; it != _resource_instance_list.end(); it++ ) { 00173 if(((*it)->instance_id() == inst_id)) { 00174 // Resource found. 00175 res = *it; 00176 break; 00177 } 00178 } 00179 } 00180 return res; 00181 } 00182 00183 const M2MResourceInstanceList& M2MResource::resource_instances() const 00184 { 00185 return _resource_instance_list; 00186 } 00187 00188 uint16_t M2MResource::resource_instance_count() const 00189 { 00190 return (uint16_t)_resource_instance_list.size(); 00191 } 00192 00193 bool M2MResource::delayed_response() const 00194 { 00195 return _delayed_response; 00196 } 00197 00198 bool M2MResource::handle_observation_attribute(char *&query) 00199 { 00200 tr_debug("M2MResource::handle_observation_attribute - is_under_observation(%d)", is_under_observation()); 00201 bool success = false; 00202 M2MReportHandler *handler = M2MBase::report_handler(); 00203 if (handler) { 00204 success = handler->parse_notification_attribute(query, 00205 M2MBase::base_type(), _resource_type); 00206 if (success) { 00207 if (is_under_observation()) { 00208 handler->set_under_observation(true); 00209 } 00210 } 00211 else { 00212 handler->set_default_values(); 00213 } 00214 00215 if (success) { 00216 if(!_resource_instance_list.empty()) { 00217 M2MResourceInstanceList::const_iterator it; 00218 it = _resource_instance_list.begin(); 00219 for ( ; it != _resource_instance_list.end(); it++ ) { 00220 M2MReportHandler *report_handler = (*it)->report_handler(); 00221 if(report_handler && is_under_observation()) { 00222 report_handler->set_notification_trigger(); 00223 } 00224 } 00225 } 00226 } 00227 } 00228 return success; 00229 } 00230 00231 void M2MResource::add_observation_level(M2MBase::Observation observation_level) 00232 { 00233 M2MBase::add_observation_level(observation_level); 00234 if(!_resource_instance_list.empty()) { 00235 M2MResourceInstanceList::const_iterator inst; 00236 inst = _resource_instance_list.begin(); 00237 for ( ; inst != _resource_instance_list.end(); inst++ ) { 00238 (*inst)->add_observation_level(observation_level); 00239 } 00240 } 00241 } 00242 00243 void M2MResource::remove_observation_level(M2MBase::Observation observation_level) 00244 { 00245 M2MBase::remove_observation_level(observation_level); 00246 if(!_resource_instance_list.empty()) { 00247 M2MResourceInstanceList::const_iterator inst; 00248 inst = _resource_instance_list.begin(); 00249 for ( ; inst != _resource_instance_list.end(); inst++ ) { 00250 (*inst)->remove_observation_level(observation_level); 00251 } 00252 } 00253 } 00254 00255 void M2MResource::add_resource_instance(M2MResourceInstance *res) 00256 { 00257 tr_debug("M2MResource::add_resource_instance()"); 00258 if(res) { 00259 _resource_instance_list.push_back(res); 00260 } 00261 } 00262 00263 sn_coap_hdr_s* M2MResource::handle_get_request(nsdl_s *nsdl, 00264 sn_coap_hdr_s *received_coap_header, 00265 M2MObservationHandler *observation_handler) 00266 { 00267 tr_debug("M2MResource::handle_get_request()"); 00268 sn_coap_msg_code_e msg_code = COAP_MSG_CODE_RESPONSE_CONTENT; 00269 sn_coap_hdr_s * coap_response = NULL; 00270 if(_has_multiple_instances) { 00271 coap_response = sn_nsdl_build_response(nsdl, 00272 received_coap_header, 00273 msg_code); 00274 if(received_coap_header) { 00275 // process the GET if we have registered a callback for it 00276 if ((operation() & SN_GRS_GET_ALLOWED) != 0) { 00277 if(coap_response) { 00278 uint16_t coap_content_type = 0; 00279 bool content_type_present = false; 00280 if(received_coap_header->content_type_ptr){ 00281 content_type_present = true; 00282 coap_response->content_type_ptr = alloc_copy(received_coap_header->content_type_ptr, 00283 received_coap_header->content_type_len); 00284 if(coap_response->content_type_ptr) { 00285 coap_response->content_type_len = received_coap_header->content_type_len; 00286 for(uint8_t i = 0; i < coap_response->content_type_len; i++) { 00287 coap_content_type = (coap_content_type << 8) + 00288 (coap_response->content_type_ptr[i] & 0xFF); 00289 } 00290 } 00291 } 00292 00293 if(!content_type_present && 00294 M2MBase::coap_content_type() == COAP_CONTENT_OMA_TLV_TYPE) { 00295 coap_content_type = COAP_CONTENT_OMA_TLV_TYPE; 00296 } 00297 00298 tr_debug("M2MResource::handle_get_request() - Request Content-Type %d", coap_content_type); 00299 if (!coap_response->content_type_ptr) { 00300 coap_response->content_type_ptr = 00301 m2m::String::convert_integer_to_array(coap_content_type, 00302 coap_response->content_type_len); 00303 if (coap_response->content_type_ptr) { 00304 set_coap_content_type(coap_content_type); 00305 } 00306 } 00307 uint8_t *data = NULL; 00308 uint32_t data_length = 0; 00309 // fill in the CoAP response payload 00310 if(COAP_CONTENT_OMA_TLV_TYPE == coap_content_type) { 00311 M2MTLVSerializer *serializer = new M2MTLVSerializer(); 00312 if(serializer) { 00313 data = serializer->serialize(this, data_length); 00314 delete serializer; 00315 } 00316 } else { 00317 msg_code = COAP_MSG_CODE_RESPONSE_UNSUPPORTED_CONTENT_FORMAT; // Content format not supported 00318 } 00319 00320 coap_response->payload_len = data_length; 00321 coap_response->payload_ptr = data; 00322 00323 coap_response->options_list_ptr = (sn_coap_options_list_s*)malloc(sizeof(sn_coap_options_list_s)); 00324 memset(coap_response->options_list_ptr, 0, sizeof(sn_coap_options_list_s)); 00325 00326 coap_response->options_list_ptr->max_age_ptr = 00327 m2m::String::convert_integer_to_array(max_age(), 00328 coap_response->options_list_ptr->max_age_len); 00329 00330 if(received_coap_header->options_list_ptr) { 00331 if(received_coap_header->options_list_ptr->observe) { 00332 if (is_observable()) { 00333 uint32_t number = 0; 00334 uint8_t observe_option = 0; 00335 if(received_coap_header->options_list_ptr->observe_ptr) { 00336 observe_option = *received_coap_header->options_list_ptr->observe_ptr; 00337 } 00338 if(START_OBSERVATION == observe_option) { 00339 tr_debug("M2MResource::handle_get_request - Starts Observation"); 00340 // If the observe length is 0 means register for observation. 00341 if(received_coap_header->options_list_ptr->observe_len != 0) { 00342 for(int i=0;i < received_coap_header->options_list_ptr->observe_len; i++) { 00343 number = (*(received_coap_header->options_list_ptr->observe_ptr + i) & 0xff) << 00344 8*(received_coap_header->options_list_ptr->observe_len- 1 - i); 00345 } 00346 } 00347 if(received_coap_header->token_ptr) { 00348 tr_debug("M2MResource::handle_get_request - Sets Observation Token to resource"); 00349 set_observation_token(received_coap_header->token_ptr, 00350 received_coap_header->token_len); 00351 } 00352 00353 // If the observe value is 0 means register for observation. 00354 if(number == 0) { 00355 tr_debug("M2MResource::handle_get_request - Put Resource under Observation"); 00356 M2MResourceInstanceList::const_iterator it; 00357 it = _resource_instance_list.begin(); 00358 for (; it!=_resource_instance_list.end(); it++ ) { 00359 tr_debug("M2MResource::handle_get_request - set_resource_observer"); 00360 (*it)->set_resource_observer(this); 00361 (*it)->add_observation_level(M2MBase::R_Attribute); 00362 } 00363 set_under_observation(true,observation_handler); 00364 M2MBase::add_observation_level(M2MBase::R_Attribute); 00365 coap_response->options_list_ptr->observe_ptr = 00366 m2m::String::convert_integer_to_array(observation_number(), 00367 coap_response->options_list_ptr->observe_len); 00368 } 00369 } else if (STOP_OBSERVATION == observe_option) { 00370 tr_debug("M2MResource::handle_get_request - Stops Observation"); 00371 set_under_observation(false,NULL); 00372 M2MBase::remove_observation_level(M2MBase::R_Attribute); 00373 M2MResourceInstanceList::const_iterator it; 00374 it = _resource_instance_list.begin(); 00375 for (; it!=_resource_instance_list.end(); it++ ) { 00376 (*it)->set_resource_observer(NULL); 00377 } 00378 } 00379 msg_code = COAP_MSG_CODE_RESPONSE_CONTENT; 00380 } 00381 else { 00382 msg_code = COAP_MSG_CODE_RESPONSE_METHOD_NOT_ALLOWED; 00383 } 00384 } 00385 } 00386 } 00387 } else { 00388 tr_error("M2MResource::handle_get_request - Return COAP_MSG_CODE_RESPONSE_METHOD_NOT_ALLOWED"); 00389 // Operation is not allowed. 00390 msg_code = COAP_MSG_CODE_RESPONSE_METHOD_NOT_ALLOWED; 00391 } 00392 } 00393 if(coap_response) { 00394 coap_response->msg_code = msg_code; 00395 } 00396 } else { 00397 coap_response = M2MResourceInstance::handle_get_request(nsdl, 00398 received_coap_header, 00399 observation_handler); 00400 } 00401 return coap_response; 00402 } 00403 00404 sn_coap_hdr_s* M2MResource::handle_put_request(nsdl_s *nsdl, 00405 sn_coap_hdr_s *received_coap_header, 00406 M2MObservationHandler *observation_handler, 00407 bool &execute_value_updated) 00408 { 00409 tr_debug("M2MResource::handle_put_request()"); 00410 sn_coap_msg_code_e msg_code = COAP_MSG_CODE_RESPONSE_CHANGED; // 2.04 00411 sn_coap_hdr_s * coap_response = NULL; 00412 if(_has_multiple_instances) { 00413 coap_response = sn_nsdl_build_response(nsdl, 00414 received_coap_header, 00415 msg_code); 00416 // process the PUT if we have registered a callback for it 00417 if(received_coap_header) { 00418 uint16_t coap_content_type = 0; 00419 bool content_type_present = false; 00420 if(received_coap_header->content_type_ptr) { 00421 if(coap_response) { 00422 content_type_present = true; 00423 coap_response->content_type_ptr = alloc_copy(received_coap_header->content_type_ptr, 00424 received_coap_header->content_type_len); 00425 if(coap_response->content_type_ptr) { 00426 coap_response->content_type_len = received_coap_header->content_type_len; 00427 for(uint8_t i = 0; i < coap_response->content_type_len; i++) { 00428 coap_content_type = (coap_content_type << 8) + 00429 (coap_response->content_type_ptr[i] & 0xFF); 00430 } 00431 } 00432 } 00433 } 00434 if(received_coap_header->options_list_ptr && 00435 received_coap_header->options_list_ptr->uri_query_ptr) { 00436 char *query = (char*)alloc_string_copy(received_coap_header->options_list_ptr->uri_query_ptr, 00437 received_coap_header->options_list_ptr->uri_query_len); 00438 if (query){ 00439 msg_code = COAP_MSG_CODE_RESPONSE_CHANGED; 00440 tr_debug("M2MResource::handle_put_request() - Query %s", query); 00441 // if anything was updated, re-initialize the stored notification attributes 00442 if (!handle_observation_attribute(query)){ 00443 tr_debug("M2MResource::handle_put_request() - Invalid query"); 00444 msg_code = COAP_MSG_CODE_RESPONSE_BAD_REQUEST; // 4.00 00445 } 00446 free(query); 00447 } 00448 } else if ((operation() & SN_GRS_PUT_ALLOWED) != 0) { 00449 if(!content_type_present && 00450 M2MBase::coap_content_type() == COAP_CONTENT_OMA_TLV_TYPE) { 00451 coap_content_type = COAP_CONTENT_OMA_TLV_TYPE; 00452 } 00453 00454 tr_debug("M2MResource::handle_put_request() - Request Content-Type %d", coap_content_type); 00455 00456 if(COAP_CONTENT_OMA_TLV_TYPE == coap_content_type) { 00457 M2MTLVDeserializer *deserializer = new M2MTLVDeserializer(); 00458 if(deserializer) { 00459 M2MTLVDeserializer::Error error = M2MTLVDeserializer::None; 00460 error = deserializer->deserialize_resource_instances(received_coap_header->payload_ptr, 00461 received_coap_header->payload_len, 00462 *this, 00463 M2MTLVDeserializer::Put); 00464 switch(error) { 00465 case M2MTLVDeserializer::None: 00466 if(observation_handler) { 00467 String value = ""; 00468 if (received_coap_header->uri_path_ptr != NULL && 00469 received_coap_header->uri_path_len > 0) { 00470 00471 value.append_raw((char*)received_coap_header->uri_path_ptr,received_coap_header->uri_path_len); 00472 } 00473 execute_value_updated = true; 00474 } 00475 msg_code = COAP_MSG_CODE_RESPONSE_CHANGED; 00476 break; 00477 case M2MTLVDeserializer::NotFound: 00478 msg_code = COAP_MSG_CODE_RESPONSE_NOT_FOUND; 00479 break; 00480 case M2MTLVDeserializer::NotAllowed: 00481 msg_code = COAP_MSG_CODE_RESPONSE_METHOD_NOT_ALLOWED; 00482 break; 00483 case M2MTLVDeserializer::NotValid: 00484 msg_code = COAP_MSG_CODE_RESPONSE_BAD_REQUEST; 00485 break; 00486 } 00487 delete deserializer; 00488 } 00489 } else { 00490 msg_code =COAP_MSG_CODE_RESPONSE_UNSUPPORTED_CONTENT_FORMAT; 00491 } // if(COAP_CONTENT_OMA_TLV_TYPE == coap_content_type) 00492 } else { 00493 // Operation is not allowed. 00494 tr_error("M2MResource::handle_put_request() - COAP_MSG_CODE_RESPONSE_METHOD_NOT_ALLOWED"); 00495 msg_code = COAP_MSG_CODE_RESPONSE_METHOD_NOT_ALLOWED; 00496 } 00497 } else { 00498 msg_code = COAP_MSG_CODE_RESPONSE_METHOD_NOT_ALLOWED; 00499 } 00500 if(coap_response) { 00501 coap_response->msg_code = msg_code; 00502 } 00503 } else { 00504 coap_response = M2MResourceInstance::handle_put_request(nsdl, 00505 received_coap_header, 00506 observation_handler, 00507 execute_value_updated); 00508 } 00509 return coap_response; 00510 } 00511 00512 sn_coap_hdr_s* M2MResource::handle_post_request(nsdl_s *nsdl, 00513 sn_coap_hdr_s *received_coap_header, 00514 M2MObservationHandler */*observation_handler*/, 00515 bool &/*execute_value_updated*/) 00516 { 00517 tr_debug("M2MResource::handle_post_request()"); 00518 sn_coap_msg_code_e msg_code = COAP_MSG_CODE_RESPONSE_CHANGED; // 2.04 00519 sn_coap_hdr_s * coap_response = sn_nsdl_build_response(nsdl, 00520 received_coap_header, 00521 msg_code); 00522 // process the POST if we have registered a callback for it 00523 if(received_coap_header) { 00524 if ((operation() & SN_GRS_POST_ALLOWED) != 0) { 00525 M2MResource::M2MExecuteParameter *exec_params = new M2MResource::M2MExecuteParameter(); 00526 if (exec_params) { 00527 exec_params->_object_name = object_name(); 00528 exec_params->_resource_name = name(); 00529 exec_params->_object_instance_id = object_instance_id(); 00530 } 00531 uint16_t coap_content_type = 0; 00532 if(received_coap_header->payload_ptr) { 00533 if(received_coap_header->content_type_ptr) { 00534 for(uint8_t i = 0; i < received_coap_header->content_type_len; i++) { 00535 coap_content_type = (coap_content_type << 8) + (received_coap_header->content_type_ptr[i] & 0xFF); 00536 } 00537 } 00538 if(coap_content_type == 0) { 00539 if (exec_params){ 00540 exec_params->_value = alloc_string_copy(received_coap_header->payload_ptr, 00541 received_coap_header->payload_len); 00542 if (exec_params->_value) { 00543 exec_params->_value_length = received_coap_header->payload_len; 00544 } 00545 } 00546 } else { 00547 msg_code = COAP_MSG_CODE_RESPONSE_UNSUPPORTED_CONTENT_FORMAT; 00548 } 00549 } 00550 if(COAP_MSG_CODE_RESPONSE_CHANGED == msg_code) { 00551 tr_debug("M2MResource::handle_post_request - Execute resource function"); 00552 execute(exec_params); 00553 if(_delayed_response) { 00554 coap_response->msg_type = COAP_MSG_TYPE_ACKNOWLEDGEMENT; 00555 coap_response->msg_code = COAP_MSG_CODE_EMPTY; 00556 coap_response->msg_id = received_coap_header->msg_id; 00557 if(received_coap_header->token_len) { 00558 free(_delayed_token); 00559 _delayed_token_len = 0; 00560 00561 _delayed_token = alloc_copy(received_coap_header->token_ptr, received_coap_header->token_len); 00562 if(_delayed_token) { 00563 _delayed_token_len = received_coap_header->token_len; 00564 } 00565 } 00566 } else { 00567 uint32_t length = 0; 00568 get_value(coap_response->payload_ptr, length); 00569 coap_response->payload_len = length; 00570 } 00571 } 00572 delete exec_params; 00573 } else { // if ((object->operation() & SN_GRS_POST_ALLOWED) != 0) 00574 tr_error("M2MResource::handle_post_request - COAP_MSG_CODE_RESPONSE_METHOD_NOT_ALLOWED"); 00575 msg_code = COAP_MSG_CODE_RESPONSE_METHOD_NOT_ALLOWED; // 4.05 00576 } 00577 } else { //if(object && received_coap_header) 00578 tr_error("M2MResource::handle_post_request - COAP_MSG_CODE_RESPONSE_METHOD_NOT_ALLOWED"); 00579 msg_code = COAP_MSG_CODE_RESPONSE_METHOD_NOT_ALLOWED; // 4.01 00580 } 00581 if(coap_response) { 00582 coap_response->msg_code = msg_code; 00583 } 00584 return coap_response; 00585 } 00586 00587 void M2MResource::notification_update() 00588 { 00589 tr_debug("M2MResource::notification_update()"); 00590 M2MReportHandler *report_handler = M2MBase::report_handler(); 00591 if(report_handler && is_observable()) { 00592 report_handler->set_notification_trigger(); 00593 } 00594 } 00595 00596 M2MResource::M2MExecuteParameter::M2MExecuteParameter() 00597 { 00598 _value = NULL; 00599 _value_length = 0; 00600 _object_name = ""; 00601 _resource_name = ""; 00602 _object_instance_id = 0; 00603 } 00604 00605 M2MResource::M2MExecuteParameter::~M2MExecuteParameter() 00606 { 00607 free(_value); 00608 } 00609 00610 uint8_t *M2MResource::M2MExecuteParameter::get_argument_value() const 00611 { 00612 return _value; 00613 } 00614 00615 uint16_t M2MResource::M2MExecuteParameter::get_argument_value_length() const 00616 { 00617 return _value_length; 00618 } 00619 00620 const String& M2MResource::M2MExecuteParameter::get_argument_object_name() const 00621 { 00622 return _object_name; 00623 } 00624 00625 const String& M2MResource::M2MExecuteParameter::get_argument_resource_name() const 00626 { 00627 return _resource_name; 00628 } 00629 00630 uint16_t M2MResource::M2MExecuteParameter::get_argument_object_instance_id() const 00631 { 00632 return _object_instance_id; 00633 }
Generated on Tue Jul 12 2022 13:05:11 by
 1.7.2
 1.7.2