cc3100_Socket_Wifi_Server with Ethernet Interface not working

Dependencies:   EthernetInterface mbed-rtos mbed

Fork of cc3100_Test_Demo by David Fletcher

Committer:
dflet
Date:
Tue Feb 10 12:09:29 2015 +0000
Revision:
0:e89ba455dbcf
Child:
3:b89198ac2efe
For test only! Not much has been tested, but the 2 demo apps run ok. Alot more work needs to be done!

Who changed what in which revision?

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