use TCP to connect to mbed connector

Fork of mbedConnectorInterfaceWithDM by Doug Anson

Committer:
ansond
Date:
Wed Feb 24 05:52:00 2016 +0000
Revision:
8:f950fb1b78c0
Parent:
0:1f1f55e73248
Child:
9:faa43faea4ca
massive update and re-org

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 8:f950fb1b78c0 23 #include "mbed-connector-interface/Options.h"
ansond 8:f950fb1b78c0 24
ansond 8:f950fb1b78c0 25 namespace Connector {
ansond 8:f950fb1b78c0 26
ansond 8:f950fb1b78c0 27 // default constructor
ansond 8:f950fb1b78c0 28 Options::Options()
ansond 8:f950fb1b78c0 29 {
ansond 8:f950fb1b78c0 30 }
ansond 8:f950fb1b78c0 31
ansond 8:f950fb1b78c0 32 // copy constructor
ansond 8:f950fb1b78c0 33 Options::Options(const Options &opt)
ansond 8:f950fb1b78c0 34 {
ansond 8:f950fb1b78c0 35 }
ansond 8:f950fb1b78c0 36
ansond 8:f950fb1b78c0 37 // destructors
ansond 8:f950fb1b78c0 38 Options::~Options()
ansond 8:f950fb1b78c0 39 {
ansond 8:f950fb1b78c0 40 }
ansond 8:f950fb1b78c0 41
ansond 8:f950fb1b78c0 42 // lifetime pointer
ansond 8:f950fb1b78c0 43 int Options::getLifetime()
ansond 8:f950fb1b78c0 44 {
ansond 8:f950fb1b78c0 45 return this->m_lifetime;
ansond 8:f950fb1b78c0 46 }
ansond 8:f950fb1b78c0 47
ansond 8:f950fb1b78c0 48 // NSP domain
ansond 8:f950fb1b78c0 49 string Options::getDomain()
ansond 8:f950fb1b78c0 50 {
ansond 8:f950fb1b78c0 51 return this->m_domain;
ansond 8:f950fb1b78c0 52 }
ansond 8:f950fb1b78c0 53
ansond 8:f950fb1b78c0 54 // Endpoint name
ansond 8:f950fb1b78c0 55 string Options::getEndpointNodename()
ansond 8:f950fb1b78c0 56 {
ansond 8:f950fb1b78c0 57 return this->m_node_name;
ansond 8:f950fb1b78c0 58 }
ansond 8:f950fb1b78c0 59
ansond 8:f950fb1b78c0 60 // Endpoint Type
ansond 8:f950fb1b78c0 61 string Options::getEndpointType()
ansond 8:f950fb1b78c0 62 {
ansond 8:f950fb1b78c0 63 return this->m_endpoint_type;
ansond 8:f950fb1b78c0 64 }
ansond 8:f950fb1b78c0 65
ansond 8:f950fb1b78c0 66 // mbed Registation update period
ansond 8:f950fb1b78c0 67 int Options::getRegUpdatePeriod()
ansond 8:f950fb1b78c0 68 {
ansond 8:f950fb1b78c0 69 return this->m_reg_update_period;
ansond 8:f950fb1b78c0 70 }
ansond 8:f950fb1b78c0 71
ansond 8:f950fb1b78c0 72 // Connector URL
ansond 8:f950fb1b78c0 73 char *Options::getConnectorURL()
ansond 8:f950fb1b78c0 74 {
ansond 8:f950fb1b78c0 75 return (char *)this->m_connector_url.c_str();
ansond 8:f950fb1b78c0 76 }
ansond 0:1f1f55e73248 77
ansond 8:f950fb1b78c0 78 // Device Resources
ansond 8:f950fb1b78c0 79 DeviceResourcesList *Options::getDeviceResourceList()
ansond 8:f950fb1b78c0 80 {
ansond 8:f950fb1b78c0 81 return &this->m_device_resources;
ansond 8:f950fb1b78c0 82 }
ansond 8:f950fb1b78c0 83
ansond 8:f950fb1b78c0 84 // Static Resources
ansond 8:f950fb1b78c0 85 StaticResourcesList *Options::getStaticResourceList()
ansond 8:f950fb1b78c0 86 {
ansond 8:f950fb1b78c0 87 return &this->m_static_resources;
ansond 8:f950fb1b78c0 88 }
ansond 8:f950fb1b78c0 89
ansond 8:f950fb1b78c0 90 // Dynamic Resources
ansond 8:f950fb1b78c0 91 DynamicResourcesList *Options::getDynamicResourceList()
ansond 8:f950fb1b78c0 92 {
ansond 8:f950fb1b78c0 93 return &this->m_dynamic_resources;
ansond 8:f950fb1b78c0 94 }
ansond 8:f950fb1b78c0 95
ansond 8:f950fb1b78c0 96 // WiFi SSID
ansond 8:f950fb1b78c0 97 string Options::getWiFiSSID() {
ansond 8:f950fb1b78c0 98 return this->m_wifi_ssid;
ansond 8:f950fb1b78c0 99 }
ansond 8:f950fb1b78c0 100
ansond 8:f950fb1b78c0 101 // WiFi AuthType
ansond 8:f950fb1b78c0 102 WiFiAuthTypes Options::getWiFiAuthType() {
ansond 8:f950fb1b78c0 103 return this->m_wifi_auth_type;
ansond 8:f950fb1b78c0 104 }
ansond 8:f950fb1b78c0 105
ansond 8:f950fb1b78c0 106 // WiFi AuthKey
ansond 8:f950fb1b78c0 107 string Options::getWiFiAuthKey() {
ansond 8:f950fb1b78c0 108 return this->m_wifi_auth_key;
ansond 8:f950fb1b78c0 109 }
ansond 8:f950fb1b78c0 110
ansond 8:f950fb1b78c0 111 // 802.15.4 Pre Shared Key
ansond 8:f950fb1b78c0 112 unsigned char *Options::getPreSharedKey() {
ansond 8:f950fb1b78c0 113 return this->m_psk;
ansond 8:f950fb1b78c0 114 }
ansond 8:f950fb1b78c0 115
ansond 8:f950fb1b78c0 116 // 802.15.4 Pre Shared Key Identity
ansond 8:f950fb1b78c0 117 unsigned char *Options::getPreSharedKeyIdentity() {
ansond 8:f950fb1b78c0 118 return this->m_psk_identity;
ansond 8:f950fb1b78c0 119 }
ansond 8:f950fb1b78c0 120
ansond 8:f950fb1b78c0 121 // Immediate Observationing Enabled
ansond 8:f950fb1b78c0 122 bool Options::immedateObservationEnabled() {
ansond 8:f950fb1b78c0 123 return this->m_enable_immediate_observation;
ansond 8:f950fb1b78c0 124 }
ansond 8:f950fb1b78c0 125
ansond 8:f950fb1b78c0 126 // Enable/Disable Observation control via GET
ansond 8:f950fb1b78c0 127 bool Options::enableGETObservationControl() {
ansond 8:f950fb1b78c0 128 return this->m_enable_get_obs_control;
ansond 8:f950fb1b78c0 129 }
ansond 8:f950fb1b78c0 130
ansond 8:f950fb1b78c0 131 // Get the Server Certificate
ansond 8:f950fb1b78c0 132 uint8_t *Options::getServerCertificate() {
ansond 8:f950fb1b78c0 133 return (uint8_t *) this->m_server_cert;
ansond 8:f950fb1b78c0 134 }
ansond 8:f950fb1b78c0 135
ansond 8:f950fb1b78c0 136 // Get the Server Certificate length
ansond 8:f950fb1b78c0 137 int Options::getServerCertificateSize() {
ansond 8:f950fb1b78c0 138 return this->m_server_cert_length;
ansond 8:f950fb1b78c0 139 }
ansond 8:f950fb1b78c0 140
ansond 8:f950fb1b78c0 141 // Get the Client Certificate
ansond 8:f950fb1b78c0 142 uint8_t *Options::getClientCertificate() {
ansond 8:f950fb1b78c0 143 return (uint8_t *) this->m_client_cert;
ansond 8:f950fb1b78c0 144 }
ansond 8:f950fb1b78c0 145
ansond 8:f950fb1b78c0 146 // Get the Client Certificate length
ansond 8:f950fb1b78c0 147 int Options::getClientCertificateSize() {
ansond 8:f950fb1b78c0 148 return this->m_client_cert_length;
ansond 8:f950fb1b78c0 149 }
ansond 8:f950fb1b78c0 150
ansond 8:f950fb1b78c0 151 // Get the Client Key
ansond 8:f950fb1b78c0 152 uint8_t *Options::getClientKey() {
ansond 8:f950fb1b78c0 153 return (uint8_t *) this->m_client_key;
ansond 8:f950fb1b78c0 154 }
ansond 8:f950fb1b78c0 155
ansond 8:f950fb1b78c0 156 // Get the Client Key length
ansond 8:f950fb1b78c0 157 int Options::getClientKeySize() {
ansond 8:f950fb1b78c0 158 return this->m_client_key_length;
ansond 8:f950fb1b78c0 159 }
ansond 8:f950fb1b78c0 160
ansond 8:f950fb1b78c0 161 } // namespace Connector