mbed Connector Interface simplification API on top of mbed-client
Fork of mbedConnectorInterfaceV3 by
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!
source/Options.cpp@27:b8aaf7dc7023, 2016-06-14 (annotated)
- Committer:
- ansond
- Date:
- Tue Jun 14 04:01:34 2016 +0000
- Revision:
- 27:b8aaf7dc7023
- Parent:
- 19:56f958475694
- Child:
- 33:1d0b855df5a5
Initial merge and update of device and firmware objects
Who changed what in which revision?
User | Revision | Line number | New 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 | 10:3f79b5e67c22 | 24 | #include "mbed-connector-interface/Utils.h" |
ansond | 8:f950fb1b78c0 | 25 | |
ansond | 8:f950fb1b78c0 | 26 | namespace Connector { |
ansond | 8:f950fb1b78c0 | 27 | |
ansond | 8:f950fb1b78c0 | 28 | // default constructor |
ansond | 8:f950fb1b78c0 | 29 | Options::Options() |
ansond | 8:f950fb1b78c0 | 30 | { |
ansond | 8:f950fb1b78c0 | 31 | } |
ansond | 8:f950fb1b78c0 | 32 | |
ansond | 8:f950fb1b78c0 | 33 | // copy constructor |
ansond | 8:f950fb1b78c0 | 34 | Options::Options(const Options &opt) |
ansond | 8:f950fb1b78c0 | 35 | { |
ansond | 8:f950fb1b78c0 | 36 | } |
ansond | 8:f950fb1b78c0 | 37 | |
ansond | 8:f950fb1b78c0 | 38 | // destructors |
ansond | 8:f950fb1b78c0 | 39 | Options::~Options() |
ansond | 8:f950fb1b78c0 | 40 | { |
ansond | 8:f950fb1b78c0 | 41 | } |
ansond | 8:f950fb1b78c0 | 42 | |
ansond | 8:f950fb1b78c0 | 43 | // lifetime pointer |
ansond | 8:f950fb1b78c0 | 44 | int Options::getLifetime() |
ansond | 8:f950fb1b78c0 | 45 | { |
ansond | 8:f950fb1b78c0 | 46 | return this->m_lifetime; |
ansond | 8:f950fb1b78c0 | 47 | } |
ansond | 8:f950fb1b78c0 | 48 | |
ansond | 8:f950fb1b78c0 | 49 | // NSP domain |
ansond | 8:f950fb1b78c0 | 50 | string Options::getDomain() |
ansond | 8:f950fb1b78c0 | 51 | { |
ansond | 8:f950fb1b78c0 | 52 | return this->m_domain; |
ansond | 8:f950fb1b78c0 | 53 | } |
ansond | 8:f950fb1b78c0 | 54 | |
ansond | 8:f950fb1b78c0 | 55 | // Endpoint name |
ansond | 8:f950fb1b78c0 | 56 | string Options::getEndpointNodename() |
ansond | 8:f950fb1b78c0 | 57 | { |
ansond | 8:f950fb1b78c0 | 58 | return this->m_node_name; |
ansond | 8:f950fb1b78c0 | 59 | } |
ansond | 8:f950fb1b78c0 | 60 | |
ansond | 8:f950fb1b78c0 | 61 | // Endpoint Type |
ansond | 8:f950fb1b78c0 | 62 | string Options::getEndpointType() |
ansond | 8:f950fb1b78c0 | 63 | { |
ansond | 8:f950fb1b78c0 | 64 | return this->m_endpoint_type; |
ansond | 8:f950fb1b78c0 | 65 | } |
ansond | 8:f950fb1b78c0 | 66 | |
ansond | 8:f950fb1b78c0 | 67 | // mbed Registation update period |
ansond | 8:f950fb1b78c0 | 68 | int Options::getRegUpdatePeriod() |
ansond | 8:f950fb1b78c0 | 69 | { |
ansond | 8:f950fb1b78c0 | 70 | return this->m_reg_update_period; |
ansond | 8:f950fb1b78c0 | 71 | } |
ansond | 8:f950fb1b78c0 | 72 | |
ansond | 8:f950fb1b78c0 | 73 | // Connector URL |
ansond | 8:f950fb1b78c0 | 74 | char *Options::getConnectorURL() |
ansond | 8:f950fb1b78c0 | 75 | { |
ansond | 8:f950fb1b78c0 | 76 | return (char *)this->m_connector_url.c_str(); |
ansond | 8:f950fb1b78c0 | 77 | } |
ansond | 0:1f1f55e73248 | 78 | |
ansond | 10:3f79b5e67c22 | 79 | // Connector Port |
ansond | 10:3f79b5e67c22 | 80 | uint16_t Options::getConnectorPort() |
ansond | 10:3f79b5e67c22 | 81 | { |
ansond | 10:3f79b5e67c22 | 82 | return extract_port_from_url(this->getConnectorURL(),DEF_COAP_PORT); |
ansond | 10:3f79b5e67c22 | 83 | } |
ansond | 10:3f79b5e67c22 | 84 | |
ansond | 27:b8aaf7dc7023 | 85 | // Device Resources Object |
ansond | 27:b8aaf7dc7023 | 86 | void *Options::getDeviceResourcesObject() |
ansond | 8:f950fb1b78c0 | 87 | { |
ansond | 27:b8aaf7dc7023 | 88 | return this->m_device_resources_object; |
ansond | 27:b8aaf7dc7023 | 89 | } |
ansond | 27:b8aaf7dc7023 | 90 | |
ansond | 27:b8aaf7dc7023 | 91 | // Firmware Resources Object |
ansond | 27:b8aaf7dc7023 | 92 | void *Options::getFirmwareResourcesObject() |
ansond | 27:b8aaf7dc7023 | 93 | { |
ansond | 27:b8aaf7dc7023 | 94 | return this->m_firmware_resources_object; |
ansond | 8:f950fb1b78c0 | 95 | } |
ansond | 8:f950fb1b78c0 | 96 | |
ansond | 8:f950fb1b78c0 | 97 | // Static Resources |
ansond | 8:f950fb1b78c0 | 98 | StaticResourcesList *Options::getStaticResourceList() |
ansond | 8:f950fb1b78c0 | 99 | { |
ansond | 8:f950fb1b78c0 | 100 | return &this->m_static_resources; |
ansond | 8:f950fb1b78c0 | 101 | } |
ansond | 8:f950fb1b78c0 | 102 | |
ansond | 8:f950fb1b78c0 | 103 | // Dynamic Resources |
ansond | 8:f950fb1b78c0 | 104 | DynamicResourcesList *Options::getDynamicResourceList() |
ansond | 8:f950fb1b78c0 | 105 | { |
ansond | 8:f950fb1b78c0 | 106 | return &this->m_dynamic_resources; |
ansond | 8:f950fb1b78c0 | 107 | } |
ansond | 8:f950fb1b78c0 | 108 | |
ansond | 8:f950fb1b78c0 | 109 | // WiFi SSID |
ansond | 8:f950fb1b78c0 | 110 | string Options::getWiFiSSID() { |
ansond | 8:f950fb1b78c0 | 111 | return this->m_wifi_ssid; |
ansond | 8:f950fb1b78c0 | 112 | } |
ansond | 8:f950fb1b78c0 | 113 | |
ansond | 8:f950fb1b78c0 | 114 | // WiFi AuthType |
ansond | 8:f950fb1b78c0 | 115 | WiFiAuthTypes Options::getWiFiAuthType() { |
ansond | 8:f950fb1b78c0 | 116 | return this->m_wifi_auth_type; |
ansond | 8:f950fb1b78c0 | 117 | } |
ansond | 8:f950fb1b78c0 | 118 | |
ansond | 8:f950fb1b78c0 | 119 | // WiFi AuthKey |
ansond | 8:f950fb1b78c0 | 120 | string Options::getWiFiAuthKey() { |
ansond | 8:f950fb1b78c0 | 121 | return this->m_wifi_auth_key; |
ansond | 8:f950fb1b78c0 | 122 | } |
ansond | 8:f950fb1b78c0 | 123 | |
ansond | 8:f950fb1b78c0 | 124 | // 802.15.4 Pre Shared Key |
ansond | 8:f950fb1b78c0 | 125 | unsigned char *Options::getPreSharedKey() { |
ansond | 8:f950fb1b78c0 | 126 | return this->m_psk; |
ansond | 8:f950fb1b78c0 | 127 | } |
ansond | 8:f950fb1b78c0 | 128 | |
ansond | 8:f950fb1b78c0 | 129 | // 802.15.4 Pre Shared Key Identity |
ansond | 8:f950fb1b78c0 | 130 | unsigned char *Options::getPreSharedKeyIdentity() { |
ansond | 8:f950fb1b78c0 | 131 | return this->m_psk_identity; |
ansond | 8:f950fb1b78c0 | 132 | } |
ansond | 8:f950fb1b78c0 | 133 | |
ansond | 9:faa43faea4ca | 134 | // 802.15.4 Mesh Type |
ansond | 9:faa43faea4ca | 135 | MeshTypes Options::getMeshType() { |
ansond | 9:faa43faea4ca | 136 | return this->m_mesh_type; |
ansond | 9:faa43faea4ca | 137 | } |
ansond | 9:faa43faea4ca | 138 | |
ansond | 10:3f79b5e67c22 | 139 | // CoAP Connection Type |
ansond | 10:3f79b5e67c22 | 140 | CoAPConnectionTypes Options::getCoAPConnectionType() { |
ansond | 10:3f79b5e67c22 | 141 | return this->m_coap_connection_type; |
ansond | 10:3f79b5e67c22 | 142 | } |
ansond | 10:3f79b5e67c22 | 143 | |
ansond | 10:3f79b5e67c22 | 144 | // IP Address Type |
ansond | 10:3f79b5e67c22 | 145 | IPAddressTypes Options::getIPAddressType() { |
ansond | 10:3f79b5e67c22 | 146 | return this->m_ip_address_type; |
ansond | 10:3f79b5e67c22 | 147 | } |
ansond | 10:3f79b5e67c22 | 148 | |
ansond | 8:f950fb1b78c0 | 149 | // Immediate Observationing Enabled |
ansond | 8:f950fb1b78c0 | 150 | bool Options::immedateObservationEnabled() { |
ansond | 8:f950fb1b78c0 | 151 | return this->m_enable_immediate_observation; |
ansond | 8:f950fb1b78c0 | 152 | } |
ansond | 8:f950fb1b78c0 | 153 | |
ansond | 8:f950fb1b78c0 | 154 | // Enable/Disable Observation control via GET |
ansond | 8:f950fb1b78c0 | 155 | bool Options::enableGETObservationControl() { |
ansond | 8:f950fb1b78c0 | 156 | return this->m_enable_get_obs_control; |
ansond | 8:f950fb1b78c0 | 157 | } |
ansond | 8:f950fb1b78c0 | 158 | |
ansond | 8:f950fb1b78c0 | 159 | // Get the Server Certificate |
ansond | 8:f950fb1b78c0 | 160 | uint8_t *Options::getServerCertificate() { |
ansond | 8:f950fb1b78c0 | 161 | return (uint8_t *) this->m_server_cert; |
ansond | 8:f950fb1b78c0 | 162 | } |
ansond | 8:f950fb1b78c0 | 163 | |
ansond | 8:f950fb1b78c0 | 164 | // Get the Server Certificate length |
ansond | 8:f950fb1b78c0 | 165 | int Options::getServerCertificateSize() { |
ansond | 8:f950fb1b78c0 | 166 | return this->m_server_cert_length; |
ansond | 8:f950fb1b78c0 | 167 | } |
ansond | 8:f950fb1b78c0 | 168 | |
ansond | 8:f950fb1b78c0 | 169 | // Get the Client Certificate |
ansond | 8:f950fb1b78c0 | 170 | uint8_t *Options::getClientCertificate() { |
ansond | 8:f950fb1b78c0 | 171 | return (uint8_t *) this->m_client_cert; |
ansond | 8:f950fb1b78c0 | 172 | } |
ansond | 8:f950fb1b78c0 | 173 | |
ansond | 8:f950fb1b78c0 | 174 | // Get the Client Certificate length |
ansond | 8:f950fb1b78c0 | 175 | int Options::getClientCertificateSize() { |
ansond | 8:f950fb1b78c0 | 176 | return this->m_client_cert_length; |
ansond | 8:f950fb1b78c0 | 177 | } |
ansond | 8:f950fb1b78c0 | 178 | |
ansond | 8:f950fb1b78c0 | 179 | // Get the Client Key |
ansond | 8:f950fb1b78c0 | 180 | uint8_t *Options::getClientKey() { |
ansond | 8:f950fb1b78c0 | 181 | return (uint8_t *) this->m_client_key; |
ansond | 8:f950fb1b78c0 | 182 | } |
ansond | 8:f950fb1b78c0 | 183 | |
ansond | 8:f950fb1b78c0 | 184 | // Get the Client Key length |
ansond | 8:f950fb1b78c0 | 185 | int Options::getClientKeySize() { |
ansond | 8:f950fb1b78c0 | 186 | return this->m_client_key_length; |
ansond | 8:f950fb1b78c0 | 187 | } |
ansond | 8:f950fb1b78c0 | 188 | |
ansond | 19:56f958475694 | 189 | // Get our Endpoint |
ansond | 19:56f958475694 | 190 | void *Options::getEndpoint() { |
ansond | 19:56f958475694 | 191 | return this->m_endpoint; |
ansond | 19:56f958475694 | 192 | } |
ansond | 19:56f958475694 | 193 | |
ansond | 8:f950fb1b78c0 | 194 | } // namespace Connector |