use TCP to connect to mbed connector
Fork of mbedConnectorInterfaceWithDM by
mbed-connector-interface/DeviceManagementResponder.h@13:9edad7677211, 2016-06-08 (annotated)
- Committer:
- ansond
- Date:
- Wed Jun 08 22:32:08 2016 +0000
- Revision:
- 13:9edad7677211
- Child:
- 14:d9ce4e56684e
updated to latest revision with new DM functions
Who changed what in which revision?
User | Revision | Line number | New 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 | 13:9edad7677211 | 79 | /** |
ansond | 13:9edad7677211 | 80 | Set our FOTA manifest |
ansond | 13:9edad7677211 | 81 | @param fota_manifest input the input FOTA manifest |
ansond | 13:9edad7677211 | 82 | */ |
ansond | 13:9edad7677211 | 83 | virtual void setFOTAManifest(const char *fota_manifest); |
ansond | 13:9edad7677211 | 84 | |
ansond | 13:9edad7677211 | 85 | /** |
ansond | 13:9edad7677211 | 86 | ACTION: Deregister device |
ansond | 13:9edad7677211 | 87 | @param challenge input the input authentication challenge |
ansond | 13:9edad7677211 | 88 | */ |
ansond | 13:9edad7677211 | 89 | virtual void deregisterDevice(const void *challenge); |
ansond | 13:9edad7677211 | 90 | |
ansond | 13:9edad7677211 | 91 | /** |
ansond | 13:9edad7677211 | 92 | ACTION: Reboot device |
ansond | 13:9edad7677211 | 93 | @param challenge input the input authentication challenge |
ansond | 13:9edad7677211 | 94 | */ |
ansond | 13:9edad7677211 | 95 | virtual void rebootDevice(const void *challenge); |
ansond | 13:9edad7677211 | 96 | |
ansond | 13:9edad7677211 | 97 | /** |
ansond | 13:9edad7677211 | 98 | ACTION: Reset device |
ansond | 13:9edad7677211 | 99 | @param challenge input the input authentication challenge |
ansond | 13:9edad7677211 | 100 | */ |
ansond | 13:9edad7677211 | 101 | virtual void resetDevice(const void *challenge); |
ansond | 13:9edad7677211 | 102 | |
ansond | 13:9edad7677211 | 103 | /** |
ansond | 13:9edad7677211 | 104 | ACTION: Invoke FOTA (default: empty action) |
ansond | 13:9edad7677211 | 105 | @param challenge input the input authentication challenge |
ansond | 13:9edad7677211 | 106 | */ |
ansond | 13:9edad7677211 | 107 | virtual void invokeFOTA(const void *challenge); |
ansond | 13:9edad7677211 | 108 | |
ansond | 13:9edad7677211 | 109 | /** |
ansond | 13:9edad7677211 | 110 | Set the State Resource |
ansond | 13:9edad7677211 | 111 | @param state_resource input the state resource instance |
ansond | 13:9edad7677211 | 112 | */ |
ansond | 13:9edad7677211 | 113 | void setStateResource(const void *state_resource); |
ansond | 13:9edad7677211 | 114 | |
ansond | 13:9edad7677211 | 115 | /** |
ansond | 13:9edad7677211 | 116 | Set the Result Resource |
ansond | 13:9edad7677211 | 117 | @param result_resource input the result resource instance |
ansond | 13:9edad7677211 | 118 | */ |
ansond | 13:9edad7677211 | 119 | void setResultResource(const void *result_resource); |
ansond | 13:9edad7677211 | 120 | |
ansond | 13:9edad7677211 | 121 | /** |
ansond | 13:9edad7677211 | 122 | Get the State Resource |
ansond | 13:9edad7677211 | 123 | @return the state resource or NULL |
ansond | 13:9edad7677211 | 124 | */ |
ansond | 13:9edad7677211 | 125 | void *getStateResource(); |
ansond | 13:9edad7677211 | 126 | |
ansond | 13:9edad7677211 | 127 | /** |
ansond | 13:9edad7677211 | 128 | Get the Result Resource |
ansond | 13:9edad7677211 | 129 | @return the result resource or NULL |
ansond | 13:9edad7677211 | 130 | */ |
ansond | 13:9edad7677211 | 131 | void *getResultResource(); |
ansond | 13:9edad7677211 | 132 | |
ansond | 13:9edad7677211 | 133 | private: |
ansond | 13:9edad7677211 | 134 | Logger *m_logger; |
ansond | 13:9edad7677211 | 135 | Authenticator *m_authenticator; |
ansond | 13:9edad7677211 | 136 | void *m_endpoint; |
ansond | 13:9edad7677211 | 137 | char *m_fota_manifest; |
ansond | 13:9edad7677211 | 138 | |
ansond | 13:9edad7677211 | 139 | responder_fn m_reboot_responder_fn; |
ansond | 13:9edad7677211 | 140 | responder_fn m_reset_responder_fn; |
ansond | 13:9edad7677211 | 141 | responder_fn m_fota_invocation_fn; |
ansond | 13:9edad7677211 | 142 | |
ansond | 13:9edad7677211 | 143 | bool authenticate(const void *challenge); |
ansond | 13:9edad7677211 | 144 | |
ansond | 13:9edad7677211 | 145 | void *m_state_resource; |
ansond | 13:9edad7677211 | 146 | void *m_result_resource; |
ansond | 13:9edad7677211 | 147 | }; |
ansond | 13:9edad7677211 | 148 | |
ansond | 13:9edad7677211 | 149 | #endif // __DEVICE_MANAGEMENT_RESPONDER_H__ |