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

Committer:
spastor
Date:
Tue Dec 03 13:34:02 2013 +0000
Revision:
0:1c358ea10753
First commit

Who changed what in which revision?

UserRevisionLine numberNew 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 #include <ctype.h>
spastor 0:1c358ea10753 14 #include "connector_config.h"
spastor 0:1c358ea10753 15 #include "connector_debug.h"
spastor 0:1c358ea10753 16 #include "connector_api.h"
spastor 0:1c358ea10753 17 #include "ecc_platform.h"
spastor 0:1c358ea10753 18
spastor 0:1c358ea10753 19 /* Cloud Connector Configuration routines */
spastor 0:1c358ea10753 20
spastor 0:1c358ea10753 21 /*
spastor 0:1c358ea10753 22 * Routine to get the IP address, you will need to modify this routine for your
spastor 0:1c358ea10753 23 * platform.
spastor 0:1c358ea10753 24 */
spastor 0:1c358ea10753 25 static uint32_t ipaddress(uint32_t a, uint32_t b, uint32_t c, uint32_t d)
spastor 0:1c358ea10753 26 {
spastor 0:1c358ea10753 27 return ((d & 0xFF) << 24) | ((c & 0xFF) << 16) | ((b & 0xFF) << 8) | (a & 0xFF);
spastor 0:1c358ea10753 28 }
spastor 0:1c358ea10753 29 static connector_callback_status_t app_get_ip_address(connector_config_ip_address_t * const config_ip)
spastor 0:1c358ea10753 30 {
spastor 0:1c358ea10753 31 /* Fill in the size and IP address */
spastor 0:1c358ea10753 32 static uint32_t ipaddr;
spastor 0:1c358ea10753 33 ipaddr = ipaddress(10,101,2,70);
spastor 0:1c358ea10753 34 config_ip->ip_address_type = connector_ip_address_ipv4;
spastor 0:1c358ea10753 35 config_ip->address = &ipaddr;
spastor 0:1c358ea10753 36
spastor 0:1c358ea10753 37 return connector_callback_continue;
spastor 0:1c358ea10753 38 }
spastor 0:1c358ea10753 39
spastor 0:1c358ea10753 40 #define MAC_ADDR_LENGTH 6
spastor 0:1c358ea10753 41 static uint8_t const device_mac_addr[MAC_ADDR_LENGTH] = {0x00, 0x04, 0x9D, 0xAB, 0xCD, 0xEF};
spastor 0:1c358ea10753 42
spastor 0:1c358ea10753 43 static connector_callback_status_t app_get_mac_addr(connector_config_pointer_data_t * const config_mac)
spastor 0:1c358ea10753 44 {
spastor 0:1c358ea10753 45 /*#error "Specify device MAC address for LAN connection"*/
spastor 0:1c358ea10753 46 ASSERT(config_mac->bytes_required == MAC_ADDR_LENGTH);
spastor 0:1c358ea10753 47
spastor 0:1c358ea10753 48 config_mac->data = (uint8_t *)device_mac_addr;
spastor 0:1c358ea10753 49
spastor 0:1c358ea10753 50 return connector_callback_continue;
spastor 0:1c358ea10753 51 }
spastor 0:1c358ea10753 52
spastor 0:1c358ea10753 53 #define DEVICE_ID_LENGTH 16
spastor 0:1c358ea10753 54 #define DEVICE_ID_FILENAME "device_id.cfg"
spastor 0:1c358ea10753 55 #define EXECUTABLE_NAME "connector"
spastor 0:1c358ea10753 56
spastor 0:1c358ea10753 57 static uint8_t provisioned_device_id[DEVICE_ID_LENGTH];
spastor 0:1c358ea10753 58
spastor 0:1c358ea10753 59 static connector_callback_status_t app_load_device_id(connector_config_pointer_data_t * const config_device_id)
spastor 0:1c358ea10753 60 {
spastor 0:1c358ea10753 61 config_device_id->data = provisioned_device_id;
spastor 0:1c358ea10753 62
spastor 0:1c358ea10753 63 return connector_callback_continue;
spastor 0:1c358ea10753 64 }
spastor 0:1c358ea10753 65
spastor 0:1c358ea10753 66 static connector_callback_status_t app_save_device_id(connector_config_pointer_data_t * const config_device_id)
spastor 0:1c358ea10753 67 {
spastor 0:1c358ea10753 68 memcpy(config_device_id->data, provisioned_device_id, sizeof provisioned_device_id);
spastor 0:1c358ea10753 69
spastor 0:1c358ea10753 70 return connector_callback_continue;
spastor 0:1c358ea10753 71 }
spastor 0:1c358ea10753 72
spastor 0:1c358ea10753 73 #if !(defined CONNECTOR_VENDOR_ID)
spastor 0:1c358ea10753 74 static connector_callback_status_t app_get_vendor_id(connector_config_vendor_id_t * const config_vendor)
spastor 0:1c358ea10753 75 {
spastor 0:1c358ea10753 76 /*#error "Specify vendor id"*/
spastor 0:1c358ea10753 77
spastor 0:1c358ea10753 78 static uint32_t const device_vendor_id = 0x030000DB;
spastor 0:1c358ea10753 79 config_vendor->id = device_vendor_id;
spastor 0:1c358ea10753 80
spastor 0:1c358ea10753 81 return connector_callback_continue;
spastor 0:1c358ea10753 82 }
spastor 0:1c358ea10753 83 #endif
spastor 0:1c358ea10753 84
spastor 0:1c358ea10753 85 #if !(defined CONNECTOR_DEVICE_TYPE)
spastor 0:1c358ea10753 86 static connector_callback_status_t app_get_device_type(connector_config_pointer_string_t * const config_device_type)
spastor 0:1c358ea10753 87 {
spastor 0:1c358ea10753 88 static char const device_type[] = "Linux Application";
spastor 0:1c358ea10753 89
spastor 0:1c358ea10753 90 /* Return pointer to device type. */
spastor 0:1c358ea10753 91 config_device_type->string = (char *)device_type;
spastor 0:1c358ea10753 92 config_device_type->length = sizeof device_type -1;
spastor 0:1c358ea10753 93
spastor 0:1c358ea10753 94 return connector_callback_continue;
spastor 0:1c358ea10753 95 }
spastor 0:1c358ea10753 96 #endif
spastor 0:1c358ea10753 97
spastor 0:1c358ea10753 98 #if !(defined CONNECTOR_CLOUD_URL)
spastor 0:1c358ea10753 99 static connector_callback_status_t app_get_device_cloud_url(connector_config_pointer_string_t * const config_url)
spastor 0:1c358ea10753 100 {
spastor 0:1c358ea10753 101 static char const connector_cloud_url[] = "login.etherios.com";
spastor 0:1c358ea10753 102
spastor 0:1c358ea10753 103 config_url->string = (char *)connector_cloud_url;
spastor 0:1c358ea10753 104 config_url->length = sizeof connector_cloud_url - 1;
spastor 0:1c358ea10753 105
spastor 0:1c358ea10753 106 return connector_callback_continue;
spastor 0:1c358ea10753 107 }
spastor 0:1c358ea10753 108 #endif
spastor 0:1c358ea10753 109
spastor 0:1c358ea10753 110 #if !(defined CONNECTOR_CLOUD_PHONE)
spastor 0:1c358ea10753 111
spastor 0:1c358ea10753 112 /* Configure the phone number of the server where to send SMSs.
spastor 0:1c358ea10753 113 * Will be updated if a SMSs provisioning message arrives from the server.
spastor 0:1c358ea10753 114 * If set to nothing, will require a provisioning message from the server for initialization.
spastor 0:1c358ea10753 115 */
spastor 0:1c358ea10753 116 static char connector_cloud_phone[] = "447786201216"; /* phone number corresponding to login.etherios.com */
spastor 0:1c358ea10753 117
spastor 0:1c358ea10753 118 static connector_callback_status_t app_get_device_cloud_phone(connector_config_pointer_string_t * const config_phone)
spastor 0:1c358ea10753 119 {
spastor 0:1c358ea10753 120
spastor 0:1c358ea10753 121 config_phone->string = (char *)connector_cloud_phone;
spastor 0:1c358ea10753 122 config_phone->length = sizeof connector_cloud_phone - 1;
spastor 0:1c358ea10753 123
spastor 0:1c358ea10753 124 return connector_callback_continue;
spastor 0:1c358ea10753 125 }
spastor 0:1c358ea10753 126
spastor 0:1c358ea10753 127 static connector_callback_status_t app_set_device_cloud_phone(connector_config_pointer_string_t * const config_phone)
spastor 0:1c358ea10753 128 {
spastor 0:1c358ea10753 129 if (config_phone->length > (sizeof connector_cloud_phone -1))
spastor 0:1c358ea10753 130 {
spastor 0:1c358ea10753 131 APP_DEBUG("app_set_device_cloud_phone: Not enough room to store cloud_phone.\n");
spastor 0:1c358ea10753 132 return connector_callback_error;
spastor 0:1c358ea10753 133 }
spastor 0:1c358ea10753 134
spastor 0:1c358ea10753 135 strcpy(connector_cloud_phone, config_phone->string);
spastor 0:1c358ea10753 136
spastor 0:1c358ea10753 137 /* Maybe user want to save connector_cloud_phone to persistent storage */
spastor 0:1c358ea10753 138
spastor 0:1c358ea10753 139 return connector_callback_continue;
spastor 0:1c358ea10753 140 }
spastor 0:1c358ea10753 141 #endif
spastor 0:1c358ea10753 142
spastor 0:1c358ea10753 143 #if !(defined CONNECTOR_CLOUD_SERVICE_ID)
spastor 0:1c358ea10753 144
spastor 0:1c358ea10753 145 /* Service-Id used to communicate with the server through SMS
spastor 0:1c358ea10753 146 * if empty, not shared-code used (default when using long codes)
spastor 0:1c358ea10753 147 * When using shared-codes within US you may need to use "idgp"
spastor 0:1c358ea10753 148 */
spastor 0:1c358ea10753 149 static char connector_cloud_service_id[] = ""; /* empty: No shared-code used */
spastor 0:1c358ea10753 150
spastor 0:1c358ea10753 151 static connector_callback_status_t app_get_device_cloud_service_id(connector_config_pointer_string_t * const config_service_id)
spastor 0:1c358ea10753 152 {
spastor 0:1c358ea10753 153
spastor 0:1c358ea10753 154 config_service_id->string = (char *)connector_cloud_service_id;
spastor 0:1c358ea10753 155 config_service_id->length = strlen(connector_cloud_service_id);
spastor 0:1c358ea10753 156
spastor 0:1c358ea10753 157 return connector_callback_continue;
spastor 0:1c358ea10753 158 }
spastor 0:1c358ea10753 159 #endif
spastor 0:1c358ea10753 160
spastor 0:1c358ea10753 161 #if !(defined CONNECTOR_CONNECTION_TYPE)
spastor 0:1c358ea10753 162 static connector_callback_status_t app_get_connection_type(connector_config_connection_type_t * const config_connection)
spastor 0:1c358ea10753 163 {
spastor 0:1c358ea10753 164
spastor 0:1c358ea10753 165 /* Return pointer to connection type */
spastor 0:1c358ea10753 166 config_connection->type = connector_connection_type_lan;
spastor 0:1c358ea10753 167
spastor 0:1c358ea10753 168 return connector_callback_continue;
spastor 0:1c358ea10753 169 }
spastor 0:1c358ea10753 170 #endif
spastor 0:1c358ea10753 171
spastor 0:1c358ea10753 172 #if !(defined CONNECTOR_WAN_LINK_SPEED_IN_BITS_PER_SECOND)
spastor 0:1c358ea10753 173 static connector_callback_status_t app_get_link_speed(connector_config_link_speed_t * const config_link)
spastor 0:1c358ea10753 174 {
spastor 0:1c358ea10753 175 config_link->speed = 0;
spastor 0:1c358ea10753 176
spastor 0:1c358ea10753 177 return connector_callback_continue;
spastor 0:1c358ea10753 178 }
spastor 0:1c358ea10753 179 #endif
spastor 0:1c358ea10753 180
spastor 0:1c358ea10753 181 #if !(defined CONNECTOR_WAN_PHONE_NUMBER_DIALED)
spastor 0:1c358ea10753 182 static connector_callback_status_t app_get_phone_number(connector_config_pointer_string_t * const config_phone_number)
spastor 0:1c358ea10753 183 {
spastor 0:1c358ea10753 184 /*
spastor 0:1c358ea10753 185 * Return pointer to phone number for WAN connection type.
spastor 0:1c358ea10753 186 */
spastor 0:1c358ea10753 187 static char const phone_number[] ="000-000-0000";
spastor 0:1c358ea10753 188
spastor 0:1c358ea10753 189 config_phone_number->string = (char *)phone_number;
spastor 0:1c358ea10753 190 config_phone_number->length = sizeof phone_number -1;
spastor 0:1c358ea10753 191
spastor 0:1c358ea10753 192 return connector_callback_continue;
spastor 0:1c358ea10753 193 }
spastor 0:1c358ea10753 194 #endif
spastor 0:1c358ea10753 195
spastor 0:1c358ea10753 196 #if !(defined CONNECTOR_TX_KEEPALIVE_IN_SECONDS)
spastor 0:1c358ea10753 197 /* Keep alives are from the prospective of Device Cloud */
spastor 0:1c358ea10753 198 /* This keep alive is sent from Device Cloud to the device */
spastor 0:1c358ea10753 199 static connector_callback_status_t app_get_tx_keepalive_interval(connector_config_keepalive_t * const config_keepalive)
spastor 0:1c358ea10753 200 {
spastor 0:1c358ea10753 201
spastor 0:1c358ea10753 202 #define DEVICE_TX_KEEPALIVE_INTERVAL_IN_SECONDS 90
spastor 0:1c358ea10753 203 /* Return Tx keepalive interval in seconds */
spastor 0:1c358ea10753 204 config_keepalive->interval_in_seconds = DEVICE_TX_KEEPALIVE_INTERVAL_IN_SECONDS;
spastor 0:1c358ea10753 205
spastor 0:1c358ea10753 206 return connector_callback_continue;
spastor 0:1c358ea10753 207 }
spastor 0:1c358ea10753 208 #endif
spastor 0:1c358ea10753 209
spastor 0:1c358ea10753 210 #if !(defined CONNECTOR_RX_KEEPALIVE_IN_SECONDS)
spastor 0:1c358ea10753 211 /* This keep alive is sent from the device to Device Cloud */
spastor 0:1c358ea10753 212 static connector_callback_status_t app_get_rx_keepalive_interval(connector_config_keepalive_t * const config_keepalive)
spastor 0:1c358ea10753 213 {
spastor 0:1c358ea10753 214 #define DEVICE_RX_KEEPALIVE_INTERVAL_IN_SECONDS 60
spastor 0:1c358ea10753 215 /* Return Rx keepalive interval in seconds */
spastor 0:1c358ea10753 216 config_keepalive->interval_in_seconds = DEVICE_RX_KEEPALIVE_INTERVAL_IN_SECONDS;
spastor 0:1c358ea10753 217
spastor 0:1c358ea10753 218 return connector_callback_continue;
spastor 0:1c358ea10753 219 }
spastor 0:1c358ea10753 220 #endif
spastor 0:1c358ea10753 221
spastor 0:1c358ea10753 222 #if !(defined CONNECTOR_WAIT_COUNT)
spastor 0:1c358ea10753 223 static connector_callback_status_t app_get_wait_count(connector_config_wait_count_t * const config_wait)
spastor 0:1c358ea10753 224 {
spastor 0:1c358ea10753 225 #define DEVICE_WAIT_COUNT 5
spastor 0:1c358ea10753 226 /*
spastor 0:1c358ea10753 227 * Return wait count (number of times not receiving Tx keepalive
spastor 0:1c358ea10753 228 * from Device Cloud is allowed).
spastor 0:1c358ea10753 229 */
spastor 0:1c358ea10753 230 config_wait->count = DEVICE_WAIT_COUNT;
spastor 0:1c358ea10753 231
spastor 0:1c358ea10753 232 return connector_callback_continue;
spastor 0:1c358ea10753 233 }
spastor 0:1c358ea10753 234 #endif
spastor 0:1c358ea10753 235
spastor 0:1c358ea10753 236 #if (defined CONNECTOR_FIRMWARE_SERVICE) && !(defined CONNECTOR_FIRMWARE_SUPPORT)
spastor 0:1c358ea10753 237 static connector_callback_status_t app_get_firmware_support(connector_config_supported_t * const config_status)
spastor 0:1c358ea10753 238 {
spastor 0:1c358ea10753 239 config_status->supported = connector_true;
spastor 0:1c358ea10753 240
spastor 0:1c358ea10753 241 return connector_callback_continue;
spastor 0:1c358ea10753 242 }
spastor 0:1c358ea10753 243 #endif
spastor 0:1c358ea10753 244
spastor 0:1c358ea10753 245 #if (defined CONNECTOR_DATA_SERVICE) && !(defined CONNECTOR_DATA_SERVICE_SUPPORT)
spastor 0:1c358ea10753 246 static connector_callback_status_t app_get_data_service_support(connector_config_supported_t * const config_status)
spastor 0:1c358ea10753 247 {
spastor 0:1c358ea10753 248 config_status->supported = connector_true;
spastor 0:1c358ea10753 249
spastor 0:1c358ea10753 250 return connector_callback_continue;
spastor 0:1c358ea10753 251 }
spastor 0:1c358ea10753 252 #endif
spastor 0:1c358ea10753 253
spastor 0:1c358ea10753 254 #if (defined CONNECTOR_FILE_SYSTEM) && !(defined CONNECTOR_FILE_SYSTEM_SUPPORT)
spastor 0:1c358ea10753 255 static connector_callback_status_t app_get_file_system_support(connector_config_supported_t * const config_status)
spastor 0:1c358ea10753 256 {
spastor 0:1c358ea10753 257 config_status->supported = connector_true;
spastor 0:1c358ea10753 258
spastor 0:1c358ea10753 259 return connector_callback_continue;
spastor 0:1c358ea10753 260 }
spastor 0:1c358ea10753 261 #endif
spastor 0:1c358ea10753 262
spastor 0:1c358ea10753 263 #if (defined CONNECTOR_RCI_SERVICE) && !(defined CONNECTOR_REMOTE_CONFIGURATION_SUPPORT)
spastor 0:1c358ea10753 264 static connector_callback_status_t app_get_remote_configuration_support(connector_config_supported_t * const config_status)
spastor 0:1c358ea10753 265 {
spastor 0:1c358ea10753 266 config_status->supported = connector_true;
spastor 0:1c358ea10753 267
spastor 0:1c358ea10753 268 return connector_callback_continue;
spastor 0:1c358ea10753 269 }
spastor 0:1c358ea10753 270 #endif
spastor 0:1c358ea10753 271
spastor 0:1c358ea10753 272 #if ((defined CONNECTOR_DATA_SERVICE) || (defined CONNECTOR_FILE_SYSTEM) || (defined CONNECTOR_RCI_SERVICE)) && !(defined CONNECTOR_MSG_MAX_TRANSACTION)
spastor 0:1c358ea10753 273 static connector_callback_status_t app_get_max_message_transactions(connector_config_max_transaction_t * const config_max_transaction)
spastor 0:1c358ea10753 274 {
spastor 0:1c358ea10753 275 #define CONNECTOR_MAX_MSG_TRANSACTIONS 1
spastor 0:1c358ea10753 276
spastor 0:1c358ea10753 277 config_max_transaction->count = CONNECTOR_MAX_MSG_TRANSACTIONS;
spastor 0:1c358ea10753 278
spastor 0:1c358ea10753 279 return connector_callback_continue;
spastor 0:1c358ea10753 280 }
spastor 0:1c358ea10753 281 #endif
spastor 0:1c358ea10753 282
spastor 0:1c358ea10753 283 #if !(defined CONNECTOR_DEVICE_ID_METHOD)
spastor 0:1c358ea10753 284 static connector_callback_status_t app_get_device_id_method(connector_config_device_id_method_t * const config_device)
spastor 0:1c358ea10753 285 {
spastor 0:1c358ea10753 286
spastor 0:1c358ea10753 287 config_device->method = connector_device_id_method_auto;
spastor 0:1c358ea10753 288
spastor 0:1c358ea10753 289 return connector_callback_continue;
spastor 0:1c358ea10753 290 }
spastor 0:1c358ea10753 291 #endif
spastor 0:1c358ea10753 292
spastor 0:1c358ea10753 293 /* Converts the first digit char ('0' to '9') to a nibble starting at index and working backwards. */
spastor 0:1c358ea10753 294 static unsigned int digit_to_nibble(char const * const string, int * const index)
spastor 0:1c358ea10753 295 {
spastor 0:1c358ea10753 296 unsigned int nibble = 0;
spastor 0:1c358ea10753 297 int current;
spastor 0:1c358ea10753 298
spastor 0:1c358ea10753 299 for (current = *index; current >= 0; current--)
spastor 0:1c358ea10753 300 {
spastor 0:1c358ea10753 301 int const ch = string[current];
spastor 0:1c358ea10753 302
spastor 0:1c358ea10753 303 if (isxdigit(ch))
spastor 0:1c358ea10753 304 {
spastor 0:1c358ea10753 305 if (isdigit(ch))
spastor 0:1c358ea10753 306 nibble = ch - '0';
spastor 0:1c358ea10753 307 else
spastor 0:1c358ea10753 308 nibble = toupper(ch) - 'A' + 0xA;
spastor 0:1c358ea10753 309 break;
spastor 0:1c358ea10753 310 }
spastor 0:1c358ea10753 311 }
spastor 0:1c358ea10753 312 *index = current - 1;
spastor 0:1c358ea10753 313
spastor 0:1c358ea10753 314 return nibble;
spastor 0:1c358ea10753 315 }
spastor 0:1c358ea10753 316
spastor 0:1c358ea10753 317 /* Parse a string with non-digit characters into an array (i.e.: 0123456-78-901234-5 will be stored in {0x01, 0x23, 0x45, 0x67, 0x89, 0x01, 0x23, 0x45}) */
spastor 0:1c358ea10753 318 static int str_to_uint8_array(char const * const str, uint8_t * const array, size_t const array_size)
spastor 0:1c358ea10753 319 {
spastor 0:1c358ea10753 320 int i;
spastor 0:1c358ea10753 321 int const string_length = strlen(str);
spastor 0:1c358ea10753 322 int index = string_length - 1;
spastor 0:1c358ea10753 323
spastor 0:1c358ea10753 324 for (i = array_size - 1; i >= 0; i--)
spastor 0:1c358ea10753 325 {
spastor 0:1c358ea10753 326 unsigned int const ls_nibble = digit_to_nibble(str, &index);
spastor 0:1c358ea10753 327 unsigned int const ms_nibble = digit_to_nibble(str, &index);
spastor 0:1c358ea10753 328
spastor 0:1c358ea10753 329 array[i] = (ms_nibble << 4) + ls_nibble;
spastor 0:1c358ea10753 330 }
spastor 0:1c358ea10753 331
spastor 0:1c358ea10753 332 return 0;
spastor 0:1c358ea10753 333 }
spastor 0:1c358ea10753 334
spastor 0:1c358ea10753 335 static connector_callback_status_t app_get_imei_number(connector_config_pointer_data_t * const config_imei)
spastor 0:1c358ea10753 336 {
spastor 0:1c358ea10753 337 #define APP_IMEI_LENGTH 8
spastor 0:1c358ea10753 338 #define APP_IMEI_STRING_LENGTH (sizeof("000000-00-000000-0") - 1)
spastor 0:1c358ea10753 339 /* Each nibble corresponds a decimal digit.
spastor 0:1c358ea10753 340 * Most upper nibble must be 0.
spastor 0:1c358ea10753 341 */
spastor 0:1c358ea10753 342 char const app_imei_number_string[APP_IMEI_STRING_LENGTH] = "000000-00-000000-0";
spastor 0:1c358ea10753 343 static uint8_t app_imei_number[APP_IMEI_LENGTH] = {0};
spastor 0:1c358ea10753 344
spastor 0:1c358ea10753 345 str_to_uint8_array(app_imei_number_string, app_imei_number, sizeof app_imei_number);
spastor 0:1c358ea10753 346
spastor 0:1c358ea10753 347 config_imei->data = app_imei_number;
spastor 0:1c358ea10753 348 ASSERT(config_imei->bytes_required == sizeof app_imei_number);
spastor 0:1c358ea10753 349 return connector_callback_continue;
spastor 0:1c358ea10753 350 }
spastor 0:1c358ea10753 351
spastor 0:1c358ea10753 352 static connector_callback_status_t app_start_network_tcp(connector_config_connect_type_t * const config_connect)
spastor 0:1c358ea10753 353 {
spastor 0:1c358ea10753 354 config_connect->type = connector_connect_auto;
spastor 0:1c358ea10753 355 return connector_callback_continue;
spastor 0:1c358ea10753 356 }
spastor 0:1c358ea10753 357
spastor 0:1c358ea10753 358 static connector_callback_status_t app_start_network_udp(connector_config_connect_type_t * const config_connect)
spastor 0:1c358ea10753 359 {
spastor 0:1c358ea10753 360 config_connect->type = connector_connect_auto;
spastor 0:1c358ea10753 361 return connector_callback_continue;
spastor 0:1c358ea10753 362 }
spastor 0:1c358ea10753 363
spastor 0:1c358ea10753 364 static connector_callback_status_t app_start_network_sms(connector_config_connect_type_t * const config_connect)
spastor 0:1c358ea10753 365 {
spastor 0:1c358ea10753 366 config_connect->type = connector_connect_auto;
spastor 0:1c358ea10753 367 return connector_callback_continue;
spastor 0:1c358ea10753 368 }
spastor 0:1c358ea10753 369
spastor 0:1c358ea10753 370 #if !(defined CONNECTOR_WAN_TYPE)
spastor 0:1c358ea10753 371 static connector_callback_status_t app_get_wan_type(connector_config_wan_type_t * const config_wan)
spastor 0:1c358ea10753 372 {
spastor 0:1c358ea10753 373
spastor 0:1c358ea10753 374 config_wan->type = connector_wan_type_imei;
spastor 0:1c358ea10753 375
spastor 0:1c358ea10753 376 return connector_callback_continue;
spastor 0:1c358ea10753 377 }
spastor 0:1c358ea10753 378 #endif
spastor 0:1c358ea10753 379
spastor 0:1c358ea10753 380 static connector_callback_status_t app_get_esn(connector_config_pointer_data_t * const config_esn)
spastor 0:1c358ea10753 381 {
spastor 0:1c358ea10753 382 #define APP_ESN_HEX_LENGTH 4
spastor 0:1c358ea10753 383 #define APP_ESN_HEX_STRING_LENGTH (sizeof("00000000") - 1)
spastor 0:1c358ea10753 384 /* Each nibble corresponds a decimal digit.
spastor 0:1c358ea10753 385 * Most upper nibble must be 0.
spastor 0:1c358ea10753 386 */
spastor 0:1c358ea10753 387 char const app_esn_hex_string[APP_ESN_HEX_STRING_LENGTH] = "00000000";
spastor 0:1c358ea10753 388 static uint8_t app_esn_hex[APP_ESN_HEX_LENGTH] = {0};
spastor 0:1c358ea10753 389
spastor 0:1c358ea10753 390 str_to_uint8_array(app_esn_hex_string, app_esn_hex, sizeof app_esn_hex);
spastor 0:1c358ea10753 391 config_esn->data = app_esn_hex;
spastor 0:1c358ea10753 392 ASSERT(config_esn->bytes_required == sizeof app_esn_hex);
spastor 0:1c358ea10753 393
spastor 0:1c358ea10753 394 return connector_callback_continue;
spastor 0:1c358ea10753 395 }
spastor 0:1c358ea10753 396
spastor 0:1c358ea10753 397 static connector_callback_status_t app_get_meid(connector_config_pointer_data_t * const config_meid)
spastor 0:1c358ea10753 398 {
spastor 0:1c358ea10753 399 #define APP_MEID_HEX_LENGTH 7
spastor 0:1c358ea10753 400 #define APP_MEID_HEX_STRING_LENGTH (sizeof("00000000000000") - 1)
spastor 0:1c358ea10753 401 /* Each nibble corresponds a decimal digit.
spastor 0:1c358ea10753 402 * Most upper nibble must be 0.
spastor 0:1c358ea10753 403 */
spastor 0:1c358ea10753 404 char const app_meid_hex_string[APP_MEID_HEX_STRING_LENGTH] = "00000000000000";
spastor 0:1c358ea10753 405 static uint8_t app_meid_hex[APP_MEID_HEX_LENGTH] = {0};
spastor 0:1c358ea10753 406
spastor 0:1c358ea10753 407 str_to_uint8_array(app_meid_hex_string, app_meid_hex, sizeof app_meid_hex);
spastor 0:1c358ea10753 408
spastor 0:1c358ea10753 409 config_meid->data = app_meid_hex;
spastor 0:1c358ea10753 410 ASSERT(config_meid->bytes_required == sizeof app_meid_hex);
spastor 0:1c358ea10753 411
spastor 0:1c358ea10753 412 return connector_callback_continue;
spastor 0:1c358ea10753 413 }
spastor 0:1c358ea10753 414
spastor 0:1c358ea10753 415 #if !(defined CONNECTOR_IDENTITY_VERIFICATION)
spastor 0:1c358ea10753 416 static connector_callback_status_t app_get_identity_verification(connector_config_identity_verification_t * const config_identity)
spastor 0:1c358ea10753 417 {
spastor 0:1c358ea10753 418
spastor 0:1c358ea10753 419 config_identity->type = connector_identity_verification_simple;
spastor 0:1c358ea10753 420
spastor 0:1c358ea10753 421 return connector_callback_continue;
spastor 0:1c358ea10753 422 }
spastor 0:1c358ea10753 423 #endif
spastor 0:1c358ea10753 424
spastor 0:1c358ea10753 425 static connector_callback_status_t app_get_password(connector_config_pointer_string_t * const config_password)
spastor 0:1c358ea10753 426 {
spastor 0:1c358ea10753 427 static char const connector_password[] = "";
spastor 0:1c358ea10753 428
spastor 0:1c358ea10753 429 /* Return pointer to password. */
spastor 0:1c358ea10753 430 config_password->string = (char *)connector_password;
spastor 0:1c358ea10753 431 config_password->length = sizeof connector_password -1;
spastor 0:1c358ea10753 432
spastor 0:1c358ea10753 433 return connector_callback_continue;
spastor 0:1c358ea10753 434 }
spastor 0:1c358ea10753 435
spastor 0:1c358ea10753 436 /* End of Cloud Connector configuration routines */
spastor 0:1c358ea10753 437 #if (defined CONNECTOR_DEBUG)
spastor 0:1c358ea10753 438
spastor 0:1c358ea10753 439 #define enum_to_case(name) case name: result = #name; break
spastor 0:1c358ea10753 440
spastor 0:1c358ea10753 441 static char const * app_class_to_string(connector_class_id_t const value)
spastor 0:1c358ea10753 442 {
spastor 0:1c358ea10753 443 char const * result = NULL;
spastor 0:1c358ea10753 444 switch (value)
spastor 0:1c358ea10753 445 {
spastor 0:1c358ea10753 446 enum_to_case(connector_class_id_config);
spastor 0:1c358ea10753 447 enum_to_case(connector_class_id_operating_system);
spastor 0:1c358ea10753 448 enum_to_case(connector_class_id_firmware);
spastor 0:1c358ea10753 449 enum_to_case(connector_class_id_data_service);
spastor 0:1c358ea10753 450 enum_to_case(connector_class_id_remote_config);
spastor 0:1c358ea10753 451 enum_to_case(connector_class_id_file_system);
spastor 0:1c358ea10753 452 enum_to_case(connector_class_id_network_tcp);
spastor 0:1c358ea10753 453 enum_to_case(connector_class_id_network_udp);
spastor 0:1c358ea10753 454 enum_to_case(connector_class_id_network_sms);
spastor 0:1c358ea10753 455 enum_to_case(connector_class_id_status);
spastor 0:1c358ea10753 456 enum_to_case(connector_class_id_short_message);
spastor 0:1c358ea10753 457 enum_to_case(connector_class_id_data_point);
spastor 0:1c358ea10753 458 }
spastor 0:1c358ea10753 459 return result;
spastor 0:1c358ea10753 460 }
spastor 0:1c358ea10753 461
spastor 0:1c358ea10753 462 static char const * app_config_class_to_string(connector_request_id_config_t const value)
spastor 0:1c358ea10753 463 {
spastor 0:1c358ea10753 464 char const * result = NULL;
spastor 0:1c358ea10753 465 switch (value)
spastor 0:1c358ea10753 466 {
spastor 0:1c358ea10753 467 enum_to_case(connector_request_id_config_device_id);
spastor 0:1c358ea10753 468 enum_to_case(connector_request_id_config_set_device_id);
spastor 0:1c358ea10753 469 enum_to_case(connector_request_id_config_vendor_id);
spastor 0:1c358ea10753 470 enum_to_case(connector_request_id_config_device_type);
spastor 0:1c358ea10753 471 enum_to_case(connector_request_id_config_device_cloud_url);
spastor 0:1c358ea10753 472 enum_to_case(connector_request_id_config_get_device_cloud_phone);
spastor 0:1c358ea10753 473 enum_to_case(connector_request_id_config_set_device_cloud_phone);
spastor 0:1c358ea10753 474 enum_to_case(connector_request_id_config_device_cloud_service_id);
spastor 0:1c358ea10753 475 enum_to_case(connector_request_id_config_connection_type);
spastor 0:1c358ea10753 476 enum_to_case(connector_request_id_config_mac_addr);
spastor 0:1c358ea10753 477 enum_to_case(connector_request_id_config_link_speed);
spastor 0:1c358ea10753 478 enum_to_case(connector_request_id_config_phone_number);
spastor 0:1c358ea10753 479 enum_to_case(connector_request_id_config_tx_keepalive);
spastor 0:1c358ea10753 480 enum_to_case(connector_request_id_config_rx_keepalive);
spastor 0:1c358ea10753 481 enum_to_case(connector_request_id_config_wait_count);
spastor 0:1c358ea10753 482 enum_to_case(connector_request_id_config_ip_addr);
spastor 0:1c358ea10753 483 enum_to_case(connector_request_id_config_error_status);
spastor 0:1c358ea10753 484 enum_to_case(connector_request_id_config_firmware_facility);
spastor 0:1c358ea10753 485 enum_to_case(connector_request_id_config_data_service);
spastor 0:1c358ea10753 486 enum_to_case(connector_request_id_config_file_system);
spastor 0:1c358ea10753 487 enum_to_case(connector_request_id_config_remote_configuration);
spastor 0:1c358ea10753 488 enum_to_case(connector_request_id_config_max_transaction);
spastor 0:1c358ea10753 489 enum_to_case(connector_request_id_config_device_id_method);
spastor 0:1c358ea10753 490 enum_to_case(connector_request_id_config_imei_number);
spastor 0:1c358ea10753 491 enum_to_case(connector_request_id_config_network_tcp);
spastor 0:1c358ea10753 492 enum_to_case(connector_request_id_config_network_udp);
spastor 0:1c358ea10753 493 enum_to_case(connector_request_id_config_network_sms);
spastor 0:1c358ea10753 494 enum_to_case(connector_request_id_config_wan_type);
spastor 0:1c358ea10753 495 enum_to_case(connector_request_id_config_esn);
spastor 0:1c358ea10753 496 enum_to_case(connector_request_id_config_meid);
spastor 0:1c358ea10753 497 enum_to_case(connector_request_id_config_identity_verification);
spastor 0:1c358ea10753 498 enum_to_case(connector_request_id_config_password);
spastor 0:1c358ea10753 499 }
spastor 0:1c358ea10753 500 return result;
spastor 0:1c358ea10753 501 }
spastor 0:1c358ea10753 502
spastor 0:1c358ea10753 503 static char const * app_network_class_to_string(connector_request_id_network_t const value)
spastor 0:1c358ea10753 504 {
spastor 0:1c358ea10753 505 char const * result = NULL;
spastor 0:1c358ea10753 506 switch (value)
spastor 0:1c358ea10753 507 {
spastor 0:1c358ea10753 508 enum_to_case(connector_request_id_network_open);
spastor 0:1c358ea10753 509 enum_to_case(connector_request_id_network_send);
spastor 0:1c358ea10753 510 enum_to_case(connector_request_id_network_receive);
spastor 0:1c358ea10753 511 enum_to_case(connector_request_id_network_close);
spastor 0:1c358ea10753 512 }
spastor 0:1c358ea10753 513 return result;
spastor 0:1c358ea10753 514 }
spastor 0:1c358ea10753 515
spastor 0:1c358ea10753 516 static char const * app_os_class_to_string(connector_request_id_os_t const value)
spastor 0:1c358ea10753 517 {
spastor 0:1c358ea10753 518 char const * result = NULL;
spastor 0:1c358ea10753 519 switch (value)
spastor 0:1c358ea10753 520 {
spastor 0:1c358ea10753 521 enum_to_case(connector_request_id_os_malloc);
spastor 0:1c358ea10753 522 enum_to_case(connector_request_id_os_free);
spastor 0:1c358ea10753 523 enum_to_case(connector_request_id_os_system_up_time);
spastor 0:1c358ea10753 524 enum_to_case(connector_request_id_os_yield);
spastor 0:1c358ea10753 525 enum_to_case(connector_request_id_os_reboot);
spastor 0:1c358ea10753 526 }
spastor 0:1c358ea10753 527 return result;
spastor 0:1c358ea10753 528 }
spastor 0:1c358ea10753 529
spastor 0:1c358ea10753 530 #if (defined CONNECTOR_FIRMWARE_SERVICE)
spastor 0:1c358ea10753 531 static char const * app_firmware_class_to_string(connector_request_id_firmware_t const value)
spastor 0:1c358ea10753 532 {
spastor 0:1c358ea10753 533 char const * result = NULL;
spastor 0:1c358ea10753 534 switch (value)
spastor 0:1c358ea10753 535 {
spastor 0:1c358ea10753 536 enum_to_case(connector_request_id_firmware_target_count);
spastor 0:1c358ea10753 537 enum_to_case(connector_request_id_firmware_info);
spastor 0:1c358ea10753 538 enum_to_case(connector_request_id_firmware_download_start);
spastor 0:1c358ea10753 539 enum_to_case(connector_request_id_firmware_download_data);
spastor 0:1c358ea10753 540 enum_to_case(connector_request_id_firmware_download_complete);
spastor 0:1c358ea10753 541 enum_to_case(connector_request_id_firmware_download_abort);
spastor 0:1c358ea10753 542 enum_to_case(connector_request_id_firmware_target_reset);
spastor 0:1c358ea10753 543 }
spastor 0:1c358ea10753 544 return result;
spastor 0:1c358ea10753 545 }
spastor 0:1c358ea10753 546 #endif
spastor 0:1c358ea10753 547
spastor 0:1c358ea10753 548 #if (defined CONNECTOR_RCI_SERVICE)
spastor 0:1c358ea10753 549 static char const * app_remote_config_class_to_string(connector_request_id_remote_config_t const value)
spastor 0:1c358ea10753 550 {
spastor 0:1c358ea10753 551 char const * result = NULL;
spastor 0:1c358ea10753 552 switch (value)
spastor 0:1c358ea10753 553 {
spastor 0:1c358ea10753 554 enum_to_case(connector_request_id_remote_config_session_start);
spastor 0:1c358ea10753 555 enum_to_case(connector_request_id_remote_config_action_start);
spastor 0:1c358ea10753 556 enum_to_case(connector_request_id_remote_config_group_start);
spastor 0:1c358ea10753 557 enum_to_case(connector_request_id_remote_config_group_process);
spastor 0:1c358ea10753 558 enum_to_case(connector_request_id_remote_config_group_end);
spastor 0:1c358ea10753 559 enum_to_case(connector_request_id_remote_config_action_end);
spastor 0:1c358ea10753 560 enum_to_case(connector_request_id_remote_config_session_end);
spastor 0:1c358ea10753 561 enum_to_case(connector_request_id_remote_config_session_cancel);
spastor 0:1c358ea10753 562 }
spastor 0:1c358ea10753 563 return result;
spastor 0:1c358ea10753 564 }
spastor 0:1c358ea10753 565 #endif
spastor 0:1c358ea10753 566
spastor 0:1c358ea10753 567 #if (defined CONNECTOR_FILE_SYSTEM)
spastor 0:1c358ea10753 568 static char const * app_file_system_class_to_string(connector_request_id_file_system_t const value)
spastor 0:1c358ea10753 569 {
spastor 0:1c358ea10753 570 char const * result = NULL;
spastor 0:1c358ea10753 571 switch (value)
spastor 0:1c358ea10753 572 {
spastor 0:1c358ea10753 573 enum_to_case(connector_request_id_file_system_open);
spastor 0:1c358ea10753 574 enum_to_case(connector_request_id_file_system_read);
spastor 0:1c358ea10753 575 enum_to_case(connector_request_id_file_system_write);
spastor 0:1c358ea10753 576 enum_to_case(connector_request_id_file_system_lseek);
spastor 0:1c358ea10753 577 enum_to_case(connector_request_id_file_system_ftruncate);
spastor 0:1c358ea10753 578 enum_to_case(connector_request_id_file_system_close);
spastor 0:1c358ea10753 579 enum_to_case(connector_request_id_file_system_remove);
spastor 0:1c358ea10753 580 enum_to_case(connector_request_id_file_system_stat);
spastor 0:1c358ea10753 581 enum_to_case(connector_request_id_file_system_stat_dir_entry);
spastor 0:1c358ea10753 582 enum_to_case(connector_request_id_file_system_opendir);
spastor 0:1c358ea10753 583 enum_to_case(connector_request_id_file_system_readdir);
spastor 0:1c358ea10753 584 enum_to_case(connector_request_id_file_system_closedir);
spastor 0:1c358ea10753 585 enum_to_case(connector_request_id_file_system_get_error);
spastor 0:1c358ea10753 586 enum_to_case(connector_request_id_file_system_session_error);
spastor 0:1c358ea10753 587 enum_to_case(connector_request_id_file_system_hash);
spastor 0:1c358ea10753 588 }
spastor 0:1c358ea10753 589 return result;
spastor 0:1c358ea10753 590 }
spastor 0:1c358ea10753 591 #endif
spastor 0:1c358ea10753 592
spastor 0:1c358ea10753 593 #if (defined CONNECTOR_DATA_SERVICE)
spastor 0:1c358ea10753 594 static char const * app_data_service_class_to_string(connector_request_id_data_service_t const value)
spastor 0:1c358ea10753 595 {
spastor 0:1c358ea10753 596 char const * result = NULL;
spastor 0:1c358ea10753 597 switch (value)
spastor 0:1c358ea10753 598 {
spastor 0:1c358ea10753 599 enum_to_case(connector_request_id_data_service_send_length);
spastor 0:1c358ea10753 600 enum_to_case(connector_request_id_data_service_send_data);
spastor 0:1c358ea10753 601 enum_to_case(connector_request_id_data_service_send_status);
spastor 0:1c358ea10753 602 enum_to_case(connector_request_id_data_service_send_response);
spastor 0:1c358ea10753 603 enum_to_case(connector_request_id_data_service_receive_target);
spastor 0:1c358ea10753 604 enum_to_case(connector_request_id_data_service_receive_data);
spastor 0:1c358ea10753 605 enum_to_case(connector_request_id_data_service_receive_status);
spastor 0:1c358ea10753 606 enum_to_case(connector_request_id_data_service_receive_reply_length);
spastor 0:1c358ea10753 607 enum_to_case(connector_request_id_data_service_receive_reply_data);
spastor 0:1c358ea10753 608 }
spastor 0:1c358ea10753 609 return result;
spastor 0:1c358ea10753 610 }
spastor 0:1c358ea10753 611 #endif
spastor 0:1c358ea10753 612
spastor 0:1c358ea10753 613 #if (defined CONNECTOR_DATA_POINTS)
spastor 0:1c358ea10753 614 static char const * app_data_point_class_to_string(connector_request_id_data_point_t const value)
spastor 0:1c358ea10753 615 {
spastor 0:1c358ea10753 616 char const * result = NULL;
spastor 0:1c358ea10753 617 switch (value)
spastor 0:1c358ea10753 618 {
spastor 0:1c358ea10753 619 enum_to_case(connector_request_id_data_point_binary_response);
spastor 0:1c358ea10753 620 enum_to_case(connector_request_id_data_point_binary_status);
spastor 0:1c358ea10753 621 enum_to_case(connector_request_id_data_point_single_response);
spastor 0:1c358ea10753 622 enum_to_case(connector_request_id_data_point_single_status);
spastor 0:1c358ea10753 623 }
spastor 0:1c358ea10753 624 return result;
spastor 0:1c358ea10753 625 }
spastor 0:1c358ea10753 626 #endif
spastor 0:1c358ea10753 627
spastor 0:1c358ea10753 628 static char const * app_status_class_to_string(connector_request_id_status_t const value)
spastor 0:1c358ea10753 629 {
spastor 0:1c358ea10753 630 char const * result = NULL;
spastor 0:1c358ea10753 631 switch (value)
spastor 0:1c358ea10753 632 {
spastor 0:1c358ea10753 633 enum_to_case(connector_request_id_status_tcp);
spastor 0:1c358ea10753 634 enum_to_case(connector_request_id_status_stop_completed);
spastor 0:1c358ea10753 635 }
spastor 0:1c358ea10753 636 return result;
spastor 0:1c358ea10753 637 }
spastor 0:1c358ea10753 638
spastor 0:1c358ea10753 639 #if (defined CONNECTOR_SHORT_MESSAGE)
spastor 0:1c358ea10753 640 static char const * app_sm_class_to_string(connector_request_id_sm_t const value)
spastor 0:1c358ea10753 641 {
spastor 0:1c358ea10753 642 char const * result = NULL;
spastor 0:1c358ea10753 643 switch (value)
spastor 0:1c358ea10753 644 {
spastor 0:1c358ea10753 645 enum_to_case(connector_request_id_sm_ping_request);
spastor 0:1c358ea10753 646 enum_to_case(connector_request_id_sm_ping_response);
spastor 0:1c358ea10753 647 enum_to_case(connector_request_id_sm_cli_request);
spastor 0:1c358ea10753 648 enum_to_case(connector_request_id_sm_cli_response);
spastor 0:1c358ea10753 649 enum_to_case(connector_request_id_sm_cli_response_length);
spastor 0:1c358ea10753 650 enum_to_case(connector_request_id_sm_cli_status);
spastor 0:1c358ea10753 651 enum_to_case(connector_request_id_sm_more_data);
spastor 0:1c358ea10753 652 enum_to_case(connector_request_id_sm_opaque_response);
spastor 0:1c358ea10753 653 enum_to_case(connector_request_id_sm_config_request);
spastor 0:1c358ea10753 654 }
spastor 0:1c358ea10753 655 return result;
spastor 0:1c358ea10753 656 }
spastor 0:1c358ea10753 657 #endif
spastor 0:1c358ea10753 658
spastor 0:1c358ea10753 659 static char const * app_status_error_to_string(connector_status_t const value)
spastor 0:1c358ea10753 660 {
spastor 0:1c358ea10753 661 char const * result = NULL;
spastor 0:1c358ea10753 662 switch (value)
spastor 0:1c358ea10753 663 {
spastor 0:1c358ea10753 664 enum_to_case(connector_success);
spastor 0:1c358ea10753 665 enum_to_case(connector_init_error);
spastor 0:1c358ea10753 666 enum_to_case(connector_abort);
spastor 0:1c358ea10753 667 enum_to_case(connector_invalid_data_size);
spastor 0:1c358ea10753 668 enum_to_case(connector_invalid_data_range);
spastor 0:1c358ea10753 669 enum_to_case(connector_keepalive_error);
spastor 0:1c358ea10753 670 enum_to_case(connector_invalid_data);
spastor 0:1c358ea10753 671 enum_to_case(connector_device_terminated);
spastor 0:1c358ea10753 672 enum_to_case(connector_service_busy);
spastor 0:1c358ea10753 673 enum_to_case(connector_invalid_response);
spastor 0:1c358ea10753 674 enum_to_case(connector_no_resource);
spastor 0:1c358ea10753 675 enum_to_case(connector_unavailable);
spastor 0:1c358ea10753 676 enum_to_case(connector_idle);
spastor 0:1c358ea10753 677 enum_to_case(connector_working);
spastor 0:1c358ea10753 678 enum_to_case(connector_pending);
spastor 0:1c358ea10753 679 enum_to_case(connector_active);
spastor 0:1c358ea10753 680 enum_to_case(connector_device_error);
spastor 0:1c358ea10753 681 enum_to_case(connector_open_error);
spastor 0:1c358ea10753 682
spastor 0:1c358ea10753 683 enum_to_case(connector_invalid_payload_packet);
spastor 0:1c358ea10753 684 enum_to_case(connector_bad_version);
spastor 0:1c358ea10753 685 enum_to_case(connector_exceed_timeout);
spastor 0:1c358ea10753 686
spastor 0:1c358ea10753 687 }
spastor 0:1c358ea10753 688 return result;
spastor 0:1c358ea10753 689 }
spastor 0:1c358ea10753 690
spastor 0:1c358ea10753 691 /*
spastor 0:1c358ea10753 692 * This routine is called when a configuration error is encountered by Cloud Connector.
spastor 0:1c358ea10753 693 * This is currently used as a debug tool for finding configuration errors.
spastor 0:1c358ea10753 694 */
spastor 0:1c358ea10753 695 static connector_callback_status_t app_config_error(connector_config_error_status_t const * const error_data)
spastor 0:1c358ea10753 696 {
spastor 0:1c358ea10753 697
spastor 0:1c358ea10753 698 connector_callback_status_t result = connector_callback_continue;
spastor 0:1c358ea10753 699
spastor 0:1c358ea10753 700 APP_DEBUG("app_config_error: Class: %s (%d) ", app_class_to_string(error_data->class_id), error_data->class_id);
spastor 0:1c358ea10753 701
spastor 0:1c358ea10753 702 switch (error_data->class_id)
spastor 0:1c358ea10753 703 {
spastor 0:1c358ea10753 704 case connector_class_id_config:
spastor 0:1c358ea10753 705 APP_DEBUG("Request: %s (%d) ", app_config_class_to_string(error_data->request_id.config_request), error_data->request_id.config_request);
spastor 0:1c358ea10753 706 break;
spastor 0:1c358ea10753 707 case connector_class_id_network_tcp:
spastor 0:1c358ea10753 708 case connector_class_id_network_udp:
spastor 0:1c358ea10753 709 case connector_class_id_network_sms:
spastor 0:1c358ea10753 710 APP_DEBUG("Request: %s (%d) ", app_network_class_to_string(error_data->request_id.network_request), error_data->request_id.network_request);
spastor 0:1c358ea10753 711 break;
spastor 0:1c358ea10753 712 case connector_class_id_operating_system:
spastor 0:1c358ea10753 713 APP_DEBUG("Request: %s (%d) ", app_os_class_to_string(error_data->request_id.os_request), error_data->request_id.os_request);
spastor 0:1c358ea10753 714 break;
spastor 0:1c358ea10753 715
spastor 0:1c358ea10753 716 #if (defined CONNECTOR_FIRMWARE_SERVICE)
spastor 0:1c358ea10753 717 case connector_class_id_firmware:
spastor 0:1c358ea10753 718 APP_DEBUG("Request: %s (%d) ", app_firmware_class_to_string(error_data->request_id.firmware_request), error_data->request_id.firmware_request);
spastor 0:1c358ea10753 719 break;
spastor 0:1c358ea10753 720 #endif
spastor 0:1c358ea10753 721
spastor 0:1c358ea10753 722 #if (defined CONNECTOR_DATA_SERVICE)
spastor 0:1c358ea10753 723 case connector_class_id_data_service:
spastor 0:1c358ea10753 724 APP_DEBUG("Request: %s (%d) ", app_data_service_class_to_string(error_data->request_id.data_service_request), error_data->request_id.data_service_request);
spastor 0:1c358ea10753 725 break;
spastor 0:1c358ea10753 726 #endif
spastor 0:1c358ea10753 727
spastor 0:1c358ea10753 728 #if (defined CONNECTOR_DATA_POINTS)
spastor 0:1c358ea10753 729 case connector_class_id_data_point:
spastor 0:1c358ea10753 730 APP_DEBUG("Request: %s (%d) ", app_data_point_class_to_string(error_data->request_id.data_point_request), error_data->request_id.data_point_request);
spastor 0:1c358ea10753 731 break;
spastor 0:1c358ea10753 732 #endif
spastor 0:1c358ea10753 733
spastor 0:1c358ea10753 734 #if (defined CONNECTOR_FILE_SYSTEM)
spastor 0:1c358ea10753 735 case connector_class_id_file_system:
spastor 0:1c358ea10753 736 APP_DEBUG("Request: %s (%d) ", app_file_system_class_to_string(error_data->request_id.file_system_request), error_data->request_id.file_system_request);
spastor 0:1c358ea10753 737 break;
spastor 0:1c358ea10753 738 #endif
spastor 0:1c358ea10753 739
spastor 0:1c358ea10753 740 #if (defined CONNECTOR_RCI_SERVICE)
spastor 0:1c358ea10753 741 case connector_class_id_remote_config:
spastor 0:1c358ea10753 742 APP_DEBUG("Request: %s (%d) ", app_remote_config_class_to_string(error_data->request_id.remote_config_request), error_data->request_id.remote_config_request);
spastor 0:1c358ea10753 743 break;
spastor 0:1c358ea10753 744 #endif
spastor 0:1c358ea10753 745
spastor 0:1c358ea10753 746 case connector_class_id_status:
spastor 0:1c358ea10753 747 APP_DEBUG("Request: %s (%d) ", app_status_class_to_string(error_data->request_id.status_request), error_data->request_id.status_request);
spastor 0:1c358ea10753 748 break;
spastor 0:1c358ea10753 749
spastor 0:1c358ea10753 750 #if (defined CONNECTOR_SHORT_MESSAGE)
spastor 0:1c358ea10753 751 case connector_class_id_short_message:
spastor 0:1c358ea10753 752 APP_DEBUG("Request: %s (%d) ", app_sm_class_to_string(error_data->request_id.sm_request), error_data->request_id.sm_request);
spastor 0:1c358ea10753 753 break;
spastor 0:1c358ea10753 754 #endif
spastor 0:1c358ea10753 755
spastor 0:1c358ea10753 756 default:
spastor 0:1c358ea10753 757 APP_DEBUG("unknown class id = %d ", error_data->class_id);
spastor 0:1c358ea10753 758 break;
spastor 0:1c358ea10753 759 }
spastor 0:1c358ea10753 760
spastor 0:1c358ea10753 761 APP_DEBUG("Error status: %s (%d)\n", app_status_error_to_string(error_data->status), error_data->status);
spastor 0:1c358ea10753 762
spastor 0:1c358ea10753 763 return result;
spastor 0:1c358ea10753 764 }
spastor 0:1c358ea10753 765 #endif
spastor 0:1c358ea10753 766
spastor 0:1c358ea10753 767 /*
spastor 0:1c358ea10753 768 * Configuration callback routine.
spastor 0:1c358ea10753 769 */
spastor 0:1c358ea10753 770 connector_callback_status_t app_config_handler(connector_request_id_config_t const request_id, void * const data)
spastor 0:1c358ea10753 771 {
spastor 0:1c358ea10753 772 connector_callback_status_t status;
spastor 0:1c358ea10753 773
spastor 0:1c358ea10753 774
spastor 0:1c358ea10753 775 switch (request_id)
spastor 0:1c358ea10753 776 {
spastor 0:1c358ea10753 777 case connector_request_id_config_device_id:
spastor 0:1c358ea10753 778 status = app_load_device_id(data);
spastor 0:1c358ea10753 779 break;
spastor 0:1c358ea10753 780
spastor 0:1c358ea10753 781 case connector_request_id_config_set_device_id:
spastor 0:1c358ea10753 782 status = app_save_device_id(data);
spastor 0:1c358ea10753 783 break;
spastor 0:1c358ea10753 784
spastor 0:1c358ea10753 785 case connector_request_id_config_mac_addr:
spastor 0:1c358ea10753 786 status = app_get_mac_addr(data);
spastor 0:1c358ea10753 787 break;
spastor 0:1c358ea10753 788
spastor 0:1c358ea10753 789 #if !(defined CONNECTOR_VENDOR_ID)
spastor 0:1c358ea10753 790 case connector_request_id_config_vendor_id:
spastor 0:1c358ea10753 791 status = app_get_vendor_id(data);
spastor 0:1c358ea10753 792 break;
spastor 0:1c358ea10753 793 #endif
spastor 0:1c358ea10753 794
spastor 0:1c358ea10753 795 #if !(defined CONNECTOR_DEVICE_TYPE)
spastor 0:1c358ea10753 796 case connector_request_id_config_device_type:
spastor 0:1c358ea10753 797 status = app_get_device_type(data);
spastor 0:1c358ea10753 798 break;
spastor 0:1c358ea10753 799 #endif
spastor 0:1c358ea10753 800
spastor 0:1c358ea10753 801 #if !(defined CONNECTOR_CLOUD_URL)
spastor 0:1c358ea10753 802 case connector_request_id_config_device_cloud_url:
spastor 0:1c358ea10753 803 status = app_get_device_cloud_url(data);
spastor 0:1c358ea10753 804 break;
spastor 0:1c358ea10753 805 #endif
spastor 0:1c358ea10753 806
spastor 0:1c358ea10753 807 #if !(defined CONNECTOR_CLOUD_PHONE)
spastor 0:1c358ea10753 808 case connector_request_id_config_get_device_cloud_phone:
spastor 0:1c358ea10753 809 status = app_get_device_cloud_phone(data);
spastor 0:1c358ea10753 810 break;
spastor 0:1c358ea10753 811
spastor 0:1c358ea10753 812 case connector_request_id_config_set_device_cloud_phone:
spastor 0:1c358ea10753 813 status = app_set_device_cloud_phone(data);
spastor 0:1c358ea10753 814 break;
spastor 0:1c358ea10753 815 #endif
spastor 0:1c358ea10753 816
spastor 0:1c358ea10753 817 #if !(defined CONNECTOR_CLOUD_SERVICE_ID)
spastor 0:1c358ea10753 818 case connector_request_id_config_device_cloud_service_id:
spastor 0:1c358ea10753 819 status = app_get_device_cloud_service_id(data);
spastor 0:1c358ea10753 820 break;
spastor 0:1c358ea10753 821 #endif
spastor 0:1c358ea10753 822
spastor 0:1c358ea10753 823 #if !(defined CONNECTOR_CONNECTION_TYPE)
spastor 0:1c358ea10753 824 case connector_request_id_config_connection_type:
spastor 0:1c358ea10753 825 status = app_get_connection_type(data);
spastor 0:1c358ea10753 826 break;
spastor 0:1c358ea10753 827 #endif
spastor 0:1c358ea10753 828
spastor 0:1c358ea10753 829 #if !(defined CONNECTOR_WAN_LINK_SPEED_IN_BITS_PER_SECOND)
spastor 0:1c358ea10753 830 case connector_request_id_config_link_speed:
spastor 0:1c358ea10753 831 status = app_get_link_speed(data);
spastor 0:1c358ea10753 832 break;
spastor 0:1c358ea10753 833 #endif
spastor 0:1c358ea10753 834
spastor 0:1c358ea10753 835 #if !(defined CONNECTOR_WAN_PHONE_NUMBER_DIALED)
spastor 0:1c358ea10753 836 case connector_request_id_config_phone_number:
spastor 0:1c358ea10753 837 status = app_get_phone_number(data);
spastor 0:1c358ea10753 838 break;
spastor 0:1c358ea10753 839 #endif
spastor 0:1c358ea10753 840
spastor 0:1c358ea10753 841 #if !(defined CONNECTOR_TX_KEEPALIVE_IN_SECONDS)
spastor 0:1c358ea10753 842 case connector_request_id_config_tx_keepalive:
spastor 0:1c358ea10753 843 status = app_get_tx_keepalive_interval(data);
spastor 0:1c358ea10753 844 break;
spastor 0:1c358ea10753 845 #endif
spastor 0:1c358ea10753 846
spastor 0:1c358ea10753 847 #if !(defined CONNECTOR_RX_KEEPALIVE_IN_SECONDS)
spastor 0:1c358ea10753 848 case connector_request_id_config_rx_keepalive:
spastor 0:1c358ea10753 849 status = app_get_rx_keepalive_interval(data);
spastor 0:1c358ea10753 850 break;
spastor 0:1c358ea10753 851 #endif
spastor 0:1c358ea10753 852
spastor 0:1c358ea10753 853 #if !(defined CONNECTOR_WAIT_COUNT)
spastor 0:1c358ea10753 854 case connector_request_id_config_wait_count:
spastor 0:1c358ea10753 855 status = app_get_wait_count(data);
spastor 0:1c358ea10753 856 break;
spastor 0:1c358ea10753 857 #endif
spastor 0:1c358ea10753 858
spastor 0:1c358ea10753 859 case connector_request_id_config_ip_addr:
spastor 0:1c358ea10753 860 status = app_get_ip_address(data);
spastor 0:1c358ea10753 861 break;
spastor 0:1c358ea10753 862
spastor 0:1c358ea10753 863 #ifdef CONNECTOR_DEBUG
spastor 0:1c358ea10753 864 case connector_request_id_config_error_status:
spastor 0:1c358ea10753 865 status = app_config_error(data);
spastor 0:1c358ea10753 866 break;
spastor 0:1c358ea10753 867 #endif
spastor 0:1c358ea10753 868
spastor 0:1c358ea10753 869 #if (defined CONNECTOR_FIRMWARE_SERVICE) && !(defined CONNECTOR_FIRMWARE_SUPPORT)
spastor 0:1c358ea10753 870 case connector_request_id_config_firmware_facility:
spastor 0:1c358ea10753 871 status = app_get_firmware_support(data);
spastor 0:1c358ea10753 872 break;
spastor 0:1c358ea10753 873 #endif
spastor 0:1c358ea10753 874
spastor 0:1c358ea10753 875 #if (defined CONNECTOR_DATA_SERVICE) && !(defined CONNECTOR_DATA_SERVICE_SUPPORT)
spastor 0:1c358ea10753 876 case connector_request_id_config_data_service:
spastor 0:1c358ea10753 877 status = app_get_data_service_support(data);
spastor 0:1c358ea10753 878 break;
spastor 0:1c358ea10753 879 #endif
spastor 0:1c358ea10753 880
spastor 0:1c358ea10753 881 #if (defined CONNECTOR_FILE_SYSTEM) && !(defined CONNECTOR_FILE_SYSTEM_SUPPORT)
spastor 0:1c358ea10753 882 case connector_request_id_config_file_system:
spastor 0:1c358ea10753 883 status = app_get_file_system_support(data);
spastor 0:1c358ea10753 884 break;
spastor 0:1c358ea10753 885 #endif
spastor 0:1c358ea10753 886
spastor 0:1c358ea10753 887 #if (defined CONNECTOR_RCI_SERVICE) && !(defined CONNECTOR_REMOTE_CONFIGURATION_SUPPORT)
spastor 0:1c358ea10753 888 case connector_request_id_config_remote_configuration:
spastor 0:1c358ea10753 889 status = app_get_remote_configuration_support(data);
spastor 0:1c358ea10753 890 break;
spastor 0:1c358ea10753 891 #endif
spastor 0:1c358ea10753 892
spastor 0:1c358ea10753 893 #if ((defined CONNECTOR_DATA_SERVICE) || (defined CONNECTOR_FILE_SYSTEM) || (defined CONNECTOR_RCI_SERVICE)) && !(defined CONNECTOR_MSG_MAX_TRANSACTION)
spastor 0:1c358ea10753 894 case connector_request_id_config_max_transaction:
spastor 0:1c358ea10753 895 status = app_get_max_message_transactions(data);
spastor 0:1c358ea10753 896 break;
spastor 0:1c358ea10753 897 #endif
spastor 0:1c358ea10753 898
spastor 0:1c358ea10753 899 #if !(defined CONNECTOR_DEVICE_ID_METHOD)
spastor 0:1c358ea10753 900 case connector_request_id_config_device_id_method:
spastor 0:1c358ea10753 901 status = app_get_device_id_method(data);
spastor 0:1c358ea10753 902 break;
spastor 0:1c358ea10753 903 #endif
spastor 0:1c358ea10753 904
spastor 0:1c358ea10753 905 case connector_request_id_config_imei_number:
spastor 0:1c358ea10753 906 status = app_get_imei_number(data);
spastor 0:1c358ea10753 907 break;
spastor 0:1c358ea10753 908
spastor 0:1c358ea10753 909 #if !(defined CONNECTOR_NETWORK_TCP_START)
spastor 0:1c358ea10753 910 case connector_request_id_config_network_tcp:
spastor 0:1c358ea10753 911 status = app_start_network_tcp(data);
spastor 0:1c358ea10753 912 break;
spastor 0:1c358ea10753 913 #endif
spastor 0:1c358ea10753 914
spastor 0:1c358ea10753 915 #if !(defined CONNECTOR_NETWORK_UDP_START)
spastor 0:1c358ea10753 916 case connector_request_id_config_network_udp:
spastor 0:1c358ea10753 917 status = app_start_network_udp(data);
spastor 0:1c358ea10753 918 break;
spastor 0:1c358ea10753 919 #endif
spastor 0:1c358ea10753 920
spastor 0:1c358ea10753 921 #if !(defined CONNECTOR_NETWORK_SMS_START)
spastor 0:1c358ea10753 922 case connector_request_id_config_network_sms:
spastor 0:1c358ea10753 923 status = app_start_network_sms(data);
spastor 0:1c358ea10753 924 break;
spastor 0:1c358ea10753 925 #endif
spastor 0:1c358ea10753 926
spastor 0:1c358ea10753 927 #if !(defined CONNECTOR_WAN_TYPE)
spastor 0:1c358ea10753 928 case connector_request_id_config_wan_type:
spastor 0:1c358ea10753 929 status = app_get_wan_type(data);
spastor 0:1c358ea10753 930 break;
spastor 0:1c358ea10753 931 #endif
spastor 0:1c358ea10753 932
spastor 0:1c358ea10753 933 case connector_request_id_config_esn:
spastor 0:1c358ea10753 934 status = app_get_esn(data);
spastor 0:1c358ea10753 935 break;
spastor 0:1c358ea10753 936
spastor 0:1c358ea10753 937 case connector_request_id_config_meid:
spastor 0:1c358ea10753 938 status = app_get_meid(data);
spastor 0:1c358ea10753 939 break;
spastor 0:1c358ea10753 940
spastor 0:1c358ea10753 941 #if !(defined CONNECTOR_IDENTITY_VERIFICATION)
spastor 0:1c358ea10753 942 case connector_request_id_config_identity_verification:
spastor 0:1c358ea10753 943 status = app_get_identity_verification(data);
spastor 0:1c358ea10753 944 break;
spastor 0:1c358ea10753 945 #endif
spastor 0:1c358ea10753 946
spastor 0:1c358ea10753 947 case connector_request_id_config_password:
spastor 0:1c358ea10753 948 status = app_get_password(data);
spastor 0:1c358ea10753 949 break;
spastor 0:1c358ea10753 950
spastor 0:1c358ea10753 951 default:
spastor 0:1c358ea10753 952 APP_DEBUG("app_config_callback: unknown configuration request= %d\n", request_id);
spastor 0:1c358ea10753 953 status = connector_callback_unrecognized;
spastor 0:1c358ea10753 954 break;
spastor 0:1c358ea10753 955 }
spastor 0:1c358ea10753 956
spastor 0:1c358ea10753 957 return status;
spastor 0:1c358ea10753 958 }
spastor 0:1c358ea10753 959
spastor 0:1c358ea10753 960