mbed client lightswitch demo

Dependencies:   mbed Socket lwip-eth lwip-sys lwip

Fork of mbed-client-classic-example-lwip by Austin Blackstone

Committer:
mbedAustin
Date:
Thu Jun 09 17:08:36 2016 +0000
Revision:
11:cada08fc8a70
Commit for public Consumption

Who changed what in which revision?

UserRevisionLine numberNew 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_H
mbedAustin 11:cada08fc8a70 17 #define M2M_INTERFACE_H
mbedAustin 11:cada08fc8a70 18
mbedAustin 11:cada08fc8a70 19 #include <stdint.h>
mbedAustin 11:cada08fc8a70 20 #include "mbed-client/m2mvector.h"
mbedAustin 11:cada08fc8a70 21 #include "mbed-client/m2mconfig.h"
mbedAustin 11:cada08fc8a70 22 #include "mbed-client/functionpointer.h"
mbedAustin 11:cada08fc8a70 23
mbedAustin 11:cada08fc8a70 24 //FORWARD DECLARATION
mbedAustin 11:cada08fc8a70 25 class M2MSecurity;
mbedAustin 11:cada08fc8a70 26 class M2MObject;
mbedAustin 11:cada08fc8a70 27 class M2MInterfaceObserver;
mbedAustin 11:cada08fc8a70 28
mbedAustin 11:cada08fc8a70 29 typedef Vector<M2MObject *> M2MObjectList;
mbedAustin 11:cada08fc8a70 30 typedef FP callback_handler;
mbedAustin 11:cada08fc8a70 31
mbedAustin 11:cada08fc8a70 32 /**
mbedAustin 11:cada08fc8a70 33 * @brief M2MInterface.
mbedAustin 11:cada08fc8a70 34 * This class provides an interface for handling all the mbed Client Interface operations
mbedAustin 11:cada08fc8a70 35 * defined in the OMA LWM2M specifications.
mbedAustin 11:cada08fc8a70 36 * This includes Bootstrapping, Client Registration, Device Management &
mbedAustin 11:cada08fc8a70 37 * Service Enablement and Information Reporting.
mbedAustin 11:cada08fc8a70 38 */
mbedAustin 11:cada08fc8a70 39
mbedAustin 11:cada08fc8a70 40 class M2MInterface {
mbedAustin 11:cada08fc8a70 41
mbedAustin 11:cada08fc8a70 42 public:
mbedAustin 11:cada08fc8a70 43
mbedAustin 11:cada08fc8a70 44 /**
mbedAustin 11:cada08fc8a70 45 * @brief Enum defining different kinds of errors
mbedAustin 11:cada08fc8a70 46 * that can occur during various client operations.
mbedAustin 11:cada08fc8a70 47 */
mbedAustin 11:cada08fc8a70 48 typedef enum {
mbedAustin 11:cada08fc8a70 49 ErrorNone = 0,
mbedAustin 11:cada08fc8a70 50 AlreadyExists,
mbedAustin 11:cada08fc8a70 51 BootstrapFailed,
mbedAustin 11:cada08fc8a70 52 InvalidParameters,
mbedAustin 11:cada08fc8a70 53 NotRegistered,
mbedAustin 11:cada08fc8a70 54 Timeout,
mbedAustin 11:cada08fc8a70 55 NetworkError,
mbedAustin 11:cada08fc8a70 56 ResponseParseFailed,
mbedAustin 11:cada08fc8a70 57 UnknownError,
mbedAustin 11:cada08fc8a70 58 MemoryFail,
mbedAustin 11:cada08fc8a70 59 NotAllowed
mbedAustin 11:cada08fc8a70 60 }Error;
mbedAustin 11:cada08fc8a70 61
mbedAustin 11:cada08fc8a70 62 /**
mbedAustin 11:cada08fc8a70 63 * @brief Enum defining different kinds of binding
mbedAustin 11:cada08fc8a70 64 * modes handled for client operations.
mbedAustin 11:cada08fc8a70 65 */
mbedAustin 11:cada08fc8a70 66 typedef enum {
mbedAustin 11:cada08fc8a70 67 NOT_SET = 0,
mbedAustin 11:cada08fc8a70 68 UDP = 0x01,
mbedAustin 11:cada08fc8a70 69 UDP_QUEUE = 0x03,
mbedAustin 11:cada08fc8a70 70 SMS = 0x04,
mbedAustin 11:cada08fc8a70 71 SMS_QUEUE =0x06,
mbedAustin 11:cada08fc8a70 72 UDP_SMS_QUEUE = 0x07,
mbedAustin 11:cada08fc8a70 73 TCP = 0x08, //not real value, spec does not have one!
mbedAustin 11:cada08fc8a70 74 TCP_QUEUE = 0x09 //not real value, spec does not have one!
mbedAustin 11:cada08fc8a70 75 }BindingMode;
mbedAustin 11:cada08fc8a70 76
mbedAustin 11:cada08fc8a70 77 /**
mbedAustin 11:cada08fc8a70 78 * @brief Enum defining different kinds of network
mbedAustin 11:cada08fc8a70 79 * stacks that can be used by the mbed Client.
mbedAustin 11:cada08fc8a70 80 */
mbedAustin 11:cada08fc8a70 81 typedef enum {
mbedAustin 11:cada08fc8a70 82 Uninitialized = 0,
mbedAustin 11:cada08fc8a70 83 LwIP_IPv4,
mbedAustin 11:cada08fc8a70 84 LwIP_IPv6,
mbedAustin 11:cada08fc8a70 85 Reserved,
mbedAustin 11:cada08fc8a70 86 Nanostack_IPv6,
mbedAustin 11:cada08fc8a70 87 Unknown
mbedAustin 11:cada08fc8a70 88 }NetworkStack;
mbedAustin 11:cada08fc8a70 89
mbedAustin 11:cada08fc8a70 90 public:
mbedAustin 11:cada08fc8a70 91
mbedAustin 11:cada08fc8a70 92 virtual ~M2MInterface(){}
mbedAustin 11:cada08fc8a70 93
mbedAustin 11:cada08fc8a70 94 /**
mbedAustin 11:cada08fc8a70 95 * @brief Initiates bootstrapping of the client with the provided Bootstrap
mbedAustin 11:cada08fc8a70 96 * server information.
mbedAustin 11:cada08fc8a70 97 * NOTE: This API is not supported for developers!!
mbedAustin 11:cada08fc8a70 98 * @param security_object, Security object that contains information
mbedAustin 11:cada08fc8a70 99 * required for successful bootstrapping of the client.
mbedAustin 11:cada08fc8a70 100 */
mbedAustin 11:cada08fc8a70 101 virtual void bootstrap(M2MSecurity *security_object) = 0;
mbedAustin 11:cada08fc8a70 102
mbedAustin 11:cada08fc8a70 103 /**
mbedAustin 11:cada08fc8a70 104 * @brief Cancels the ongoing bootstrapping operation of the client. If the client has
mbedAustin 11:cada08fc8a70 105 * already successfully bootstrapped this function deletes the existing
mbedAustin 11:cada08fc8a70 106 * bootstrap information from the client.
mbedAustin 11:cada08fc8a70 107 * NOTE: This API is not supported for developers!!
mbedAustin 11:cada08fc8a70 108 */
mbedAustin 11:cada08fc8a70 109 virtual void cancel_bootstrap() = 0;
mbedAustin 11:cada08fc8a70 110
mbedAustin 11:cada08fc8a70 111 /**
mbedAustin 11:cada08fc8a70 112 * @brief Initiates the registration of the provided Security object to the
mbedAustin 11:cada08fc8a70 113 * corresponding LWM2M server.
mbedAustin 11:cada08fc8a70 114 * @param security_object, Security object that contains information
mbedAustin 11:cada08fc8a70 115 * required for registering to the LWM2M server.
mbedAustin 11:cada08fc8a70 116 * If the client wants to register to multiple LWM2M servers it must call
mbedAustin 11:cada08fc8a70 117 * this function once for each of the LWM2M server objects separately.
mbedAustin 11:cada08fc8a70 118 * @param object_list, Objects that contain information about the
mbedAustin 11:cada08fc8a70 119 * client attempting to register to the LWM2M server.
mbedAustin 11:cada08fc8a70 120 */
mbedAustin 11:cada08fc8a70 121 virtual void register_object(M2MSecurity *security_object, const M2MObjectList &object_list) = 0;
mbedAustin 11:cada08fc8a70 122
mbedAustin 11:cada08fc8a70 123 /**
mbedAustin 11:cada08fc8a70 124 * @brief Updates or refreshes the client's registration on the LWM2M
mbedAustin 11:cada08fc8a70 125 * server.
mbedAustin 11:cada08fc8a70 126 * @param security_object, Security object from which the device object
mbedAustin 11:cada08fc8a70 127 * needs to update registration. If there is only one LWM2M server registered
mbedAustin 11:cada08fc8a70 128 * this parameter can be NULL.
mbedAustin 11:cada08fc8a70 129 * @param lifetime, Lifetime for the endpoint client in seconds. If the same value
mbedAustin 11:cada08fc8a70 130 * has to be passed then put the default value as 0.
mbedAustin 11:cada08fc8a70 131 */
mbedAustin 11:cada08fc8a70 132 virtual void update_registration(M2MSecurity *security_object, const uint32_t lifetime = 0) = 0;
mbedAustin 11:cada08fc8a70 133
mbedAustin 11:cada08fc8a70 134 /**
mbedAustin 11:cada08fc8a70 135 * @brief Unregisters the registered object from the LWM2M server.
mbedAustin 11:cada08fc8a70 136 * @param security_object, Security object from which the device object
mbedAustin 11:cada08fc8a70 137 * needs to be unregistered. If there is only one LWM2M server registered
mbedAustin 11:cada08fc8a70 138 * this parameter can be NULL.
mbedAustin 11:cada08fc8a70 139 */
mbedAustin 11:cada08fc8a70 140 virtual void unregister_object(M2MSecurity* security_object = NULL) = 0;
mbedAustin 11:cada08fc8a70 141
mbedAustin 11:cada08fc8a70 142 /**
mbedAustin 11:cada08fc8a70 143 * @brief Sets the function that will be called for indicating that the client
mbedAustin 11:cada08fc8a70 144 * is going to sleep when the Binding mode is selected with Queue mode.
mbedAustin 11:cada08fc8a70 145 * @param callback, Function pointer that will be called when the client
mbedAustin 11:cada08fc8a70 146 * goes to sleep.
mbedAustin 11:cada08fc8a70 147 */
mbedAustin 11:cada08fc8a70 148 virtual void set_queue_sleep_handler(callback_handler handler) = 0;
mbedAustin 11:cada08fc8a70 149
mbedAustin 11:cada08fc8a70 150 };
mbedAustin 11:cada08fc8a70 151
mbedAustin 11:cada08fc8a70 152 #endif // M2M_INTERFACE_H