Ram Gandikota / Mbed OS ABCD
Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers m2mobject_stub.cpp Source File

m2mobject_stub.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 "m2mobject_stub.h"
00017 
00018 u_int16_t m2mobject_stub::int_value;
00019 bool m2mobject_stub::bool_value;
00020 M2MObjectInstance* m2mobject_stub::inst;
00021 
00022 // The statically initialized object list must be bigh enough to cater
00023 // for all the tests, or the utest framework will complain for memory leak.
00024 M2MObjectInstanceList m2mobject_stub::instance_list(12);
00025 
00026 M2MBase::BaseType m2mobject_stub::base_type;
00027 sn_coap_hdr_s *m2mobject_stub::header;
00028 
00029 void m2mobject_stub::clear()
00030 {
00031     int_value = 0;
00032     bool_value = false;
00033     m2mobject_stub::base_type = M2MBase::Object;
00034     instance_list.clear();
00035     header = NULL;
00036 }
00037 
00038 M2MObject::M2MObject(const String &object_name, char *path, bool external_blockwise_store)
00039 : M2MBase(object_name,
00040           M2MBase::Dynamic,
00041           "",
00042           path,
00043           external_blockwise_store),
00044   _max_instance_count(65535)
00045 {
00046 
00047 }
00048 
00049 M2MObject::M2MObject(const M2MBase::lwm2m_parameters_s* static_res)
00050 : M2MBase(static_res),
00051   _max_instance_count(65535)
00052 {
00053 
00054 }
00055 
00056 M2MObject::~M2MObject()
00057 {
00058 }
00059 
00060 M2MObjectInstance* M2MObject::create_object_instance(uint16_t instance_id)
00061 {
00062     return m2mobject_stub::inst;
00063 }
00064 
00065 bool M2MObject::remove_object_instance(uint16_t)
00066 {
00067     return m2mobject_stub::bool_value;
00068 }
00069 
00070 M2MObjectInstance* M2MObject::object_instance(uint16_t) const
00071 {
00072     return m2mobject_stub::inst;
00073 }
00074 
00075 const M2MObjectInstanceList& M2MObject::instances() const
00076 {
00077     return m2mobject_stub::instance_list;
00078 }
00079 
00080 uint16_t M2MObject::instance_count() const
00081 {
00082     return m2mobject_stub::int_value;
00083 }
00084 
00085 M2MBase::BaseType M2MObject::base_type() const
00086 {
00087     return m2mobject_stub::base_type;
00088 }
00089 
00090 void M2MObject::add_observation_level(M2MBase::Observation)
00091 {
00092 
00093 }
00094 
00095 void M2MObject::remove_observation_level(M2MBase::Observation)
00096 {
00097 
00098 }
00099 
00100 sn_coap_hdr_s* M2MObject::handle_get_request(nsdl_s *,
00101                                   sn_coap_hdr_s *,
00102                                   M2MObservationHandler *)
00103 {
00104     return m2mobject_stub::header;
00105 }
00106 
00107 sn_coap_hdr_s* M2MObject::handle_put_request(nsdl_s *,
00108                                   sn_coap_hdr_s *,
00109                                   M2MObservationHandler *,
00110                                   bool &execute)
00111 {
00112     execute = m2mobject_stub::bool_value;
00113     return m2mobject_stub::header;
00114 }
00115 
00116 sn_coap_hdr_s* M2MObject::handle_post_request(nsdl_s *,
00117                                    sn_coap_hdr_s *,
00118                                    M2MObservationHandler *,
00119                                    bool &,
00120                                    sn_nsdl_addr_s *)
00121 {
00122     return m2mobject_stub::header;
00123 }
00124 
00125 void M2MObject::notification_update(uint16_t obj_instance_id)
00126 {
00127 }