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.
Dependencies: MAX44000 PWM_Tone_Library nexpaq_mdk
Fork of LED_Demo by
m2minterfacefactory.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/m2minterfacefactory.h" 00017 #include "mbed-client/m2mserver.h" 00018 #include "mbed-client/m2mdevice.h" 00019 #include "mbed-client/m2mfirmware.h" 00020 #include "mbed-client/m2mobject.h" 00021 #include "mbed-client/m2mconstants.h" 00022 #include "mbed-client/m2mconfig.h" 00023 #include "include/m2minterfaceimpl.h" 00024 #include "mbed-trace/mbed_trace.h" 00025 00026 #define TRACE_GROUP "mClt" 00027 00028 M2MInterface* M2MInterfaceFactory::create_interface(M2MInterfaceObserver &observer, 00029 const String &endpoint_name, 00030 const String &endpoint_type, 00031 const int32_t life_time, 00032 const uint16_t listen_port, 00033 const String &domain, 00034 M2MInterface::BindingMode mode, 00035 M2MInterface::NetworkStack stack, 00036 const String &context_address) 00037 { 00038 tr_debug("M2MInterfaceFactory::create_interface - IN"); 00039 tr_debug("M2MInterfaceFactory::create_interface - parameters endpoint name : %s",endpoint_name.c_str()); 00040 tr_debug("M2MInterfaceFactory::create_interface - parameters endpoint type : %s",endpoint_type.c_str()); 00041 tr_debug("M2MInterfaceFactory::create_interface - parameters life time(in secs): %d",life_time); 00042 tr_debug("M2MInterfaceFactory::create_interface - parameters Listen Port : %d",listen_port); 00043 tr_debug("M2MInterfaceFactory::create_interface - parameters Binding Mode : %d",(int)mode); 00044 tr_debug("M2MInterfaceFactory::create_interface - parameters NetworkStack : %d",(int)stack); 00045 M2MInterfaceImpl *interface = NULL; 00046 00047 00048 bool endpoint_type_valid = true; 00049 if(!endpoint_type.empty()) { 00050 if(endpoint_type.size() > MAX_ALLOWED_STRING_LENGTH){ 00051 endpoint_type_valid = false; 00052 } 00053 } 00054 00055 bool domain_valid = true; 00056 if(!domain.empty()) { 00057 if(domain.size() > MAX_ALLOWED_STRING_LENGTH){ 00058 domain_valid = false; 00059 } 00060 } 00061 00062 if(((life_time == -1) || (life_time >= MINIMUM_REGISTRATION_TIME)) && 00063 !endpoint_name.empty() && (endpoint_name.size() <= MAX_ALLOWED_STRING_LENGTH) && 00064 endpoint_type_valid && domain_valid) { 00065 tr_debug("M2MInterfaceFactory::create_interface - Creating M2MInterfaceImpl"); 00066 interface = new M2MInterfaceImpl(observer, endpoint_name, 00067 endpoint_type, life_time, 00068 listen_port, domain, mode, 00069 stack, context_address); 00070 00071 } 00072 tr_debug("M2MInterfaceFactory::create_interface - OUT"); 00073 return interface; 00074 } 00075 00076 M2MSecurity* M2MInterfaceFactory::create_security(M2MSecurity::ServerType server_type) 00077 { 00078 tr_debug("M2MInterfaceFactory::create_security"); 00079 M2MSecurity *security = new M2MSecurity(server_type); 00080 return security; 00081 } 00082 00083 M2MServer* M2MInterfaceFactory::create_server() 00084 { 00085 tr_debug("M2MInterfaceFactory::create_server"); 00086 M2MServer *server = new M2MServer(); 00087 return server; 00088 } 00089 00090 M2MDevice* M2MInterfaceFactory::create_device() 00091 { 00092 tr_debug("M2MInterfaceFactory::create_device"); 00093 M2MDevice* device = M2MDevice::get_instance(); 00094 return device; 00095 } 00096 00097 M2MFirmware* M2MInterfaceFactory::create_firmware() 00098 { 00099 tr_debug("M2MInterfaceFactory::create_firmware"); 00100 M2MFirmware* firmware = M2MFirmware::get_instance(); 00101 return firmware; 00102 } 00103 00104 M2MObject* M2MInterfaceFactory::create_object(const String &name) 00105 { 00106 tr_debug("M2MInterfaceFactory::create_object : Name : %s", name.c_str()); 00107 if(name.size() > MAX_ALLOWED_STRING_LENGTH || name.empty()){ 00108 return NULL; 00109 } 00110 00111 M2MObject *object = NULL; 00112 object = new M2MObject(name); 00113 return object; 00114 }
Generated on Tue Jul 12 2022 12:28:37 by
