![](/media/cache/profiles/debfdc81854eac26ec993b55a659c6e1.jpg.50x50_q85.jpg)
mbed client lightswitch demo
Dependencies: mbed Socket lwip-eth lwip-sys lwip
Fork of mbed-client-classic-example-lwip by
mbed-client/source/m2mserver.cpp@11:cada08fc8a70, 2016-06-09 (annotated)
- Committer:
- mbedAustin
- Date:
- Thu Jun 09 17:08:36 2016 +0000
- Revision:
- 11:cada08fc8a70
Commit for public Consumption
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
mbedAustin | 11:cada08fc8a70 | 1 | /* |
mbedAustin | 11:cada08fc8a70 | 2 | * Copyright (c) 2015 ARM Limited. All rights reserved. |
mbedAustin | 11:cada08fc8a70 | 3 | * SPDX-License-Identifier: Apache-2.0 |
mbedAustin | 11:cada08fc8a70 | 4 | * Licensed under the Apache License, Version 2.0 (the License); you may |
mbedAustin | 11:cada08fc8a70 | 5 | * not use this file except in compliance with the License. |
mbedAustin | 11:cada08fc8a70 | 6 | * You may obtain a copy of the License at |
mbedAustin | 11:cada08fc8a70 | 7 | * |
mbedAustin | 11:cada08fc8a70 | 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
mbedAustin | 11:cada08fc8a70 | 9 | * |
mbedAustin | 11:cada08fc8a70 | 10 | * Unless required by applicable law or agreed to in writing, software |
mbedAustin | 11:cada08fc8a70 | 11 | * distributed under the License is distributed on an AS IS BASIS, WITHOUT |
mbedAustin | 11:cada08fc8a70 | 12 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
mbedAustin | 11:cada08fc8a70 | 13 | * See the License for the specific language governing permissions and |
mbedAustin | 11:cada08fc8a70 | 14 | * limitations under the License. |
mbedAustin | 11:cada08fc8a70 | 15 | */ |
mbedAustin | 11:cada08fc8a70 | 16 | #include <cstdio> |
mbedAustin | 11:cada08fc8a70 | 17 | #include "mbed-client/m2mserver.h" |
mbedAustin | 11:cada08fc8a70 | 18 | #include "mbed-client/m2mconstants.h" |
mbedAustin | 11:cada08fc8a70 | 19 | #include "mbed-client/m2mobject.h" |
mbedAustin | 11:cada08fc8a70 | 20 | #include "mbed-client/m2mobjectinstance.h" |
mbedAustin | 11:cada08fc8a70 | 21 | #include "mbed-client/m2mresource.h" |
mbedAustin | 11:cada08fc8a70 | 22 | |
mbedAustin | 11:cada08fc8a70 | 23 | |
mbedAustin | 11:cada08fc8a70 | 24 | M2MServer::M2MServer() |
mbedAustin | 11:cada08fc8a70 | 25 | : M2MObject(M2M_SERVER_ID) |
mbedAustin | 11:cada08fc8a70 | 26 | { |
mbedAustin | 11:cada08fc8a70 | 27 | M2MObject::create_object_instance(); |
mbedAustin | 11:cada08fc8a70 | 28 | |
mbedAustin | 11:cada08fc8a70 | 29 | _server_instance = object_instance(); |
mbedAustin | 11:cada08fc8a70 | 30 | |
mbedAustin | 11:cada08fc8a70 | 31 | if(_server_instance) { |
mbedAustin | 11:cada08fc8a70 | 32 | |
mbedAustin | 11:cada08fc8a70 | 33 | M2MResource* res = _server_instance->create_dynamic_resource(SERVER_SHORT_SERVER_ID, |
mbedAustin | 11:cada08fc8a70 | 34 | OMA_RESOURCE_TYPE, |
mbedAustin | 11:cada08fc8a70 | 35 | M2MResourceInstance::INTEGER, |
mbedAustin | 11:cada08fc8a70 | 36 | true); |
mbedAustin | 11:cada08fc8a70 | 37 | if(res) { |
mbedAustin | 11:cada08fc8a70 | 38 | res->set_operation(M2MBase::GET_PUT_ALLOWED); |
mbedAustin | 11:cada08fc8a70 | 39 | } |
mbedAustin | 11:cada08fc8a70 | 40 | res = _server_instance->create_dynamic_resource(SERVER_LIFETIME, |
mbedAustin | 11:cada08fc8a70 | 41 | OMA_RESOURCE_TYPE, |
mbedAustin | 11:cada08fc8a70 | 42 | M2MResourceInstance::INTEGER, |
mbedAustin | 11:cada08fc8a70 | 43 | true); |
mbedAustin | 11:cada08fc8a70 | 44 | if(res) { |
mbedAustin | 11:cada08fc8a70 | 45 | res->set_operation(M2MBase::GET_PUT_POST_ALLOWED); |
mbedAustin | 11:cada08fc8a70 | 46 | } |
mbedAustin | 11:cada08fc8a70 | 47 | res = _server_instance->create_dynamic_resource(SERVER_NOTIFICATION_STORAGE, |
mbedAustin | 11:cada08fc8a70 | 48 | OMA_RESOURCE_TYPE, |
mbedAustin | 11:cada08fc8a70 | 49 | M2MResourceInstance::BOOLEAN, |
mbedAustin | 11:cada08fc8a70 | 50 | true); |
mbedAustin | 11:cada08fc8a70 | 51 | if(res) { |
mbedAustin | 11:cada08fc8a70 | 52 | res->set_operation(M2MBase::GET_PUT_POST_ALLOWED); |
mbedAustin | 11:cada08fc8a70 | 53 | } |
mbedAustin | 11:cada08fc8a70 | 54 | res = _server_instance->create_dynamic_resource(SERVER_BINDING, |
mbedAustin | 11:cada08fc8a70 | 55 | OMA_RESOURCE_TYPE, |
mbedAustin | 11:cada08fc8a70 | 56 | M2MResourceInstance::STRING, |
mbedAustin | 11:cada08fc8a70 | 57 | true); |
mbedAustin | 11:cada08fc8a70 | 58 | if(res) { |
mbedAustin | 11:cada08fc8a70 | 59 | res->set_operation(M2MBase::GET_PUT_POST_ALLOWED); |
mbedAustin | 11:cada08fc8a70 | 60 | } |
mbedAustin | 11:cada08fc8a70 | 61 | res = _server_instance->create_dynamic_resource(SERVER_REGISTRATION_UPDATE, |
mbedAustin | 11:cada08fc8a70 | 62 | OMA_RESOURCE_TYPE, |
mbedAustin | 11:cada08fc8a70 | 63 | M2MResourceInstance::OPAQUE, |
mbedAustin | 11:cada08fc8a70 | 64 | false); |
mbedAustin | 11:cada08fc8a70 | 65 | if(res) { |
mbedAustin | 11:cada08fc8a70 | 66 | res->set_operation(M2MBase::POST_ALLOWED); |
mbedAustin | 11:cada08fc8a70 | 67 | } |
mbedAustin | 11:cada08fc8a70 | 68 | } |
mbedAustin | 11:cada08fc8a70 | 69 | } |
mbedAustin | 11:cada08fc8a70 | 70 | |
mbedAustin | 11:cada08fc8a70 | 71 | M2MServer::~M2MServer() |
mbedAustin | 11:cada08fc8a70 | 72 | { |
mbedAustin | 11:cada08fc8a70 | 73 | |
mbedAustin | 11:cada08fc8a70 | 74 | } |
mbedAustin | 11:cada08fc8a70 | 75 | |
mbedAustin | 11:cada08fc8a70 | 76 | M2MResource* M2MServer::create_resource(ServerResource resource, uint32_t value) |
mbedAustin | 11:cada08fc8a70 | 77 | { |
mbedAustin | 11:cada08fc8a70 | 78 | M2MResource* res = NULL; |
mbedAustin | 11:cada08fc8a70 | 79 | String server_id = ""; |
mbedAustin | 11:cada08fc8a70 | 80 | if(!is_resource_present(resource)) { |
mbedAustin | 11:cada08fc8a70 | 81 | switch(resource) { |
mbedAustin | 11:cada08fc8a70 | 82 | case DefaultMinPeriod: |
mbedAustin | 11:cada08fc8a70 | 83 | server_id = SERVER_DEFAULT_MIN_PERIOD; |
mbedAustin | 11:cada08fc8a70 | 84 | break; |
mbedAustin | 11:cada08fc8a70 | 85 | case DefaultMaxPeriod: |
mbedAustin | 11:cada08fc8a70 | 86 | server_id = SERVER_DEFAULT_MAX_PERIOD; |
mbedAustin | 11:cada08fc8a70 | 87 | break; |
mbedAustin | 11:cada08fc8a70 | 88 | case DisableTimeout: |
mbedAustin | 11:cada08fc8a70 | 89 | server_id = SERVER_DISABLE_TIMEOUT; |
mbedAustin | 11:cada08fc8a70 | 90 | break; |
mbedAustin | 11:cada08fc8a70 | 91 | default: |
mbedAustin | 11:cada08fc8a70 | 92 | break; |
mbedAustin | 11:cada08fc8a70 | 93 | } |
mbedAustin | 11:cada08fc8a70 | 94 | } |
mbedAustin | 11:cada08fc8a70 | 95 | if(!server_id.empty()) { |
mbedAustin | 11:cada08fc8a70 | 96 | if(_server_instance) { |
mbedAustin | 11:cada08fc8a70 | 97 | res = _server_instance->create_dynamic_resource(server_id, |
mbedAustin | 11:cada08fc8a70 | 98 | OMA_RESOURCE_TYPE, |
mbedAustin | 11:cada08fc8a70 | 99 | M2MResourceInstance::INTEGER, |
mbedAustin | 11:cada08fc8a70 | 100 | true); |
mbedAustin | 11:cada08fc8a70 | 101 | if(res) { |
mbedAustin | 11:cada08fc8a70 | 102 | res->set_operation(M2MBase::GET_PUT_POST_ALLOWED); |
mbedAustin | 11:cada08fc8a70 | 103 | // If resource is created then set the value. |
mbedAustin | 11:cada08fc8a70 | 104 | char *buffer = (char*)malloc(20); |
mbedAustin | 11:cada08fc8a70 | 105 | if(buffer) { |
mbedAustin | 11:cada08fc8a70 | 106 | int size = snprintf(buffer, 20,"%ld",(long int)value); |
mbedAustin | 11:cada08fc8a70 | 107 | res->set_value((const uint8_t*)buffer,(uint32_t)size); |
mbedAustin | 11:cada08fc8a70 | 108 | free(buffer); |
mbedAustin | 11:cada08fc8a70 | 109 | } |
mbedAustin | 11:cada08fc8a70 | 110 | } |
mbedAustin | 11:cada08fc8a70 | 111 | } |
mbedAustin | 11:cada08fc8a70 | 112 | } |
mbedAustin | 11:cada08fc8a70 | 113 | return res; |
mbedAustin | 11:cada08fc8a70 | 114 | } |
mbedAustin | 11:cada08fc8a70 | 115 | |
mbedAustin | 11:cada08fc8a70 | 116 | M2MResource* M2MServer::create_resource(ServerResource resource) |
mbedAustin | 11:cada08fc8a70 | 117 | { |
mbedAustin | 11:cada08fc8a70 | 118 | M2MResource* res = NULL; |
mbedAustin | 11:cada08fc8a70 | 119 | if(!is_resource_present(resource)) { |
mbedAustin | 11:cada08fc8a70 | 120 | if(M2MServer::Disable == resource) { |
mbedAustin | 11:cada08fc8a70 | 121 | if(_server_instance) { |
mbedAustin | 11:cada08fc8a70 | 122 | res = _server_instance->create_dynamic_resource(SERVER_DISABLE, |
mbedAustin | 11:cada08fc8a70 | 123 | OMA_RESOURCE_TYPE, |
mbedAustin | 11:cada08fc8a70 | 124 | M2MResourceInstance::OPAQUE, |
mbedAustin | 11:cada08fc8a70 | 125 | false); |
mbedAustin | 11:cada08fc8a70 | 126 | if(res) { |
mbedAustin | 11:cada08fc8a70 | 127 | res->set_operation(M2MBase::POST_ALLOWED); |
mbedAustin | 11:cada08fc8a70 | 128 | } |
mbedAustin | 11:cada08fc8a70 | 129 | } |
mbedAustin | 11:cada08fc8a70 | 130 | } |
mbedAustin | 11:cada08fc8a70 | 131 | } |
mbedAustin | 11:cada08fc8a70 | 132 | return res; |
mbedAustin | 11:cada08fc8a70 | 133 | } |
mbedAustin | 11:cada08fc8a70 | 134 | |
mbedAustin | 11:cada08fc8a70 | 135 | bool M2MServer::delete_resource(ServerResource resource) |
mbedAustin | 11:cada08fc8a70 | 136 | { |
mbedAustin | 11:cada08fc8a70 | 137 | bool success = false; |
mbedAustin | 11:cada08fc8a70 | 138 | String server_id = ""; |
mbedAustin | 11:cada08fc8a70 | 139 | switch(resource) { |
mbedAustin | 11:cada08fc8a70 | 140 | case DefaultMinPeriod: |
mbedAustin | 11:cada08fc8a70 | 141 | server_id = SERVER_DEFAULT_MIN_PERIOD; |
mbedAustin | 11:cada08fc8a70 | 142 | break; |
mbedAustin | 11:cada08fc8a70 | 143 | case DefaultMaxPeriod: |
mbedAustin | 11:cada08fc8a70 | 144 | server_id = SERVER_DEFAULT_MAX_PERIOD; |
mbedAustin | 11:cada08fc8a70 | 145 | break; |
mbedAustin | 11:cada08fc8a70 | 146 | case Disable: |
mbedAustin | 11:cada08fc8a70 | 147 | server_id = SERVER_DISABLE; |
mbedAustin | 11:cada08fc8a70 | 148 | break; |
mbedAustin | 11:cada08fc8a70 | 149 | case DisableTimeout: |
mbedAustin | 11:cada08fc8a70 | 150 | server_id = SERVER_DISABLE_TIMEOUT; |
mbedAustin | 11:cada08fc8a70 | 151 | break; |
mbedAustin | 11:cada08fc8a70 | 152 | default: |
mbedAustin | 11:cada08fc8a70 | 153 | break; |
mbedAustin | 11:cada08fc8a70 | 154 | } |
mbedAustin | 11:cada08fc8a70 | 155 | if(!server_id.empty()) { |
mbedAustin | 11:cada08fc8a70 | 156 | if(_server_instance) { |
mbedAustin | 11:cada08fc8a70 | 157 | success = _server_instance->remove_resource(server_id); |
mbedAustin | 11:cada08fc8a70 | 158 | } |
mbedAustin | 11:cada08fc8a70 | 159 | } |
mbedAustin | 11:cada08fc8a70 | 160 | return success; |
mbedAustin | 11:cada08fc8a70 | 161 | } |
mbedAustin | 11:cada08fc8a70 | 162 | |
mbedAustin | 11:cada08fc8a70 | 163 | bool M2MServer::set_resource_value(ServerResource resource, |
mbedAustin | 11:cada08fc8a70 | 164 | const String &value) |
mbedAustin | 11:cada08fc8a70 | 165 | { |
mbedAustin | 11:cada08fc8a70 | 166 | bool success = false; |
mbedAustin | 11:cada08fc8a70 | 167 | M2MResource* res = get_resource(resource); |
mbedAustin | 11:cada08fc8a70 | 168 | if(res && (M2MServer::Binding == resource)) { |
mbedAustin | 11:cada08fc8a70 | 169 | success = res->set_value((const uint8_t*)value.c_str(),(uint32_t)value.length()); |
mbedAustin | 11:cada08fc8a70 | 170 | } |
mbedAustin | 11:cada08fc8a70 | 171 | return success; |
mbedAustin | 11:cada08fc8a70 | 172 | } |
mbedAustin | 11:cada08fc8a70 | 173 | |
mbedAustin | 11:cada08fc8a70 | 174 | bool M2MServer::set_resource_value(ServerResource resource, |
mbedAustin | 11:cada08fc8a70 | 175 | uint32_t value) |
mbedAustin | 11:cada08fc8a70 | 176 | { |
mbedAustin | 11:cada08fc8a70 | 177 | bool success = false; |
mbedAustin | 11:cada08fc8a70 | 178 | M2MResource* res = get_resource(resource); |
mbedAustin | 11:cada08fc8a70 | 179 | if(res) { |
mbedAustin | 11:cada08fc8a70 | 180 | if(M2MServer::ShortServerID == resource || |
mbedAustin | 11:cada08fc8a70 | 181 | M2MServer::Lifetime == resource || |
mbedAustin | 11:cada08fc8a70 | 182 | M2MServer::DefaultMinPeriod == resource || |
mbedAustin | 11:cada08fc8a70 | 183 | M2MServer::DefaultMaxPeriod == resource || |
mbedAustin | 11:cada08fc8a70 | 184 | M2MServer::DisableTimeout == resource || |
mbedAustin | 11:cada08fc8a70 | 185 | M2MServer::NotificationStorage == resource) { |
mbedAustin | 11:cada08fc8a70 | 186 | // If it is any of the above resource |
mbedAustin | 11:cada08fc8a70 | 187 | // set the value of the resource. |
mbedAustin | 11:cada08fc8a70 | 188 | char *buffer = (char*)malloc(20); |
mbedAustin | 11:cada08fc8a70 | 189 | if(buffer) { |
mbedAustin | 11:cada08fc8a70 | 190 | int size = snprintf(buffer, 20,"%ld",(long int)value); |
mbedAustin | 11:cada08fc8a70 | 191 | success = res->set_value((const uint8_t*)buffer, |
mbedAustin | 11:cada08fc8a70 | 192 | (uint32_t)size); |
mbedAustin | 11:cada08fc8a70 | 193 | free(buffer); |
mbedAustin | 11:cada08fc8a70 | 194 | } |
mbedAustin | 11:cada08fc8a70 | 195 | } |
mbedAustin | 11:cada08fc8a70 | 196 | } |
mbedAustin | 11:cada08fc8a70 | 197 | return success; |
mbedAustin | 11:cada08fc8a70 | 198 | } |
mbedAustin | 11:cada08fc8a70 | 199 | |
mbedAustin | 11:cada08fc8a70 | 200 | String M2MServer::resource_value_string(ServerResource resource) const |
mbedAustin | 11:cada08fc8a70 | 201 | { |
mbedAustin | 11:cada08fc8a70 | 202 | String value = ""; |
mbedAustin | 11:cada08fc8a70 | 203 | M2MResource* res = get_resource(resource); |
mbedAustin | 11:cada08fc8a70 | 204 | if(res && (M2MServer::Binding == resource)) { |
mbedAustin | 11:cada08fc8a70 | 205 | uint8_t* buffer = NULL; |
mbedAustin | 11:cada08fc8a70 | 206 | uint32_t length = 0; |
mbedAustin | 11:cada08fc8a70 | 207 | res->get_value(buffer,length); |
mbedAustin | 11:cada08fc8a70 | 208 | |
mbedAustin | 11:cada08fc8a70 | 209 | char *char_buffer = (char*)malloc(length+1); |
mbedAustin | 11:cada08fc8a70 | 210 | if(char_buffer) { |
mbedAustin | 11:cada08fc8a70 | 211 | memset(char_buffer,0,length+1); |
mbedAustin | 11:cada08fc8a70 | 212 | memcpy(char_buffer,(char*)buffer,length); |
mbedAustin | 11:cada08fc8a70 | 213 | |
mbedAustin | 11:cada08fc8a70 | 214 | String s_name(char_buffer); |
mbedAustin | 11:cada08fc8a70 | 215 | value = s_name; |
mbedAustin | 11:cada08fc8a70 | 216 | if(char_buffer) { |
mbedAustin | 11:cada08fc8a70 | 217 | free(char_buffer); |
mbedAustin | 11:cada08fc8a70 | 218 | } |
mbedAustin | 11:cada08fc8a70 | 219 | } |
mbedAustin | 11:cada08fc8a70 | 220 | if(buffer) { |
mbedAustin | 11:cada08fc8a70 | 221 | free(buffer); |
mbedAustin | 11:cada08fc8a70 | 222 | } |
mbedAustin | 11:cada08fc8a70 | 223 | } |
mbedAustin | 11:cada08fc8a70 | 224 | return value; |
mbedAustin | 11:cada08fc8a70 | 225 | } |
mbedAustin | 11:cada08fc8a70 | 226 | |
mbedAustin | 11:cada08fc8a70 | 227 | |
mbedAustin | 11:cada08fc8a70 | 228 | uint32_t M2MServer::resource_value_int(ServerResource resource) const |
mbedAustin | 11:cada08fc8a70 | 229 | { |
mbedAustin | 11:cada08fc8a70 | 230 | uint32_t value = 0; |
mbedAustin | 11:cada08fc8a70 | 231 | M2MResource* res = get_resource(resource); |
mbedAustin | 11:cada08fc8a70 | 232 | if(res) { |
mbedAustin | 11:cada08fc8a70 | 233 | if(M2MServer::ShortServerID == resource || |
mbedAustin | 11:cada08fc8a70 | 234 | M2MServer::Lifetime == resource || |
mbedAustin | 11:cada08fc8a70 | 235 | M2MServer::DefaultMinPeriod == resource || |
mbedAustin | 11:cada08fc8a70 | 236 | M2MServer::DefaultMaxPeriod == resource || |
mbedAustin | 11:cada08fc8a70 | 237 | M2MServer::DisableTimeout == resource || |
mbedAustin | 11:cada08fc8a70 | 238 | M2MServer::NotificationStorage == resource) { |
mbedAustin | 11:cada08fc8a70 | 239 | // Get the value and convert it into integer |
mbedAustin | 11:cada08fc8a70 | 240 | uint8_t* buffer = NULL; |
mbedAustin | 11:cada08fc8a70 | 241 | uint32_t length = 0; |
mbedAustin | 11:cada08fc8a70 | 242 | res->get_value(buffer,length); |
mbedAustin | 11:cada08fc8a70 | 243 | if(buffer) { |
mbedAustin | 11:cada08fc8a70 | 244 | value = atoi((const char*)buffer); |
mbedAustin | 11:cada08fc8a70 | 245 | free(buffer); |
mbedAustin | 11:cada08fc8a70 | 246 | } |
mbedAustin | 11:cada08fc8a70 | 247 | } |
mbedAustin | 11:cada08fc8a70 | 248 | } |
mbedAustin | 11:cada08fc8a70 | 249 | return value; |
mbedAustin | 11:cada08fc8a70 | 250 | } |
mbedAustin | 11:cada08fc8a70 | 251 | |
mbedAustin | 11:cada08fc8a70 | 252 | bool M2MServer::is_resource_present(ServerResource resource) const |
mbedAustin | 11:cada08fc8a70 | 253 | { |
mbedAustin | 11:cada08fc8a70 | 254 | bool success = false; |
mbedAustin | 11:cada08fc8a70 | 255 | M2MResource *res = get_resource(resource); |
mbedAustin | 11:cada08fc8a70 | 256 | if(res) { |
mbedAustin | 11:cada08fc8a70 | 257 | success = true; |
mbedAustin | 11:cada08fc8a70 | 258 | } |
mbedAustin | 11:cada08fc8a70 | 259 | return success; |
mbedAustin | 11:cada08fc8a70 | 260 | } |
mbedAustin | 11:cada08fc8a70 | 261 | |
mbedAustin | 11:cada08fc8a70 | 262 | uint16_t M2MServer::total_resource_count() const |
mbedAustin | 11:cada08fc8a70 | 263 | { |
mbedAustin | 11:cada08fc8a70 | 264 | uint16_t total_count = 0; |
mbedAustin | 11:cada08fc8a70 | 265 | if(_server_instance) { |
mbedAustin | 11:cada08fc8a70 | 266 | total_count = _server_instance->resources().size(); |
mbedAustin | 11:cada08fc8a70 | 267 | } |
mbedAustin | 11:cada08fc8a70 | 268 | return total_count; |
mbedAustin | 11:cada08fc8a70 | 269 | } |
mbedAustin | 11:cada08fc8a70 | 270 | |
mbedAustin | 11:cada08fc8a70 | 271 | M2MResource* M2MServer::get_resource(ServerResource res) const |
mbedAustin | 11:cada08fc8a70 | 272 | { |
mbedAustin | 11:cada08fc8a70 | 273 | M2MResource* res_object = NULL; |
mbedAustin | 11:cada08fc8a70 | 274 | String res_name = ""; |
mbedAustin | 11:cada08fc8a70 | 275 | switch(res) { |
mbedAustin | 11:cada08fc8a70 | 276 | case ShortServerID: |
mbedAustin | 11:cada08fc8a70 | 277 | res_name = SERVER_SHORT_SERVER_ID; |
mbedAustin | 11:cada08fc8a70 | 278 | break; |
mbedAustin | 11:cada08fc8a70 | 279 | case Lifetime: |
mbedAustin | 11:cada08fc8a70 | 280 | res_name = SERVER_LIFETIME; |
mbedAustin | 11:cada08fc8a70 | 281 | break; |
mbedAustin | 11:cada08fc8a70 | 282 | case DefaultMinPeriod: |
mbedAustin | 11:cada08fc8a70 | 283 | res_name = SERVER_DEFAULT_MIN_PERIOD; |
mbedAustin | 11:cada08fc8a70 | 284 | break; |
mbedAustin | 11:cada08fc8a70 | 285 | case DefaultMaxPeriod: |
mbedAustin | 11:cada08fc8a70 | 286 | res_name = SERVER_DEFAULT_MAX_PERIOD; |
mbedAustin | 11:cada08fc8a70 | 287 | break; |
mbedAustin | 11:cada08fc8a70 | 288 | case Disable: |
mbedAustin | 11:cada08fc8a70 | 289 | res_name = SERVER_DISABLE; |
mbedAustin | 11:cada08fc8a70 | 290 | break; |
mbedAustin | 11:cada08fc8a70 | 291 | case DisableTimeout: |
mbedAustin | 11:cada08fc8a70 | 292 | res_name = SERVER_DISABLE_TIMEOUT; |
mbedAustin | 11:cada08fc8a70 | 293 | break; |
mbedAustin | 11:cada08fc8a70 | 294 | case NotificationStorage: |
mbedAustin | 11:cada08fc8a70 | 295 | res_name = SERVER_NOTIFICATION_STORAGE; |
mbedAustin | 11:cada08fc8a70 | 296 | break; |
mbedAustin | 11:cada08fc8a70 | 297 | case Binding: |
mbedAustin | 11:cada08fc8a70 | 298 | res_name = SERVER_BINDING; |
mbedAustin | 11:cada08fc8a70 | 299 | break; |
mbedAustin | 11:cada08fc8a70 | 300 | case RegistrationUpdate: |
mbedAustin | 11:cada08fc8a70 | 301 | res_name = SERVER_REGISTRATION_UPDATE; |
mbedAustin | 11:cada08fc8a70 | 302 | break; |
mbedAustin | 11:cada08fc8a70 | 303 | } |
mbedAustin | 11:cada08fc8a70 | 304 | if(!res_name.empty()) { |
mbedAustin | 11:cada08fc8a70 | 305 | if(_server_instance) { |
mbedAustin | 11:cada08fc8a70 | 306 | res_object = _server_instance->resource(res_name); |
mbedAustin | 11:cada08fc8a70 | 307 | } |
mbedAustin | 11:cada08fc8a70 | 308 | } |
mbedAustin | 11:cada08fc8a70 | 309 | return res_object; |
mbedAustin | 11:cada08fc8a70 | 310 | } |