mbedConnectorInterface back port from mbedOS v3 using mbed-client C++ call interface

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers DeviceManagementResponder.h Source File

DeviceManagementResponder.h

Go to the documentation of this file.
00001 /**
00002  * @file    DeviceManagementResponder.h
00003  * @brief   mbed CoAP Endpoint Device Management Responder class
00004  * @author  Doug Anson
00005  * @version 1.0
00006  * @see
00007  *
00008  * Copyright (c) 2016
00009  *
00010  * Licensed under the Apache License, Version 2.0 (the "License");
00011  * you may not use this file except in compliance with the License.
00012  * You may obtain a copy of the License at
00013  *
00014  *     http://www.apache.org/licenses/LICENSE-2.0
00015  *
00016  * Unless required by applicable law or agreed to in writing, software
00017  * distributed under the License is distributed on an "AS IS" BASIS,
00018  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00019  * See the License for the specific language governing permissions and
00020  * limitations under the License.
00021  */
00022 
00023 #ifndef __DEVICE_MANAGEMENT_RESPONDER_H__
00024 #define __DEVICE_MANAGEMENT_RESPONDER_H__
00025 
00026 // Logger
00027 #include "mbed-connector-interface/Logger.h"
00028 
00029 // Authenticator Support
00030 #include "mbed-connector-interface/Authenticator.h"
00031 
00032 // invocation handler signature
00033 typedef bool (*responder_fn)(const void *ep,const void *logger,const void *data); 
00034 
00035 class DeviceManagementResponder {
00036     public:
00037         /**
00038         Default constructor
00039         @param logger input logger instance
00040         @param authenticator input authentication instance
00041         */
00042         DeviceManagementResponder(const Logger *logger,const Authenticator *authenticator);
00043         
00044         /**
00045         Copy constructor
00046         @param resource input the DeviceManagementResponder that is to be deep copied
00047         */
00048         DeviceManagementResponder(const DeviceManagementResponder &manager);
00049     
00050         /**
00051         Destructor
00052         */
00053         virtual ~DeviceManagementResponder();
00054         
00055         /**
00056         Set the Endpoint instance
00057         @param ep input the endpoint instance pointer
00058         */
00059         void setEndpoint(const void *ep);
00060         
00061         /** 
00062         Set our Reboot Responder handler function
00063         @param reboot_responder_fn input the device reboot responder function pointer
00064         */
00065         void setRebootResponderHandler(responder_fn reboot_responder_fn);
00066         
00067         /** 
00068         Set our Reset Responder handler function
00069         @param reset_responder_fn input the device reset responder function pointer
00070         */
00071         void setResetResponderHandler(responder_fn reset_responder_fn);
00072         
00073         /** 
00074         Set our FOTA invocation handler function
00075         @param fota_invocation_fn input the FOTA invocation handler function pointer
00076         */
00077         void setFOTAInvocationHandler(responder_fn fota_invocation_fn);
00078         
00079         /**
00080         Set our FOTA manifest
00081         @param fota_manifest input the input FOTA manifest
00082         */
00083         virtual void setFOTAManifest(const char *fota_manifest);
00084         
00085         /**
00086         Get our FOTA manifest
00087         @return the FOTA manifest
00088         */
00089         virtual char *getFOTAManifest();
00090         
00091         /**
00092         ACTION: Deregister device
00093         @param challenge input the input authentication challenge
00094         */
00095         virtual void deregisterDevice(const void *challenge);
00096         
00097         /**
00098         ACTION: Reboot device
00099         @param challenge input the input authentication challenge
00100         */
00101         virtual void rebootDevice(const void *challenge);
00102         
00103         /**
00104         ACTION: Reset device 
00105         @param challenge input the input authentication challenge
00106         */
00107         virtual void resetDevice(const void *challenge);
00108         
00109         /**
00110         ACTION: Invoke FOTA (default: empty action)
00111         @param challenge input the input authentication challenge
00112         */
00113         virtual void invokeFOTA(const void *challenge);
00114         
00115         /**
00116         Set the FirmwareComposite Resource
00117         @param firmware_composite_resource input the Firmware composite resource instance
00118         */
00119         void setFirmwareCompositeResource(const void *firmware_composite_resource);
00120         
00121         /**
00122         Get the FirmwareComposite Resource
00123         @return the Firmware composite resource or NULL
00124         */
00125         void *getFirmwareCompositeResource();
00126     
00127     private:
00128         Logger                      *m_logger;
00129         Authenticator               *m_authenticator;
00130         void                        *m_endpoint;
00131         char                        *m_fota_manifest;
00132         
00133         responder_fn                 m_reboot_responder_fn;
00134         responder_fn                 m_reset_responder_fn;
00135         responder_fn                 m_fota_invocation_fn;
00136         
00137         bool                         authenticate(const void *challenge);
00138         
00139         void                        *m_firmware_composite_resource;
00140 };
00141 
00142 #endif // __DEVICE_MANAGEMENT_RESPONDER_H__