Etherios Cloud Connector very first porting for mbed. Tested in an LPC1768
Etherios Cloud Connector for Embedded v2.1.0.3 library for mbed. Early porting.
This port is centered mainly in the platform code. So it should work properly with the provided examples of send_data, device_request, data_points, RCI and firmware_update (stub implementation, not a real one... yet ;-)). Filesystem is not implemented yet, and some examples might need changes.
To run, it needs the following libraries: - mbed - mbed-rtos - EthernetInterface
Find more information (and the source code!) about Etherios Cloud Connector for Embedded here: http://www.etherios.com/products/devicecloud/support/connector and in: http://www.etherios.com
private/connector_tcp_config.h@1:908afea5a49d, 2013-12-03 (annotated)
- Committer:
- spastor
- Date:
- Tue Dec 03 14:10:48 2013 +0000
- Revision:
- 1:908afea5a49d
- Parent:
- 0:1c358ea10753
Use internal Thread.h instead of Threads.h
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
spastor | 0:1c358ea10753 | 1 | /* |
spastor | 0:1c358ea10753 | 2 | * Copyright (c) 2013 Digi International Inc., |
spastor | 0:1c358ea10753 | 3 | * All rights not expressly granted are reserved. |
spastor | 0:1c358ea10753 | 4 | * |
spastor | 0:1c358ea10753 | 5 | * This Source Code Form is subject to the terms of the Mozilla Public |
spastor | 0:1c358ea10753 | 6 | * License, v. 2.0. If a copy of the MPL was not distributed with this file, |
spastor | 0:1c358ea10753 | 7 | * You can obtain one at http://mozilla.org/MPL/2.0/. |
spastor | 0:1c358ea10753 | 8 | * |
spastor | 0:1c358ea10753 | 9 | * Digi International Inc. 11001 Bren Road East, Minnetonka, MN 55343 |
spastor | 0:1c358ea10753 | 10 | * ======================================================================= |
spastor | 0:1c358ea10753 | 11 | */ |
spastor | 0:1c358ea10753 | 12 | |
spastor | 0:1c358ea10753 | 13 | |
spastor | 0:1c358ea10753 | 14 | #if !(defined CONNECTOR_VENDOR_ID) |
spastor | 0:1c358ea10753 | 15 | static connector_status_t get_config_vendor_id(connector_data_t * const connector_ptr) |
spastor | 0:1c358ea10753 | 16 | { |
spastor | 0:1c358ea10753 | 17 | connector_status_t result = connector_working; |
spastor | 0:1c358ea10753 | 18 | connector_config_vendor_id_t config_vendor; |
spastor | 0:1c358ea10753 | 19 | |
spastor | 0:1c358ea10753 | 20 | { |
spastor | 0:1c358ea10753 | 21 | connector_callback_status_t status; |
spastor | 0:1c358ea10753 | 22 | connector_request_id_t request_id; |
spastor | 0:1c358ea10753 | 23 | |
spastor | 0:1c358ea10753 | 24 | request_id.config_request = connector_request_id_config_vendor_id; |
spastor | 0:1c358ea10753 | 25 | status = connector_callback(connector_ptr->callback, connector_class_id_config, request_id, &config_vendor); |
spastor | 0:1c358ea10753 | 26 | |
spastor | 0:1c358ea10753 | 27 | switch (status) |
spastor | 0:1c358ea10753 | 28 | { |
spastor | 0:1c358ea10753 | 29 | case connector_callback_continue: |
spastor | 0:1c358ea10753 | 30 | { |
spastor | 0:1c358ea10753 | 31 | uint32_t const max_vendor_id = CONNECTOR_MAX_VENDOR_ID_NUMBER; |
spastor | 0:1c358ea10753 | 32 | /* coverity[uninit_use] */ |
spastor | 0:1c358ea10753 | 33 | if ((config_vendor.id == 0) || (config_vendor.id >= max_vendor_id)) |
spastor | 0:1c358ea10753 | 34 | { |
spastor | 0:1c358ea10753 | 35 | notify_error_status(connector_ptr->callback, connector_class_id_config, request_id, connector_invalid_data_range); |
spastor | 0:1c358ea10753 | 36 | result = connector_abort; |
spastor | 0:1c358ea10753 | 37 | } |
spastor | 0:1c358ea10753 | 38 | else |
spastor | 0:1c358ea10753 | 39 | connector_ptr->edp_data.config.vendor_id = config_vendor.id; |
spastor | 0:1c358ea10753 | 40 | |
spastor | 0:1c358ea10753 | 41 | } |
spastor | 0:1c358ea10753 | 42 | break; |
spastor | 0:1c358ea10753 | 43 | |
spastor | 0:1c358ea10753 | 44 | case connector_callback_busy: |
spastor | 0:1c358ea10753 | 45 | case connector_callback_abort: |
spastor | 0:1c358ea10753 | 46 | case connector_callback_error: |
spastor | 0:1c358ea10753 | 47 | case connector_callback_unrecognized: |
spastor | 0:1c358ea10753 | 48 | result = connector_abort; |
spastor | 0:1c358ea10753 | 49 | break; |
spastor | 0:1c358ea10753 | 50 | } |
spastor | 0:1c358ea10753 | 51 | } |
spastor | 0:1c358ea10753 | 52 | |
spastor | 0:1c358ea10753 | 53 | return result; |
spastor | 0:1c358ea10753 | 54 | } |
spastor | 0:1c358ea10753 | 55 | #endif |
spastor | 0:1c358ea10753 | 56 | |
spastor | 0:1c358ea10753 | 57 | #if !(defined CONNECTOR_DEVICE_TYPE) |
spastor | 0:1c358ea10753 | 58 | static connector_status_t get_config_device_type(connector_data_t * const connector_ptr) |
spastor | 0:1c358ea10753 | 59 | { |
spastor | 0:1c358ea10753 | 60 | connector_status_t result = connector_working; |
spastor | 0:1c358ea10753 | 61 | connector_config_pointer_string_t device_type; |
spastor | 0:1c358ea10753 | 62 | connector_request_id_t request_id; |
spastor | 0:1c358ea10753 | 63 | |
spastor | 0:1c358ea10753 | 64 | { |
spastor | 0:1c358ea10753 | 65 | connector_callback_status_t status; |
spastor | 0:1c358ea10753 | 66 | |
spastor | 0:1c358ea10753 | 67 | request_id.config_request = connector_request_id_config_device_type; |
spastor | 0:1c358ea10753 | 68 | status = connector_callback(connector_ptr->callback, connector_class_id_config, request_id, &device_type); |
spastor | 0:1c358ea10753 | 69 | |
spastor | 0:1c358ea10753 | 70 | switch (status) |
spastor | 0:1c358ea10753 | 71 | { |
spastor | 0:1c358ea10753 | 72 | case connector_callback_continue: |
spastor | 0:1c358ea10753 | 73 | /* coverity[uninit_use] */ |
spastor | 0:1c358ea10753 | 74 | if (device_type.string == NULL) |
spastor | 0:1c358ea10753 | 75 | result = connector_invalid_data; |
spastor | 0:1c358ea10753 | 76 | /* coverity[uninit_use] */ |
spastor | 0:1c358ea10753 | 77 | else if ((device_type.length == 0) || (device_type.length > DEVICE_TYPE_LENGTH)) |
spastor | 0:1c358ea10753 | 78 | result = connector_invalid_data_size; |
spastor | 0:1c358ea10753 | 79 | else |
spastor | 0:1c358ea10753 | 80 | { |
spastor | 0:1c358ea10753 | 81 | connector_ptr->edp_data.config.device_type_length = device_type.length; |
spastor | 0:1c358ea10753 | 82 | connector_ptr->edp_data.config.device_type = device_type.string; |
spastor | 0:1c358ea10753 | 83 | } |
spastor | 0:1c358ea10753 | 84 | break; |
spastor | 0:1c358ea10753 | 85 | |
spastor | 0:1c358ea10753 | 86 | case connector_callback_busy: |
spastor | 0:1c358ea10753 | 87 | case connector_callback_abort: |
spastor | 0:1c358ea10753 | 88 | case connector_callback_error: |
spastor | 0:1c358ea10753 | 89 | case connector_callback_unrecognized: |
spastor | 0:1c358ea10753 | 90 | result = connector_abort; |
spastor | 0:1c358ea10753 | 91 | goto done; |
spastor | 0:1c358ea10753 | 92 | } |
spastor | 0:1c358ea10753 | 93 | } |
spastor | 0:1c358ea10753 | 94 | |
spastor | 0:1c358ea10753 | 95 | if (result != connector_working) |
spastor | 0:1c358ea10753 | 96 | { |
spastor | 0:1c358ea10753 | 97 | notify_error_status(connector_ptr->callback, connector_class_id_config, request_id, result); |
spastor | 0:1c358ea10753 | 98 | result = connector_abort; |
spastor | 0:1c358ea10753 | 99 | } |
spastor | 0:1c358ea10753 | 100 | |
spastor | 0:1c358ea10753 | 101 | done: |
spastor | 0:1c358ea10753 | 102 | return result; |
spastor | 0:1c358ea10753 | 103 | } |
spastor | 0:1c358ea10753 | 104 | #endif |
spastor | 0:1c358ea10753 | 105 | |
spastor | 0:1c358ea10753 | 106 | #if !(defined CONNECTOR_RX_KEEPALIVE_IN_SECONDS) || !(defined CONNECTOR_TX_KEEPALIVE_IN_SECONDS) |
spastor | 0:1c358ea10753 | 107 | static connector_status_t get_config_keepalive(connector_data_t * const connector_ptr, connector_request_id_config_t const config_request) |
spastor | 0:1c358ea10753 | 108 | { |
spastor | 0:1c358ea10753 | 109 | connector_status_t result = connector_working; |
spastor | 0:1c358ea10753 | 110 | connector_config_keepalive_t keepalive; |
spastor | 0:1c358ea10753 | 111 | |
spastor | 0:1c358ea10753 | 112 | ASSERT((config_request == connector_request_id_config_rx_keepalive) || (config_request == connector_request_id_config_tx_keepalive)); |
spastor | 0:1c358ea10753 | 113 | { |
spastor | 0:1c358ea10753 | 114 | connector_callback_status_t status; |
spastor | 0:1c358ea10753 | 115 | connector_request_id_t request_id; |
spastor | 0:1c358ea10753 | 116 | |
spastor | 0:1c358ea10753 | 117 | request_id.config_request = config_request; |
spastor | 0:1c358ea10753 | 118 | status = connector_callback(connector_ptr->callback, connector_class_id_config, request_id, &keepalive); |
spastor | 0:1c358ea10753 | 119 | |
spastor | 0:1c358ea10753 | 120 | switch (status) |
spastor | 0:1c358ea10753 | 121 | { |
spastor | 0:1c358ea10753 | 122 | case connector_callback_continue: |
spastor | 0:1c358ea10753 | 123 | { |
spastor | 0:1c358ea10753 | 124 | |
spastor | 0:1c358ea10753 | 125 | #if !defined(CONNECTOR_TX_KEEPALIVE_IN_SECONDS) && !defined(CONNECTOR_RX_KEEPALIVE_IN_SECONDS) |
spastor | 0:1c358ea10753 | 126 | connector_bool_t const is_tx = connector_bool(config_request == connector_request_id_config_tx_keepalive); |
spastor | 0:1c358ea10753 | 127 | uint16_t const min_interval = is_tx ? MIN_TX_KEEPALIVE_INTERVAL_IN_SECONDS : MIN_RX_KEEPALIVE_INTERVAL_IN_SECONDS; |
spastor | 0:1c358ea10753 | 128 | uint16_t const max_interval = is_tx ? MAX_TX_KEEPALIVE_INTERVAL_IN_SECONDS : MAX_RX_KEEPALIVE_INTERVAL_IN_SECONDS; |
spastor | 0:1c358ea10753 | 129 | |
spastor | 0:1c358ea10753 | 130 | #elif !(defined CONNECTOR_TX_KEEPALIVE_IN_SECONDS) |
spastor | 0:1c358ea10753 | 131 | uint16_t const min_interval = MIN_TX_KEEPALIVE_INTERVAL_IN_SECONDS; |
spastor | 0:1c358ea10753 | 132 | uint16_t const max_interval = MAX_TX_KEEPALIVE_INTERVAL_IN_SECONDS; |
spastor | 0:1c358ea10753 | 133 | |
spastor | 0:1c358ea10753 | 134 | #elif !(defined CONNECTOR_RX_KEEPALIVE_IN_SECONDS) |
spastor | 0:1c358ea10753 | 135 | uint16_t const min_interval = MIN_RX_KEEPALIVE_INTERVAL_IN_SECONDS; |
spastor | 0:1c358ea10753 | 136 | uint16_t const max_interval = MAX_RX_KEEPALIVE_INTERVAL_IN_SECONDS; |
spastor | 0:1c358ea10753 | 137 | #endif |
spastor | 0:1c358ea10753 | 138 | /* coverity[uninit_use] */ |
spastor | 0:1c358ea10753 | 139 | if ((keepalive.interval_in_seconds < min_interval) || (keepalive.interval_in_seconds > max_interval)) |
spastor | 0:1c358ea10753 | 140 | { |
spastor | 0:1c358ea10753 | 141 | notify_error_status(connector_ptr->callback, connector_class_id_config, request_id, connector_invalid_data_range); |
spastor | 0:1c358ea10753 | 142 | result = connector_abort; |
spastor | 0:1c358ea10753 | 143 | goto done; |
spastor | 0:1c358ea10753 | 144 | } |
spastor | 0:1c358ea10753 | 145 | |
spastor | 0:1c358ea10753 | 146 | { |
spastor | 0:1c358ea10753 | 147 | #if !defined(CONNECTOR_TX_KEEPALIVE_IN_SECONDS) && !defined(CONNECTOR_RX_KEEPALIVE_IN_SECONDS) |
spastor | 0:1c358ea10753 | 148 | uint16_t * const keepalive_store_at = is_tx ? &connector_ptr->edp_data.config.tx_keepalive_interval : &connector_ptr->edp_data.config.rx_keepalive_interval; |
spastor | 0:1c358ea10753 | 149 | #elif !defined(CONNECTOR_TX_KEEPALIVE_IN_SECONDS) |
spastor | 0:1c358ea10753 | 150 | uint16_t * const keepalive_store_at = &connector_ptr->edp_data.config.tx_keepalive_interval; |
spastor | 0:1c358ea10753 | 151 | #elif !defined(CONNECTOR_RX_KEEPALIVE_IN_SECONDS) |
spastor | 0:1c358ea10753 | 152 | uint16_t * const keepalive_store_at = &connector_ptr->edp_data.config.rx_keepalive_interval; |
spastor | 0:1c358ea10753 | 153 | #endif |
spastor | 0:1c358ea10753 | 154 | *keepalive_store_at = keepalive.interval_in_seconds; |
spastor | 0:1c358ea10753 | 155 | } |
spastor | 0:1c358ea10753 | 156 | break; |
spastor | 0:1c358ea10753 | 157 | } |
spastor | 0:1c358ea10753 | 158 | case connector_callback_busy: |
spastor | 0:1c358ea10753 | 159 | case connector_callback_abort: |
spastor | 0:1c358ea10753 | 160 | case connector_callback_error: |
spastor | 0:1c358ea10753 | 161 | case connector_callback_unrecognized: |
spastor | 0:1c358ea10753 | 162 | result = connector_abort; |
spastor | 0:1c358ea10753 | 163 | goto done; |
spastor | 0:1c358ea10753 | 164 | } |
spastor | 0:1c358ea10753 | 165 | } |
spastor | 0:1c358ea10753 | 166 | |
spastor | 0:1c358ea10753 | 167 | done: |
spastor | 0:1c358ea10753 | 168 | return result; |
spastor | 0:1c358ea10753 | 169 | } |
spastor | 0:1c358ea10753 | 170 | #endif |
spastor | 0:1c358ea10753 | 171 | |
spastor | 0:1c358ea10753 | 172 | #if !(defined CONNECTOR_WAIT_COUNT) |
spastor | 0:1c358ea10753 | 173 | static connector_status_t get_config_wait_count(connector_data_t * const connector_ptr) |
spastor | 0:1c358ea10753 | 174 | { |
spastor | 0:1c358ea10753 | 175 | connector_status_t result = connector_working; |
spastor | 0:1c358ea10753 | 176 | connector_config_wait_count_t wait_count; |
spastor | 0:1c358ea10753 | 177 | |
spastor | 0:1c358ea10753 | 178 | { |
spastor | 0:1c358ea10753 | 179 | connector_callback_status_t status; |
spastor | 0:1c358ea10753 | 180 | connector_request_id_t request_id; |
spastor | 0:1c358ea10753 | 181 | |
spastor | 0:1c358ea10753 | 182 | request_id.config_request = connector_request_id_config_wait_count; |
spastor | 0:1c358ea10753 | 183 | status = connector_callback(connector_ptr->callback, connector_class_id_config, request_id, &wait_count); |
spastor | 0:1c358ea10753 | 184 | |
spastor | 0:1c358ea10753 | 185 | switch (status) |
spastor | 0:1c358ea10753 | 186 | { |
spastor | 0:1c358ea10753 | 187 | case connector_callback_continue: |
spastor | 0:1c358ea10753 | 188 | /* coverity[uninit_use] */ |
spastor | 0:1c358ea10753 | 189 | if ((wait_count.count < WAIT_COUNT_MIN) || |
spastor | 0:1c358ea10753 | 190 | (wait_count.count > WAIT_COUNT_MAX)) |
spastor | 0:1c358ea10753 | 191 | { |
spastor | 0:1c358ea10753 | 192 | notify_error_status(connector_ptr->callback, connector_class_id_config, request_id, connector_invalid_data_range); |
spastor | 0:1c358ea10753 | 193 | result = connector_abort; |
spastor | 0:1c358ea10753 | 194 | } |
spastor | 0:1c358ea10753 | 195 | else |
spastor | 0:1c358ea10753 | 196 | { |
spastor | 0:1c358ea10753 | 197 | connector_ptr->edp_data.config.wait_count = wait_count.count; |
spastor | 0:1c358ea10753 | 198 | } |
spastor | 0:1c358ea10753 | 199 | break; |
spastor | 0:1c358ea10753 | 200 | |
spastor | 0:1c358ea10753 | 201 | case connector_callback_busy: |
spastor | 0:1c358ea10753 | 202 | case connector_callback_abort: |
spastor | 0:1c358ea10753 | 203 | case connector_callback_error: |
spastor | 0:1c358ea10753 | 204 | case connector_callback_unrecognized: |
spastor | 0:1c358ea10753 | 205 | result = connector_abort; |
spastor | 0:1c358ea10753 | 206 | break; |
spastor | 0:1c358ea10753 | 207 | } |
spastor | 0:1c358ea10753 | 208 | } |
spastor | 0:1c358ea10753 | 209 | return result; |
spastor | 0:1c358ea10753 | 210 | } |
spastor | 0:1c358ea10753 | 211 | #endif |
spastor | 0:1c358ea10753 | 212 | |
spastor | 0:1c358ea10753 | 213 | |
spastor | 0:1c358ea10753 | 214 | static connector_status_t get_config_ip_addr(connector_data_t * const connector_ptr) |
spastor | 0:1c358ea10753 | 215 | { |
spastor | 0:1c358ea10753 | 216 | #define CC_IPV6_ADDRESS_LENGTH 16 |
spastor | 0:1c358ea10753 | 217 | #define CC_IPV4_ADDRESS_LENGTH 4 |
spastor | 0:1c358ea10753 | 218 | |
spastor | 0:1c358ea10753 | 219 | connector_status_t result = connector_working; |
spastor | 0:1c358ea10753 | 220 | connector_config_ip_address_t config_ip; |
spastor | 0:1c358ea10753 | 221 | connector_request_id_t request_id; |
spastor | 0:1c358ea10753 | 222 | |
spastor | 0:1c358ea10753 | 223 | { |
spastor | 0:1c358ea10753 | 224 | connector_callback_status_t status; |
spastor | 0:1c358ea10753 | 225 | |
spastor | 0:1c358ea10753 | 226 | request_id.config_request = connector_request_id_config_ip_addr; |
spastor | 0:1c358ea10753 | 227 | status = connector_callback(connector_ptr->callback, connector_class_id_config, request_id, &config_ip); |
spastor | 0:1c358ea10753 | 228 | |
spastor | 0:1c358ea10753 | 229 | switch (status) |
spastor | 0:1c358ea10753 | 230 | { |
spastor | 0:1c358ea10753 | 231 | case connector_callback_continue: |
spastor | 0:1c358ea10753 | 232 | { |
spastor | 0:1c358ea10753 | 233 | #define CC_ZERO_IP_ADDR 0x00000000 |
spastor | 0:1c358ea10753 | 234 | #define CC_BROADCAST_IP_ADDR 0xFFFFFFFF |
spastor | 0:1c358ea10753 | 235 | |
spastor | 0:1c358ea10753 | 236 | /* coverity[uninit_use] */ |
spastor | 0:1c358ea10753 | 237 | if (config_ip.address == NULL) |
spastor | 0:1c358ea10753 | 238 | { |
spastor | 0:1c358ea10753 | 239 | result = connector_invalid_data; |
spastor | 0:1c358ea10753 | 240 | goto error; |
spastor | 0:1c358ea10753 | 241 | } |
spastor | 0:1c358ea10753 | 242 | /* coverity[uninit_use] */ |
spastor | 0:1c358ea10753 | 243 | if ((config_ip.ip_address_type != connector_ip_address_ipv6) && (config_ip.ip_address_type != connector_ip_address_ipv4)) |
spastor | 0:1c358ea10753 | 244 | { |
spastor | 0:1c358ea10753 | 245 | result = connector_invalid_data_size; |
spastor | 0:1c358ea10753 | 246 | goto error; |
spastor | 0:1c358ea10753 | 247 | } |
spastor | 0:1c358ea10753 | 248 | |
spastor | 0:1c358ea10753 | 249 | if (config_ip.ip_address_type == connector_ip_address_ipv4) |
spastor | 0:1c358ea10753 | 250 | { |
spastor | 0:1c358ea10753 | 251 | static uint32_t const zero_ip_addr = CC_ZERO_IP_ADDR; |
spastor | 0:1c358ea10753 | 252 | static uint32_t const broadcast_ip_addr = CC_BROADCAST_IP_ADDR; |
spastor | 0:1c358ea10753 | 253 | |
spastor | 0:1c358ea10753 | 254 | uint32_t const ip = LoadBE32(config_ip.address); |
spastor | 0:1c358ea10753 | 255 | |
spastor | 0:1c358ea10753 | 256 | if ((ip == LoadBE32(&zero_ip_addr)) || (ip == LoadBE32(&broadcast_ip_addr))) |
spastor | 0:1c358ea10753 | 257 | { |
spastor | 0:1c358ea10753 | 258 | result = connector_invalid_data_range; |
spastor | 0:1c358ea10753 | 259 | goto error; |
spastor | 0:1c358ea10753 | 260 | } |
spastor | 0:1c358ea10753 | 261 | } |
spastor | 0:1c358ea10753 | 262 | |
spastor | 0:1c358ea10753 | 263 | connector_ptr->edp_data.config.ip_addr_length = (config_ip.ip_address_type == connector_ip_address_ipv4) ? CC_IPV4_ADDRESS_LENGTH : CC_IPV6_ADDRESS_LENGTH; |
spastor | 0:1c358ea10753 | 264 | connector_ptr->edp_data.config.ip_addr = config_ip.address; |
spastor | 0:1c358ea10753 | 265 | break; |
spastor | 0:1c358ea10753 | 266 | } |
spastor | 0:1c358ea10753 | 267 | |
spastor | 0:1c358ea10753 | 268 | case connector_callback_busy: |
spastor | 0:1c358ea10753 | 269 | case connector_callback_abort: |
spastor | 0:1c358ea10753 | 270 | case connector_callback_error: |
spastor | 0:1c358ea10753 | 271 | case connector_callback_unrecognized: |
spastor | 0:1c358ea10753 | 272 | result = connector_abort; |
spastor | 0:1c358ea10753 | 273 | goto done; |
spastor | 0:1c358ea10753 | 274 | } |
spastor | 0:1c358ea10753 | 275 | } |
spastor | 0:1c358ea10753 | 276 | |
spastor | 0:1c358ea10753 | 277 | |
spastor | 0:1c358ea10753 | 278 | error: |
spastor | 0:1c358ea10753 | 279 | if (result != connector_working) |
spastor | 0:1c358ea10753 | 280 | { |
spastor | 0:1c358ea10753 | 281 | notify_error_status(connector_ptr->callback, connector_class_id_config, request_id, result); |
spastor | 0:1c358ea10753 | 282 | result = connector_abort; |
spastor | 0:1c358ea10753 | 283 | } |
spastor | 0:1c358ea10753 | 284 | |
spastor | 0:1c358ea10753 | 285 | done: |
spastor | 0:1c358ea10753 | 286 | return result; |
spastor | 0:1c358ea10753 | 287 | } |
spastor | 0:1c358ea10753 | 288 | |
spastor | 0:1c358ea10753 | 289 | #if !(defined CONNECTOR_IDENTITY_VERIFICATION) |
spastor | 0:1c358ea10753 | 290 | static connector_status_t get_config_identity_verification(connector_data_t * const connector_ptr) |
spastor | 0:1c358ea10753 | 291 | { |
spastor | 0:1c358ea10753 | 292 | connector_status_t result = connector_working; |
spastor | 0:1c358ea10753 | 293 | connector_config_identity_verification_t config_identity; |
spastor | 0:1c358ea10753 | 294 | |
spastor | 0:1c358ea10753 | 295 | |
spastor | 0:1c358ea10753 | 296 | { |
spastor | 0:1c358ea10753 | 297 | connector_callback_status_t status; |
spastor | 0:1c358ea10753 | 298 | connector_request_id_t request_id; |
spastor | 0:1c358ea10753 | 299 | |
spastor | 0:1c358ea10753 | 300 | request_id.config_request = connector_request_id_config_identity_verification; |
spastor | 0:1c358ea10753 | 301 | status = connector_callback(connector_ptr->callback, connector_class_id_config, request_id, &config_identity); |
spastor | 0:1c358ea10753 | 302 | |
spastor | 0:1c358ea10753 | 303 | switch (status) |
spastor | 0:1c358ea10753 | 304 | { |
spastor | 0:1c358ea10753 | 305 | case connector_callback_continue: |
spastor | 0:1c358ea10753 | 306 | /* coverity[uninit_use] */ |
spastor | 0:1c358ea10753 | 307 | switch (config_identity.type) |
spastor | 0:1c358ea10753 | 308 | { |
spastor | 0:1c358ea10753 | 309 | case connector_identity_verification_simple: |
spastor | 0:1c358ea10753 | 310 | case connector_identity_verification_password: |
spastor | 0:1c358ea10753 | 311 | connector_ptr->edp_data.config.identity_verification = config_identity.type; |
spastor | 0:1c358ea10753 | 312 | break; |
spastor | 0:1c358ea10753 | 313 | default: |
spastor | 0:1c358ea10753 | 314 | notify_error_status(connector_ptr->callback, connector_class_id_config, request_id, connector_invalid_data_range); |
spastor | 0:1c358ea10753 | 315 | result = connector_abort; |
spastor | 0:1c358ea10753 | 316 | break; |
spastor | 0:1c358ea10753 | 317 | } |
spastor | 0:1c358ea10753 | 318 | break; |
spastor | 0:1c358ea10753 | 319 | |
spastor | 0:1c358ea10753 | 320 | case connector_callback_busy: |
spastor | 0:1c358ea10753 | 321 | case connector_callback_abort: |
spastor | 0:1c358ea10753 | 322 | case connector_callback_error: |
spastor | 0:1c358ea10753 | 323 | result = connector_abort; |
spastor | 0:1c358ea10753 | 324 | break; |
spastor | 0:1c358ea10753 | 325 | |
spastor | 0:1c358ea10753 | 326 | case connector_callback_unrecognized: |
spastor | 0:1c358ea10753 | 327 | connector_ptr->edp_data.config.identity_verification = connector_identity_verification_simple; |
spastor | 0:1c358ea10753 | 328 | break; |
spastor | 0:1c358ea10753 | 329 | } |
spastor | 0:1c358ea10753 | 330 | } |
spastor | 0:1c358ea10753 | 331 | return result; |
spastor | 0:1c358ea10753 | 332 | } |
spastor | 0:1c358ea10753 | 333 | #endif |
spastor | 0:1c358ea10753 | 334 | |
spastor | 0:1c358ea10753 | 335 | static connector_status_t get_config_password(connector_data_t * const connector_ptr) |
spastor | 0:1c358ea10753 | 336 | { |
spastor | 0:1c358ea10753 | 337 | connector_status_t result = connector_working; |
spastor | 0:1c358ea10753 | 338 | connector_config_pointer_string_t config_password; |
spastor | 0:1c358ea10753 | 339 | |
spastor | 0:1c358ea10753 | 340 | |
spastor | 0:1c358ea10753 | 341 | { |
spastor | 0:1c358ea10753 | 342 | connector_callback_status_t status; |
spastor | 0:1c358ea10753 | 343 | connector_request_id_t request_id; |
spastor | 0:1c358ea10753 | 344 | |
spastor | 0:1c358ea10753 | 345 | request_id.config_request = connector_request_id_config_password; |
spastor | 0:1c358ea10753 | 346 | status = connector_callback(connector_ptr->callback, connector_class_id_config, request_id, &config_password); |
spastor | 0:1c358ea10753 | 347 | |
spastor | 0:1c358ea10753 | 348 | switch (status) |
spastor | 0:1c358ea10753 | 349 | { |
spastor | 0:1c358ea10753 | 350 | case connector_callback_continue: |
spastor | 0:1c358ea10753 | 351 | /* coverity[uninit_use] */ |
spastor | 0:1c358ea10753 | 352 | if (config_password.string == NULL) |
spastor | 0:1c358ea10753 | 353 | { |
spastor | 0:1c358ea10753 | 354 | notify_error_status(connector_ptr->callback, connector_class_id_config, request_id, connector_invalid_data); |
spastor | 0:1c358ea10753 | 355 | result = connector_abort; |
spastor | 0:1c358ea10753 | 356 | } |
spastor | 0:1c358ea10753 | 357 | else |
spastor | 0:1c358ea10753 | 358 | { |
spastor | 0:1c358ea10753 | 359 | /* coverity[uninit_use] */ |
spastor | 0:1c358ea10753 | 360 | connector_ptr->edp_data.config.password_length = config_password.length; |
spastor | 0:1c358ea10753 | 361 | connector_ptr->edp_data.config.password = config_password.string; |
spastor | 0:1c358ea10753 | 362 | |
spastor | 0:1c358ea10753 | 363 | } |
spastor | 0:1c358ea10753 | 364 | break; |
spastor | 0:1c358ea10753 | 365 | |
spastor | 0:1c358ea10753 | 366 | case connector_callback_busy: |
spastor | 0:1c358ea10753 | 367 | case connector_callback_abort: |
spastor | 0:1c358ea10753 | 368 | case connector_callback_error: |
spastor | 0:1c358ea10753 | 369 | case connector_callback_unrecognized: |
spastor | 0:1c358ea10753 | 370 | result = connector_abort; |
spastor | 0:1c358ea10753 | 371 | break; |
spastor | 0:1c358ea10753 | 372 | } |
spastor | 0:1c358ea10753 | 373 | } |
spastor | 0:1c358ea10753 | 374 | |
spastor | 0:1c358ea10753 | 375 | return result; |
spastor | 0:1c358ea10753 | 376 | } |
spastor | 0:1c358ea10753 | 377 |