use TCP to connect to mbed connector

Fork of mbedConnectorInterfaceWithDM by Doug Anson

Committer:
ansond
Date:
Wed Feb 24 14:50:03 2016 +0000
Revision:
9:faa43faea4ca
Parent:
8:f950fb1b78c0
Child:
10:3f79b5e67c22
updates

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 // Device Resources
ansond 0:1f1f55e73248 27 #include "mbed-connector-interface/DeviceResource.h"
ansond 0:1f1f55e73248 28
ansond 0:1f1f55e73248 29 // Static Resources
ansond 0:1f1f55e73248 30 #include "mbed-connector-interface/StaticResource.h"
ansond 0:1f1f55e73248 31
ansond 0:1f1f55e73248 32 // Dynamic Resources
ansond 0:1f1f55e73248 33 #include "mbed-connector-interface/DynamicResource.h"
ansond 0:1f1f55e73248 34
ansond 0:1f1f55e73248 35 // include the mbed connector resource list
ansond 0:1f1f55e73248 36 #include "mbed-connector-interface/mbedConnectorInterface.h"
ansond 0:1f1f55e73248 37
ansond 0:1f1f55e73248 38 // include the resource observer includes here so that they are not required in main.cpp
ansond 0:1f1f55e73248 39 #include "mbed-connector-interface/ThreadedResourceObserver.h"
ansond 0:1f1f55e73248 40 #include "mbed-connector-interface/TickerResourceObserver.h"
ansond 0:1f1f55e73248 41
ansond 0:1f1f55e73248 42 // Vector support
ansond 0:1f1f55e73248 43 #include <vector>
ansond 0:1f1f55e73248 44
ansond 0:1f1f55e73248 45 // Resources list
ansond 0:1f1f55e73248 46 typedef vector<DeviceResource *> DeviceResourcesList;
ansond 0:1f1f55e73248 47 typedef vector<StaticResource *> StaticResourcesList;
ansond 0:1f1f55e73248 48 typedef vector<DynamicResource *> DynamicResourcesList;
ansond 0:1f1f55e73248 49 typedef vector<ResourceObserver *> ResourceObserversList;
ansond 0:1f1f55e73248 50
ansond 0:1f1f55e73248 51 // WiFi Security types
ansond 0:1f1f55e73248 52 typedef enum {
ansond 0:1f1f55e73248 53 WIFI_WPA_PERSONAL,
ansond 0:1f1f55e73248 54 WIFI_WPA2_PERSONAL,
ansond 0:1f1f55e73248 55 WIFI_WEP,
ansond 0:1f1f55e73248 56 WIFI_NUM_TYPES
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 0:1f1f55e73248 66 namespace Connector {
ansond 0:1f1f55e73248 67
ansond 0:1f1f55e73248 68 /** Options class
ansond 0:1f1f55e73248 69 */
ansond 0:1f1f55e73248 70 class Options
ansond 0:1f1f55e73248 71 {
ansond 0:1f1f55e73248 72 public:
ansond 0:1f1f55e73248 73 /**
ansond 0:1f1f55e73248 74 Default constructor
ansond 0:1f1f55e73248 75 */
ansond 0:1f1f55e73248 76 Options();
ansond 0:1f1f55e73248 77
ansond 0:1f1f55e73248 78 /**
ansond 0:1f1f55e73248 79 Copy constructor
ansond 0:1f1f55e73248 80 */
ansond 0:1f1f55e73248 81 Options(const Options &opt);
ansond 0:1f1f55e73248 82
ansond 0:1f1f55e73248 83 /**
ansond 0:1f1f55e73248 84 Destructor
ansond 0:1f1f55e73248 85 */
ansond 0:1f1f55e73248 86 virtual ~Options();
ansond 0:1f1f55e73248 87
ansond 0:1f1f55e73248 88 /**
ansond 0:1f1f55e73248 89 Get the node lifetime
ansond 0:1f1f55e73248 90 */
ansond 0:1f1f55e73248 91 int getLifetime();
ansond 0:1f1f55e73248 92
ansond 0:1f1f55e73248 93 /**
ansond 0:1f1f55e73248 94 Get the NSP domain
ansond 0:1f1f55e73248 95 */
ansond 0:1f1f55e73248 96 string getDomain();
ansond 0:1f1f55e73248 97
ansond 0:1f1f55e73248 98 /**
ansond 0:1f1f55e73248 99 Get the node name
ansond 0:1f1f55e73248 100 */
ansond 0:1f1f55e73248 101 string getEndpointNodename();
ansond 0:1f1f55e73248 102
ansond 0:1f1f55e73248 103 /**
ansond 0:1f1f55e73248 104 Get the node type
ansond 0:1f1f55e73248 105 */
ansond 0:1f1f55e73248 106 string getEndpointType();
ansond 0:1f1f55e73248 107
ansond 0:1f1f55e73248 108 /**
ansond 0:1f1f55e73248 109 Get the mbed registration update period
ansond 0:1f1f55e73248 110 */
ansond 0:1f1f55e73248 111 int getRegUpdatePeriod();
ansond 0:1f1f55e73248 112
ansond 0:1f1f55e73248 113 /**
ansond 0:1f1f55e73248 114 Get the endpoint Connector URL
ansond 0:1f1f55e73248 115 */
ansond 0:1f1f55e73248 116 char *getConnectorURL();
ansond 0:1f1f55e73248 117
ansond 0:1f1f55e73248 118
ansond 0:1f1f55e73248 119 /**
ansond 0:1f1f55e73248 120 Get the list of device resources
ansond 0:1f1f55e73248 121 */
ansond 0:1f1f55e73248 122 DeviceResourcesList *getDeviceResourceList();
ansond 0:1f1f55e73248 123
ansond 0:1f1f55e73248 124 /**
ansond 0:1f1f55e73248 125 Get the list of static resources
ansond 0:1f1f55e73248 126 */
ansond 0:1f1f55e73248 127 StaticResourcesList *getStaticResourceList();
ansond 0:1f1f55e73248 128
ansond 0:1f1f55e73248 129 /**
ansond 0:1f1f55e73248 130 Get the list of dynamic resources
ansond 0:1f1f55e73248 131 */
ansond 0:1f1f55e73248 132 DynamicResourcesList *getDynamicResourceList();
ansond 0:1f1f55e73248 133
ansond 0:1f1f55e73248 134 /**
ansond 0:1f1f55e73248 135 Get the WiFi SSID
ansond 0:1f1f55e73248 136 */
ansond 0:1f1f55e73248 137 string getWiFiSSID();
ansond 0:1f1f55e73248 138
ansond 0:1f1f55e73248 139 /**
ansond 0:1f1f55e73248 140 Get the WiFi Auth Type
ansond 0:1f1f55e73248 141 */
ansond 0:1f1f55e73248 142 WiFiAuthTypes getWiFiAuthType();
ansond 0:1f1f55e73248 143
ansond 0:1f1f55e73248 144 /**
ansond 0:1f1f55e73248 145 Get the WiFi Auth Key
ansond 0:1f1f55e73248 146 */
ansond 0:1f1f55e73248 147 string getWiFiAuthKey();
ansond 0:1f1f55e73248 148
ansond 0:1f1f55e73248 149 /**
ansond 8:f950fb1b78c0 150 Get the 802.15.4 Pre Shared Key
ansond 0:1f1f55e73248 151 */
ansond 8:f950fb1b78c0 152 unsigned char *getPreSharedKey();
ansond 8:f950fb1b78c0 153
ansond 9:faa43faea4ca 154 /**
ansond 8:f950fb1b78c0 155 Get the 802.15.4 Pre Shared Key Identity
ansond 0:1f1f55e73248 156 */
ansond 8:f950fb1b78c0 157 unsigned char *getPreSharedKeyIdentity();
ansond 9:faa43faea4ca 158
ansond 9:faa43faea4ca 159 /**
ansond 9:faa43faea4ca 160 Get the 802.15.14 Mesh Type
ansond 9:faa43faea4ca 161 */
ansond 9:faa43faea4ca 162 MeshTypes getMeshType();
ansond 0:1f1f55e73248 163
ansond 0:1f1f55e73248 164 /**
ansond 0:1f1f55e73248 165 Enable/Disable Immediate Observationing
ansond 0:1f1f55e73248 166 */
ansond 0:1f1f55e73248 167 bool immedateObservationEnabled();
ansond 0:1f1f55e73248 168
ansond 0:1f1f55e73248 169 /**
ansond 0:1f1f55e73248 170 Enable/Disable Observation control via GET
ansond 0:1f1f55e73248 171 */
ansond 0:1f1f55e73248 172 bool enableGETObservationControl();
ansond 0:1f1f55e73248 173
ansond 0:1f1f55e73248 174 /**
ansond 0:1f1f55e73248 175 Get the Server Certificate
ansond 0:1f1f55e73248 176 */
ansond 0:1f1f55e73248 177 uint8_t *getServerCertificate();
ansond 0:1f1f55e73248 178
ansond 0:1f1f55e73248 179 /**
ansond 0:1f1f55e73248 180 Get the Server Certificate Size (bytes)
ansond 0:1f1f55e73248 181 */
ansond 0:1f1f55e73248 182 int getServerCertificateSize();
ansond 0:1f1f55e73248 183
ansond 0:1f1f55e73248 184 /**
ansond 0:1f1f55e73248 185 Get the Client Certificate
ansond 0:1f1f55e73248 186 */
ansond 0:1f1f55e73248 187 uint8_t *getClientCertificate();
ansond 0:1f1f55e73248 188
ansond 0:1f1f55e73248 189 /**
ansond 0:1f1f55e73248 190 Get the Client Certificate Size (bytes)
ansond 0:1f1f55e73248 191 */
ansond 0:1f1f55e73248 192 int getClientCertificateSize();
ansond 0:1f1f55e73248 193
ansond 0:1f1f55e73248 194 /**
ansond 0:1f1f55e73248 195 Get the Client Key
ansond 0:1f1f55e73248 196 */
ansond 0:1f1f55e73248 197 uint8_t *getClientKey();
ansond 0:1f1f55e73248 198
ansond 0:1f1f55e73248 199 /**
ansond 0:1f1f55e73248 200 Get the Client Key Size (bytes)
ansond 0:1f1f55e73248 201 */
ansond 0:1f1f55e73248 202 int getClientKeySize();
ansond 0:1f1f55e73248 203
ansond 0:1f1f55e73248 204 protected:
ansond 0:1f1f55e73248 205 // mDS Resources
ansond 0:1f1f55e73248 206 int m_lifetime;
ansond 0:1f1f55e73248 207 string m_domain;
ansond 0:1f1f55e73248 208 string m_node_name;
ansond 0:1f1f55e73248 209 string m_endpoint_type;
ansond 0:1f1f55e73248 210 int m_reg_update_period;
ansond 9:faa43faea4ca 211 string m_connector_url;
ansond 0:1f1f55e73248 212
ansond 0:1f1f55e73248 213 // WiFi Resources
ansond 0:1f1f55e73248 214 string m_wifi_ssid;
ansond 0:1f1f55e73248 215 string m_wifi_auth_key;
ansond 9:faa43faea4ca 216 WiFiAuthTypes m_wifi_auth_type;
ansond 0:1f1f55e73248 217
ansond 0:1f1f55e73248 218 // 802.15.4 Resources
ansond 9:faa43faea4ca 219 unsigned char m_psk[16];
ansond 9:faa43faea4ca 220 unsigned char m_psk_identity[2];
ansond 9:faa43faea4ca 221 MeshTypes m_mesh_type;
ansond 0:1f1f55e73248 222
ansond 0:1f1f55e73248 223 // DTLS/TLS Resources
ansond 0:1f1f55e73248 224 uint8_t m_server_cert[MAX_SERVER_CERT_LENGTH];
ansond 0:1f1f55e73248 225 int m_server_cert_length;
ansond 0:1f1f55e73248 226 uint8_t m_client_cert[MAX_CLIENT_CERT_LENGTH];
ansond 0:1f1f55e73248 227 int m_client_cert_length;
ansond 0:1f1f55e73248 228 uint8_t m_client_key[MAX_CLIENT_KEY_LENGTH];
ansond 0:1f1f55e73248 229 int m_client_key_length;
ansond 0:1f1f55e73248 230
ansond 0:1f1f55e73248 231 // CoAP behavior adjustments
ansond 0:1f1f55e73248 232 bool m_enable_immediate_observation;
ansond 0:1f1f55e73248 233 bool m_enable_get_obs_control;
ansond 0:1f1f55e73248 234
ansond 0:1f1f55e73248 235 // Endpoint Resources
ansond 0:1f1f55e73248 236 DeviceResourcesList m_device_resources;
ansond 0:1f1f55e73248 237 StaticResourcesList m_static_resources;
ansond 0:1f1f55e73248 238 DynamicResourcesList m_dynamic_resources;
ansond 0:1f1f55e73248 239 ResourceObserversList m_resource_observers;
ansond 0:1f1f55e73248 240 };
ansond 0:1f1f55e73248 241
ansond 0:1f1f55e73248 242 } // namespace Connector
ansond 0:1f1f55e73248 243
ansond 0:1f1f55e73248 244 #endif // __OPTIONS_H__