David Fletcher / Mbed 2 deprecated cc3100_Test_websock_Camera_CM4F

Dependencies:   mbed

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers cc3100.h Source File

cc3100.h

00001 /*
00002  * device.h - CC31xx/CC32xx Host Driver Implementation
00003  *
00004  * Copyright (C) 2014 Texas Instruments Incorporated - http://www.ti.com/
00005  *
00006  *
00007  *  Redistribution and use in source and binary forms, with or without
00008  *  modification, are permitted provided that the following conditions
00009  *  are met:
00010  *
00011  *    Redistributions of source code must retain the above copyright
00012  *    notice, this list of conditions and the following disclaimer.
00013  *
00014  *    Redistributions in binary form must reproduce the above copyright
00015  *    notice, this list of conditions and the following disclaimer in the
00016  *    documentation and/or other materials provided with the
00017  *    distribution.
00018  *
00019  *    Neither the name of Texas Instruments Incorporated nor the names of
00020  *    its contributors may be used to endorse or promote products derived
00021  *    from this software without specific prior written permission.
00022  *
00023  *  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
00024  *  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
00025  *  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
00026  *  A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
00027  *  OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
00028  *  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
00029  *  LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
00030  *  DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
00031  *  THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
00032  *  (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
00033  *  OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00034  *
00035 */
00036 
00037 #ifndef DEVICE_H_
00038 #define DEVICE_H_
00039 
00040 /*****************************************************************************/
00041 /* Include files                                                             */
00042 /*****************************************************************************/
00043 #include "mbed.h"
00044 #include "cc3100_simplelink.h"
00045 #include "cc3100_driver.h"
00046 #include "cc3100_wlan_rx_filters.h"
00047 
00048 #include "cc3100_spi.h"
00049 #include "cc3100_netcfg.h"
00050 
00051 namespace mbed_cc3100 {
00052 
00053 /*!
00054 
00055     \addtogroup device
00056     @{
00057 
00058 */
00059     const int16_t ROLE_UNKNOWN_ERR          =            -1;
00060 
00061     const uint16_t   MAX_BUFF_SIZE =  1460;
00062     extern uint32_t  g_PingPacketsRecv;
00063     extern uint32_t  g_GatewayIP;
00064     extern uint32_t  g_StationIP;
00065     extern uint32_t  g_DestinationIP;
00066     extern uint32_t  g_BytesReceived; // variable to store the file size 
00067     extern uint32_t  g_Status;
00068     extern uint8_t   g_buff[MAX_BUFF_SIZE+1];
00069     extern int32_t   g_SockID;
00070 
00071 
00072 /* File on the serial flash */
00073 #define FILE_NAME "cc3000_module.pdf"
00074 #define HOST_NAME       "www.ti.com"
00075 
00076 #define HTTP_FILE_NOT_FOUND    "404 Not Found" /* HTTP file not found response */
00077 //#define HTTP_STATUS_OK         "200 OK"  /* HTTP status ok response */
00078 #define HTTP_CONTENT_LENGTH    "Content-Length:"  /* HTTP content length header */
00079 #define HTTP_TRANSFER_ENCODING "Transfer-Encoding:" /* HTTP transfer encoding header */
00080 #define HTTP_ENCODING_CHUNKED  "chunked" /* HTTP transfer encoding header value */
00081 #define HTTP_CONNECTION        "Connection:" /* HTTP Connection header */
00082 #define HTTP_CONNECTION_CLOSE  "close"  /* HTTP Connection header value */
00083 #define HTTP_END_OF_HEADER  "\r\n\r\n"  /* string marking the end of headers in response */
00084 
00085 /*****************************************************************************/
00086 /* Macro declarations                                                        */
00087 /*****************************************************************************/
00088 
00089 const uint16_t IP_LEASE_TIME    =    3600;
00090 
00091 const uint16_t SIZE_45K      =  46080;  /* Serial flash file size 45 KB */
00092 const uint16_t READ_SIZE     =  1450;
00093 const uint8_t SPACE          =  32;
00094 
00095 const uint16_t PING_INTERVAL   =   1000;
00096 const uint8_t  PING_SIZE       =   20;
00097 const uint16_t PING_TIMEOUT    =   3000;
00098 const uint8_t  PING_ATTEMPTS   =   3;
00099 const uint8_t  PING_PKT_SIZE   =   20; 
00100 
00101 const uint8_t SL_STOP_TIMEOUT    =    0xFF;
00102 
00103 /* SL internal Error codes */
00104 
00105 /* Receive this error in case there are no resources to issue the command
00106    If possible, increase the number of MAX_CUNCURENT_ACTIONS (result in memory increase)
00107    If not, try again later */
00108 const int16_t SL_POOL_IS_EMPTY  = (-2000);
00109 
00110 /* Receive this error in case a given length for RX buffer was too small.
00111    Receive payload was bigger than the given buffer size. Therefore, payload is cut according to receive size
00112    Recommend to increase buffer size */
00113 const int16_t SL_ESMALLBUF      = (-2001);
00114 
00115 /* Receive this error in case zero length is supplied to a "get" API
00116    Recommend to supply length according to requested information (view options defines for help) */
00117 const int16_t SL_EZEROLEN       = (-2002);
00118 
00119 /* User supplied invalid parameter */
00120 const int16_t SL_INVALPARAM     = (-2003);
00121 
00122 /* Failed to open interface  */
00123 const int16_t SL_BAD_INTERFACE  = (-2004);
00124 
00125 /* End of SL internal Error codes */
00126 
00127 /*****************************************************************************/
00128 /* Errors returned from the general error async event                        */
00129 /*****************************************************************************/        
00130     
00131 /* Use bit 32: Lower bits of status variable are used for NWP events
00132  *      1 in a 'status_variable', the device has completed the ping operation
00133  *      0 in a 'status_variable', the device has not completed the ping operation
00134  */
00135 //const uint32_t STATUS_BIT_PING_DONE = 31;
00136 
00137 /* Status bits - These are used to set/reset the corresponding bits in a 'status_variable' */
00138 typedef enum {
00139     STATUS_BIT_CONNECTION =  0, /* If this bit is:
00140                                  *      1 in a 'status_variable', the device is connected to the AP
00141                                  *      0 in a 'status_variable', the device is not connected to the AP
00142                                  */
00143 
00144     STATUS_BIT_STA_CONNECTED,    /* If this bit is:
00145                                   *      1 in a 'status_variable', client is connected to device
00146                                   *      0 in a 'status_variable', client is not connected to device
00147                                   */
00148 
00149     STATUS_BIT_IP_ACQUIRED,       /* If this bit is:
00150                                    *      1 in a 'status_variable', the device has acquired an IP
00151                                    *      0 in a 'status_variable', the device has not acquired an IP
00152                                    */
00153 
00154     STATUS_BIT_IP_LEASED,           /* If this bit is:
00155                                       *      1 in a 'status_variable', the device has leased an IP
00156                                       *      0 in a 'status_variable', the device has not leased an IP
00157                                       */
00158 
00159     STATUS_BIT_CONNECTION_FAILED,   /* If this bit is:
00160                                      *      1 in a 'status_variable', failed to connect to device
00161                                      *      0 in a 'status_variable'
00162                                      */
00163 
00164     STATUS_BIT_P2P_NEG_REQ_RECEIVED,/* If this bit is:
00165                                      *      1 in a 'status_variable', connection requested by remote wifi-direct device
00166                                      *      0 in a 'status_variable',
00167                                      */
00168     STATUS_BIT_SMARTCONFIG_DONE,    /* If this bit is:
00169                                      *      1 in a 'status_variable', smartconfig completed
00170                                      *      0 in a 'status_variable', smartconfig event couldn't complete
00171                                      */
00172 
00173     STATUS_BIT_SMARTCONFIG_STOPPED,  /* If this bit is:
00174                                      *      1 in a 'status_variable', smartconfig process stopped
00175                                      *      0 in a 'status_variable', smartconfig process running
00176                                      */
00177                                      
00178     STATUS_BIT_PING_DONE = 31
00179                                      /* Use bit 32: Lower bits of status variable are used for NWP events
00180                                       *      1 in a 'status_variable', the device has completed the ping operation
00181                                       *      0 in a 'status_variable', the device has not completed the ping operation
00182                                       */                                 
00183 
00184 } e_StatusBits;        
00185     
00186 /* Application specific status/error codes */
00187 typedef enum {
00188     LAN_CONNECTION_FAILED = -0x7D0,        /* Choosing this number to avoid overlap with host-driver's error codes */
00189     CAMERA_CAPTURE_FAILED = -0x7D0,
00190     INTERNET_CONNECTION_FAILED = LAN_CONNECTION_FAILED - 1,
00191     DEVICE_NOT_IN_STATION_MODE = INTERNET_CONNECTION_FAILED - 1,
00192     DEVICE_NOT_IN_AP_MODE = DEVICE_NOT_IN_STATION_MODE - 1,
00193     DEVICE_NOT_IN_P2P_MODE = DEVICE_NOT_IN_STATION_MODE - 1,
00194     HTTP_SEND_ERROR = DEVICE_NOT_IN_STATION_MODE - 1,
00195     HTTP_RECV_ERROR = HTTP_SEND_ERROR - 1,
00196     HTTP_INVALID_RESPONSE = HTTP_RECV_ERROR -1,
00197     SNTP_SEND_ERROR = DEVICE_NOT_IN_STATION_MODE - 1,
00198     SNTP_RECV_ERROR = SNTP_SEND_ERROR - 1,
00199     SNTP_SERVER_RESPONSE_ERROR = SNTP_RECV_ERROR - 1,
00200     INVALID_HEX_STRING = DEVICE_NOT_IN_STATION_MODE - 1,
00201     TCP_RECV_ERROR = INVALID_HEX_STRING - 1,
00202     TCP_SEND_ERROR = TCP_RECV_ERROR - 1,
00203     FILE_NOT_FOUND_ERROR = TCP_SEND_ERROR - 1,
00204     INVALID_SERVER_RESPONSE = FILE_NOT_FOUND_ERROR - 1,
00205     FORMAT_NOT_SUPPORTED = INVALID_SERVER_RESPONSE - 1,
00206     FILE_WRITE_ERROR = FORMAT_NOT_SUPPORTED - 1,
00207     INVALID_FILE = FILE_WRITE_ERROR - 1,
00208 
00209     STATUS_CODE_MAX = -0xBB8
00210 } e_AppStatusCodes;    
00211     
00212     /* Send types */
00213 typedef enum {
00214     SL_ERR_SENDER_HEALTH_MON,
00215     SL_ERR_SENDER_CLI_UART,
00216     SL_ERR_SENDER_SUPPLICANT,
00217     SL_ERR_SENDER_NETWORK_STACK,
00218     SL_ERR_SENDER_WLAN_DRV_IF,
00219     SL_ERR_SENDER_WILINK,
00220     SL_ERR_SENDER_INIT_APP,
00221     SL_ERR_SENDER_NETX,
00222     SL_ERR_SENDER_HOST_APD,
00223     SL_ERR_SENDER_MDNS,
00224     SL_ERR_SENDER_HTTP_SERVER,
00225     SL_ERR_SENDER_DHCP_SERVER,
00226     SL_ERR_SENDER_DHCP_CLIENT,
00227     SL_ERR_DISPATCHER,
00228     SL_ERR_NUM_SENDER_LAST=0xFF
00229 } SlErrorSender_e;
00230 
00231 /* Error codes */
00232 const int8_t SL_ERROR_STATIC_ADDR_SUBNET_ERROR                  = (-60);  /* network stack error*/
00233 const int8_t SL_ERROR_ILLEGAL_CHANNEL                           = (-61);  /* supplicant error */
00234 const int8_t SL_ERROR_SUPPLICANT_ERROR                          = (-72);  /* init error code */
00235 const int8_t SL_ERROR_HOSTAPD_INIT_FAIL                         = (-73);  /* init error code */
00236 const int8_t SL_ERROR_HOSTAPD_INIT_IF_FAIL                      = (-74);  /* init error code */
00237 const int8_t SL_ERROR_WLAN_DRV_INIT_FAIL                        = (-75);  /* init error code */
00238 const int8_t SL_ERROR_WLAN_DRV_START_FAIL                       = (-76);  /* wlan start error */
00239 const int8_t SL_ERROR_FS_FILE_TABLE_LOAD_FAILED                 = (-77);  /* init file system failed */
00240 const int8_t SL_ERROR_PREFERRED_NETWORKS_FILE_LOAD_FAILED       = (-78);  /* init file system failed */
00241 const int8_t SL_ERROR_HOSTAPD_BSSID_VALIDATION_ERROR            = (-79);  /* Ap configurations BSSID error */
00242 const int8_t SL_ERROR_HOSTAPD_FAILED_TO_SETUP_INTERFACE         = (-80);  /* Ap configurations interface error */
00243 const int8_t SL_ERROR_MDNS_ENABLE_FAIL                          = (-81);  /* mDNS enable failed                */
00244 const int8_t SL_ERROR_HTTP_SERVER_ENABLE_FAILED                 = (-82);  /* HTTP server enable failed         */
00245 const int8_t SL_ERROR_DHCP_SERVER_ENABLE_FAILED                 = (-83);  /* DHCP server enable failed         */
00246 const int8_t SL_ERROR_PREFERRED_NETWORK_LIST_FULL               = (-93);  /* supplicant error  */
00247 const int8_t SL_ERROR_PREFERRED_NETWORKS_FILE_WRITE_FAILED      = (-94);  /* supplicant error  */
00248 const int8_t SL_ERROR_DHCP_CLIENT_RENEW_FAILED                  = (-100); /* DHCP client error */
00249 /* WLAN Connection management status */
00250 const int8_t SL_ERROR_CON_MGMT_STATUS_UNSPECIFIED               = (-102);
00251 const int8_t SL_ERROR_CON_MGMT_STATUS_AUTH_REJECT               = (-103);
00252 const int8_t SL_ERROR_CON_MGMT_STATUS_ASSOC_REJECT              = (-104);
00253 const int8_t SL_ERROR_CON_MGMT_STATUS_SECURITY_FAILURE          = (-105);
00254 const int8_t SL_ERROR_CON_MGMT_STATUS_AP_DEAUTHENTICATE         = (-106);
00255 const int8_t SL_ERROR_CON_MGMT_STATUS_AP_DISASSOCIATE           = (-107);
00256 const int8_t SL_ERROR_CON_MGMT_STATUS_ROAMING_TRIGGER           = (-108);
00257 const int8_t SL_ERROR_CON_MGMT_STATUS_DISCONNECT_DURING_CONNECT = (-109);
00258 const int8_t SL_ERROR_CON_MGMT_STATUS_SG_RESELECT               = (-110);
00259 const int8_t SL_ERROR_CON_MGMT_STATUS_ROC_FAILURE               = (-111);
00260 const int8_t SL_ERROR_CON_MGMT_STATUS_MIC_FAILURE               = (-112);
00261 /* end of WLAN connection management error statuses */
00262 const int8_t SL_ERROR_WAKELOCK_ERROR_PREFIX                     = (-115);  /* Wake lock expired */
00263 const int8_t SL_ERROR_LENGTH_ERROR_PREFIX                       = (-116);  /* Uart header length error */
00264 const int8_t SL_ERROR_MDNS_CREATE_FAIL                          = (-121);  /* mDNS create failed */
00265 const int8_t SL_ERROR_GENERAL_ERROR                             = (-127);
00266 
00267 
00268 
00269 const int8_t SL_DEVICE_GENERAL_CONFIGURATION           = (1);
00270 const int8_t SL_DEVICE_GENERAL_CONFIGURATION_DATE_TIME = (11);
00271 const int8_t SL_DEVICE_GENERAL_VERSION                 = (12);
00272 const int8_t SL_DEVICE_STATUS                          = (2);
00273 
00274 /*
00275     Declare the different event group classifications
00276     The SimpleLink device send asynchronous events. Each event has a group
00277     classification according to its nature.
00278 */
00279 #if 1
00280 /* SL_EVENT_CLASS_WLAN connection user events */
00281 const int8_t SL_WLAN_CONNECT_EVENT                   =  (1);
00282 const int8_t SL_WLAN_DISCONNECT_EVENT                =  (2);
00283 /* WLAN Smart Config user events */
00284 const int8_t SL_WLAN_SMART_CONFIG_COMPLETE_EVENT     =  (3);
00285 const int8_t SL_WLAN_SMART_CONFIG_STOP_EVENT         =  (4);
00286 /* WLAN AP user events */
00287 const int8_t SL_WLAN_STA_CONNECTED_EVENT             =  (5);
00288 const int8_t SL_WLAN_STA_DISCONNECTED_EVENT          =  (6);
00289 /* WLAN P2P user events */
00290 const int8_t SL_WLAN_P2P_DEV_FOUND_EVENT             =  (7);
00291 const int8_t    SL_WLAN_P2P_NEG_REQ_RECEIVED_EVENT   =  (8);
00292 const int8_t SL_WLAN_CONNECTION_FAILED_EVENT         =  (9);
00293 /* SL_EVENT_CLASS_DEVICE user events */
00294 const int8_t SL_DEVICE_FATAL_ERROR_EVENT             =  (1);
00295 const int8_t SL_DEVICE_ABORT_ERROR_EVENT             =  (2);
00296 /* SL_EVENT_CLASS_BSD user events */
00297 const int8_t    SL_SOCKET_TX_FAILED_EVENT            =  (1);
00298 const int8_t SL_SOCKET_ASYNC_EVENT                   =  (2);
00299 /* SL_EVENT_CLASS_NETAPP user events */
00300 const int8_t    SL_NETAPP_IPV4_IPACQUIRED_EVENT      =  (1);
00301 const int8_t    SL_NETAPP_IPV6_IPACQUIRED_EVENT      =  (2);
00302 const int8_t SL_NETAPP_IP_LEASED_EVENT               =  (3);
00303 const int8_t SL_NETAPP_IP_RELEASED_EVENT             =  (4);
00304 
00305 /* Server Events */
00306 const int8_t SL_NETAPP_HTTPGETTOKENVALUE_EVENT       =   (1);
00307 const int8_t SL_NETAPP_HTTPPOSTTOKENVALUE_EVENT      =   (2);
00308 #endif
00309 
00310 /*
00311     Declare the different event group classifications for sl_DevGet
00312     for getting status indications
00313  */
00314 
00315 /* Events list to mask/unmask*/
00316 const int8_t SL_EVENT_CLASS_GLOBAL                   =  (0);
00317 const int8_t SL_EVENT_CLASS_DEVICE                   =  (1);
00318 const int8_t SL_EVENT_CLASS_WLAN                     =  (2);
00319 const int8_t SL_EVENT_CLASS_BSD                      =  (3);
00320 const int8_t SL_EVENT_CLASS_NETAPP                   =  (4);
00321 const int8_t SL_EVENT_CLASS_NETCFG                   =  (5);
00322 const int8_t SL_EVENT_CLASS_FS                       =  (6);
00323 
00324 
00325 /******************  DEVICE CLASS status ****************/
00326 const uint32_t EVENT_DROPPED_DEVICE_ASYNC_GENERAL_ERROR         = (0x00000001L);
00327 const uint32_t STATUS_DEVICE_SMART_CONFIG_ACTIVE                = (0x80000000L);
00328 
00329 /******************  WLAN CLASS status ****************/
00330 const uint32_t EVENT_DROPPED_WLAN_WLANASYNCONNECTEDRESPONSE     = (0x00000001L);
00331 const uint32_t EVENT_DROPPED_WLAN_WLANASYNCDISCONNECTEDRESPONSE = (0x00000002L);
00332 const uint32_t EVENT_DROPPED_WLAN_STA_CONNECTED                 = (0x00000004L);
00333 const uint32_t EVENT_DROPPED_WLAN_STA_DISCONNECTED              = (0x00000008L);
00334 const uint32_t STATUS_WLAN_STA_CONNECTED                        = (0x80000000L);
00335 
00336 /******************  NETAPP CLASS status ****************/
00337 const uint32_t EVENT_DROPPED_NETAPP_IPACQUIRED                  = (0x00000001L);
00338 const uint32_t EVENT_DROPPED_NETAPP_IPACQUIRED_V6               = (0x00000002L);
00339 const uint32_t EVENT_DROPPED_NETAPP_IP_LEASED                   = (0x00000004L);
00340 const uint32_t EVENT_DROPPED_NETAPP_IP_RELEASED                 = (0x00000008L);
00341 
00342 /******************  BSD CLASS status ****************/
00343 const uint32_t EVENT_DROPPED_SOCKET_TXFAILEDASYNCRESPONSE       = (0x00000001L);
00344 
00345 /******************  FS CLASS  ****************/
00346 
00347 /*****************************************************************************/
00348 /* Structure/Enum declarations                                               */
00349 /*****************************************************************************/
00350 
00351 #ifdef SL_IF_TYPE_UART
00352 typedef struct {
00353     uint32_t             BaudRate;
00354     uint8_t              FlowControlEnable;
00355     uint8_t              CommPort;
00356 } SlUartIfParams_t;
00357 #endif
00358 
00359 typedef struct {
00360     uint32_t               ChipId;
00361     uint32_t               FwVersion[4];
00362     uint8_t                PhyVersion[4];
00363 } _SlPartialVersion;
00364 
00365 typedef struct {
00366     _SlPartialVersion ChipFwAndPhyVersion;
00367     uint32_t               NwpVersion[4];
00368     uint16_t               RomVersion;
00369     uint16_t               Padding;
00370 } SlVersionFull;
00371 
00372 typedef struct
00373 {
00374     uint32_t                AbortType;
00375     uint32_t                AbortData;
00376 }sl_DeviceReportAbort;
00377 
00378 typedef struct {
00379     int8_t                status;
00380     SlErrorSender_e        sender;
00381 } sl_DeviceReport;
00382 
00383 typedef union {
00384     sl_DeviceReport           deviceEvent;
00385     sl_DeviceReportAbort      deviceReport;
00386 } _SlDeviceEventData_u;
00387 
00388 typedef struct {
00389     uint32_t             Event;
00390     _SlDeviceEventData_u EventData;
00391 } SlDeviceEvent_t;
00392 
00393 typedef struct {
00394     /* time */
00395     uint32_t                sl_tm_sec;
00396     uint32_t                sl_tm_min;
00397     uint32_t                sl_tm_hour;
00398     /* date */
00399     uint32_t                sl_tm_day; /* 1-31 */
00400     uint32_t                sl_tm_mon; /* 1-12 */
00401     uint32_t                sl_tm_year; /*  YYYY 4 digits  */
00402     uint32_t                sl_tm_week_day; /* not required */
00403     uint32_t                sl_tm_year_day; /* not required */
00404     uint32_t                reserved[3];
00405 } SlDateTime_t;
00406 
00407 /******************************************************************************/
00408 /* Type declarations                                                          */
00409 /******************************************************************************/
00410 typedef void (*P_INIT_CALLBACK)(uint32_t Status);
00411 
00412 class cc3100_netcfg;
00413 
00414 class cc3100
00415 {
00416 
00417 public:
00418 
00419     cc3100(PinName button1_irq, PinName button2_irq, PinName cc3100_irq, PinName cc3100_nHIB, PinName cc3100_cs, SPI cc3100_spi);
00420 
00421     ~cc3100();
00422 
00423     /*****************************************************************************/
00424     /* Function prototypes                                                       */
00425     /*****************************************************************************/
00426     int32_t initializeAppVariables(void);
00427     
00428     int32_t Network_AP_InitDriver(void);
00429     
00430     int32_t establishConnectionWithAP(void);
00431     
00432     int32_t checkLanConnection(void);
00433     
00434     int32_t checkInternetConnection(void);
00435     
00436     int32_t createUDPConnection(void);
00437     
00438     int32_t createConnection(uint32_t DestinationIP);
00439 
00440     int32_t getChunkSize(int32_t *len, uint8_t **p_Buff, uint32_t *chunk_size);
00441     
00442     int32_t hexToi(unsigned char *ptr);
00443     
00444 //    int32_t getFile(void);
00445     
00446     int32_t disconnectFromAP(void);
00447     
00448     uint16_t itoa(int16_t cNum, uint8_t *cString);
00449     
00450     int32_t Network_IF_InitDriver(uint32_t uiMode);    
00451     
00452     int32_t configureSimpleLinkToDefaultState(void);
00453     
00454     int16_t _sl_GetStartResponseConvert(uint32_t Status);
00455 
00456     void _sl_HandleAsync_InitComplete(void *pVoidBuf); 
00457     
00458     bool IS_PING_DONE(uint32_t status_variable,const uint32_t bit);
00459     bool IS_CONNECTED(uint32_t status_variable,const uint32_t bit);
00460     bool IS_STA_CONNECTED(uint32_t status_variable,const uint32_t bit);
00461     bool IS_IP_ACQUIRED(uint32_t status_variable,const uint32_t bit);
00462     bool IS_IP_LEASED(uint32_t status_variable,const uint32_t bit);
00463     bool IS_CONNECTION_FAILED(uint32_t status_variable,const uint32_t bit);
00464     bool IS_P2P_NEG_REQ_RECEIVED(uint32_t status_variable,const uint32_t bit);
00465     bool IS_SMARTCONFIG_DONE(uint32_t status_variable,const uint32_t bit);
00466     bool IS_SMARTCONFIG_STOPPED(uint32_t status_variable,const uint32_t bit);
00467     
00468     
00469     
00470     void CLR_STATUS_BIT(uint32_t status_variable, const uint32_t bit);
00471     void SET_STATUS_BIT(uint32_t status_variable, const uint32_t bit);
00472     void CLR_STATUS_BIT_ALL(uint32_t status_variable);
00473 
00474     /*!
00475         \brief Start the SimpleLink device
00476 
00477         This function initialize the communication interface, set the enable pin
00478         of the device, and call to the init complete callback.
00479 
00480         \param[in]      pIfHdl              Opened Interface Object. In case the interface
00481                                             must be opened outside the SimpleLink Driver, the
00482                                             user might give the handler to be used in \n
00483                                             any access of the communication interface with the
00484                                             device (UART/SPI). \n
00485                                             The SimpleLink driver will open an interface port
00486                                             only if this parameter is null! \n
00487         \param[in]      pDevName            The name of the device to open. Could be used when
00488                                             the pIfHdl is null, to transfer information to the
00489                                             open interface function \n
00490                                             This pointer could be used to pass additional information to
00491                                             sl_IfOpen in case it is required (e.g. UART com port name)
00492         \param[in]      pInitCallBack       Pointer to function that would be called
00493                                             on completion of the initialization process.\n
00494                                             If this parameter is NULL the function is
00495                                             blocked until the device initialization
00496                                             is completed, otherwise the function returns
00497                                             immediately.
00498 
00499         \return         Returns the current active role (STA/AP/P2P) or an error code:
00500                         - ROLE_STA, ROLE_AP, ROLE_P2P in case of success,
00501                           otherwise in failure one of the following is return:
00502                         - ROLE_STA_ERR  (Failure to load MAC/PHY in STA role)
00503                         - ROLE_AP_ERR  (Failure to load MAC/PHY in AP role)
00504                         - ROLE_P2P_ERR  (Failure to load MAC/PHY in P2P role)
00505 
00506 
00507          \sa             sl_Stop
00508 
00509         \note           belongs to \ref basic_api
00510 
00511         \warning        This function must be called before any other SimpleLink API is used, or after sl_Stop is called for reinit the device
00512         \par            Example:
00513         \code
00514                        An example for open interface without callback routine. The interface name and handler are
00515                        handled by the sl_IfOpen routine:
00516 
00517                         if( sl_Start(NULL, NULL, NULL) < 0 )
00518                        {
00519                            LOG("Error opening interface to device\n");
00520                        }
00521         \endcode
00522     */
00523 #if _SL_INCLUDE_FUNC(sl_Start)
00524     int16_t sl_Start(const void* pIfHdl, int8_t*  pDevName, const P_INIT_CALLBACK pInitCallBack);
00525 #endif
00526 
00527     /*!
00528         \brief Stop the SimpleLink device
00529 
00530         This function clears the enable pin of the device, closes the communication \n
00531         interface and invokes the stop complete callback
00532 
00533         \param[in]      timeout                       Stop timeout in msec. Should be used to give the device time to finish \n
00534                                                       any transmission/reception that is not completed when the function was called. \n
00535                         Additional options:
00536                         - 0                             Enter to hibernate immediately \n
00537                         - 0xFFFF                        Host waits for device's response before \n
00538                                                         hibernating, without timeout protection \n
00539                         - 0 < Timeout[msec] < 0xFFFF    Host waits for device's response before \n
00540                                                         hibernating, with a defined timeout protection \n
00541                                                         This timeout defines the max time to wait. The NWP \n
00542                                                         response can be sent earlier than this timeout.
00543 
00544         \return         On success, zero is returned. On error, -1 is returned
00545 
00546         \sa             sl_Start
00547 
00548         \note           This API will shutdown the device and invoke the "i/f close" function regardless \n
00549                         if it was opened implicitly or explicitly. \n
00550                         It is up to the platform interface library to properly handle interface close \n
00551                         routine \n
00552                         belongs to \ref basic_api \n
00553         \warning
00554     */
00555 #if _SL_INCLUDE_FUNC(sl_Stop)
00556     int16_t sl_Stop(const uint16_t timeout);
00557 #endif
00558 
00559 
00560     /*!
00561         \brief     Internal function for setting device configurations
00562 
00563         \return    On success, zero is returned. On error, -1 is
00564                    returned
00565 
00566         \param[in] DeviceSetId   configuration id
00567         \param[in] Option         configurations option
00568         \param[in] ConfigLen     configurations len
00569         \param[in] pValues         configurations values
00570 
00571         \sa
00572         \note
00573         \warning
00574         \par   Examples:
00575         \code
00576              Setting device time and date example:
00577 
00578              SlDateTime_t dateTime= {0};
00579              dateTime.sl_tm_day =   (uint32_t)23;          // Day of month (DD format) range 1-13
00580              dateTime.sl_tm_mon =   (uint32_t)6;           // Month (MM format) in the range of 1-12
00581              dateTime.sl_tm_year =  (uint32_t)2014;        // Year (YYYY format)
00582              dateTime.sl_tm_hour =  (uint32_t)17;          // Hours in the range of 0-23
00583              dateTime.sl_tm_min =   (uint32_t)55;          // Minutes in the range of 0-59
00584              dateTime.sl_tm_sec =   (uint32_t)22;          // Seconds in the range of  0-59
00585              sl_DevSet(SL_DEVICE_GENERAL_CONFIGURATION,
00586                        SL_DEVICE_GENERAL_CONFIGURATION_DATE_TIME,
00587                        sizeof(SlDateTime_t),
00588                        (uint8_t *)(&dateTime));
00589 
00590         \endcode
00591     */
00592 #if _SL_INCLUDE_FUNC(sl_DevSet)
00593     int32_t sl_DevSet(const uint8_t DeviceSetId , const uint8_t Option, const uint8_t ConfigLen, const uint8_t *pValues);
00594 #endif
00595 
00596     /*!
00597         \brief      Internal function for getting device configurations
00598         \return     On success, zero is returned. On error, -1 is
00599                     returned
00600         \param[in]  DeviceGetId   configuration id - example SL_DEVICE_STATUS
00601         \param[out] pOption   Get configurations option, example for get status options
00602                                 - SL_EVENT_CLASS_GLOBAL
00603                                 - SL_EVENT_CLASS_DEVICE
00604                                 - SL_EVENT_CLASS_WLAN
00605                                 - SL_EVENT_CLASS_BSD
00606                                 - SL_EVENT_CLASS_NETAPP
00607                                 - SL_EVENT_CLASS_NETCFG
00608                                 - SL_EVENT_CLASS_FS
00609         \param[out] pConfigLen   The length of the allocated memory as input, when the
00610                                  function complete, the value of this parameter would be
00611                                  the len that actually read from the device.\n
00612                                  If the device return length that is longer from the input
00613                                  value, the function will cut the end of the returned structure
00614                                  and will return SL_ESMALLBUF
00615         \param[out] pValues      Get configurations values
00616         \sa
00617         \note
00618         \warning
00619         \par        Examples:
00620         \code
00621          Example for getting WLAN class status:
00622          uint32_t statusWlan;
00623          uint8_t pConfigOpt;
00624          uint8_t pConfigLen;
00625          pConfigLen = sizeof(_u32);
00626          pConfigOpt = SL_EVENT_CLASS_WLAN;
00627          sl_DevGet(SL_DEVICE_STATUS,&pConfigOpt,&pConfigLen,(uint8_t *)(&statusWlan));
00628          Example for getting version:
00629          SlVersionFull ver;
00630          pConfigLen = sizeof(ver);
00631          pConfigOpt = SL_DEVICE_GENERAL_VERSION;
00632          sl_DevGet(SL_DEVICE_GENERAL_CONFIGURATION,&pConfigOpt,&pConfigLen,(uint8_t *)(&ver));
00633          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",
00634                  ver.ChipFwAndPhyVersion.ChipId,
00635                  ver.ChipFwAndPhyVersion.FwVersion[0],ver.ChipFwAndPhyVersion.FwVersion[1],
00636                  ver.ChipFwAndPhyVersion.FwVersion[2],ver.ChipFwAndPhyVersion.FwVersion[3],
00637                  ver.ChipFwAndPhyVersion.PhyVersion[0],ver.ChipFwAndPhyVersion.PhyVersion[1],
00638                  ver.ChipFwAndPhyVersion.PhyVersion[2],ver.ChipFwAndPhyVersion.PhyVersion[3],
00639                  ver.NwpVersion[0],ver.NwpVersion[1],ver.NwpVersion[2],ver.NwpVersion[3],
00640                  ver.RomVersion,
00641                  SL_MAJOR_VERSION_NUM,SL_MINOR_VERSION_NUM,SL_VERSION_NUM,SL_SUB_VERSION_NUM);
00642 
00643          \endcode
00644          \code
00645              Getting Device time and date example:
00646 
00647              SlDateTime_t dateTime =  {0};
00648              int8_t configLen = sizeof(SlDateTime_t);
00649              int8_t configOpt = SL_DEVICE_GENERAL_CONFIGURATION_DATE_TIME;
00650              sl_DevGet(SL_DEVICE_GENERAL_CONFIGURATION,&configOpt, &configLen,(uint8_t *)(&dateTime));
00651 
00652              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
00653                      dateTime.sl_tm_hour,dateTime.sl_tm_min,dateTime.sl_tm_sec);
00654          \endcode
00655     */
00656 #if _SL_INCLUDE_FUNC(sl_DevGet)
00657     int32_t sl_DevGet(const uint8_t DeviceGetId, uint8_t *pOption,uint8_t *pConfigLen, uint8_t *pValues);
00658 #endif
00659 
00660 
00661     /*!
00662         \brief          Set asynchronous event mask
00663 
00664         Mask asynchronous events from the device. Masked events do not
00665         generate asynchronous messages from the device.
00666         By default - all events are active
00667 
00668         \param[in]      EventClass          The classification groups that the
00669                                             mask is referred to. Need to be one of
00670                                             the following:
00671                                             - SL_EVENT_CLASS_GLOBAL
00672                                             - SL_EVENT_CLASS_DEVICE
00673                                             - SL_EVENT_CLASS_WLAN
00674                                             - SL_EVENT_CLASS_BSD
00675                                             - SL_EVENT_CLASS_NETAPP
00676                                             - SL_EVENT_CLASS_NETCFG
00677                                             - SL_EVENT_CLASS_FS
00678 
00679 
00680         \param[in]      Mask               Event Mask bitmap. Valid mask are (per group):
00681                                             - SL_EVENT_CLASS_WLAN user events
00682                                               - SL_WLAN_CONNECT_EVENT
00683                                               - SL_WLAN_DISCONNECT_EVENT
00684                                             - SL_EVENT_CLASS_DEVICE user events
00685                                               - SL_DEVICE_FATAL_ERROR_EVENT
00686                                             - SL_EVENT_CLASS_BSD user events
00687                                               - SL_SOCKET_TX_FAILED_EVENT
00688                                               - SL_SOCKET_ASYNC_EVENT
00689                                             - SL_EVENT_CLASS_NETAPP user events
00690                                               - SL_NETAPP_IPV4_IPACQUIRED_EVENT
00691                                               - SL_NETAPP_IPV6_IPACQUIRED_EVENT
00692 
00693         \return         On success, zero is returned. On error, -1 is returned
00694 
00695         \sa             sl_EventMaskGet
00696 
00697         \note           belongs to \ref ext_api
00698 
00699         \warning
00700         \par           Example:
00701         \code
00702 
00703         An example of masking connection/disconnection async events from WLAN class:
00704                        sl_EventMaskSet(SL_EVENT_CLASS_WLAN, (SL_WLAN_CONNECT_EVENT | SL_WLAN_DISCONNECT_EVENT) );
00705 
00706         \endcode
00707     */
00708 #if _SL_INCLUDE_FUNC(sl_EventMaskSet)
00709     int16_t sl_EventMaskSet(const uint8_t EventClass , const uint32_t Mask);
00710 #endif
00711 
00712     /*!
00713         \brief Get current event mask of the device
00714 
00715         return the events bit mask from the device. In case that event is
00716         masked, the device is not sending this event.
00717 
00718         \param[in]      EventClass          The classification groups that the
00719                                             mask is referred to. Need to be one of
00720                                             the following:
00721                                             - SL_EVENT_CLASS_GLOBAL
00722                                             - SL_EVENT_CLASS_DEVICE
00723                                             - SL_EVENT_CLASS_WLAN
00724                                             - SL_EVENT_CLASS_BSD
00725                                             - SL_EVENT_CLASS_NETAPP
00726                                             - SL_EVENT_CLASS_NETCFG
00727                                             - SL_EVENT_CLASS_FS
00728 
00729         \param[out]      pMask              Pointer to Mask bitmap where the
00730                                             value should be stored. Bitmasks are the same as in \ref sl_EventMaskSet
00731 
00732         \return         On success, zero is returned. On error, -1 is returned
00733 
00734         \sa             sl_EventMaskSet
00735 
00736         \note           belongs to \ref ext_api
00737 
00738         \warning
00739         \par           Example:
00740         \code
00741 
00742         An example of getting an event mask for WLAN class
00743         uint32_t maskWlan;
00744                        sl_StatusGet(SL_EVENT_CLASS_WLAN,&maskWlan);
00745 
00746        \endcode
00747     */
00748 #if _SL_INCLUDE_FUNC(sl_EventMaskGet)
00749     int16_t sl_EventMaskGet(const uint8_t EventClass, uint32_t *pMask);
00750 #endif
00751 
00752 
00753     /*!
00754         \brief the simple link task entry
00755 
00756         \Param
00757         This function must be called from the main loop or from dedicated thread in
00758         the following cases:
00759             - Non-Os Platform - should be called from the mail loop
00760             - Multi Threaded Platform when the user does not implement the external spawn functions -
00761                should be called from dedicated thread allocated to the simplelink driver.
00762                In this mode the function never return.
00763 
00764         \return         None
00765 
00766         \sa             sl_Stop
00767 
00768         \note           belongs to \ref basic_api
00769 
00770         \warning        This function must be called from a thread that is start running before
00771                         any call to other simple link API
00772     */
00773 #if _SL_INCLUDE_FUNC(sl_Task)
00774     void sl_Task(void);
00775 #endif
00776 
00777 
00778     /*!
00779         \brief Setting the internal uart mode
00780 
00781         \param[in]      pUartParams          Pointer to the uart configuration parameter set:
00782                                              baudrate     - up to 711 Kbps
00783                                              flow control - enable/disable
00784                                              comm port    - the comm port number
00785 
00786         \return         On success zero is returned, otherwise - Failed.
00787 
00788         \sa             sl_Stop
00789 
00790         \note           belongs to \ref basic_api
00791 
00792         \warning        This function must consider the host uart capability
00793     */
00794 #ifdef SL_IF_TYPE_UART
00795 #if _SL_INCLUDE_FUNC(sl_UartSetMode)
00796     int16_t sl_UartSetMode(const SlUartIfParams_t* pUartParams);
00797 #endif
00798 #endif
00799 
00800 public:
00801     
00802     cc3100_spi               _spi;
00803     cc3100_driver            _driver;
00804 //#ifndef SL_PLATFORM_MULTI_THREADED 
00805 #if (!defined (SL_PLATFORM_MULTI_THREADED)) && (!defined (SL_PLATFORM_EXTERNAL_SPAWN))  
00806     cc3100_nonos             _nonos;
00807 #endif    
00808     cc3100_wlan              _wlan;
00809     cc3100_wlan_rx_filters   _wlan_filters;    
00810     cc3100_netapp            _netapp;
00811     cc3100_fs                _fs;
00812     cc3100_netcfg            _netcfg;    
00813     cc3100_socket            _socket;
00814     cc3100_flowcont          _flowcont;
00815 
00816 
00817 protected:
00818     
00819 
00820 };//class
00821 
00822 }//namespace mbed_cc3100
00823 
00824 /*!
00825 
00826  Close the Doxygen group.
00827  @}
00828 
00829  */
00830 
00831 
00832 #endif  /*  __DEVICE_H__ */
00833 
00834 
00835