Ram Gandikota
/
metronome
FRDM K64F Metronome
mbed-client/test/mbedclient/utest/stub/m2mobject_stub.cpp@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 | #include "m2mobject_stub.h" |
ram54288 | 0:a2cb7295a1f7 | 17 | |
ram54288 | 0:a2cb7295a1f7 | 18 | u_int16_t m2mobject_stub::int_value; |
ram54288 | 0:a2cb7295a1f7 | 19 | bool m2mobject_stub::bool_value; |
ram54288 | 0:a2cb7295a1f7 | 20 | M2MObjectInstance* m2mobject_stub::inst; |
ram54288 | 0:a2cb7295a1f7 | 21 | |
ram54288 | 0:a2cb7295a1f7 | 22 | // The statically initialized object list must be bigh enough to cater |
ram54288 | 0:a2cb7295a1f7 | 23 | // for all the tests, or the utest framework will complain for memory leak. |
ram54288 | 0:a2cb7295a1f7 | 24 | M2MObjectInstanceList m2mobject_stub::instance_list(12); |
ram54288 | 0:a2cb7295a1f7 | 25 | |
ram54288 | 0:a2cb7295a1f7 | 26 | M2MBase::BaseType m2mobject_stub::base_type; |
ram54288 | 0:a2cb7295a1f7 | 27 | sn_coap_hdr_s *m2mobject_stub::header; |
ram54288 | 0:a2cb7295a1f7 | 28 | |
ram54288 | 0:a2cb7295a1f7 | 29 | void m2mobject_stub::clear() |
ram54288 | 0:a2cb7295a1f7 | 30 | { |
ram54288 | 0:a2cb7295a1f7 | 31 | int_value = 0; |
ram54288 | 0:a2cb7295a1f7 | 32 | bool_value = false; |
ram54288 | 0:a2cb7295a1f7 | 33 | m2mobject_stub::base_type = M2MBase::Object; |
ram54288 | 0:a2cb7295a1f7 | 34 | instance_list.clear(); |
ram54288 | 0:a2cb7295a1f7 | 35 | header = NULL; |
ram54288 | 0:a2cb7295a1f7 | 36 | } |
ram54288 | 0:a2cb7295a1f7 | 37 | |
ram54288 | 0:a2cb7295a1f7 | 38 | M2MObject::M2MObject(const String &object_name, char *path, bool external_blockwise_store) |
ram54288 | 0:a2cb7295a1f7 | 39 | : M2MBase(object_name, |
ram54288 | 0:a2cb7295a1f7 | 40 | M2MBase::Dynamic, |
ram54288 | 0:a2cb7295a1f7 | 41 | "", |
ram54288 | 0:a2cb7295a1f7 | 42 | path, |
ram54288 | 0:a2cb7295a1f7 | 43 | external_blockwise_store), |
ram54288 | 0:a2cb7295a1f7 | 44 | _max_instance_count(65535) |
ram54288 | 0:a2cb7295a1f7 | 45 | { |
ram54288 | 0:a2cb7295a1f7 | 46 | |
ram54288 | 0:a2cb7295a1f7 | 47 | } |
ram54288 | 0:a2cb7295a1f7 | 48 | |
ram54288 | 0:a2cb7295a1f7 | 49 | M2MObject::M2MObject(const M2MBase::lwm2m_parameters_s* static_res) |
ram54288 | 0:a2cb7295a1f7 | 50 | : M2MBase(static_res), |
ram54288 | 0:a2cb7295a1f7 | 51 | _max_instance_count(65535) |
ram54288 | 0:a2cb7295a1f7 | 52 | { |
ram54288 | 0:a2cb7295a1f7 | 53 | |
ram54288 | 0:a2cb7295a1f7 | 54 | } |
ram54288 | 0:a2cb7295a1f7 | 55 | |
ram54288 | 0:a2cb7295a1f7 | 56 | M2MObject::~M2MObject() |
ram54288 | 0:a2cb7295a1f7 | 57 | { |
ram54288 | 0:a2cb7295a1f7 | 58 | } |
ram54288 | 0:a2cb7295a1f7 | 59 | |
ram54288 | 0:a2cb7295a1f7 | 60 | M2MObjectInstance* M2MObject::create_object_instance(uint16_t instance_id) |
ram54288 | 0:a2cb7295a1f7 | 61 | { |
ram54288 | 0:a2cb7295a1f7 | 62 | return m2mobject_stub::inst; |
ram54288 | 0:a2cb7295a1f7 | 63 | } |
ram54288 | 0:a2cb7295a1f7 | 64 | |
ram54288 | 0:a2cb7295a1f7 | 65 | bool M2MObject::remove_object_instance(uint16_t) |
ram54288 | 0:a2cb7295a1f7 | 66 | { |
ram54288 | 0:a2cb7295a1f7 | 67 | return m2mobject_stub::bool_value; |
ram54288 | 0:a2cb7295a1f7 | 68 | } |
ram54288 | 0:a2cb7295a1f7 | 69 | |
ram54288 | 0:a2cb7295a1f7 | 70 | M2MObjectInstance* M2MObject::object_instance(uint16_t) const |
ram54288 | 0:a2cb7295a1f7 | 71 | { |
ram54288 | 0:a2cb7295a1f7 | 72 | return m2mobject_stub::inst; |
ram54288 | 0:a2cb7295a1f7 | 73 | } |
ram54288 | 0:a2cb7295a1f7 | 74 | |
ram54288 | 0:a2cb7295a1f7 | 75 | const M2MObjectInstanceList& M2MObject::instances() const |
ram54288 | 0:a2cb7295a1f7 | 76 | { |
ram54288 | 0:a2cb7295a1f7 | 77 | return m2mobject_stub::instance_list; |
ram54288 | 0:a2cb7295a1f7 | 78 | } |
ram54288 | 0:a2cb7295a1f7 | 79 | |
ram54288 | 0:a2cb7295a1f7 | 80 | uint16_t M2MObject::instance_count() const |
ram54288 | 0:a2cb7295a1f7 | 81 | { |
ram54288 | 0:a2cb7295a1f7 | 82 | return m2mobject_stub::int_value; |
ram54288 | 0:a2cb7295a1f7 | 83 | } |
ram54288 | 0:a2cb7295a1f7 | 84 | |
ram54288 | 0:a2cb7295a1f7 | 85 | M2MBase::BaseType M2MObject::base_type() const |
ram54288 | 0:a2cb7295a1f7 | 86 | { |
ram54288 | 0:a2cb7295a1f7 | 87 | return m2mobject_stub::base_type; |
ram54288 | 0:a2cb7295a1f7 | 88 | } |
ram54288 | 0:a2cb7295a1f7 | 89 | |
ram54288 | 0:a2cb7295a1f7 | 90 | void M2MObject::add_observation_level(M2MBase::Observation) |
ram54288 | 0:a2cb7295a1f7 | 91 | { |
ram54288 | 0:a2cb7295a1f7 | 92 | |
ram54288 | 0:a2cb7295a1f7 | 93 | } |
ram54288 | 0:a2cb7295a1f7 | 94 | |
ram54288 | 0:a2cb7295a1f7 | 95 | void M2MObject::remove_observation_level(M2MBase::Observation) |
ram54288 | 0:a2cb7295a1f7 | 96 | { |
ram54288 | 0:a2cb7295a1f7 | 97 | |
ram54288 | 0:a2cb7295a1f7 | 98 | } |
ram54288 | 0:a2cb7295a1f7 | 99 | |
ram54288 | 0:a2cb7295a1f7 | 100 | sn_coap_hdr_s* M2MObject::handle_get_request(nsdl_s *, |
ram54288 | 0:a2cb7295a1f7 | 101 | sn_coap_hdr_s *, |
ram54288 | 0:a2cb7295a1f7 | 102 | M2MObservationHandler *) |
ram54288 | 0:a2cb7295a1f7 | 103 | { |
ram54288 | 0:a2cb7295a1f7 | 104 | return m2mobject_stub::header; |
ram54288 | 0:a2cb7295a1f7 | 105 | } |
ram54288 | 0:a2cb7295a1f7 | 106 | |
ram54288 | 0:a2cb7295a1f7 | 107 | sn_coap_hdr_s* M2MObject::handle_put_request(nsdl_s *, |
ram54288 | 0:a2cb7295a1f7 | 108 | sn_coap_hdr_s *, |
ram54288 | 0:a2cb7295a1f7 | 109 | M2MObservationHandler *, |
ram54288 | 0:a2cb7295a1f7 | 110 | bool &execute) |
ram54288 | 0:a2cb7295a1f7 | 111 | { |
ram54288 | 0:a2cb7295a1f7 | 112 | execute = m2mobject_stub::bool_value; |
ram54288 | 0:a2cb7295a1f7 | 113 | return m2mobject_stub::header; |
ram54288 | 0:a2cb7295a1f7 | 114 | } |
ram54288 | 0:a2cb7295a1f7 | 115 | |
ram54288 | 0:a2cb7295a1f7 | 116 | sn_coap_hdr_s* M2MObject::handle_post_request(nsdl_s *, |
ram54288 | 0:a2cb7295a1f7 | 117 | sn_coap_hdr_s *, |
ram54288 | 0:a2cb7295a1f7 | 118 | M2MObservationHandler *, |
ram54288 | 0:a2cb7295a1f7 | 119 | bool &, |
ram54288 | 0:a2cb7295a1f7 | 120 | sn_nsdl_addr_s *) |
ram54288 | 0:a2cb7295a1f7 | 121 | { |
ram54288 | 0:a2cb7295a1f7 | 122 | return m2mobject_stub::header; |
ram54288 | 0:a2cb7295a1f7 | 123 | } |
ram54288 | 0:a2cb7295a1f7 | 124 | |
ram54288 | 0:a2cb7295a1f7 | 125 | void M2MObject::notification_update(uint16_t obj_instance_id) |
ram54288 | 0:a2cb7295a1f7 | 126 | { |
ram54288 | 0:a2cb7295a1f7 | 127 | } |