use TCP to connect to mbed connector

Fork of mbedConnectorInterfaceWithDM by Doug Anson

Committer:
ansond
Date:
Thu Jun 23 22:26:15 2016 +0000
Revision:
49:c603a22495bb
Parent:
36:5ec1fdffe40e
Child:
54:dfee8691c83a
reduced memory usage

Who changed what in which revision?

UserRevisionLine numberNew contents of line
ansond 0:1f1f55e73248 1 /**
ansond 0:1f1f55e73248 2 * @file Options.h
ansond 0:1f1f55e73248 3 * @brief mbed CoAP Options (immutable OptionsBuilder instance) class header
ansond 0:1f1f55e73248 4 * @author Doug Anson/Chris Paola
ansond 0:1f1f55e73248 5 * @version 1.0
ansond 0:1f1f55e73248 6 * @see
ansond 0:1f1f55e73248 7 *
ansond 0:1f1f55e73248 8 * Copyright (c) 2014
ansond 0:1f1f55e73248 9 *
ansond 0:1f1f55e73248 10 * Licensed under the Apache License, Version 2.0 (the "License");
ansond 0:1f1f55e73248 11 * you may not use this file except in compliance with the License.
ansond 0:1f1f55e73248 12 * You may obtain a copy of the License at
ansond 0:1f1f55e73248 13 *
ansond 0:1f1f55e73248 14 * http://www.apache.org/licenses/LICENSE-2.0
ansond 0:1f1f55e73248 15 *
ansond 0:1f1f55e73248 16 * Unless required by applicable law or agreed to in writing, software
ansond 0:1f1f55e73248 17 * distributed under the License is distributed on an "AS IS" BASIS,
ansond 0:1f1f55e73248 18 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
ansond 0:1f1f55e73248 19 * See the License for the specific language governing permissions and
ansond 0:1f1f55e73248 20 * limitations under the License.
ansond 0:1f1f55e73248 21 */
ansond 0:1f1f55e73248 22
ansond 0:1f1f55e73248 23 #ifndef __OPTIONS_H__
ansond 0:1f1f55e73248 24 #define __OPTIONS_H__
ansond 0:1f1f55e73248 25
ansond 0:1f1f55e73248 26 // Static Resources
ansond 0:1f1f55e73248 27 #include "mbed-connector-interface/StaticResource.h"
ansond 0:1f1f55e73248 28
ansond 0:1f1f55e73248 29 // Dynamic Resources
ansond 0:1f1f55e73248 30 #include "mbed-connector-interface/DynamicResource.h"
ansond 0:1f1f55e73248 31
ansond 0:1f1f55e73248 32 // include the mbed connector resource list
ansond 0:1f1f55e73248 33 #include "mbed-connector-interface/mbedConnectorInterface.h"
ansond 0:1f1f55e73248 34
ansond 0:1f1f55e73248 35 // include the resource observer includes here so that they are not required in main.cpp
ansond 0:1f1f55e73248 36 #include "mbed-connector-interface/ThreadedResourceObserver.h"
ansond 0:1f1f55e73248 37 #include "mbed-connector-interface/TickerResourceObserver.h"
ansond 36:5ec1fdffe40e 38 #include "mbed-connector-interface/MinarResourceObserver.h"
ansond 0:1f1f55e73248 39
ansond 0:1f1f55e73248 40 // Vector support
ansond 0:1f1f55e73248 41 #include <vector>
ansond 0:1f1f55e73248 42
ansond 0:1f1f55e73248 43 // Resources list
ansond 0:1f1f55e73248 44 typedef vector<StaticResource *> StaticResourcesList;
ansond 0:1f1f55e73248 45 typedef vector<DynamicResource *> DynamicResourcesList;
ansond 0:1f1f55e73248 46 typedef vector<ResourceObserver *> ResourceObserversList;
ansond 0:1f1f55e73248 47
ansond 10:3f79b5e67c22 48 // Default CoAP URL
ansond 10:3f79b5e67c22 49 #define DEF_COAP_PORT 5683
ansond 10:3f79b5e67c22 50
ansond 12:d0e61bac8c27 51 // WiFi Security types (maps to wifi_security_t)
ansond 0:1f1f55e73248 52 typedef enum {
ansond 12:d0e61bac8c27 53 WIFI_NONE = 0,
ansond 12:d0e61bac8c27 54 WIFI_WEP,
ansond 0:1f1f55e73248 55 WIFI_WPA_PERSONAL,
ansond 12:d0e61bac8c27 56 WIFI_WPA2_PERSONAL
ansond 0:1f1f55e73248 57 } WiFiAuthTypes;
ansond 0:1f1f55e73248 58
ansond 9:faa43faea4ca 59 // Mesh Types
ansond 9:faa43faea4ca 60 typedef enum {
ansond 9:faa43faea4ca 61 MESH_THREAD,
ansond 9:faa43faea4ca 62 MESH_6LOWPAN_ND,
ansond 9:faa43faea4ca 63 MESH_NUM_TYPES
ansond 9:faa43faea4ca 64 } MeshTypes;
ansond 9:faa43faea4ca 65
ansond 10:3f79b5e67c22 66 // Connection Types for CoAP
ansond 10:3f79b5e67c22 67 typedef enum {
ansond 10:3f79b5e67c22 68 COAP_TCP,
ansond 10:3f79b5e67c22 69 COAP_UDP,
ansond 10:3f79b5e67c22 70 COAP_NUM_TYPES
ansond 10:3f79b5e67c22 71 } CoAPConnectionTypes;
ansond 10:3f79b5e67c22 72
ansond 10:3f79b5e67c22 73 // IP Address Types
ansond 10:3f79b5e67c22 74 typedef enum {
ansond 10:3f79b5e67c22 75 IP_ADDRESS_TYPE_IPV4,
ansond 10:3f79b5e67c22 76 IP_ADDRESS_TYPE_IPV6,
ansond 10:3f79b5e67c22 77 IP_ADDRESS_TYPE_NUM_TYPES
ansond 10:3f79b5e67c22 78 } IPAddressTypes;
ansond 10:3f79b5e67c22 79
ansond 0:1f1f55e73248 80 namespace Connector {
ansond 0:1f1f55e73248 81
ansond 0:1f1f55e73248 82 /** Options class
ansond 0:1f1f55e73248 83 */
ansond 0:1f1f55e73248 84 class Options
ansond 0:1f1f55e73248 85 {
ansond 0:1f1f55e73248 86 public:
ansond 0:1f1f55e73248 87 /**
ansond 0:1f1f55e73248 88 Default constructor
ansond 0:1f1f55e73248 89 */
ansond 0:1f1f55e73248 90 Options();
ansond 0:1f1f55e73248 91
ansond 0:1f1f55e73248 92 /**
ansond 0:1f1f55e73248 93 Copy constructor
ansond 0:1f1f55e73248 94 */
ansond 0:1f1f55e73248 95 Options(const Options &opt);
ansond 0:1f1f55e73248 96
ansond 0:1f1f55e73248 97 /**
ansond 0:1f1f55e73248 98 Destructor
ansond 0:1f1f55e73248 99 */
ansond 0:1f1f55e73248 100 virtual ~Options();
ansond 0:1f1f55e73248 101
ansond 0:1f1f55e73248 102 /**
ansond 0:1f1f55e73248 103 Get the node lifetime
ansond 0:1f1f55e73248 104 */
ansond 10:3f79b5e67c22 105 int getLifetime();
ansond 0:1f1f55e73248 106
ansond 0:1f1f55e73248 107 /**
ansond 0:1f1f55e73248 108 Get the NSP domain
ansond 0:1f1f55e73248 109 */
ansond 0:1f1f55e73248 110 string getDomain();
ansond 0:1f1f55e73248 111
ansond 0:1f1f55e73248 112 /**
ansond 0:1f1f55e73248 113 Get the node name
ansond 0:1f1f55e73248 114 */
ansond 0:1f1f55e73248 115 string getEndpointNodename();
ansond 0:1f1f55e73248 116
ansond 0:1f1f55e73248 117 /**
ansond 0:1f1f55e73248 118 Get the node type
ansond 0:1f1f55e73248 119 */
ansond 0:1f1f55e73248 120 string getEndpointType();
ansond 0:1f1f55e73248 121
ansond 0:1f1f55e73248 122 /**
ansond 0:1f1f55e73248 123 Get the mbed registration update period
ansond 0:1f1f55e73248 124 */
ansond 0:1f1f55e73248 125 int getRegUpdatePeriod();
ansond 0:1f1f55e73248 126
ansond 0:1f1f55e73248 127 /**
ansond 0:1f1f55e73248 128 Get the endpoint Connector URL
ansond 0:1f1f55e73248 129 */
ansond 0:1f1f55e73248 130 char *getConnectorURL();
ansond 0:1f1f55e73248 131
ansond 10:3f79b5e67c22 132 /**
ansond 10:3f79b5e67c22 133 Get the connector connection port from the URL
ansond 10:3f79b5e67c22 134 */
ansond 10:3f79b5e67c22 135 uint16_t getConnectorPort();
ansond 10:3f79b5e67c22 136
ansond 0:1f1f55e73248 137 /**
ansond 27:b8aaf7dc7023 138 Get the Device Resources Object Instance
ansond 0:1f1f55e73248 139 */
ansond 27:b8aaf7dc7023 140 void *getDeviceResourcesObject();
ansond 27:b8aaf7dc7023 141
ansond 27:b8aaf7dc7023 142 /**
ansond 27:b8aaf7dc7023 143 Get the Firmware Resources Object Instance
ansond 27:b8aaf7dc7023 144 */
ansond 27:b8aaf7dc7023 145 void *getFirmwareResourcesObject();
ansond 0:1f1f55e73248 146
ansond 0:1f1f55e73248 147 /**
ansond 0:1f1f55e73248 148 Get the list of static resources
ansond 0:1f1f55e73248 149 */
ansond 0:1f1f55e73248 150 StaticResourcesList *getStaticResourceList();
ansond 0:1f1f55e73248 151
ansond 0:1f1f55e73248 152 /**
ansond 0:1f1f55e73248 153 Get the list of dynamic resources
ansond 0:1f1f55e73248 154 */
ansond 0:1f1f55e73248 155 DynamicResourcesList *getDynamicResourceList();
ansond 0:1f1f55e73248 156
ansond 0:1f1f55e73248 157 /**
ansond 0:1f1f55e73248 158 Get the WiFi SSID
ansond 0:1f1f55e73248 159 */
ansond 0:1f1f55e73248 160 string getWiFiSSID();
ansond 0:1f1f55e73248 161
ansond 0:1f1f55e73248 162 /**
ansond 0:1f1f55e73248 163 Get the WiFi Auth Type
ansond 0:1f1f55e73248 164 */
ansond 0:1f1f55e73248 165 WiFiAuthTypes getWiFiAuthType();
ansond 0:1f1f55e73248 166
ansond 0:1f1f55e73248 167 /**
ansond 0:1f1f55e73248 168 Get the WiFi Auth Key
ansond 0:1f1f55e73248 169 */
ansond 0:1f1f55e73248 170 string getWiFiAuthKey();
ansond 0:1f1f55e73248 171
ansond 0:1f1f55e73248 172 /**
ansond 8:f950fb1b78c0 173 Get the 802.15.4 Pre Shared Key
ansond 0:1f1f55e73248 174 */
ansond 8:f950fb1b78c0 175 unsigned char *getPreSharedKey();
ansond 8:f950fb1b78c0 176
ansond 10:3f79b5e67c22 177 /**
ansond 8:f950fb1b78c0 178 Get the 802.15.4 Pre Shared Key Identity
ansond 0:1f1f55e73248 179 */
ansond 8:f950fb1b78c0 180 unsigned char *getPreSharedKeyIdentity();
ansond 9:faa43faea4ca 181
ansond 9:faa43faea4ca 182 /**
ansond 9:faa43faea4ca 183 Get the 802.15.14 Mesh Type
ansond 9:faa43faea4ca 184 */
ansond 9:faa43faea4ca 185 MeshTypes getMeshType();
ansond 10:3f79b5e67c22 186
ansond 10:3f79b5e67c22 187 /**
ansond 10:3f79b5e67c22 188 Get the CoAP Connection Type
ansond 10:3f79b5e67c22 189 */
ansond 10:3f79b5e67c22 190 CoAPConnectionTypes getCoAPConnectionType();
ansond 10:3f79b5e67c22 191
ansond 10:3f79b5e67c22 192 /**
ansond 10:3f79b5e67c22 193 Get the IP Address Type
ansond 10:3f79b5e67c22 194 */
ansond 10:3f79b5e67c22 195 IPAddressTypes getIPAddressType();
ansond 0:1f1f55e73248 196
ansond 0:1f1f55e73248 197 /**
ansond 0:1f1f55e73248 198 Enable/Disable Immediate Observationing
ansond 0:1f1f55e73248 199 */
ansond 0:1f1f55e73248 200 bool immedateObservationEnabled();
ansond 0:1f1f55e73248 201
ansond 0:1f1f55e73248 202 /**
ansond 0:1f1f55e73248 203 Enable/Disable Observation control via GET
ansond 0:1f1f55e73248 204 */
ansond 0:1f1f55e73248 205 bool enableGETObservationControl();
ansond 0:1f1f55e73248 206
ansond 0:1f1f55e73248 207 /**
ansond 0:1f1f55e73248 208 Get the Server Certificate
ansond 0:1f1f55e73248 209 */
ansond 0:1f1f55e73248 210 uint8_t *getServerCertificate();
ansond 0:1f1f55e73248 211
ansond 0:1f1f55e73248 212 /**
ansond 0:1f1f55e73248 213 Get the Server Certificate Size (bytes)
ansond 0:1f1f55e73248 214 */
ansond 0:1f1f55e73248 215 int getServerCertificateSize();
ansond 0:1f1f55e73248 216
ansond 0:1f1f55e73248 217 /**
ansond 0:1f1f55e73248 218 Get the Client Certificate
ansond 0:1f1f55e73248 219 */
ansond 0:1f1f55e73248 220 uint8_t *getClientCertificate();
ansond 0:1f1f55e73248 221
ansond 0:1f1f55e73248 222 /**
ansond 0:1f1f55e73248 223 Get the Client Certificate Size (bytes)
ansond 0:1f1f55e73248 224 */
ansond 0:1f1f55e73248 225 int getClientCertificateSize();
ansond 0:1f1f55e73248 226
ansond 0:1f1f55e73248 227 /**
ansond 0:1f1f55e73248 228 Get the Client Key
ansond 0:1f1f55e73248 229 */
ansond 0:1f1f55e73248 230 uint8_t *getClientKey();
ansond 0:1f1f55e73248 231
ansond 0:1f1f55e73248 232 /**
ansond 0:1f1f55e73248 233 Get the Client Key Size (bytes)
ansond 0:1f1f55e73248 234 */
ansond 0:1f1f55e73248 235 int getClientKeySize();
ansond 0:1f1f55e73248 236
ansond 19:56f958475694 237 /**
ansond 19:56f958475694 238 Get Our Endpoint
ansond 19:56f958475694 239 */
ansond 19:56f958475694 240 void *getEndpoint();
ansond 19:56f958475694 241
ansond 0:1f1f55e73248 242 protected:
ansond 0:1f1f55e73248 243 // mDS Resources
ansond 0:1f1f55e73248 244 int m_lifetime;
ansond 0:1f1f55e73248 245 string m_domain;
ansond 0:1f1f55e73248 246 string m_node_name;
ansond 0:1f1f55e73248 247 string m_endpoint_type;
ansond 0:1f1f55e73248 248 int m_reg_update_period;
ansond 9:faa43faea4ca 249 string m_connector_url;
ansond 0:1f1f55e73248 250
ansond 0:1f1f55e73248 251 // WiFi Resources
ansond 0:1f1f55e73248 252 string m_wifi_ssid;
ansond 0:1f1f55e73248 253 string m_wifi_auth_key;
ansond 9:faa43faea4ca 254 WiFiAuthTypes m_wifi_auth_type;
ansond 10:3f79b5e67c22 255
ansond 10:3f79b5e67c22 256 // CoAP Connection Types
ansond 10:3f79b5e67c22 257 CoAPConnectionTypes m_coap_connection_type;
ansond 10:3f79b5e67c22 258
ansond 10:3f79b5e67c22 259 // IP Address Types
ansond 10:3f79b5e67c22 260 IPAddressTypes m_ip_address_type;
ansond 0:1f1f55e73248 261
ansond 0:1f1f55e73248 262 // 802.15.4 Resources
ansond 9:faa43faea4ca 263 unsigned char m_psk[16];
ansond 9:faa43faea4ca 264 unsigned char m_psk_identity[2];
ansond 10:3f79b5e67c22 265 MeshTypes m_mesh_type;
ansond 0:1f1f55e73248 266
ansond 0:1f1f55e73248 267 // DTLS/TLS Resources
ansond 49:c603a22495bb 268 uint8_t *m_server_cert;
ansond 0:1f1f55e73248 269 int m_server_cert_length;
ansond 49:c603a22495bb 270 uint8_t *m_client_cert;
ansond 0:1f1f55e73248 271 int m_client_cert_length;
ansond 49:c603a22495bb 272 uint8_t *m_client_key;
ansond 0:1f1f55e73248 273 int m_client_key_length;
ansond 0:1f1f55e73248 274
ansond 0:1f1f55e73248 275 // CoAP behavior adjustments
ansond 0:1f1f55e73248 276 bool m_enable_immediate_observation;
ansond 0:1f1f55e73248 277 bool m_enable_get_obs_control;
ansond 0:1f1f55e73248 278
ansond 0:1f1f55e73248 279 // Endpoint Resources
ansond 27:b8aaf7dc7023 280 void *m_device_resources_object;
ansond 27:b8aaf7dc7023 281 void *m_firmware_resources_object;
ansond 15:c11dbe4d354c 282 StaticResourcesList m_static_resources;
ansond 15:c11dbe4d354c 283 DynamicResourcesList m_dynamic_resources;
ansond 15:c11dbe4d354c 284 ResourceObserversList m_resource_observers;
ansond 20:90964c5070e1 285
ansond 20:90964c5070e1 286 // Our Endpoint
ansond 20:90964c5070e1 287 void *m_endpoint;
ansond 0:1f1f55e73248 288 };
ansond 0:1f1f55e73248 289
ansond 0:1f1f55e73248 290 } // namespace Connector
ansond 0:1f1f55e73248 291
ansond 10:3f79b5e67c22 292 #endif // __OPTIONS_H__