mbed client lightswitch demo
Dependencies: mbed Socket lwip-eth lwip-sys lwip
Fork of mbed-client-classic-example-lwip by
mbed-client/mbed-client/m2minterfacefactory.h@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 | #ifndef M2M_INTERFACE_FACTORY_H |
| mbedAustin | 11:cada08fc8a70 | 17 | #define M2M_INTERFACE_FACTORY_H |
| mbedAustin | 11:cada08fc8a70 | 18 | |
| mbedAustin | 11:cada08fc8a70 | 19 | #include <stdlib.h> |
| mbedAustin | 11:cada08fc8a70 | 20 | #include "mbed-client/m2msecurity.h" |
| mbedAustin | 11:cada08fc8a70 | 21 | #include "mbed-client/m2mresource.h" |
| mbedAustin | 11:cada08fc8a70 | 22 | #include "mbed-client/m2minterfaceobserver.h" |
| mbedAustin | 11:cada08fc8a70 | 23 | |
| mbedAustin | 11:cada08fc8a70 | 24 | //FORWARD DECLARATION |
| mbedAustin | 11:cada08fc8a70 | 25 | class M2MDevice; |
| mbedAustin | 11:cada08fc8a70 | 26 | class M2MServer; |
| mbedAustin | 11:cada08fc8a70 | 27 | class M2MInterfaceImpl; |
| mbedAustin | 11:cada08fc8a70 | 28 | class M2MFirmware; |
| mbedAustin | 11:cada08fc8a70 | 29 | |
| mbedAustin | 11:cada08fc8a70 | 30 | /** |
| mbedAustin | 11:cada08fc8a70 | 31 | * @brief M2MInterfaceFactory. |
| mbedAustin | 11:cada08fc8a70 | 32 | * This is a factory class that provides an interface for creating an mbed Client Interface |
| mbedAustin | 11:cada08fc8a70 | 33 | * object for an application to utilize the LWM2M features provided by the client. |
| mbedAustin | 11:cada08fc8a70 | 34 | */ |
| mbedAustin | 11:cada08fc8a70 | 35 | |
| mbedAustin | 11:cada08fc8a70 | 36 | class M2MInterfaceFactory { |
| mbedAustin | 11:cada08fc8a70 | 37 | private: |
| mbedAustin | 11:cada08fc8a70 | 38 | // Prevents the use of assignment operator by accident. |
| mbedAustin | 11:cada08fc8a70 | 39 | M2MInterfaceFactory& operator=( const M2MInterfaceFactory& /*other*/ ); |
| mbedAustin | 11:cada08fc8a70 | 40 | |
| mbedAustin | 11:cada08fc8a70 | 41 | // Prevents the use of copy constructor by accident |
| mbedAustin | 11:cada08fc8a70 | 42 | M2MInterfaceFactory( const M2MInterfaceFactory& /*other*/ ); |
| mbedAustin | 11:cada08fc8a70 | 43 | |
| mbedAustin | 11:cada08fc8a70 | 44 | public: |
| mbedAustin | 11:cada08fc8a70 | 45 | |
| mbedAustin | 11:cada08fc8a70 | 46 | /** |
| mbedAustin | 11:cada08fc8a70 | 47 | * @brief Creates an interface object for the mbed Client Inteface. With this, the |
| mbedAustin | 11:cada08fc8a70 | 48 | * client can handle client operations like Bootstrapping, Client |
| mbedAustin | 11:cada08fc8a70 | 49 | * Registration, Device Management and Information Reporting. |
| mbedAustin | 11:cada08fc8a70 | 50 | * @param endpoint_name, Endpoint name of the mbed client. |
| mbedAustin | 11:cada08fc8a70 | 51 | * @param endpoint_type, Endpoint type of the mbed client, default is empty. |
| mbedAustin | 11:cada08fc8a70 | 52 | * @param life_time, Lifetime of the endpoint in seconds, |
| mbedAustin | 11:cada08fc8a70 | 53 | * if -1 it is optional. |
| mbedAustin | 11:cada08fc8a70 | 54 | * @param listen_port, Listening port for the endpoint, default is 5683. |
| mbedAustin | 11:cada08fc8a70 | 55 | * @param domain, Domain of the endpoint, default is empty. |
| mbedAustin | 11:cada08fc8a70 | 56 | * @param mode, Binding Mode of the endpoint, default is NOT_SET. |
| mbedAustin | 11:cada08fc8a70 | 57 | * @param stack, Select the underlying network stack to be used for the connection, |
| mbedAustin | 11:cada08fc8a70 | 58 | * default is LwIP_IPv4. |
| mbedAustin | 11:cada08fc8a70 | 59 | * @param context_address, Context address for M2M-HTTP, not used currently. |
| mbedAustin | 11:cada08fc8a70 | 60 | * @return M2MInterfaceImpl , Object to manage other client operations. |
| mbedAustin | 11:cada08fc8a70 | 61 | */ |
| mbedAustin | 11:cada08fc8a70 | 62 | static M2MInterface *create_interface(M2MInterfaceObserver &observer, |
| mbedAustin | 11:cada08fc8a70 | 63 | const String &endpoint_name, |
| mbedAustin | 11:cada08fc8a70 | 64 | const String &endpoint_type = "", |
| mbedAustin | 11:cada08fc8a70 | 65 | const int32_t life_time = -1, |
| mbedAustin | 11:cada08fc8a70 | 66 | const uint16_t listen_port = 5683, |
| mbedAustin | 11:cada08fc8a70 | 67 | const String &domain = "", |
| mbedAustin | 11:cada08fc8a70 | 68 | M2MInterface::BindingMode mode = M2MInterface::NOT_SET, |
| mbedAustin | 11:cada08fc8a70 | 69 | M2MInterface::NetworkStack stack = M2MInterface::LwIP_IPv4, |
| mbedAustin | 11:cada08fc8a70 | 70 | const String &context_address = ""); |
| mbedAustin | 11:cada08fc8a70 | 71 | |
| mbedAustin | 11:cada08fc8a70 | 72 | /** |
| mbedAustin | 11:cada08fc8a70 | 73 | * @brief Creates a security object for the mbed Client Inteface. With this, the |
| mbedAustin | 11:cada08fc8a70 | 74 | * client can manage Bootstrapping and Client Registration. |
| mbedAustin | 11:cada08fc8a70 | 75 | * @param ServerType, Type of the Security Object, bootstrap or LWM2M server. |
| mbedAustin | 11:cada08fc8a70 | 76 | * @return M2MSecurity, Object to manage other client operations. |
| mbedAustin | 11:cada08fc8a70 | 77 | */ |
| mbedAustin | 11:cada08fc8a70 | 78 | static M2MSecurity *create_security(M2MSecurity::ServerType server_type); |
| mbedAustin | 11:cada08fc8a70 | 79 | |
| mbedAustin | 11:cada08fc8a70 | 80 | /** |
| mbedAustin | 11:cada08fc8a70 | 81 | * @brief Creates a server object for the mbed Client Inteface. With this, the |
| mbedAustin | 11:cada08fc8a70 | 82 | * client can manage the server resources used for client operations |
| mbedAustin | 11:cada08fc8a70 | 83 | * such as Client Registration, server lifetime etc. |
| mbedAustin | 11:cada08fc8a70 | 84 | * @return M2MServer, Object to manage server client operations. |
| mbedAustin | 11:cada08fc8a70 | 85 | */ |
| mbedAustin | 11:cada08fc8a70 | 86 | static M2MServer *create_server(); |
| mbedAustin | 11:cada08fc8a70 | 87 | |
| mbedAustin | 11:cada08fc8a70 | 88 | /** |
| mbedAustin | 11:cada08fc8a70 | 89 | * @brief Creates a device object for the mbed Client Inteface. With this, the |
| mbedAustin | 11:cada08fc8a70 | 90 | * client can manage the device resources used for client operations |
| mbedAustin | 11:cada08fc8a70 | 91 | * such as Client Registration, Device Management and Information Reporting. |
| mbedAustin | 11:cada08fc8a70 | 92 | * @param name, Name of the device object. |
| mbedAustin | 11:cada08fc8a70 | 93 | * @return M2MDevice, Object to manage other client operations. |
| mbedAustin | 11:cada08fc8a70 | 94 | */ |
| mbedAustin | 11:cada08fc8a70 | 95 | static M2MDevice *create_device(); |
| mbedAustin | 11:cada08fc8a70 | 96 | |
| mbedAustin | 11:cada08fc8a70 | 97 | /** |
| mbedAustin | 11:cada08fc8a70 | 98 | * @brief Creates a firmware object for the mbed Client Inteface. With this, the |
| mbedAustin | 11:cada08fc8a70 | 99 | * client can manage the firmware resources used for the client operations |
| mbedAustin | 11:cada08fc8a70 | 100 | * such as Client Registration, Device Management and Information Reporting. |
| mbedAustin | 11:cada08fc8a70 | 101 | * @return M2MFirmware, Object to manage other client operations. |
| mbedAustin | 11:cada08fc8a70 | 102 | */ |
| mbedAustin | 11:cada08fc8a70 | 103 | static M2MFirmware *create_firmware(); |
| mbedAustin | 11:cada08fc8a70 | 104 | |
| mbedAustin | 11:cada08fc8a70 | 105 | /** |
| mbedAustin | 11:cada08fc8a70 | 106 | * @brief Creates a generic object for the mbed Client Inteface. With this, the |
| mbedAustin | 11:cada08fc8a70 | 107 | * client can manage its own customized resources used for registering |
| mbedAustin | 11:cada08fc8a70 | 108 | * Device Management and Information Reporting for those resources. |
| mbedAustin | 11:cada08fc8a70 | 109 | * @param name, Name of the object. |
| mbedAustin | 11:cada08fc8a70 | 110 | * @param id, Unique ID for the object. It should be other than the reserved |
| mbedAustin | 11:cada08fc8a70 | 111 | * LWM2M object IDs. |
| mbedAustin | 11:cada08fc8a70 | 112 | * @return M2MObject, Object to manage other mbed Client operations. |
| mbedAustin | 11:cada08fc8a70 | 113 | */ |
| mbedAustin | 11:cada08fc8a70 | 114 | static M2MObject *create_object(const String &name); |
| mbedAustin | 11:cada08fc8a70 | 115 | |
| mbedAustin | 11:cada08fc8a70 | 116 | |
| mbedAustin | 11:cada08fc8a70 | 117 | friend class Test_M2MInterfaceFactory; |
| mbedAustin | 11:cada08fc8a70 | 118 | }; |
| mbedAustin | 11:cada08fc8a70 | 119 | |
| mbedAustin | 11:cada08fc8a70 | 120 | #endif // M2M_INTERFACE_FACTORY_H |
Austin Blackstone
