Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
connector_edp_def.h
00001 /* 00002 * Copyright (c) 2013 Digi International Inc., 00003 * All rights not expressly granted are reserved. 00004 * 00005 * This Source Code Form is subject to the terms of the Mozilla Public 00006 * License, v. 2.0. If a copy of the MPL was not distributed with this file, 00007 * You can obtain one at http://mozilla.org/MPL/2.0/. 00008 * 00009 * Digi International Inc. 11001 Bren Road East, Minnetonka, MN 55343 00010 * ======================================================================= 00011 */ 00012 00013 #ifndef CONNECTOR_EDP_DEF_H_ 00014 #define CONNECTOR_EDP_DEF_H_ 00015 00016 #include "ei_packet.h" 00017 00018 #if !defined MSG_MAX_RECV_PACKET_SIZE 00019 #define MSG_MAX_RECV_PACKET_SIZE 1600 00020 #endif 00021 #if !defined MSG_MAX_SEND_PACKET_SIZE 00022 #define MSG_MAX_SEND_PACKET_SIZE 512 00023 #endif 00024 00025 #define EDP_MT_VERSION 2 00026 00027 #define DEVICE_TYPE_LENGTH 32 00028 #define CONNECTOR_MAX_TRANSACTIONS_LIMIT 255 00029 00030 /* these are limits for Tx and Rx keepalive 00031 * interval in seconds. 00032 */ 00033 #define MIN_TX_KEEPALIVE_INTERVAL_IN_SECONDS 5 00034 #define MAX_TX_KEEPALIVE_INTERVAL_IN_SECONDS 7200 00035 #define MIN_RX_KEEPALIVE_INTERVAL_IN_SECONDS 5 00036 #define MAX_RX_KEEPALIVE_INTERVAL_IN_SECONDS 7200 00037 00038 /* Limits for wait count (number of 00039 * keepalive packets) 00040 */ 00041 #define WAIT_COUNT_MIN 2 00042 #define WAIT_COUNT_MAX 64 00043 00044 /* 00045 * MT version 2 message type defines. 00046 * Refer to EDP specification rev. 14.2 for a description of MT version 2. 00047 */ 00048 #define E_MSG_MT2_TYPE_VERSION UINT32_C(0x0004) /* C -> S */ 00049 #define E_MSG_MT2_TYPE_LEGACY_EDP_VERSION UINT32_C(0x0004) /* C -> S */ 00050 #define E_MSG_MT2_TYPE_LEGACY_EDP_VER_RESP UINT32_C(0x0001) /* C <- S */ 00051 #define E_MSG_MT2_TYPE_VERSION_OK UINT32_C(0x0010) /* C <- S */ 00052 #define E_MSG_MT2_TYPE_VERSION_BAD UINT32_C(0x0011) /* C <- S */ 00053 #define E_MSG_MT2_TYPE_CLOUD_OVERLOAD UINT32_C(0x0012) /* C <- S */ 00054 #define E_MSG_MT2_TYPE_KA_RX_INTERVAL UINT32_C(0x0020) /* C -> S */ 00055 #define E_MSG_MT2_TYPE_KA_TX_INTERVAL UINT32_C(0x0021) /* C -> S */ 00056 #define E_MSG_MT2_TYPE_KA_WAIT UINT32_C(0x0022) /* C -> S */ 00057 #define E_MSG_MT2_TYPE_KA_KEEPALIVE UINT32_C(0x0030) /* bi-directional */ 00058 #define E_MSG_MT2_TYPE_PAYLOAD UINT32_C(0x0040) /* bi-directional */ 00059 00060 #define URL_PREFIX "en://" 00061 #define GET_PACKET_DATA_POINTER(p, s) (uint8_t *)(((uint8_t *)p) + (s)) 00062 00063 00064 #if (defined CONNECTOR_TX_KEEPALIVE_IN_SECONDS) 00065 #define GET_TX_KEEPALIVE_INTERVAL(connector_ptr) CONNECTOR_TX_KEEPALIVE_IN_SECONDS 00066 #else 00067 #define GET_TX_KEEPALIVE_INTERVAL(connector_ptr) connector_ptr->edp_data.config.tx_keepalive_interval 00068 #endif 00069 00070 #if (defined CONNECTOR_RX_KEEPALIVE_IN_SECONDS) 00071 #define GET_RX_KEEPALIVE_INTERVAL(connector_ptr) CONNECTOR_RX_KEEPALIVE_IN_SECONDS 00072 #else 00073 #define GET_RX_KEEPALIVE_INTERVAL(connector_ptr) connector_ptr->edp_data.config.rx_keepalive_interval 00074 #endif 00075 00076 #if (defined CONNECTOR_WAIT_COUNT) 00077 #define GET_WAIT_COUNT(connector_ptr) CONNECTOR_WAIT_COUNT 00078 #else 00079 #define GET_WAIT_COUNT(connector_ptr) connector_ptr->edp_data.config.wait_count 00080 #endif 00081 00082 #define MAX_RECEIVE_TIMEOUT_IN_SECONDS 1 00083 #define MIN_RECEIVE_TIMEOUT_IN_SECONDS 0 00084 00085 /* IRL EDP States */ 00086 typedef enum { 00087 edp_communication_connect_to_cloud, 00088 edp_communication_send_version, 00089 edp_communication_receive_version_response, 00090 edp_communication_send_keepalive, 00091 edp_initialization_send_protocol_version, 00092 edp_initialization_receive_protocol_version, 00093 edp_security_send_identity_verification, 00094 edp_security_send_device_id, 00095 #if (CONNECTOR_VERSION >= 0x02010000) 00096 edp_security_receive_device_id, 00097 #endif 00098 edp_security_send_device_cloud_url, 00099 edp_security_send_password, 00100 edp_discovery_send_vendor_id, 00101 edp_discovery_send_device_type, 00102 edp_discovery_facility, 00103 edp_discovery_send_complete, 00104 edp_facility_process 00105 00106 } connector_edp_state_t; 00107 00108 typedef enum { 00109 facility_callback_delete, 00110 facility_callback_cleanup 00111 } connector_supported_facility_cb_index_t; 00112 00113 struct connector_data; 00114 00115 typedef connector_status_t (* send_complete_cb_t)(struct connector_data * const connector_ptr, uint8_t const * const packet, connector_status_t const status, void * const user_data); 00116 00117 typedef struct connector_buffer { 00118 /* this buffer must be FIRST field in the structure 00119 * since this is used between network interface 00120 * and all facilities and facilities release the buffer 00121 * by returning the pointer of the buffer. 00122 */ 00123 uint8_t buffer[MSG_MAX_RECV_PACKET_SIZE]; 00124 struct connector_buffer * next; 00125 connector_bool_t in_use; 00126 } connector_buffer_t; 00127 00128 typedef struct connector_facility { 00129 unsigned int service_index; 00130 size_t size; 00131 connector_buffer_t * packet_buffer; 00132 void * facility_data; 00133 struct connector_facility * next; 00134 struct connector_facility * prev; 00135 uint16_t facility_num; 00136 } connector_facility_t; 00137 00138 typedef struct connector_edp_data { 00139 00140 struct { 00141 #if !(defined CONNECTOR_VENDOR_ID) 00142 uint32_t vendor_id; 00143 #endif 00144 00145 #if !(defined CONNECTOR_DEVICE_TYPE) 00146 char * device_type; 00147 size_t device_type_length; 00148 #endif 00149 00150 uint8_t * ip_addr; 00151 size_t ip_addr_length; 00152 00153 char cloud_url[CLOUD_URL_LENGTH]; 00154 size_t cloud_url_length; 00155 00156 #if !(defined CONNECTOR_IDENTITY_VERIFICATION) 00157 connector_identity_verification_t identity_verification; 00158 #endif 00159 00160 char * password; 00161 size_t password_length; 00162 00163 #if !(defined CONNECTOR_TX_KEEPALIVE_IN_SECONDS) 00164 uint16_t tx_keepalive_interval; 00165 #endif 00166 00167 #if !(defined CONNECTOR_RX_KEEPALIVE_IN_SECONDS) 00168 uint16_t rx_keepalive_interval; 00169 #endif 00170 00171 #if !(defined CONNECTOR_WAIT_COUNT) 00172 uint16_t wait_count; 00173 #endif 00174 } config; 00175 00176 struct { 00177 connector_transport_state_t initiate; 00178 connector_transport_state_t active; 00179 connector_edp_state_t edp; 00180 } state; 00181 00182 struct { 00183 struct { 00184 uint8_t buffer[MSG_MAX_SEND_PACKET_SIZE]; 00185 connector_bool_t in_use; 00186 } packet_buffer; 00187 uint8_t * ptr; 00188 size_t bytes_sent; 00189 size_t total_length; 00190 send_complete_cb_t complete_cb; 00191 void * user_data; 00192 } send_packet; 00193 00194 struct { 00195 connector_buffer_t packet_buffer; 00196 connector_buffer_t * free_packet_buffer; 00197 connector_buffer_t * data_packet; 00198 uint8_t * ptr; 00199 int index; 00200 unsigned int timeout; 00201 uint16_t packet_type; 00202 uint16_t packet_length; 00203 size_t bytes_received; 00204 size_t total_length; 00205 } receive_packet; 00206 00207 struct { 00208 connector_facility_t * current; 00209 connector_facility_t * list; 00210 uint16_t supported_mask; 00211 } facilities; 00212 00213 struct { 00214 uint8_t send_rx_packet[PACKET_EDP_HEADER_SIZE]; 00215 unsigned long last_rx_sent_time; 00216 unsigned long last_tx_received_time; 00217 uint16_t miss_tx_count; 00218 } keepalive; 00219 00220 unsigned long int connect_at; 00221 00222 connector_close_status_t close_status; 00223 connector_network_handle_t * network_handle; 00224 00225 struct { 00226 connector_bool_t is_set; 00227 connector_stop_condition_t condition; 00228 void * user_context; 00229 connector_bool_t auto_connect; 00230 } stop; 00231 00232 #if !(defined CONNECTOR_NETWORK_TCP_START) 00233 connector_connect_auto_type_t connect_type; 00234 #endif 00235 00236 } connector_edp_data_t; 00237 00238 #endif 00239
Generated on Tue Jul 12 2022 19:18:38 by
1.7.2