TI's MQTT Demo with freertos CM4F

Dependencies:   mbed

Committer:
dflet
Date:
Thu Sep 03 14:07:01 2015 +0000
Revision:
0:1e7b5dd9edb4
First commit, it's been hanging around for a while. Updated SPI mode change 1 to 0.

Who changed what in which revision?

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