Updated to use external spawn.

Fork of simplelink_V2 by David Fletcher

Committer:
dflet
Date:
Sat Jun 06 13:48:29 2015 +0000
Revision:
1:9b68e650b3f6
Parent:
0:1a07906111ec
Oppps

Who changed what in which revision?

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