use TCP to connect to mbed connector

Fork of mbedConnectorInterfaceWithDM by Doug Anson

Committer:
ansond
Date:
Tue Jun 14 18:40:15 2016 +0000
Revision:
30:db367366b1f5
Parent:
14:d9ce4e56684e
Child:
48:c02f2665cf76
updates

Who changed what in which revision?

UserRevisionLine numberNew contents of line
ansond 13:9edad7677211 1 /**
ansond 13:9edad7677211 2 * @file DeviceManagementResponder.h
ansond 13:9edad7677211 3 * @brief mbed CoAP Endpoint Device Management Responder class
ansond 13:9edad7677211 4 * @author Doug Anson
ansond 13:9edad7677211 5 * @version 1.0
ansond 13:9edad7677211 6 * @see
ansond 13:9edad7677211 7 *
ansond 13:9edad7677211 8 * Copyright (c) 2016
ansond 13:9edad7677211 9 *
ansond 13:9edad7677211 10 * Licensed under the Apache License, Version 2.0 (the "License");
ansond 13:9edad7677211 11 * you may not use this file except in compliance with the License.
ansond 13:9edad7677211 12 * You may obtain a copy of the License at
ansond 13:9edad7677211 13 *
ansond 13:9edad7677211 14 * http://www.apache.org/licenses/LICENSE-2.0
ansond 13:9edad7677211 15 *
ansond 13:9edad7677211 16 * Unless required by applicable law or agreed to in writing, software
ansond 13:9edad7677211 17 * distributed under the License is distributed on an "AS IS" BASIS,
ansond 13:9edad7677211 18 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
ansond 13:9edad7677211 19 * See the License for the specific language governing permissions and
ansond 13:9edad7677211 20 * limitations under the License.
ansond 13:9edad7677211 21 */
ansond 13:9edad7677211 22
ansond 13:9edad7677211 23 #ifndef __DEVICE_MANAGEMENT_RESPONDER_H__
ansond 13:9edad7677211 24 #define __DEVICE_MANAGEMENT_RESPONDER_H__
ansond 13:9edad7677211 25
ansond 13:9edad7677211 26 // Logger
ansond 13:9edad7677211 27 #include "mbed-connector-interface/Logger.h"
ansond 13:9edad7677211 28
ansond 13:9edad7677211 29 // Authenticator Support
ansond 13:9edad7677211 30 #include "mbed-connector-interface/Authenticator.h"
ansond 13:9edad7677211 31
ansond 13:9edad7677211 32 // invocation handler signature
ansond 13:9edad7677211 33 typedef bool (*responder_fn)(const void *ep,const void *logger,const void *data);
ansond 13:9edad7677211 34
ansond 13:9edad7677211 35 class DeviceManagementResponder {
ansond 13:9edad7677211 36 public:
ansond 13:9edad7677211 37 /**
ansond 13:9edad7677211 38 Default constructor
ansond 13:9edad7677211 39 @param logger input logger instance
ansond 13:9edad7677211 40 @param authenticator input authentication instance
ansond 13:9edad7677211 41 */
ansond 13:9edad7677211 42 DeviceManagementResponder(const Logger *logger,const Authenticator *authenticator);
ansond 13:9edad7677211 43
ansond 13:9edad7677211 44 /**
ansond 13:9edad7677211 45 Copy constructor
ansond 13:9edad7677211 46 @param resource input the DeviceManagementResponder that is to be deep copied
ansond 13:9edad7677211 47 */
ansond 13:9edad7677211 48 DeviceManagementResponder(const DeviceManagementResponder &manager);
ansond 13:9edad7677211 49
ansond 13:9edad7677211 50 /**
ansond 13:9edad7677211 51 Destructor
ansond 13:9edad7677211 52 */
ansond 13:9edad7677211 53 virtual ~DeviceManagementResponder();
ansond 13:9edad7677211 54
ansond 13:9edad7677211 55 /**
ansond 13:9edad7677211 56 Set the Endpoint instance
ansond 13:9edad7677211 57 @param ep input the endpoint instance pointer
ansond 13:9edad7677211 58 */
ansond 13:9edad7677211 59 void setEndpoint(const void *ep);
ansond 13:9edad7677211 60
ansond 13:9edad7677211 61 /**
ansond 13:9edad7677211 62 Set our Reboot Responder handler function
ansond 13:9edad7677211 63 @param reboot_responder_fn input the device reboot responder function pointer
ansond 13:9edad7677211 64 */
ansond 13:9edad7677211 65 void setRebootResponderHandler(responder_fn reboot_responder_fn);
ansond 13:9edad7677211 66
ansond 13:9edad7677211 67 /**
ansond 13:9edad7677211 68 Set our Reset Responder handler function
ansond 13:9edad7677211 69 @param reset_responder_fn input the device reset responder function pointer
ansond 13:9edad7677211 70 */
ansond 13:9edad7677211 71 void setResetResponderHandler(responder_fn reset_responder_fn);
ansond 13:9edad7677211 72
ansond 13:9edad7677211 73 /**
ansond 13:9edad7677211 74 Set our FOTA invocation handler function
ansond 13:9edad7677211 75 @param fota_invocation_fn input the FOTA invocation handler function pointer
ansond 13:9edad7677211 76 */
ansond 13:9edad7677211 77 void setFOTAInvocationHandler(responder_fn fota_invocation_fn);
ansond 13:9edad7677211 78
ansond 14:d9ce4e56684e 79
ansond 14:d9ce4e56684e 80 /**
ansond 13:9edad7677211 81 ACTION: Deregister device
ansond 13:9edad7677211 82 @param challenge input the input authentication challenge
ansond 13:9edad7677211 83 */
ansond 13:9edad7677211 84 virtual void deregisterDevice(const void *challenge);
ansond 13:9edad7677211 85
ansond 13:9edad7677211 86 /**
ansond 13:9edad7677211 87 ACTION: Reboot device
ansond 13:9edad7677211 88 @param challenge input the input authentication challenge
ansond 13:9edad7677211 89 */
ansond 13:9edad7677211 90 virtual void rebootDevice(const void *challenge);
ansond 13:9edad7677211 91
ansond 13:9edad7677211 92 /**
ansond 13:9edad7677211 93 ACTION: Reset device
ansond 13:9edad7677211 94 @param challenge input the input authentication challenge
ansond 13:9edad7677211 95 */
ansond 13:9edad7677211 96 virtual void resetDevice(const void *challenge);
ansond 13:9edad7677211 97
ansond 13:9edad7677211 98 /**
ansond 30:db367366b1f5 99 Set our FOTA manifest
ansond 30:db367366b1f5 100 @param manifest input the FOTA manifest
ansond 30:db367366b1f5 101 */
ansond 30:db367366b1f5 102 virtual void setFOTAManifest(char *manifest);
ansond 30:db367366b1f5 103
ansond 30:db367366b1f5 104 /**
ansond 30:db367366b1f5 105 Get our FOTA manifest
ansond 30:db367366b1f5 106 @return the FOTA manifest
ansond 30:db367366b1f5 107 */
ansond 30:db367366b1f5 108 virtual char *getFOTAManifest();
ansond 30:db367366b1f5 109
ansond 30:db367366b1f5 110 /**
ansond 30:db367366b1f5 111 Set our FOTA image
ansond 30:db367366b1f5 112 @param fota_image input the FOTA image
ansond 30:db367366b1f5 113 @param fota_image_length input the length of the fota image
ansond 30:db367366b1f5 114 */
ansond 30:db367366b1f5 115 virtual void setFOTAImage(void *fota_image,uint32_t fota_image_length );
ansond 30:db367366b1f5 116
ansond 30:db367366b1f5 117 /**
ansond 30:db367366b1f5 118 Get our FOTA image
ansond 30:db367366b1f5 119 @return the FOTA image
ansond 30:db367366b1f5 120 */
ansond 30:db367366b1f5 121 virtual void *getFOTAImage();
ansond 30:db367366b1f5 122
ansond 30:db367366b1f5 123 /**
ansond 30:db367366b1f5 124 Get our FOTA image length
ansond 30:db367366b1f5 125 @return the FOTA image length
ansond 30:db367366b1f5 126 */
ansond 30:db367366b1f5 127 virtual uint32_t getFOTAImageLength();
ansond 30:db367366b1f5 128
ansond 30:db367366b1f5 129 /**
ansond 13:9edad7677211 130 ACTION: Invoke FOTA (default: empty action)
ansond 13:9edad7677211 131 @param challenge input the input authentication challenge
ansond 13:9edad7677211 132 */
ansond 13:9edad7677211 133 virtual void invokeFOTA(const void *challenge);
ansond 13:9edad7677211 134
ansond 13:9edad7677211 135 private:
ansond 13:9edad7677211 136 Logger *m_logger;
ansond 13:9edad7677211 137 Authenticator *m_authenticator;
ansond 13:9edad7677211 138 void *m_endpoint;
ansond 30:db367366b1f5 139 char *m_manifest;
ansond 30:db367366b1f5 140 void *m_fota_image;
ansond 30:db367366b1f5 141 uint32_t m_fota_image_length;
ansond 13:9edad7677211 142
ansond 13:9edad7677211 143 responder_fn m_reboot_responder_fn;
ansond 13:9edad7677211 144 responder_fn m_reset_responder_fn;
ansond 13:9edad7677211 145 responder_fn m_fota_invocation_fn;
ansond 13:9edad7677211 146
ansond 13:9edad7677211 147 bool authenticate(const void *challenge);
ansond 13:9edad7677211 148 };
ansond 13:9edad7677211 149
ansond 13:9edad7677211 150 #endif // __DEVICE_MANAGEMENT_RESPONDER_H__