use TCP to connect to mbed connector

Fork of mbedConnectorInterfaceWithDM by Doug Anson

Committer:
ansond
Date:
Mon Jun 20 20:09:44 2016 +0000
Revision:
48:c02f2665cf76
Parent:
30:db367366b1f5
support for added DM calls

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 48:c02f2665cf76 33 typedef void (*initialize_fn)(const void *logger);
ansond 48:c02f2665cf76 34 typedef bool (*manifest_fn)(const void *ep,const void *logger,const void *manifest,uint32_t manifest_length);
ansond 48:c02f2665cf76 35 typedef bool (*image_set_fn)(const void *ep,const void *logger,const void *image,uint32_t image_length);
ansond 13:9edad7677211 36 typedef bool (*responder_fn)(const void *ep,const void *logger,const void *data);
ansond 13:9edad7677211 37
ansond 13:9edad7677211 38 class DeviceManagementResponder {
ansond 13:9edad7677211 39 public:
ansond 13:9edad7677211 40 /**
ansond 13:9edad7677211 41 Default constructor
ansond 13:9edad7677211 42 @param logger input logger instance
ansond 13:9edad7677211 43 @param authenticator input authentication instance
ansond 13:9edad7677211 44 */
ansond 13:9edad7677211 45 DeviceManagementResponder(const Logger *logger,const Authenticator *authenticator);
ansond 13:9edad7677211 46
ansond 13:9edad7677211 47 /**
ansond 13:9edad7677211 48 Copy constructor
ansond 13:9edad7677211 49 @param resource input the DeviceManagementResponder that is to be deep copied
ansond 13:9edad7677211 50 */
ansond 13:9edad7677211 51 DeviceManagementResponder(const DeviceManagementResponder &manager);
ansond 13:9edad7677211 52
ansond 13:9edad7677211 53 /**
ansond 13:9edad7677211 54 Destructor
ansond 13:9edad7677211 55 */
ansond 13:9edad7677211 56 virtual ~DeviceManagementResponder();
ansond 13:9edad7677211 57
ansond 13:9edad7677211 58 /**
ansond 13:9edad7677211 59 Set the Endpoint instance
ansond 13:9edad7677211 60 @param ep input the endpoint instance pointer
ansond 13:9edad7677211 61 */
ansond 13:9edad7677211 62 void setEndpoint(const void *ep);
ansond 13:9edad7677211 63
ansond 13:9edad7677211 64 /**
ansond 48:c02f2665cf76 65 Set our Initialize handler function
ansond 48:c02f2665cf76 66 @param initialize_fn input the device initialize function pointer
ansond 48:c02f2665cf76 67 */
ansond 48:c02f2665cf76 68 void setInitializeHandler(initialize_fn initialize_fn);
ansond 48:c02f2665cf76 69
ansond 48:c02f2665cf76 70 /**
ansond 13:9edad7677211 71 Set our Reboot Responder handler function
ansond 13:9edad7677211 72 @param reboot_responder_fn input the device reboot responder function pointer
ansond 13:9edad7677211 73 */
ansond 13:9edad7677211 74 void setRebootResponderHandler(responder_fn reboot_responder_fn);
ansond 13:9edad7677211 75
ansond 13:9edad7677211 76 /**
ansond 13:9edad7677211 77 Set our Reset Responder handler function
ansond 13:9edad7677211 78 @param reset_responder_fn input the device reset responder function pointer
ansond 13:9edad7677211 79 */
ansond 13:9edad7677211 80 void setResetResponderHandler(responder_fn reset_responder_fn);
ansond 13:9edad7677211 81
ansond 13:9edad7677211 82 /**
ansond 48:c02f2665cf76 83 Set our FOTA manifest handler function
ansond 48:c02f2665cf76 84 @param fota_manifest_fn input the FOTA manifest handler function pointer
ansond 48:c02f2665cf76 85 */
ansond 48:c02f2665cf76 86 void setFOTAManifestHandler(manifest_fn fota_manifest_fn);
ansond 48:c02f2665cf76 87
ansond 48:c02f2665cf76 88 /**
ansond 48:c02f2665cf76 89 Set our FOTA image set handler function
ansond 48:c02f2665cf76 90 @param fota_image_set_fn input the FOTA image set function pointer
ansond 48:c02f2665cf76 91 */
ansond 48:c02f2665cf76 92 void setFOTAImageHandler(image_set_fn fota_image_set_fn);
ansond 48:c02f2665cf76 93
ansond 48:c02f2665cf76 94 /**
ansond 13:9edad7677211 95 Set our FOTA invocation handler function
ansond 13:9edad7677211 96 @param fota_invocation_fn input the FOTA invocation handler function pointer
ansond 13:9edad7677211 97 */
ansond 13:9edad7677211 98 void setFOTAInvocationHandler(responder_fn fota_invocation_fn);
ansond 13:9edad7677211 99
ansond 14:d9ce4e56684e 100 /**
ansond 13:9edad7677211 101 ACTION: Deregister device
ansond 13:9edad7677211 102 @param challenge input the input authentication challenge
ansond 13:9edad7677211 103 */
ansond 13:9edad7677211 104 virtual void deregisterDevice(const void *challenge);
ansond 13:9edad7677211 105
ansond 13:9edad7677211 106 /**
ansond 13:9edad7677211 107 ACTION: Reboot device
ansond 13:9edad7677211 108 @param challenge input the input authentication challenge
ansond 13:9edad7677211 109 */
ansond 13:9edad7677211 110 virtual void rebootDevice(const void *challenge);
ansond 13:9edad7677211 111
ansond 13:9edad7677211 112 /**
ansond 13:9edad7677211 113 ACTION: Reset device
ansond 13:9edad7677211 114 @param challenge input the input authentication challenge
ansond 13:9edad7677211 115 */
ansond 13:9edad7677211 116 virtual void resetDevice(const void *challenge);
ansond 13:9edad7677211 117
ansond 13:9edad7677211 118 /**
ansond 30:db367366b1f5 119 Set our FOTA manifest
ansond 30:db367366b1f5 120 @param manifest input the FOTA manifest
ansond 48:c02f2665cf76 121 @param manifest_length input the length of the FOTA manifest
ansond 30:db367366b1f5 122 */
ansond 48:c02f2665cf76 123 virtual void setFOTAManifest(char *manifest,uint32_t manifest_length);
ansond 30:db367366b1f5 124
ansond 30:db367366b1f5 125 /**
ansond 30:db367366b1f5 126 Get our FOTA manifest
ansond 30:db367366b1f5 127 @return the FOTA manifest
ansond 30:db367366b1f5 128 */
ansond 30:db367366b1f5 129 virtual char *getFOTAManifest();
ansond 30:db367366b1f5 130
ansond 30:db367366b1f5 131 /**
ansond 48:c02f2665cf76 132 Get our FOTA manifest length
ansond 48:c02f2665cf76 133 @return the FOTA manifest length
ansond 48:c02f2665cf76 134 */
ansond 48:c02f2665cf76 135 virtual uint32_t getFOTAManifestLength();
ansond 48:c02f2665cf76 136
ansond 48:c02f2665cf76 137 /**
ansond 30:db367366b1f5 138 Set our FOTA image
ansond 30:db367366b1f5 139 @param fota_image input the FOTA image
ansond 30:db367366b1f5 140 @param fota_image_length input the length of the fota image
ansond 30:db367366b1f5 141 */
ansond 48:c02f2665cf76 142 virtual void setFOTAImage(void *fota_image,uint32_t fota_image_length);
ansond 30:db367366b1f5 143
ansond 30:db367366b1f5 144 /**
ansond 30:db367366b1f5 145 Get our FOTA image
ansond 30:db367366b1f5 146 @return the FOTA image
ansond 30:db367366b1f5 147 */
ansond 30:db367366b1f5 148 virtual void *getFOTAImage();
ansond 30:db367366b1f5 149
ansond 30:db367366b1f5 150 /**
ansond 30:db367366b1f5 151 Get our FOTA image length
ansond 30:db367366b1f5 152 @return the FOTA image length
ansond 30:db367366b1f5 153 */
ansond 30:db367366b1f5 154 virtual uint32_t getFOTAImageLength();
ansond 30:db367366b1f5 155
ansond 30:db367366b1f5 156 /**
ansond 13:9edad7677211 157 ACTION: Invoke FOTA (default: empty action)
ansond 13:9edad7677211 158 @param challenge input the input authentication challenge
ansond 13:9edad7677211 159 */
ansond 13:9edad7677211 160 virtual void invokeFOTA(const void *challenge);
ansond 13:9edad7677211 161
ansond 13:9edad7677211 162 private:
ansond 13:9edad7677211 163 Logger *m_logger;
ansond 13:9edad7677211 164 Authenticator *m_authenticator;
ansond 13:9edad7677211 165 void *m_endpoint;
ansond 30:db367366b1f5 166 char *m_manifest;
ansond 48:c02f2665cf76 167 int m_manifest_length;
ansond 30:db367366b1f5 168 void *m_fota_image;
ansond 30:db367366b1f5 169 uint32_t m_fota_image_length;
ansond 13:9edad7677211 170
ansond 48:c02f2665cf76 171 initialize_fn m_initialize_fn;
ansond 13:9edad7677211 172 responder_fn m_reboot_responder_fn;
ansond 13:9edad7677211 173 responder_fn m_reset_responder_fn;
ansond 48:c02f2665cf76 174 manifest_fn m_fota_manifest_fn;
ansond 48:c02f2665cf76 175 image_set_fn m_fota_image_set_fn;
ansond 13:9edad7677211 176 responder_fn m_fota_invocation_fn;
ansond 13:9edad7677211 177
ansond 13:9edad7677211 178 bool authenticate(const void *challenge);
ansond 13:9edad7677211 179 };
ansond 13:9edad7677211 180
ansond 13:9edad7677211 181 #endif // __DEVICE_MANAGEMENT_RESPONDER_H__