cc3100_Socket_Wifi_Server version for LPC1768

Dependencies:   mbed

Fork of cc3100_Test_Demo by David Fletcher

Committer:
artpes
Date:
Fri May 26 19:26:11 2017 +0000
Revision:
8:e79bacf664cc
Parent:
6:778b081f6a13
Fork

Who changed what in which revision?

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