use TCP to connect to mbed connector

Fork of mbedConnectorInterfaceWithDM by Doug Anson

Committer:
ansond
Date:
Tue Jun 14 20:18:30 2016 +0000
Revision:
38:bb6d2be4d54c
Parent:
33:1d0b855df5a5
Child:
49:c603a22495bb
cleaned up compile warnings

Who changed what in which revision?

UserRevisionLine numberNew contents of line
ansond 8:f950fb1b78c0 1 /**
ansond 8:f950fb1b78c0 2 * @file Options.cpp
ansond 8:f950fb1b78c0 3 * @brief mbed CoAP Options (immutable OptionsBuilder instance) class implementation
ansond 8:f950fb1b78c0 4 * @author Doug Anson/Chris Paola
ansond 8:f950fb1b78c0 5 * @version 1.0
ansond 8:f950fb1b78c0 6 * @see
ansond 8:f950fb1b78c0 7 *
ansond 8:f950fb1b78c0 8 * Copyright (c) 2014
ansond 8:f950fb1b78c0 9 *
ansond 8:f950fb1b78c0 10 * Licensed under the Apache License, Version 2.0 (the "License");
ansond 8:f950fb1b78c0 11 * you may not use this file except in compliance with the License.
ansond 8:f950fb1b78c0 12 * You may obtain a copy of the License at
ansond 8:f950fb1b78c0 13 *
ansond 8:f950fb1b78c0 14 * http://www.apache.org/licenses/LICENSE-2.0
ansond 8:f950fb1b78c0 15 *
ansond 8:f950fb1b78c0 16 * Unless required by applicable law or agreed to in writing, software
ansond 8:f950fb1b78c0 17 * distributed under the License is distributed on an "AS IS" BASIS,
ansond 8:f950fb1b78c0 18 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
ansond 8:f950fb1b78c0 19 * See the License for the specific language governing permissions and
ansond 8:f950fb1b78c0 20 * limitations under the License.
ansond 8:f950fb1b78c0 21 */
ansond 8:f950fb1b78c0 22
ansond 33:1d0b855df5a5 23 // Class support
ansond 8:f950fb1b78c0 24 #include "mbed-connector-interface/Options.h"
ansond 33:1d0b855df5a5 25
ansond 33:1d0b855df5a5 26 // Utils
ansond 10:3f79b5e67c22 27 #include "mbed-connector-interface/Utils.h"
ansond 8:f950fb1b78c0 28
ansond 8:f950fb1b78c0 29 namespace Connector {
ansond 8:f950fb1b78c0 30
ansond 8:f950fb1b78c0 31 // default constructor
ansond 8:f950fb1b78c0 32 Options::Options()
ansond 8:f950fb1b78c0 33 {
ansond 8:f950fb1b78c0 34 }
ansond 8:f950fb1b78c0 35
ansond 8:f950fb1b78c0 36 // copy constructor
ansond 38:bb6d2be4d54c 37 Options::Options(const Options & /* opt */)
ansond 8:f950fb1b78c0 38 {
ansond 8:f950fb1b78c0 39 }
ansond 8:f950fb1b78c0 40
ansond 8:f950fb1b78c0 41 // destructors
ansond 8:f950fb1b78c0 42 Options::~Options()
ansond 8:f950fb1b78c0 43 {
ansond 8:f950fb1b78c0 44 }
ansond 8:f950fb1b78c0 45
ansond 8:f950fb1b78c0 46 // lifetime pointer
ansond 8:f950fb1b78c0 47 int Options::getLifetime()
ansond 8:f950fb1b78c0 48 {
ansond 8:f950fb1b78c0 49 return this->m_lifetime;
ansond 8:f950fb1b78c0 50 }
ansond 8:f950fb1b78c0 51
ansond 8:f950fb1b78c0 52 // NSP domain
ansond 8:f950fb1b78c0 53 string Options::getDomain()
ansond 8:f950fb1b78c0 54 {
ansond 8:f950fb1b78c0 55 return this->m_domain;
ansond 8:f950fb1b78c0 56 }
ansond 8:f950fb1b78c0 57
ansond 8:f950fb1b78c0 58 // Endpoint name
ansond 8:f950fb1b78c0 59 string Options::getEndpointNodename()
ansond 8:f950fb1b78c0 60 {
ansond 8:f950fb1b78c0 61 return this->m_node_name;
ansond 8:f950fb1b78c0 62 }
ansond 8:f950fb1b78c0 63
ansond 8:f950fb1b78c0 64 // Endpoint Type
ansond 8:f950fb1b78c0 65 string Options::getEndpointType()
ansond 8:f950fb1b78c0 66 {
ansond 8:f950fb1b78c0 67 return this->m_endpoint_type;
ansond 8:f950fb1b78c0 68 }
ansond 8:f950fb1b78c0 69
ansond 8:f950fb1b78c0 70 // mbed Registation update period
ansond 8:f950fb1b78c0 71 int Options::getRegUpdatePeriod()
ansond 8:f950fb1b78c0 72 {
ansond 8:f950fb1b78c0 73 return this->m_reg_update_period;
ansond 8:f950fb1b78c0 74 }
ansond 8:f950fb1b78c0 75
ansond 8:f950fb1b78c0 76 // Connector URL
ansond 8:f950fb1b78c0 77 char *Options::getConnectorURL()
ansond 8:f950fb1b78c0 78 {
ansond 8:f950fb1b78c0 79 return (char *)this->m_connector_url.c_str();
ansond 8:f950fb1b78c0 80 }
ansond 0:1f1f55e73248 81
ansond 10:3f79b5e67c22 82 // Connector Port
ansond 10:3f79b5e67c22 83 uint16_t Options::getConnectorPort()
ansond 10:3f79b5e67c22 84 {
ansond 10:3f79b5e67c22 85 return extract_port_from_url(this->getConnectorURL(),DEF_COAP_PORT);
ansond 10:3f79b5e67c22 86 }
ansond 10:3f79b5e67c22 87
ansond 27:b8aaf7dc7023 88 // Device Resources Object
ansond 27:b8aaf7dc7023 89 void *Options::getDeviceResourcesObject()
ansond 8:f950fb1b78c0 90 {
ansond 27:b8aaf7dc7023 91 return this->m_device_resources_object;
ansond 27:b8aaf7dc7023 92 }
ansond 27:b8aaf7dc7023 93
ansond 27:b8aaf7dc7023 94 // Firmware Resources Object
ansond 27:b8aaf7dc7023 95 void *Options::getFirmwareResourcesObject()
ansond 27:b8aaf7dc7023 96 {
ansond 27:b8aaf7dc7023 97 return this->m_firmware_resources_object;
ansond 8:f950fb1b78c0 98 }
ansond 8:f950fb1b78c0 99
ansond 8:f950fb1b78c0 100 // Static Resources
ansond 8:f950fb1b78c0 101 StaticResourcesList *Options::getStaticResourceList()
ansond 8:f950fb1b78c0 102 {
ansond 8:f950fb1b78c0 103 return &this->m_static_resources;
ansond 8:f950fb1b78c0 104 }
ansond 8:f950fb1b78c0 105
ansond 8:f950fb1b78c0 106 // Dynamic Resources
ansond 8:f950fb1b78c0 107 DynamicResourcesList *Options::getDynamicResourceList()
ansond 8:f950fb1b78c0 108 {
ansond 8:f950fb1b78c0 109 return &this->m_dynamic_resources;
ansond 8:f950fb1b78c0 110 }
ansond 8:f950fb1b78c0 111
ansond 8:f950fb1b78c0 112 // WiFi SSID
ansond 8:f950fb1b78c0 113 string Options::getWiFiSSID() {
ansond 8:f950fb1b78c0 114 return this->m_wifi_ssid;
ansond 8:f950fb1b78c0 115 }
ansond 8:f950fb1b78c0 116
ansond 8:f950fb1b78c0 117 // WiFi AuthType
ansond 8:f950fb1b78c0 118 WiFiAuthTypes Options::getWiFiAuthType() {
ansond 8:f950fb1b78c0 119 return this->m_wifi_auth_type;
ansond 8:f950fb1b78c0 120 }
ansond 8:f950fb1b78c0 121
ansond 8:f950fb1b78c0 122 // WiFi AuthKey
ansond 8:f950fb1b78c0 123 string Options::getWiFiAuthKey() {
ansond 8:f950fb1b78c0 124 return this->m_wifi_auth_key;
ansond 8:f950fb1b78c0 125 }
ansond 8:f950fb1b78c0 126
ansond 8:f950fb1b78c0 127 // 802.15.4 Pre Shared Key
ansond 8:f950fb1b78c0 128 unsigned char *Options::getPreSharedKey() {
ansond 8:f950fb1b78c0 129 return this->m_psk;
ansond 8:f950fb1b78c0 130 }
ansond 8:f950fb1b78c0 131
ansond 8:f950fb1b78c0 132 // 802.15.4 Pre Shared Key Identity
ansond 8:f950fb1b78c0 133 unsigned char *Options::getPreSharedKeyIdentity() {
ansond 8:f950fb1b78c0 134 return this->m_psk_identity;
ansond 8:f950fb1b78c0 135 }
ansond 8:f950fb1b78c0 136
ansond 9:faa43faea4ca 137 // 802.15.4 Mesh Type
ansond 9:faa43faea4ca 138 MeshTypes Options::getMeshType() {
ansond 9:faa43faea4ca 139 return this->m_mesh_type;
ansond 9:faa43faea4ca 140 }
ansond 9:faa43faea4ca 141
ansond 10:3f79b5e67c22 142 // CoAP Connection Type
ansond 10:3f79b5e67c22 143 CoAPConnectionTypes Options::getCoAPConnectionType() {
ansond 10:3f79b5e67c22 144 return this->m_coap_connection_type;
ansond 10:3f79b5e67c22 145 }
ansond 10:3f79b5e67c22 146
ansond 10:3f79b5e67c22 147 // IP Address Type
ansond 10:3f79b5e67c22 148 IPAddressTypes Options::getIPAddressType() {
ansond 10:3f79b5e67c22 149 return this->m_ip_address_type;
ansond 10:3f79b5e67c22 150 }
ansond 10:3f79b5e67c22 151
ansond 8:f950fb1b78c0 152 // Immediate Observationing Enabled
ansond 8:f950fb1b78c0 153 bool Options::immedateObservationEnabled() {
ansond 8:f950fb1b78c0 154 return this->m_enable_immediate_observation;
ansond 8:f950fb1b78c0 155 }
ansond 8:f950fb1b78c0 156
ansond 8:f950fb1b78c0 157 // Enable/Disable Observation control via GET
ansond 8:f950fb1b78c0 158 bool Options::enableGETObservationControl() {
ansond 8:f950fb1b78c0 159 return this->m_enable_get_obs_control;
ansond 8:f950fb1b78c0 160 }
ansond 8:f950fb1b78c0 161
ansond 8:f950fb1b78c0 162 // Get the Server Certificate
ansond 8:f950fb1b78c0 163 uint8_t *Options::getServerCertificate() {
ansond 8:f950fb1b78c0 164 return (uint8_t *) this->m_server_cert;
ansond 8:f950fb1b78c0 165 }
ansond 8:f950fb1b78c0 166
ansond 8:f950fb1b78c0 167 // Get the Server Certificate length
ansond 8:f950fb1b78c0 168 int Options::getServerCertificateSize() {
ansond 8:f950fb1b78c0 169 return this->m_server_cert_length;
ansond 8:f950fb1b78c0 170 }
ansond 8:f950fb1b78c0 171
ansond 8:f950fb1b78c0 172 // Get the Client Certificate
ansond 8:f950fb1b78c0 173 uint8_t *Options::getClientCertificate() {
ansond 8:f950fb1b78c0 174 return (uint8_t *) this->m_client_cert;
ansond 8:f950fb1b78c0 175 }
ansond 8:f950fb1b78c0 176
ansond 8:f950fb1b78c0 177 // Get the Client Certificate length
ansond 8:f950fb1b78c0 178 int Options::getClientCertificateSize() {
ansond 8:f950fb1b78c0 179 return this->m_client_cert_length;
ansond 8:f950fb1b78c0 180 }
ansond 8:f950fb1b78c0 181
ansond 8:f950fb1b78c0 182 // Get the Client Key
ansond 8:f950fb1b78c0 183 uint8_t *Options::getClientKey() {
ansond 8:f950fb1b78c0 184 return (uint8_t *) this->m_client_key;
ansond 8:f950fb1b78c0 185 }
ansond 8:f950fb1b78c0 186
ansond 8:f950fb1b78c0 187 // Get the Client Key length
ansond 8:f950fb1b78c0 188 int Options::getClientKeySize() {
ansond 8:f950fb1b78c0 189 return this->m_client_key_length;
ansond 8:f950fb1b78c0 190 }
ansond 8:f950fb1b78c0 191
ansond 19:56f958475694 192 // Get our Endpoint
ansond 19:56f958475694 193 void *Options::getEndpoint() {
ansond 19:56f958475694 194 return this->m_endpoint;
ansond 19:56f958475694 195 }
ansond 19:56f958475694 196
ansond 8:f950fb1b78c0 197 } // namespace Connector