David Fletcher / Mbed 2 deprecated cc3100_Test_websock_Camera_CM4F

Dependencies:   mbed

Committer:
dflet
Date:
Fri Aug 28 21:04:44 2015 +0000
Revision:
15:5433f9d94cd7
Parent:
0:50cedd586816
Child:
19:3dd3e7f30f8b
Cam ov2640 working correctly, didnt know it also gave a jpeg header. App still not stable. Still a lot of work needed.

Who changed what in which revision?

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