mbed Connector Interface simplification API on top of mbed-client

Fork of mbedConnectorInterfaceV3 by Doug Anson

NOTE:

This repo has been replaced with https://github.com/ARMmbed/mbedConnectorInterface. No further updates will occur with this repo. Please use the github repo instead. Thanks!

Committer:
ansond
Date:
Tue Aug 09 17:18:49 2016 +0000
Revision:
54:dfee8691c83a
Parent:
49:c603a22495bb
updated

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 // Connector URL
ansond 8:f950fb1b78c0 71 char *Options::getConnectorURL()
ansond 8:f950fb1b78c0 72 {
ansond 8:f950fb1b78c0 73 return (char *)this->m_connector_url.c_str();
ansond 8:f950fb1b78c0 74 }
ansond 0:1f1f55e73248 75
ansond 10:3f79b5e67c22 76 // Connector Port
ansond 10:3f79b5e67c22 77 uint16_t Options::getConnectorPort()
ansond 10:3f79b5e67c22 78 {
ansond 10:3f79b5e67c22 79 return extract_port_from_url(this->getConnectorURL(),DEF_COAP_PORT);
ansond 10:3f79b5e67c22 80 }
ansond 10:3f79b5e67c22 81
ansond 27:b8aaf7dc7023 82 // Device Resources Object
ansond 27:b8aaf7dc7023 83 void *Options::getDeviceResourcesObject()
ansond 8:f950fb1b78c0 84 {
ansond 27:b8aaf7dc7023 85 return this->m_device_resources_object;
ansond 27:b8aaf7dc7023 86 }
ansond 27:b8aaf7dc7023 87
ansond 27:b8aaf7dc7023 88 // Firmware Resources Object
ansond 27:b8aaf7dc7023 89 void *Options::getFirmwareResourcesObject()
ansond 27:b8aaf7dc7023 90 {
ansond 27:b8aaf7dc7023 91 return this->m_firmware_resources_object;
ansond 8:f950fb1b78c0 92 }
ansond 8:f950fb1b78c0 93
ansond 8:f950fb1b78c0 94 // Static Resources
ansond 8:f950fb1b78c0 95 StaticResourcesList *Options::getStaticResourceList()
ansond 8:f950fb1b78c0 96 {
ansond 8:f950fb1b78c0 97 return &this->m_static_resources;
ansond 8:f950fb1b78c0 98 }
ansond 8:f950fb1b78c0 99
ansond 8:f950fb1b78c0 100 // Dynamic Resources
ansond 8:f950fb1b78c0 101 DynamicResourcesList *Options::getDynamicResourceList()
ansond 8:f950fb1b78c0 102 {
ansond 8:f950fb1b78c0 103 return &this->m_dynamic_resources;
ansond 8:f950fb1b78c0 104 }
ansond 8:f950fb1b78c0 105
ansond 8:f950fb1b78c0 106 // WiFi SSID
ansond 8:f950fb1b78c0 107 string Options::getWiFiSSID() {
ansond 8:f950fb1b78c0 108 return this->m_wifi_ssid;
ansond 8:f950fb1b78c0 109 }
ansond 8:f950fb1b78c0 110
ansond 8:f950fb1b78c0 111 // WiFi AuthType
ansond 8:f950fb1b78c0 112 WiFiAuthTypes Options::getWiFiAuthType() {
ansond 8:f950fb1b78c0 113 return this->m_wifi_auth_type;
ansond 8:f950fb1b78c0 114 }
ansond 8:f950fb1b78c0 115
ansond 8:f950fb1b78c0 116 // WiFi AuthKey
ansond 8:f950fb1b78c0 117 string Options::getWiFiAuthKey() {
ansond 8:f950fb1b78c0 118 return this->m_wifi_auth_key;
ansond 8:f950fb1b78c0 119 }
ansond 8:f950fb1b78c0 120
ansond 10:3f79b5e67c22 121 // CoAP Connection Type
ansond 10:3f79b5e67c22 122 CoAPConnectionTypes Options::getCoAPConnectionType() {
ansond 10:3f79b5e67c22 123 return this->m_coap_connection_type;
ansond 10:3f79b5e67c22 124 }
ansond 10:3f79b5e67c22 125
ansond 10:3f79b5e67c22 126 // IP Address Type
ansond 10:3f79b5e67c22 127 IPAddressTypes Options::getIPAddressType() {
ansond 10:3f79b5e67c22 128 return this->m_ip_address_type;
ansond 10:3f79b5e67c22 129 }
ansond 10:3f79b5e67c22 130
ansond 8:f950fb1b78c0 131 // Immediate Observationing Enabled
ansond 8:f950fb1b78c0 132 bool Options::immedateObservationEnabled() {
ansond 8:f950fb1b78c0 133 return this->m_enable_immediate_observation;
ansond 8:f950fb1b78c0 134 }
ansond 8:f950fb1b78c0 135
ansond 8:f950fb1b78c0 136 // Enable/Disable Observation control via GET
ansond 8:f950fb1b78c0 137 bool Options::enableGETObservationControl() {
ansond 8:f950fb1b78c0 138 return this->m_enable_get_obs_control;
ansond 8:f950fb1b78c0 139 }
ansond 8:f950fb1b78c0 140
ansond 8:f950fb1b78c0 141 // Get the Server Certificate
ansond 8:f950fb1b78c0 142 uint8_t *Options::getServerCertificate() {
ansond 49:c603a22495bb 143 return this->m_server_cert;
ansond 8:f950fb1b78c0 144 }
ansond 8:f950fb1b78c0 145
ansond 8:f950fb1b78c0 146 // Get the Server Certificate length
ansond 8:f950fb1b78c0 147 int Options::getServerCertificateSize() {
ansond 8:f950fb1b78c0 148 return this->m_server_cert_length;
ansond 8:f950fb1b78c0 149 }
ansond 8:f950fb1b78c0 150
ansond 8:f950fb1b78c0 151 // Get the Client Certificate
ansond 8:f950fb1b78c0 152 uint8_t *Options::getClientCertificate() {
ansond 49:c603a22495bb 153 return this->m_client_cert;
ansond 8:f950fb1b78c0 154 }
ansond 8:f950fb1b78c0 155
ansond 8:f950fb1b78c0 156 // Get the Client Certificate length
ansond 8:f950fb1b78c0 157 int Options::getClientCertificateSize() {
ansond 8:f950fb1b78c0 158 return this->m_client_cert_length;
ansond 8:f950fb1b78c0 159 }
ansond 8:f950fb1b78c0 160
ansond 8:f950fb1b78c0 161 // Get the Client Key
ansond 8:f950fb1b78c0 162 uint8_t *Options::getClientKey() {
ansond 49:c603a22495bb 163 return this->m_client_key;
ansond 8:f950fb1b78c0 164 }
ansond 8:f950fb1b78c0 165
ansond 8:f950fb1b78c0 166 // Get the Client Key length
ansond 8:f950fb1b78c0 167 int Options::getClientKeySize() {
ansond 8:f950fb1b78c0 168 return this->m_client_key_length;
ansond 8:f950fb1b78c0 169 }
ansond 8:f950fb1b78c0 170
ansond 19:56f958475694 171 // Get our Endpoint
ansond 19:56f958475694 172 void *Options::getEndpoint() {
ansond 19:56f958475694 173 return this->m_endpoint;
ansond 19:56f958475694 174 }
ansond 19:56f958475694 175
ansond 8:f950fb1b78c0 176 } // namespace Connector