Update revision to use TI's mqtt and Freertos.

Dependencies:   mbed client server

Fork of cc3100_Test_mqtt_CM3 by David Fletcher

Committer:
dflet
Date:
Thu Sep 03 14:02:37 2015 +0000
Revision:
3:a8c249046181
SPI Mode change 1 to 0

Who changed what in which revision?

UserRevisionLine numberNew contents of line
dflet 3:a8c249046181 1 /*
dflet 3:a8c249046181 2 * device.h - CC31xx/CC32xx Host Driver Implementation
dflet 3:a8c249046181 3 *
dflet 3:a8c249046181 4 * Copyright (C) 2014 Texas Instruments Incorporated - http://www.ti.com/
dflet 3:a8c249046181 5 *
dflet 3:a8c249046181 6 *
dflet 3:a8c249046181 7 * Redistribution and use in source and binary forms, with or without
dflet 3:a8c249046181 8 * modification, are permitted provided that the following conditions
dflet 3:a8c249046181 9 * are met:
dflet 3:a8c249046181 10 *
dflet 3:a8c249046181 11 * Redistributions of source code must retain the above copyright
dflet 3:a8c249046181 12 * notice, this list of conditions and the following disclaimer.
dflet 3:a8c249046181 13 *
dflet 3:a8c249046181 14 * Redistributions in binary form must reproduce the above copyright
dflet 3:a8c249046181 15 * notice, this list of conditions and the following disclaimer in the
dflet 3:a8c249046181 16 * documentation and/or other materials provided with the
dflet 3:a8c249046181 17 * distribution.
dflet 3:a8c249046181 18 *
dflet 3:a8c249046181 19 * Neither the name of Texas Instruments Incorporated nor the names of
dflet 3:a8c249046181 20 * its contributors may be used to endorse or promote products derived
dflet 3:a8c249046181 21 * from this software without specific prior written permission.
dflet 3:a8c249046181 22 *
dflet 3:a8c249046181 23 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
dflet 3:a8c249046181 24 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
dflet 3:a8c249046181 25 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
dflet 3:a8c249046181 26 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
dflet 3:a8c249046181 27 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
dflet 3:a8c249046181 28 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
dflet 3:a8c249046181 29 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
dflet 3:a8c249046181 30 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
dflet 3:a8c249046181 31 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
dflet 3:a8c249046181 32 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
dflet 3:a8c249046181 33 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
dflet 3:a8c249046181 34 *
dflet 3:a8c249046181 35 */
dflet 3:a8c249046181 36
dflet 3:a8c249046181 37 #ifndef DEVICE_H_
dflet 3:a8c249046181 38 #define DEVICE_H_
dflet 3:a8c249046181 39
dflet 3:a8c249046181 40 /*****************************************************************************/
dflet 3:a8c249046181 41 /* Include files */
dflet 3:a8c249046181 42 /*****************************************************************************/
dflet 3:a8c249046181 43 #include "mbed.h"
dflet 3:a8c249046181 44 #include "cc3100_simplelink.h"
dflet 3:a8c249046181 45 #include "cc3100_driver.h"
dflet 3:a8c249046181 46 #include "cc3100_wlan_rx_filters.h"
dflet 3:a8c249046181 47
dflet 3:a8c249046181 48 #include "cc3100_spi.h"
dflet 3:a8c249046181 49 #include "cc3100_netcfg.h"
dflet 3:a8c249046181 50
dflet 3:a8c249046181 51 namespace mbed_cc3100 {
dflet 3:a8c249046181 52
dflet 3:a8c249046181 53 /*!
dflet 3:a8c249046181 54
dflet 3:a8c249046181 55 \addtogroup device
dflet 3:a8c249046181 56 @{
dflet 3:a8c249046181 57
dflet 3:a8c249046181 58 */
dflet 3:a8c249046181 59 const int16_t ROLE_UNKNOWN_ERR = -1;
dflet 3:a8c249046181 60
dflet 3:a8c249046181 61 const uint16_t MAX_BUFF_SIZE = 1460;
dflet 3:a8c249046181 62 extern uint32_t g_PingPacketsRecv;
dflet 3:a8c249046181 63 extern uint32_t g_GatewayIP;
dflet 3:a8c249046181 64 extern uint32_t g_StationIP;
dflet 3:a8c249046181 65 extern uint32_t g_DestinationIP;
dflet 3:a8c249046181 66 extern uint32_t g_BytesReceived; // variable to store the file size
dflet 3:a8c249046181 67 extern uint32_t g_Status;
dflet 3:a8c249046181 68 extern uint8_t g_buff[MAX_BUFF_SIZE+1];
dflet 3:a8c249046181 69 extern int32_t g_SockID;
dflet 3:a8c249046181 70
dflet 3:a8c249046181 71
dflet 3:a8c249046181 72 /* File on the serial flash */
dflet 3:a8c249046181 73 #define FILE_NAME "cc3000_module.pdf"
dflet 3:a8c249046181 74 #define HOST_NAME "www.ti.com"
dflet 3:a8c249046181 75
dflet 3:a8c249046181 76 #define HTTP_FILE_NOT_FOUND "404 Not Found" /* HTTP file not found response */
dflet 3:a8c249046181 77 #define HTTP_STATUS_OK "200 OK" /* HTTP status ok response */
dflet 3:a8c249046181 78 #define HTTP_CONTENT_LENGTH "Content-Length:" /* HTTP content length header */
dflet 3:a8c249046181 79 #define HTTP_TRANSFER_ENCODING "Transfer-Encoding:" /* HTTP transfer encoding header */
dflet 3:a8c249046181 80 #define HTTP_ENCODING_CHUNKED "chunked" /* HTTP transfer encoding header value */
dflet 3:a8c249046181 81 #define HTTP_CONNECTION "Connection:" /* HTTP Connection header */
dflet 3:a8c249046181 82 #define HTTP_CONNECTION_CLOSE "close" /* HTTP Connection header value */
dflet 3:a8c249046181 83 #define HTTP_END_OF_HEADER "\r\n\r\n" /* string marking the end of headers in response */
dflet 3:a8c249046181 84
dflet 3:a8c249046181 85 /*****************************************************************************/
dflet 3:a8c249046181 86 /* Macro declarations */
dflet 3:a8c249046181 87 /*****************************************************************************/
dflet 3:a8c249046181 88
dflet 3:a8c249046181 89 const uint16_t IP_LEASE_TIME = 3600;
dflet 3:a8c249046181 90
dflet 3:a8c249046181 91 const uint16_t SIZE_45K = 46080; /* Serial flash file size 45 KB */
dflet 3:a8c249046181 92 const uint16_t READ_SIZE = 1450;
dflet 3:a8c249046181 93 const uint8_t SPACE = 32;
dflet 3:a8c249046181 94
dflet 3:a8c249046181 95 const uint16_t PING_INTERVAL = 1000;
dflet 3:a8c249046181 96 const uint8_t PING_SIZE = 20;
dflet 3:a8c249046181 97 const uint16_t PING_TIMEOUT = 3000;
dflet 3:a8c249046181 98 const uint8_t PING_ATTEMPTS = 3;
dflet 3:a8c249046181 99 const uint8_t PING_PKT_SIZE = 20;
dflet 3:a8c249046181 100
dflet 3:a8c249046181 101 const uint8_t SL_STOP_TIMEOUT = 0xFF;
dflet 3:a8c249046181 102
dflet 3:a8c249046181 103 /* SL internal Error codes */
dflet 3:a8c249046181 104
dflet 3:a8c249046181 105 /* Receive this error in case there are no resources to issue the command
dflet 3:a8c249046181 106 If possible, increase the number of MAX_CUNCURENT_ACTIONS (result in memory increase)
dflet 3:a8c249046181 107 If not, try again later */
dflet 3:a8c249046181 108 const int16_t SL_POOL_IS_EMPTY = (-2000);
dflet 3:a8c249046181 109
dflet 3:a8c249046181 110 /* Receive this error in case a given length for RX buffer was too small.
dflet 3:a8c249046181 111 Receive payload was bigger than the given buffer size. Therefore, payload is cut according to receive size
dflet 3:a8c249046181 112 Recommend to increase buffer size */
dflet 3:a8c249046181 113 const int16_t SL_ESMALLBUF = (-2001);
dflet 3:a8c249046181 114
dflet 3:a8c249046181 115 /* Receive this error in case zero length is supplied to a "get" API
dflet 3:a8c249046181 116 Recommend to supply length according to requested information (view options defines for help) */
dflet 3:a8c249046181 117 const int16_t SL_EZEROLEN = (-2002);
dflet 3:a8c249046181 118
dflet 3:a8c249046181 119 /* User supplied invalid parameter */
dflet 3:a8c249046181 120 const int16_t SL_INVALPARAM = (-2003);
dflet 3:a8c249046181 121
dflet 3:a8c249046181 122 /* Failed to open interface */
dflet 3:a8c249046181 123 const int16_t SL_BAD_INTERFACE = (-2004);
dflet 3:a8c249046181 124
dflet 3:a8c249046181 125 /* End of SL internal Error codes */
dflet 3:a8c249046181 126
dflet 3:a8c249046181 127 /*****************************************************************************/
dflet 3:a8c249046181 128 /* Errors returned from the general error async event */
dflet 3:a8c249046181 129 /*****************************************************************************/
dflet 3:a8c249046181 130
dflet 3:a8c249046181 131 /* Use bit 32: Lower bits of status variable are used for NWP events
dflet 3:a8c249046181 132 * 1 in a 'status_variable', the device has completed the ping operation
dflet 3:a8c249046181 133 * 0 in a 'status_variable', the device has not completed the ping operation
dflet 3:a8c249046181 134 */
dflet 3:a8c249046181 135 //const uint32_t STATUS_BIT_PING_DONE = 31;
dflet 3:a8c249046181 136
dflet 3:a8c249046181 137 /* Status bits - These are used to set/reset the corresponding bits in a 'status_variable' */
dflet 3:a8c249046181 138 typedef enum {
dflet 3:a8c249046181 139 STATUS_BIT_CONNECTION = 0, /* If this bit is:
dflet 3:a8c249046181 140 * 1 in a 'status_variable', the device is connected to the AP
dflet 3:a8c249046181 141 * 0 in a 'status_variable', the device is not connected to the AP
dflet 3:a8c249046181 142 */
dflet 3:a8c249046181 143
dflet 3:a8c249046181 144 STATUS_BIT_STA_CONNECTED, /* If this bit is:
dflet 3:a8c249046181 145 * 1 in a 'status_variable', client is connected to device
dflet 3:a8c249046181 146 * 0 in a 'status_variable', client is not connected to device
dflet 3:a8c249046181 147 */
dflet 3:a8c249046181 148
dflet 3:a8c249046181 149 STATUS_BIT_IP_ACQUIRED, /* If this bit is:
dflet 3:a8c249046181 150 * 1 in a 'status_variable', the device has acquired an IP
dflet 3:a8c249046181 151 * 0 in a 'status_variable', the device has not acquired an IP
dflet 3:a8c249046181 152 */
dflet 3:a8c249046181 153
dflet 3:a8c249046181 154 STATUS_BIT_IP_LEASED, /* If this bit is:
dflet 3:a8c249046181 155 * 1 in a 'status_variable', the device has leased an IP
dflet 3:a8c249046181 156 * 0 in a 'status_variable', the device has not leased an IP
dflet 3:a8c249046181 157 */
dflet 3:a8c249046181 158
dflet 3:a8c249046181 159 STATUS_BIT_CONNECTION_FAILED, /* If this bit is:
dflet 3:a8c249046181 160 * 1 in a 'status_variable', failed to connect to device
dflet 3:a8c249046181 161 * 0 in a 'status_variable'
dflet 3:a8c249046181 162 */
dflet 3:a8c249046181 163
dflet 3:a8c249046181 164 STATUS_BIT_P2P_NEG_REQ_RECEIVED,/* If this bit is:
dflet 3:a8c249046181 165 * 1 in a 'status_variable', connection requested by remote wifi-direct device
dflet 3:a8c249046181 166 * 0 in a 'status_variable',
dflet 3:a8c249046181 167 */
dflet 3:a8c249046181 168 STATUS_BIT_SMARTCONFIG_DONE, /* If this bit is:
dflet 3:a8c249046181 169 * 1 in a 'status_variable', smartconfig completed
dflet 3:a8c249046181 170 * 0 in a 'status_variable', smartconfig event couldn't complete
dflet 3:a8c249046181 171 */
dflet 3:a8c249046181 172
dflet 3:a8c249046181 173 STATUS_BIT_SMARTCONFIG_STOPPED, /* If this bit is:
dflet 3:a8c249046181 174 * 1 in a 'status_variable', smartconfig process stopped
dflet 3:a8c249046181 175 * 0 in a 'status_variable', smartconfig process running
dflet 3:a8c249046181 176 */
dflet 3:a8c249046181 177
dflet 3:a8c249046181 178 STATUS_BIT_PING_DONE = 31
dflet 3:a8c249046181 179 /* Use bit 32: Lower bits of status variable are used for NWP events
dflet 3:a8c249046181 180 * 1 in a 'status_variable', the device has completed the ping operation
dflet 3:a8c249046181 181 * 0 in a 'status_variable', the device has not completed the ping operation
dflet 3:a8c249046181 182 */
dflet 3:a8c249046181 183
dflet 3:a8c249046181 184 } e_StatusBits;
dflet 3:a8c249046181 185
dflet 3:a8c249046181 186 /* Application specific status/error codes */
dflet 3:a8c249046181 187 typedef enum {
dflet 3:a8c249046181 188 LAN_CONNECTION_FAILED = -0x7D0, /* Choosing this number to avoid overlap with host-driver's error codes */
dflet 3:a8c249046181 189 INTERNET_CONNECTION_FAILED = LAN_CONNECTION_FAILED - 1,
dflet 3:a8c249046181 190 DEVICE_NOT_IN_STATION_MODE = INTERNET_CONNECTION_FAILED - 1,
dflet 3:a8c249046181 191 HTTP_SEND_ERROR = DEVICE_NOT_IN_STATION_MODE - 1,
dflet 3:a8c249046181 192 HTTP_RECV_ERROR = HTTP_SEND_ERROR - 1,
dflet 3:a8c249046181 193 HTTP_INVALID_RESPONSE = HTTP_RECV_ERROR -1,
dflet 3:a8c249046181 194 SNTP_SEND_ERROR = DEVICE_NOT_IN_STATION_MODE - 1,
dflet 3:a8c249046181 195 SNTP_RECV_ERROR = SNTP_SEND_ERROR - 1,
dflet 3:a8c249046181 196 SNTP_SERVER_RESPONSE_ERROR = SNTP_RECV_ERROR - 1,
dflet 3:a8c249046181 197 INVALID_HEX_STRING = DEVICE_NOT_IN_STATION_MODE - 1,
dflet 3:a8c249046181 198 TCP_RECV_ERROR = INVALID_HEX_STRING - 1,
dflet 3:a8c249046181 199 TCP_SEND_ERROR = TCP_RECV_ERROR - 1,
dflet 3:a8c249046181 200 FILE_NOT_FOUND_ERROR = TCP_SEND_ERROR - 1,
dflet 3:a8c249046181 201 INVALID_SERVER_RESPONSE = FILE_NOT_FOUND_ERROR - 1,
dflet 3:a8c249046181 202 FORMAT_NOT_SUPPORTED = INVALID_SERVER_RESPONSE - 1,
dflet 3:a8c249046181 203 FILE_WRITE_ERROR = FORMAT_NOT_SUPPORTED - 1,
dflet 3:a8c249046181 204 INVALID_FILE = FILE_WRITE_ERROR - 1,
dflet 3:a8c249046181 205
dflet 3:a8c249046181 206 STATUS_CODE_MAX = -0xBB8
dflet 3:a8c249046181 207 } e_AppStatusCodes;
dflet 3:a8c249046181 208
dflet 3:a8c249046181 209 /* Send types */
dflet 3:a8c249046181 210 typedef enum {
dflet 3:a8c249046181 211 SL_ERR_SENDER_HEALTH_MON,
dflet 3:a8c249046181 212 SL_ERR_SENDER_CLI_UART,
dflet 3:a8c249046181 213 SL_ERR_SENDER_SUPPLICANT,
dflet 3:a8c249046181 214 SL_ERR_SENDER_NETWORK_STACK,
dflet 3:a8c249046181 215 SL_ERR_SENDER_WLAN_DRV_IF,
dflet 3:a8c249046181 216 SL_ERR_SENDER_WILINK,
dflet 3:a8c249046181 217 SL_ERR_SENDER_INIT_APP,
dflet 3:a8c249046181 218 SL_ERR_SENDER_NETX,
dflet 3:a8c249046181 219 SL_ERR_SENDER_HOST_APD,
dflet 3:a8c249046181 220 SL_ERR_SENDER_MDNS,
dflet 3:a8c249046181 221 SL_ERR_SENDER_HTTP_SERVER,
dflet 3:a8c249046181 222 SL_ERR_SENDER_DHCP_SERVER,
dflet 3:a8c249046181 223 SL_ERR_SENDER_DHCP_CLIENT,
dflet 3:a8c249046181 224 SL_ERR_DISPATCHER,
dflet 3:a8c249046181 225 SL_ERR_NUM_SENDER_LAST=0xFF
dflet 3:a8c249046181 226 } SlErrorSender_e;
dflet 3:a8c249046181 227
dflet 3:a8c249046181 228 /* Error codes */
dflet 3:a8c249046181 229 const int8_t SL_ERROR_STATIC_ADDR_SUBNET_ERROR = (-60); /* network stack error*/
dflet 3:a8c249046181 230 const int8_t SL_ERROR_ILLEGAL_CHANNEL = (-61); /* supplicant error */
dflet 3:a8c249046181 231 const int8_t SL_ERROR_SUPPLICANT_ERROR = (-72); /* init error code */
dflet 3:a8c249046181 232 const int8_t SL_ERROR_HOSTAPD_INIT_FAIL = (-73); /* init error code */
dflet 3:a8c249046181 233 const int8_t SL_ERROR_HOSTAPD_INIT_IF_FAIL = (-74); /* init error code */
dflet 3:a8c249046181 234 const int8_t SL_ERROR_WLAN_DRV_INIT_FAIL = (-75); /* init error code */
dflet 3:a8c249046181 235 const int8_t SL_ERROR_WLAN_DRV_START_FAIL = (-76); /* wlan start error */
dflet 3:a8c249046181 236 const int8_t SL_ERROR_FS_FILE_TABLE_LOAD_FAILED = (-77); /* init file system failed */
dflet 3:a8c249046181 237 const int8_t SL_ERROR_PREFERRED_NETWORKS_FILE_LOAD_FAILED = (-78); /* init file system failed */
dflet 3:a8c249046181 238 const int8_t SL_ERROR_HOSTAPD_BSSID_VALIDATION_ERROR = (-79); /* Ap configurations BSSID error */
dflet 3:a8c249046181 239 const int8_t SL_ERROR_HOSTAPD_FAILED_TO_SETUP_INTERFACE = (-80); /* Ap configurations interface error */
dflet 3:a8c249046181 240 const int8_t SL_ERROR_MDNS_ENABLE_FAIL = (-81); /* mDNS enable failed */
dflet 3:a8c249046181 241 const int8_t SL_ERROR_HTTP_SERVER_ENABLE_FAILED = (-82); /* HTTP server enable failed */
dflet 3:a8c249046181 242 const int8_t SL_ERROR_DHCP_SERVER_ENABLE_FAILED = (-83); /* DHCP server enable failed */
dflet 3:a8c249046181 243 const int8_t SL_ERROR_PREFERRED_NETWORK_LIST_FULL = (-93); /* supplicant error */
dflet 3:a8c249046181 244 const int8_t SL_ERROR_PREFERRED_NETWORKS_FILE_WRITE_FAILED = (-94); /* supplicant error */
dflet 3:a8c249046181 245 const int8_t SL_ERROR_DHCP_CLIENT_RENEW_FAILED = (-100); /* DHCP client error */
dflet 3:a8c249046181 246 /* WLAN Connection management status */
dflet 3:a8c249046181 247 const int8_t SL_ERROR_CON_MGMT_STATUS_UNSPECIFIED = (-102);
dflet 3:a8c249046181 248 const int8_t SL_ERROR_CON_MGMT_STATUS_AUTH_REJECT = (-103);
dflet 3:a8c249046181 249 const int8_t SL_ERROR_CON_MGMT_STATUS_ASSOC_REJECT = (-104);
dflet 3:a8c249046181 250 const int8_t SL_ERROR_CON_MGMT_STATUS_SECURITY_FAILURE = (-105);
dflet 3:a8c249046181 251 const int8_t SL_ERROR_CON_MGMT_STATUS_AP_DEAUTHENTICATE = (-106);
dflet 3:a8c249046181 252 const int8_t SL_ERROR_CON_MGMT_STATUS_AP_DISASSOCIATE = (-107);
dflet 3:a8c249046181 253 const int8_t SL_ERROR_CON_MGMT_STATUS_ROAMING_TRIGGER = (-108);
dflet 3:a8c249046181 254 const int8_t SL_ERROR_CON_MGMT_STATUS_DISCONNECT_DURING_CONNECT = (-109);
dflet 3:a8c249046181 255 const int8_t SL_ERROR_CON_MGMT_STATUS_SG_RESELECT = (-110);
dflet 3:a8c249046181 256 const int8_t SL_ERROR_CON_MGMT_STATUS_ROC_FAILURE = (-111);
dflet 3:a8c249046181 257 const int8_t SL_ERROR_CON_MGMT_STATUS_MIC_FAILURE = (-112);
dflet 3:a8c249046181 258 /* end of WLAN connection management error statuses */
dflet 3:a8c249046181 259 const int8_t SL_ERROR_WAKELOCK_ERROR_PREFIX = (-115); /* Wake lock expired */
dflet 3:a8c249046181 260 const int8_t SL_ERROR_LENGTH_ERROR_PREFIX = (-116); /* Uart header length error */
dflet 3:a8c249046181 261 const int8_t SL_ERROR_MDNS_CREATE_FAIL = (-121); /* mDNS create failed */
dflet 3:a8c249046181 262 const int8_t SL_ERROR_GENERAL_ERROR = (-127);
dflet 3:a8c249046181 263
dflet 3:a8c249046181 264
dflet 3:a8c249046181 265
dflet 3:a8c249046181 266 const int8_t SL_DEVICE_GENERAL_CONFIGURATION = (1);
dflet 3:a8c249046181 267 const int8_t SL_DEVICE_GENERAL_CONFIGURATION_DATE_TIME = (11);
dflet 3:a8c249046181 268 const int8_t SL_DEVICE_GENERAL_VERSION = (12);
dflet 3:a8c249046181 269 const int8_t SL_DEVICE_STATUS = (2);
dflet 3:a8c249046181 270
dflet 3:a8c249046181 271 /*
dflet 3:a8c249046181 272 Declare the different event group classifications
dflet 3:a8c249046181 273 The SimpleLink device send asynchronous events. Each event has a group
dflet 3:a8c249046181 274 classification according to its nature.
dflet 3:a8c249046181 275 */
dflet 3:a8c249046181 276 #if 1
dflet 3:a8c249046181 277 /* SL_EVENT_CLASS_WLAN connection user events */
dflet 3:a8c249046181 278 const int8_t SL_WLAN_CONNECT_EVENT = (1);
dflet 3:a8c249046181 279 const int8_t SL_WLAN_DISCONNECT_EVENT = (2);
dflet 3:a8c249046181 280 /* WLAN Smart Config user events */
dflet 3:a8c249046181 281 const int8_t SL_WLAN_SMART_CONFIG_COMPLETE_EVENT = (3);
dflet 3:a8c249046181 282 const int8_t SL_WLAN_SMART_CONFIG_STOP_EVENT = (4);
dflet 3:a8c249046181 283 /* WLAN AP user events */
dflet 3:a8c249046181 284 const int8_t SL_WLAN_STA_CONNECTED_EVENT = (5);
dflet 3:a8c249046181 285 const int8_t SL_WLAN_STA_DISCONNECTED_EVENT = (6);
dflet 3:a8c249046181 286 /* WLAN P2P user events */
dflet 3:a8c249046181 287 const int8_t SL_WLAN_P2P_DEV_FOUND_EVENT = (7);
dflet 3:a8c249046181 288 const int8_t SL_WLAN_P2P_NEG_REQ_RECEIVED_EVENT = (8);
dflet 3:a8c249046181 289 const int8_t SL_WLAN_CONNECTION_FAILED_EVENT = (9);
dflet 3:a8c249046181 290 /* SL_EVENT_CLASS_DEVICE user events */
dflet 3:a8c249046181 291 const int8_t SL_DEVICE_FATAL_ERROR_EVENT = (1);
dflet 3:a8c249046181 292 const int8_t SL_DEVICE_ABORT_ERROR_EVENT = (2);
dflet 3:a8c249046181 293 /* SL_EVENT_CLASS_BSD user events */
dflet 3:a8c249046181 294 const int8_t SL_SOCKET_TX_FAILED_EVENT = (1);
dflet 3:a8c249046181 295 const int8_t SL_SOCKET_ASYNC_EVENT = (2);
dflet 3:a8c249046181 296 /* SL_EVENT_CLASS_NETAPP user events */
dflet 3:a8c249046181 297 const int8_t SL_NETAPP_IPV4_IPACQUIRED_EVENT = (1);
dflet 3:a8c249046181 298 const int8_t SL_NETAPP_IPV6_IPACQUIRED_EVENT = (2);
dflet 3:a8c249046181 299 const int8_t SL_NETAPP_IP_LEASED_EVENT = (3);
dflet 3:a8c249046181 300 const int8_t SL_NETAPP_IP_RELEASED_EVENT = (4);
dflet 3:a8c249046181 301
dflet 3:a8c249046181 302 /* Server Events */
dflet 3:a8c249046181 303 const int8_t SL_NETAPP_HTTPGETTOKENVALUE_EVENT = (1);
dflet 3:a8c249046181 304 const int8_t SL_NETAPP_HTTPPOSTTOKENVALUE_EVENT = (2);
dflet 3:a8c249046181 305 #endif
dflet 3:a8c249046181 306
dflet 3:a8c249046181 307 /*
dflet 3:a8c249046181 308 Declare the different event group classifications for sl_DevGet
dflet 3:a8c249046181 309 for getting status indications
dflet 3:a8c249046181 310 */
dflet 3:a8c249046181 311
dflet 3:a8c249046181 312 /* Events list to mask/unmask*/
dflet 3:a8c249046181 313 const int8_t SL_EVENT_CLASS_GLOBAL = (0);
dflet 3:a8c249046181 314 const int8_t SL_EVENT_CLASS_DEVICE = (1);
dflet 3:a8c249046181 315 const int8_t SL_EVENT_CLASS_WLAN = (2);
dflet 3:a8c249046181 316 const int8_t SL_EVENT_CLASS_BSD = (3);
dflet 3:a8c249046181 317 const int8_t SL_EVENT_CLASS_NETAPP = (4);
dflet 3:a8c249046181 318 const int8_t SL_EVENT_CLASS_NETCFG = (5);
dflet 3:a8c249046181 319 const int8_t SL_EVENT_CLASS_FS = (6);
dflet 3:a8c249046181 320
dflet 3:a8c249046181 321
dflet 3:a8c249046181 322 /****************** DEVICE CLASS status ****************/
dflet 3:a8c249046181 323 const uint32_t EVENT_DROPPED_DEVICE_ASYNC_GENERAL_ERROR = (0x00000001L);
dflet 3:a8c249046181 324 const uint32_t STATUS_DEVICE_SMART_CONFIG_ACTIVE = (0x80000000L);
dflet 3:a8c249046181 325
dflet 3:a8c249046181 326 /****************** WLAN CLASS status ****************/
dflet 3:a8c249046181 327 const uint32_t EVENT_DROPPED_WLAN_WLANASYNCONNECTEDRESPONSE = (0x00000001L);
dflet 3:a8c249046181 328 const uint32_t EVENT_DROPPED_WLAN_WLANASYNCDISCONNECTEDRESPONSE = (0x00000002L);
dflet 3:a8c249046181 329 const uint32_t EVENT_DROPPED_WLAN_STA_CONNECTED = (0x00000004L);
dflet 3:a8c249046181 330 const uint32_t EVENT_DROPPED_WLAN_STA_DISCONNECTED = (0x00000008L);
dflet 3:a8c249046181 331 const uint32_t STATUS_WLAN_STA_CONNECTED = (0x80000000L);
dflet 3:a8c249046181 332
dflet 3:a8c249046181 333 /****************** NETAPP CLASS status ****************/
dflet 3:a8c249046181 334 const uint32_t EVENT_DROPPED_NETAPP_IPACQUIRED = (0x00000001L);
dflet 3:a8c249046181 335 const uint32_t EVENT_DROPPED_NETAPP_IPACQUIRED_V6 = (0x00000002L);
dflet 3:a8c249046181 336 const uint32_t EVENT_DROPPED_NETAPP_IP_LEASED = (0x00000004L);
dflet 3:a8c249046181 337 const uint32_t EVENT_DROPPED_NETAPP_IP_RELEASED = (0x00000008L);
dflet 3:a8c249046181 338
dflet 3:a8c249046181 339 /****************** BSD CLASS status ****************/
dflet 3:a8c249046181 340 const uint32_t EVENT_DROPPED_SOCKET_TXFAILEDASYNCRESPONSE = (0x00000001L);
dflet 3:a8c249046181 341
dflet 3:a8c249046181 342 /****************** FS CLASS ****************/
dflet 3:a8c249046181 343
dflet 3:a8c249046181 344 /*****************************************************************************/
dflet 3:a8c249046181 345 /* Structure/Enum declarations */
dflet 3:a8c249046181 346 /*****************************************************************************/
dflet 3:a8c249046181 347
dflet 3:a8c249046181 348 #ifdef SL_IF_TYPE_UART
dflet 3:a8c249046181 349 typedef struct {
dflet 3:a8c249046181 350 uint32_t BaudRate;
dflet 3:a8c249046181 351 uint8_t FlowControlEnable;
dflet 3:a8c249046181 352 uint8_t CommPort;
dflet 3:a8c249046181 353 } SlUartIfParams_t;
dflet 3:a8c249046181 354 #endif
dflet 3:a8c249046181 355
dflet 3:a8c249046181 356 typedef struct {
dflet 3:a8c249046181 357 uint32_t ChipId;
dflet 3:a8c249046181 358 uint32_t FwVersion[4];
dflet 3:a8c249046181 359 uint8_t PhyVersion[4];
dflet 3:a8c249046181 360 } _SlPartialVersion;
dflet 3:a8c249046181 361
dflet 3:a8c249046181 362 typedef struct {
dflet 3:a8c249046181 363 _SlPartialVersion ChipFwAndPhyVersion;
dflet 3:a8c249046181 364 uint32_t NwpVersion[4];
dflet 3:a8c249046181 365 uint16_t RomVersion;
dflet 3:a8c249046181 366 uint16_t Padding;
dflet 3:a8c249046181 367 } SlVersionFull;
dflet 3:a8c249046181 368
dflet 3:a8c249046181 369 typedef struct
dflet 3:a8c249046181 370 {
dflet 3:a8c249046181 371 uint32_t AbortType;
dflet 3:a8c249046181 372 uint32_t AbortData;
dflet 3:a8c249046181 373 }sl_DeviceReportAbort;
dflet 3:a8c249046181 374
dflet 3:a8c249046181 375 typedef struct {
dflet 3:a8c249046181 376 int8_t status;
dflet 3:a8c249046181 377 SlErrorSender_e sender;
dflet 3:a8c249046181 378 } sl_DeviceReport;
dflet 3:a8c249046181 379
dflet 3:a8c249046181 380 typedef union {
dflet 3:a8c249046181 381 sl_DeviceReport deviceEvent;
dflet 3:a8c249046181 382 sl_DeviceReportAbort deviceReport;
dflet 3:a8c249046181 383 } _SlDeviceEventData_u;
dflet 3:a8c249046181 384
dflet 3:a8c249046181 385 typedef struct {
dflet 3:a8c249046181 386 uint32_t Event;
dflet 3:a8c249046181 387 _SlDeviceEventData_u EventData;
dflet 3:a8c249046181 388 } SlDeviceEvent_t;
dflet 3:a8c249046181 389
dflet 3:a8c249046181 390 typedef struct {
dflet 3:a8c249046181 391 /* time */
dflet 3:a8c249046181 392 uint32_t sl_tm_sec;
dflet 3:a8c249046181 393 uint32_t sl_tm_min;
dflet 3:a8c249046181 394 uint32_t sl_tm_hour;
dflet 3:a8c249046181 395 /* date */
dflet 3:a8c249046181 396 uint32_t sl_tm_day; /* 1-31 */
dflet 3:a8c249046181 397 uint32_t sl_tm_mon; /* 1-12 */
dflet 3:a8c249046181 398 uint32_t sl_tm_year; /* YYYY 4 digits */
dflet 3:a8c249046181 399 uint32_t sl_tm_week_day; /* not required */
dflet 3:a8c249046181 400 uint32_t sl_tm_year_day; /* not required */
dflet 3:a8c249046181 401 uint32_t reserved[3];
dflet 3:a8c249046181 402 } SlDateTime_t;
dflet 3:a8c249046181 403
dflet 3:a8c249046181 404 /******************************************************************************/
dflet 3:a8c249046181 405 /* Type declarations */
dflet 3:a8c249046181 406 /******************************************************************************/
dflet 3:a8c249046181 407 typedef void (*P_INIT_CALLBACK)(uint32_t Status);
dflet 3:a8c249046181 408
dflet 3:a8c249046181 409 class cc3100_netcfg;
dflet 3:a8c249046181 410
dflet 3:a8c249046181 411 class cc3100
dflet 3:a8c249046181 412 {
dflet 3:a8c249046181 413
dflet 3:a8c249046181 414 public:
dflet 3:a8c249046181 415
dflet 3:a8c249046181 416 cc3100(PinName button1_irq, PinName button2_irq, PinName cc3100_irq, PinName cc3100_nHIB, PinName cc3100_cs, SPI cc3100_spi);
dflet 3:a8c249046181 417
dflet 3:a8c249046181 418 ~cc3100();
dflet 3:a8c249046181 419
dflet 3:a8c249046181 420 /*****************************************************************************/
dflet 3:a8c249046181 421 /* Function prototypes */
dflet 3:a8c249046181 422 /*****************************************************************************/
dflet 3:a8c249046181 423 int32_t initializeAppVariables();
dflet 3:a8c249046181 424
dflet 3:a8c249046181 425 int32_t establishConnectionWithAP(void);
dflet 3:a8c249046181 426
dflet 3:a8c249046181 427 int32_t checkLanConnection(void);
dflet 3:a8c249046181 428
dflet 3:a8c249046181 429 int32_t checkInternetConnection(void);
dflet 3:a8c249046181 430
dflet 3:a8c249046181 431 int32_t createUDPConnection(void);
dflet 3:a8c249046181 432
dflet 3:a8c249046181 433 int32_t createConnection(uint32_t DestinationIP);
dflet 3:a8c249046181 434
dflet 3:a8c249046181 435 int32_t getChunkSize(int32_t *len, uint8_t **p_Buff, uint32_t *chunk_size);
dflet 3:a8c249046181 436
dflet 3:a8c249046181 437 int32_t hexToi(unsigned char *ptr);
dflet 3:a8c249046181 438
dflet 3:a8c249046181 439 // int32_t getFile(void);
dflet 3:a8c249046181 440
dflet 3:a8c249046181 441 int32_t disconnectFromAP(void);
dflet 3:a8c249046181 442
dflet 3:a8c249046181 443 uint16_t itoa(int16_t cNum, uint8_t *cString);
dflet 3:a8c249046181 444
dflet 3:a8c249046181 445 int32_t configureSimpleLinkToDefaultState(void);
dflet 3:a8c249046181 446
dflet 3:a8c249046181 447 int16_t _sl_GetStartResponseConvert(uint32_t Status);
dflet 3:a8c249046181 448
dflet 3:a8c249046181 449 void _sl_HandleAsync_InitComplete(void *pVoidBuf);
dflet 3:a8c249046181 450
dflet 3:a8c249046181 451 bool IS_PING_DONE(uint32_t status_variable,const uint32_t bit);
dflet 3:a8c249046181 452 bool IS_CONNECTED(uint32_t status_variable,const uint32_t bit);
dflet 3:a8c249046181 453 bool IS_STA_CONNECTED(uint32_t status_variable,const uint32_t bit);
dflet 3:a8c249046181 454 bool IS_IP_ACQUIRED(uint32_t status_variable,const uint32_t bit);
dflet 3:a8c249046181 455 bool IS_IP_LEASED(uint32_t status_variable,const uint32_t bit);
dflet 3:a8c249046181 456 bool IS_CONNECTION_FAILED(uint32_t status_variable,const uint32_t bit);
dflet 3:a8c249046181 457 bool IS_P2P_NEG_REQ_RECEIVED(uint32_t status_variable,const uint32_t bit);
dflet 3:a8c249046181 458 bool IS_SMARTCONFIG_DONE(uint32_t status_variable,const uint32_t bit);
dflet 3:a8c249046181 459 bool IS_SMARTCONFIG_STOPPED(uint32_t status_variable,const uint32_t bit);
dflet 3:a8c249046181 460
dflet 3:a8c249046181 461
dflet 3:a8c249046181 462
dflet 3:a8c249046181 463 void CLR_STATUS_BIT(uint32_t status_variable, const uint32_t bit);
dflet 3:a8c249046181 464 void SET_STATUS_BIT(uint32_t status_variable, const uint32_t bit);
dflet 3:a8c249046181 465
dflet 3:a8c249046181 466
dflet 3:a8c249046181 467 /*!
dflet 3:a8c249046181 468 \brief Start the SimpleLink device
dflet 3:a8c249046181 469
dflet 3:a8c249046181 470 This function initialize the communication interface, set the enable pin
dflet 3:a8c249046181 471 of the device, and call to the init complete callback.
dflet 3:a8c249046181 472
dflet 3:a8c249046181 473 \param[in] pIfHdl Opened Interface Object. In case the interface
dflet 3:a8c249046181 474 must be opened outside the SimpleLink Driver, the
dflet 3:a8c249046181 475 user might give the handler to be used in \n
dflet 3:a8c249046181 476 any access of the communication interface with the
dflet 3:a8c249046181 477 device (UART/SPI). \n
dflet 3:a8c249046181 478 The SimpleLink driver will open an interface port
dflet 3:a8c249046181 479 only if this parameter is null! \n
dflet 3:a8c249046181 480 \param[in] pDevName The name of the device to open. Could be used when
dflet 3:a8c249046181 481 the pIfHdl is null, to transfer information to the
dflet 3:a8c249046181 482 open interface function \n
dflet 3:a8c249046181 483 This pointer could be used to pass additional information to
dflet 3:a8c249046181 484 sl_IfOpen in case it is required (e.g. UART com port name)
dflet 3:a8c249046181 485 \param[in] pInitCallBack Pointer to function that would be called
dflet 3:a8c249046181 486 on completion of the initialization process.\n
dflet 3:a8c249046181 487 If this parameter is NULL the function is
dflet 3:a8c249046181 488 blocked until the device initialization
dflet 3:a8c249046181 489 is completed, otherwise the function returns
dflet 3:a8c249046181 490 immediately.
dflet 3:a8c249046181 491
dflet 3:a8c249046181 492 \return Returns the current active role (STA/AP/P2P) or an error code:
dflet 3:a8c249046181 493 - ROLE_STA, ROLE_AP, ROLE_P2P in case of success,
dflet 3:a8c249046181 494 otherwise in failure one of the following is return:
dflet 3:a8c249046181 495 - ROLE_STA_ERR (Failure to load MAC/PHY in STA role)
dflet 3:a8c249046181 496 - ROLE_AP_ERR (Failure to load MAC/PHY in AP role)
dflet 3:a8c249046181 497 - ROLE_P2P_ERR (Failure to load MAC/PHY in P2P role)
dflet 3:a8c249046181 498
dflet 3:a8c249046181 499
dflet 3:a8c249046181 500 \sa sl_Stop
dflet 3:a8c249046181 501
dflet 3:a8c249046181 502 \note belongs to \ref basic_api
dflet 3:a8c249046181 503
dflet 3:a8c249046181 504 \warning This function must be called before any other SimpleLink API is used, or after sl_Stop is called for reinit the device
dflet 3:a8c249046181 505 \par Example:
dflet 3:a8c249046181 506 \code
dflet 3:a8c249046181 507 An example for open interface without callback routine. The interface name and handler are
dflet 3:a8c249046181 508 handled by the sl_IfOpen routine:
dflet 3:a8c249046181 509
dflet 3:a8c249046181 510 if( sl_Start(NULL, NULL, NULL) < 0 )
dflet 3:a8c249046181 511 {
dflet 3:a8c249046181 512 LOG("Error opening interface to device\n");
dflet 3:a8c249046181 513 }
dflet 3:a8c249046181 514 \endcode
dflet 3:a8c249046181 515 */
dflet 3:a8c249046181 516 #if _SL_INCLUDE_FUNC(sl_Start)
dflet 3:a8c249046181 517 int16_t sl_Start(const void* pIfHdl, int8_t* pDevName, const P_INIT_CALLBACK pInitCallBack);
dflet 3:a8c249046181 518 #endif
dflet 3:a8c249046181 519
dflet 3:a8c249046181 520 /*!
dflet 3:a8c249046181 521 \brief Stop the SimpleLink device
dflet 3:a8c249046181 522
dflet 3:a8c249046181 523 This function clears the enable pin of the device, closes the communication \n
dflet 3:a8c249046181 524 interface and invokes the stop complete callback
dflet 3:a8c249046181 525
dflet 3:a8c249046181 526 \param[in] timeout Stop timeout in msec. Should be used to give the device time to finish \n
dflet 3:a8c249046181 527 any transmission/reception that is not completed when the function was called. \n
dflet 3:a8c249046181 528 Additional options:
dflet 3:a8c249046181 529 - 0 Enter to hibernate immediately \n
dflet 3:a8c249046181 530 - 0xFFFF Host waits for device's response before \n
dflet 3:a8c249046181 531 hibernating, without timeout protection \n
dflet 3:a8c249046181 532 - 0 < Timeout[msec] < 0xFFFF Host waits for device's response before \n
dflet 3:a8c249046181 533 hibernating, with a defined timeout protection \n
dflet 3:a8c249046181 534 This timeout defines the max time to wait. The NWP \n
dflet 3:a8c249046181 535 response can be sent earlier than this timeout.
dflet 3:a8c249046181 536
dflet 3:a8c249046181 537 \return On success, zero is returned. On error, -1 is returned
dflet 3:a8c249046181 538
dflet 3:a8c249046181 539 \sa sl_Start
dflet 3:a8c249046181 540
dflet 3:a8c249046181 541 \note This API will shutdown the device and invoke the "i/f close" function regardless \n
dflet 3:a8c249046181 542 if it was opened implicitly or explicitly. \n
dflet 3:a8c249046181 543 It is up to the platform interface library to properly handle interface close \n
dflet 3:a8c249046181 544 routine \n
dflet 3:a8c249046181 545 belongs to \ref basic_api \n
dflet 3:a8c249046181 546 \warning
dflet 3:a8c249046181 547 */
dflet 3:a8c249046181 548 #if _SL_INCLUDE_FUNC(sl_Stop)
dflet 3:a8c249046181 549 int16_t sl_Stop(const uint16_t timeout);
dflet 3:a8c249046181 550 #endif
dflet 3:a8c249046181 551
dflet 3:a8c249046181 552
dflet 3:a8c249046181 553 /*!
dflet 3:a8c249046181 554 \brief Internal function for setting device configurations
dflet 3:a8c249046181 555
dflet 3:a8c249046181 556 \return On success, zero is returned. On error, -1 is
dflet 3:a8c249046181 557 returned
dflet 3:a8c249046181 558
dflet 3:a8c249046181 559 \param[in] DeviceSetId configuration id
dflet 3:a8c249046181 560 \param[in] Option configurations option
dflet 3:a8c249046181 561 \param[in] ConfigLen configurations len
dflet 3:a8c249046181 562 \param[in] pValues configurations values
dflet 3:a8c249046181 563
dflet 3:a8c249046181 564 \sa
dflet 3:a8c249046181 565 \note
dflet 3:a8c249046181 566 \warning
dflet 3:a8c249046181 567 \par Examples:
dflet 3:a8c249046181 568 \code
dflet 3:a8c249046181 569 Setting device time and date example:
dflet 3:a8c249046181 570
dflet 3:a8c249046181 571 SlDateTime_t dateTime= {0};
dflet 3:a8c249046181 572 dateTime.sl_tm_day = (uint32_t)23; // Day of month (DD format) range 1-13
dflet 3:a8c249046181 573 dateTime.sl_tm_mon = (uint32_t)6; // Month (MM format) in the range of 1-12
dflet 3:a8c249046181 574 dateTime.sl_tm_year = (uint32_t)2014; // Year (YYYY format)
dflet 3:a8c249046181 575 dateTime.sl_tm_hour = (uint32_t)17; // Hours in the range of 0-23
dflet 3:a8c249046181 576 dateTime.sl_tm_min = (uint32_t)55; // Minutes in the range of 0-59
dflet 3:a8c249046181 577 dateTime.sl_tm_sec = (uint32_t)22; // Seconds in the range of 0-59
dflet 3:a8c249046181 578 sl_DevSet(SL_DEVICE_GENERAL_CONFIGURATION,
dflet 3:a8c249046181 579 SL_DEVICE_GENERAL_CONFIGURATION_DATE_TIME,
dflet 3:a8c249046181 580 sizeof(SlDateTime_t),
dflet 3:a8c249046181 581 (uint8_t *)(&dateTime));
dflet 3:a8c249046181 582
dflet 3:a8c249046181 583 \endcode
dflet 3:a8c249046181 584 */
dflet 3:a8c249046181 585 #if _SL_INCLUDE_FUNC(sl_DevSet)
dflet 3:a8c249046181 586 int32_t sl_DevSet(const uint8_t DeviceSetId , const uint8_t Option, const uint8_t ConfigLen, const uint8_t *pValues);
dflet 3:a8c249046181 587 #endif
dflet 3:a8c249046181 588
dflet 3:a8c249046181 589 /*!
dflet 3:a8c249046181 590 \brief Internal function for getting device configurations
dflet 3:a8c249046181 591 \return On success, zero is returned. On error, -1 is
dflet 3:a8c249046181 592 returned
dflet 3:a8c249046181 593 \param[in] DeviceGetId configuration id - example SL_DEVICE_STATUS
dflet 3:a8c249046181 594 \param[out] pOption Get configurations option, example for get status options
dflet 3:a8c249046181 595 - SL_EVENT_CLASS_GLOBAL
dflet 3:a8c249046181 596 - SL_EVENT_CLASS_DEVICE
dflet 3:a8c249046181 597 - SL_EVENT_CLASS_WLAN
dflet 3:a8c249046181 598 - SL_EVENT_CLASS_BSD
dflet 3:a8c249046181 599 - SL_EVENT_CLASS_NETAPP
dflet 3:a8c249046181 600 - SL_EVENT_CLASS_NETCFG
dflet 3:a8c249046181 601 - SL_EVENT_CLASS_FS
dflet 3:a8c249046181 602 \param[out] pConfigLen The length of the allocated memory as input, when the
dflet 3:a8c249046181 603 function complete, the value of this parameter would be
dflet 3:a8c249046181 604 the len that actually read from the device.\n
dflet 3:a8c249046181 605 If the device return length that is longer from the input
dflet 3:a8c249046181 606 value, the function will cut the end of the returned structure
dflet 3:a8c249046181 607 and will return SL_ESMALLBUF
dflet 3:a8c249046181 608 \param[out] pValues Get configurations values
dflet 3:a8c249046181 609 \sa
dflet 3:a8c249046181 610 \note
dflet 3:a8c249046181 611 \warning
dflet 3:a8c249046181 612 \par Examples:
dflet 3:a8c249046181 613 \code
dflet 3:a8c249046181 614 Example for getting WLAN class status:
dflet 3:a8c249046181 615 uint32_t statusWlan;
dflet 3:a8c249046181 616 uint8_t pConfigOpt;
dflet 3:a8c249046181 617 uint8_t pConfigLen;
dflet 3:a8c249046181 618 pConfigLen = sizeof(_u32);
dflet 3:a8c249046181 619 pConfigOpt = SL_EVENT_CLASS_WLAN;
dflet 3:a8c249046181 620 sl_DevGet(SL_DEVICE_STATUS,&pConfigOpt,&pConfigLen,(uint8_t *)(&statusWlan));
dflet 3:a8c249046181 621 Example for getting version:
dflet 3:a8c249046181 622 SlVersionFull ver;
dflet 3:a8c249046181 623 pConfigLen = sizeof(ver);
dflet 3:a8c249046181 624 pConfigOpt = SL_DEVICE_GENERAL_VERSION;
dflet 3:a8c249046181 625 sl_DevGet(SL_DEVICE_GENERAL_CONFIGURATION,&pConfigOpt,&pConfigLen,(uint8_t *)(&ver));
dflet 3:a8c249046181 626 printf("CHIP %d\nMAC 31.%d.%d.%d.%d\nPHY %d.%d.%d.%d\nNWP %d.%d.%d.%d\nROM %d\nHOST %d.%d.%d.%d\n",
dflet 3:a8c249046181 627 ver.ChipFwAndPhyVersion.ChipId,
dflet 3:a8c249046181 628 ver.ChipFwAndPhyVersion.FwVersion[0],ver.ChipFwAndPhyVersion.FwVersion[1],
dflet 3:a8c249046181 629 ver.ChipFwAndPhyVersion.FwVersion[2],ver.ChipFwAndPhyVersion.FwVersion[3],
dflet 3:a8c249046181 630 ver.ChipFwAndPhyVersion.PhyVersion[0],ver.ChipFwAndPhyVersion.PhyVersion[1],
dflet 3:a8c249046181 631 ver.ChipFwAndPhyVersion.PhyVersion[2],ver.ChipFwAndPhyVersion.PhyVersion[3],
dflet 3:a8c249046181 632 ver.NwpVersion[0],ver.NwpVersion[1],ver.NwpVersion[2],ver.NwpVersion[3],
dflet 3:a8c249046181 633 ver.RomVersion,
dflet 3:a8c249046181 634 SL_MAJOR_VERSION_NUM,SL_MINOR_VERSION_NUM,SL_VERSION_NUM,SL_SUB_VERSION_NUM);
dflet 3:a8c249046181 635
dflet 3:a8c249046181 636 \endcode
dflet 3:a8c249046181 637 \code
dflet 3:a8c249046181 638 Getting Device time and date example:
dflet 3:a8c249046181 639
dflet 3:a8c249046181 640 SlDateTime_t dateTime = {0};
dflet 3:a8c249046181 641 int8_t configLen = sizeof(SlDateTime_t);
dflet 3:a8c249046181 642 int8_t configOpt = SL_DEVICE_GENERAL_CONFIGURATION_DATE_TIME;
dflet 3:a8c249046181 643 sl_DevGet(SL_DEVICE_GENERAL_CONFIGURATION,&configOpt, &configLen,(uint8_t *)(&dateTime));
dflet 3:a8c249046181 644
dflet 3:a8c249046181 645 printf("Day %d,Mon %d,Year %d,Hour %,Min %d,Sec %d\n",dateTime.sl_tm_day,dateTime.sl_tm_mon,dateTime.sl_tm_year
dflet 3:a8c249046181 646 dateTime.sl_tm_hour,dateTime.sl_tm_min,dateTime.sl_tm_sec);
dflet 3:a8c249046181 647 \endcode
dflet 3:a8c249046181 648 */
dflet 3:a8c249046181 649 #if _SL_INCLUDE_FUNC(sl_DevGet)
dflet 3:a8c249046181 650 int32_t sl_DevGet(const uint8_t DeviceGetId, uint8_t *pOption,uint8_t *pConfigLen, uint8_t *pValues);
dflet 3:a8c249046181 651 #endif
dflet 3:a8c249046181 652
dflet 3:a8c249046181 653
dflet 3:a8c249046181 654 /*!
dflet 3:a8c249046181 655 \brief Set asynchronous event mask
dflet 3:a8c249046181 656
dflet 3:a8c249046181 657 Mask asynchronous events from the device. Masked events do not
dflet 3:a8c249046181 658 generate asynchronous messages from the device.
dflet 3:a8c249046181 659 By default - all events are active
dflet 3:a8c249046181 660
dflet 3:a8c249046181 661 \param[in] EventClass The classification groups that the
dflet 3:a8c249046181 662 mask is referred to. Need to be one of
dflet 3:a8c249046181 663 the following:
dflet 3:a8c249046181 664 - SL_EVENT_CLASS_GLOBAL
dflet 3:a8c249046181 665 - SL_EVENT_CLASS_DEVICE
dflet 3:a8c249046181 666 - SL_EVENT_CLASS_WLAN
dflet 3:a8c249046181 667 - SL_EVENT_CLASS_BSD
dflet 3:a8c249046181 668 - SL_EVENT_CLASS_NETAPP
dflet 3:a8c249046181 669 - SL_EVENT_CLASS_NETCFG
dflet 3:a8c249046181 670 - SL_EVENT_CLASS_FS
dflet 3:a8c249046181 671
dflet 3:a8c249046181 672
dflet 3:a8c249046181 673 \param[in] Mask Event Mask bitmap. Valid mask are (per group):
dflet 3:a8c249046181 674 - SL_EVENT_CLASS_WLAN user events
dflet 3:a8c249046181 675 - SL_WLAN_CONNECT_EVENT
dflet 3:a8c249046181 676 - SL_WLAN_DISCONNECT_EVENT
dflet 3:a8c249046181 677 - SL_EVENT_CLASS_DEVICE user events
dflet 3:a8c249046181 678 - SL_DEVICE_FATAL_ERROR_EVENT
dflet 3:a8c249046181 679 - SL_EVENT_CLASS_BSD user events
dflet 3:a8c249046181 680 - SL_SOCKET_TX_FAILED_EVENT
dflet 3:a8c249046181 681 - SL_SOCKET_ASYNC_EVENT
dflet 3:a8c249046181 682 - SL_EVENT_CLASS_NETAPP user events
dflet 3:a8c249046181 683 - SL_NETAPP_IPV4_IPACQUIRED_EVENT
dflet 3:a8c249046181 684 - SL_NETAPP_IPV6_IPACQUIRED_EVENT
dflet 3:a8c249046181 685
dflet 3:a8c249046181 686 \return On success, zero is returned. On error, -1 is returned
dflet 3:a8c249046181 687
dflet 3:a8c249046181 688 \sa sl_EventMaskGet
dflet 3:a8c249046181 689
dflet 3:a8c249046181 690 \note belongs to \ref ext_api
dflet 3:a8c249046181 691
dflet 3:a8c249046181 692 \warning
dflet 3:a8c249046181 693 \par Example:
dflet 3:a8c249046181 694 \code
dflet 3:a8c249046181 695
dflet 3:a8c249046181 696 An example of masking connection/disconnection async events from WLAN class:
dflet 3:a8c249046181 697 sl_EventMaskSet(SL_EVENT_CLASS_WLAN, (SL_WLAN_CONNECT_EVENT | SL_WLAN_DISCONNECT_EVENT) );
dflet 3:a8c249046181 698
dflet 3:a8c249046181 699 \endcode
dflet 3:a8c249046181 700 */
dflet 3:a8c249046181 701 #if _SL_INCLUDE_FUNC(sl_EventMaskSet)
dflet 3:a8c249046181 702 int16_t sl_EventMaskSet(const uint8_t EventClass , const uint32_t Mask);
dflet 3:a8c249046181 703 #endif
dflet 3:a8c249046181 704
dflet 3:a8c249046181 705 /*!
dflet 3:a8c249046181 706 \brief Get current event mask of the device
dflet 3:a8c249046181 707
dflet 3:a8c249046181 708 return the events bit mask from the device. In case that event is
dflet 3:a8c249046181 709 masked, the device is not sending this event.
dflet 3:a8c249046181 710
dflet 3:a8c249046181 711 \param[in] EventClass The classification groups that the
dflet 3:a8c249046181 712 mask is referred to. Need to be one of
dflet 3:a8c249046181 713 the following:
dflet 3:a8c249046181 714 - SL_EVENT_CLASS_GLOBAL
dflet 3:a8c249046181 715 - SL_EVENT_CLASS_DEVICE
dflet 3:a8c249046181 716 - SL_EVENT_CLASS_WLAN
dflet 3:a8c249046181 717 - SL_EVENT_CLASS_BSD
dflet 3:a8c249046181 718 - SL_EVENT_CLASS_NETAPP
dflet 3:a8c249046181 719 - SL_EVENT_CLASS_NETCFG
dflet 3:a8c249046181 720 - SL_EVENT_CLASS_FS
dflet 3:a8c249046181 721
dflet 3:a8c249046181 722 \param[out] pMask Pointer to Mask bitmap where the
dflet 3:a8c249046181 723 value should be stored. Bitmasks are the same as in \ref sl_EventMaskSet
dflet 3:a8c249046181 724
dflet 3:a8c249046181 725 \return On success, zero is returned. On error, -1 is returned
dflet 3:a8c249046181 726
dflet 3:a8c249046181 727 \sa sl_EventMaskSet
dflet 3:a8c249046181 728
dflet 3:a8c249046181 729 \note belongs to \ref ext_api
dflet 3:a8c249046181 730
dflet 3:a8c249046181 731 \warning
dflet 3:a8c249046181 732 \par Example:
dflet 3:a8c249046181 733 \code
dflet 3:a8c249046181 734
dflet 3:a8c249046181 735 An example of getting an event mask for WLAN class
dflet 3:a8c249046181 736 uint32_t maskWlan;
dflet 3:a8c249046181 737 sl_StatusGet(SL_EVENT_CLASS_WLAN,&maskWlan);
dflet 3:a8c249046181 738
dflet 3:a8c249046181 739 \endcode
dflet 3:a8c249046181 740 */
dflet 3:a8c249046181 741 #if _SL_INCLUDE_FUNC(sl_EventMaskGet)
dflet 3:a8c249046181 742 int16_t sl_EventMaskGet(const uint8_t EventClass, uint32_t *pMask);
dflet 3:a8c249046181 743 #endif
dflet 3:a8c249046181 744
dflet 3:a8c249046181 745
dflet 3:a8c249046181 746 /*!
dflet 3:a8c249046181 747 \brief the simple link task entry
dflet 3:a8c249046181 748
dflet 3:a8c249046181 749 \Param
dflet 3:a8c249046181 750 This function must be called from the main loop or from dedicated thread in
dflet 3:a8c249046181 751 the following cases:
dflet 3:a8c249046181 752 - Non-Os Platform - should be called from the mail loop
dflet 3:a8c249046181 753 - Multi Threaded Platform when the user does not implement the external spawn functions -
dflet 3:a8c249046181 754 should be called from dedicated thread allocated to the simplelink driver.
dflet 3:a8c249046181 755 In this mode the function never return.
dflet 3:a8c249046181 756
dflet 3:a8c249046181 757 \return None
dflet 3:a8c249046181 758
dflet 3:a8c249046181 759 \sa sl_Stop
dflet 3:a8c249046181 760
dflet 3:a8c249046181 761 \note belongs to \ref basic_api
dflet 3:a8c249046181 762
dflet 3:a8c249046181 763 \warning This function must be called from a thread that is start running before
dflet 3:a8c249046181 764 any call to other simple link API
dflet 3:a8c249046181 765 */
dflet 3:a8c249046181 766 #if _SL_INCLUDE_FUNC(sl_Task)
dflet 3:a8c249046181 767 void sl_Task(void);
dflet 3:a8c249046181 768 #endif
dflet 3:a8c249046181 769
dflet 3:a8c249046181 770
dflet 3:a8c249046181 771 /*!
dflet 3:a8c249046181 772 \brief Setting the internal uart mode
dflet 3:a8c249046181 773
dflet 3:a8c249046181 774 \param[in] pUartParams Pointer to the uart configuration parameter set:
dflet 3:a8c249046181 775 baudrate - up to 711 Kbps
dflet 3:a8c249046181 776 flow control - enable/disable
dflet 3:a8c249046181 777 comm port - the comm port number
dflet 3:a8c249046181 778
dflet 3:a8c249046181 779 \return On success zero is returned, otherwise - Failed.
dflet 3:a8c249046181 780
dflet 3:a8c249046181 781 \sa sl_Stop
dflet 3:a8c249046181 782
dflet 3:a8c249046181 783 \note belongs to \ref basic_api
dflet 3:a8c249046181 784
dflet 3:a8c249046181 785 \warning This function must consider the host uart capability
dflet 3:a8c249046181 786 */
dflet 3:a8c249046181 787 #ifdef SL_IF_TYPE_UART
dflet 3:a8c249046181 788 #if _SL_INCLUDE_FUNC(sl_UartSetMode)
dflet 3:a8c249046181 789 int16_t sl_UartSetMode(const SlUartIfParams_t* pUartParams);
dflet 3:a8c249046181 790 #endif
dflet 3:a8c249046181 791 #endif
dflet 3:a8c249046181 792
dflet 3:a8c249046181 793 public:
dflet 3:a8c249046181 794
dflet 3:a8c249046181 795 cc3100_spi _spi;
dflet 3:a8c249046181 796 cc3100_driver _driver;
dflet 3:a8c249046181 797 #ifndef SL_PLATFORM_MULTI_THREADED
dflet 3:a8c249046181 798 cc3100_nonos _nonos;
dflet 3:a8c249046181 799 #endif
dflet 3:a8c249046181 800 cc3100_wlan _wlan;
dflet 3:a8c249046181 801 cc3100_wlan_rx_filters _wlan_filters;
dflet 3:a8c249046181 802 cc3100_netapp _netapp;
dflet 3:a8c249046181 803 cc3100_fs _fs;
dflet 3:a8c249046181 804 cc3100_netcfg _netcfg;
dflet 3:a8c249046181 805 cc3100_socket _socket;
dflet 3:a8c249046181 806 cc3100_flowcont _flowcont;
dflet 3:a8c249046181 807
dflet 3:a8c249046181 808
dflet 3:a8c249046181 809 protected:
dflet 3:a8c249046181 810
dflet 3:a8c249046181 811
dflet 3:a8c249046181 812 };//class
dflet 3:a8c249046181 813
dflet 3:a8c249046181 814 }//namespace mbed_cc3100
dflet 3:a8c249046181 815
dflet 3:a8c249046181 816 /*!
dflet 3:a8c249046181 817
dflet 3:a8c249046181 818 Close the Doxygen group.
dflet 3:a8c249046181 819 @}
dflet 3:a8c249046181 820
dflet 3:a8c249046181 821 */
dflet 3:a8c249046181 822
dflet 3:a8c249046181 823
dflet 3:a8c249046181 824 #endif /* __DEVICE_H__ */
dflet 3:a8c249046181 825
dflet 3:a8c249046181 826
dflet 3:a8c249046181 827