cc3100_Socket_Wifi_Server with Ethernet Interface not working

Dependencies:   EthernetInterface mbed-rtos mbed

Fork of cc3100_Test_Demo by David Fletcher

Embed: (wiki syntax)

« Back to documentation index

Device

Device

Functions

int32_t initializeAppVariables ()
 This function initializes the application variables.
int32_t establishConnectionWithAP (void)
 Obtain the file from the server.
int32_t checkLanConnection (void)
 This function checks the LAN connection by pinging the AP's gateway.
int32_t checkInternetConnection (void)
 This function checks the internet connection by pinging the external-host (HOST_NAME)
int32_t createUDPConnection (void)
 Create UDP socket to communicate with server.
int32_t createConnection (uint32_t DestinationIP)
 Create connection with server.
int32_t getChunkSize (int32_t *len, uint8_t **p_Buff, uint32_t *chunk_size)
 Calculate the file chunk size.
int32_t hexToi (unsigned char *ptr)
 Convert hex to decimal base.
int32_t disconnectFromAP (void)
 Disconnecting from a WLAN Access point.
int32_t configureSimpleLinkToDefaultState (void)
 This function configure the SimpleLink device in its default state. It:

  • Sets the mode to STATION
  • Configures connection policy to Auto and AutoSmartConfig
  • Deletes all the stored profiles
  • Enables DHCP
  • Disables Scan policy
  • Sets Tx power to maximum
  • Sets power policy to normal
  • Unregisters mDNS services
  • Remove all filters.

int16_t sl_Start (const void *pIfHdl, int8_t *pDevName, const P_INIT_CALLBACK pInitCallBack)
 Start the SimpleLink device.
int16_t sl_Stop (const uint16_t timeout)
 Stop the SimpleLink device.
int32_t sl_DevSet (const uint8_t DeviceSetId, const uint8_t Option, const uint8_t ConfigLen, const uint8_t *pValues)
 Internal function for setting device configurations.
int32_t sl_DevGet (const uint8_t DeviceGetId, uint8_t *pOption, uint8_t *pConfigLen, uint8_t *pValues)
 Internal function for getting device configurations.
int16_t sl_EventMaskSet (const uint8_t EventClass, const uint32_t Mask)
 Set asynchronous event mask.
int16_t sl_EventMaskGet (const uint8_t EventClass, uint32_t *pMask)
 Get current event mask of the device.
void sl_Task (void)
 the simple link task entry
int16_t sl_UartSetMode (const SlUartIfParams_t *pUartParams)
 Setting the internal uart mode.

Function Documentation

int32_t checkInternetConnection ( void   ) [inherited]

This function checks the internet connection by pinging the external-host (HOST_NAME)

Parameters:
[in]None
Returns:
0 on success, negative error-code on error

Definition at line 781 of file cc3100.cpp.

int32_t checkLanConnection ( void   ) [inherited]

This function checks the LAN connection by pinging the AP's gateway.

Parameters:
[in]None
Returns:
0 on success, negative error-code on error

Definition at line 737 of file cc3100.cpp.

int32_t configureSimpleLinkToDefaultState ( void   ) [inherited]

This function configure the SimpleLink device in its default state. It:

  • Sets the mode to STATION
  • Configures connection policy to Auto and AutoSmartConfig
  • Deletes all the stored profiles
  • Enables DHCP
  • Disables Scan policy
  • Sets Tx power to maximum
  • Sets power policy to normal
  • Unregisters mDNS services
  • Remove all filters.

Parameters:
[in]none
Returns:
On success, zero is returned. On error, negative is returned

Definition at line 147 of file cc3100.cpp.

int32_t createConnection ( uint32_t  DestinationIP ) [inherited]

Create connection with server.

This function opens a socket and create the endpoint communication with server

Parameters:
[in]DestinationIP- IP address of the server
Returns:
socket id for success and negative for error

Definition at line 284 of file cc3100.cpp.

int32_t createUDPConnection ( void   ) [inherited]

Create UDP socket to communicate with server.

Parameters:
[in]none
Returns:
Socket descriptor for success otherwise negative
Warning:

Definition at line 263 of file cc3100.cpp.

int32_t disconnectFromAP ( void   ) [inherited]

Disconnecting from a WLAN Access point.

This function disconnects from the connected AP

Parameters:
[in]None
Returns:
none
Note:
Warning:
If the WLAN disconnection fails, we will be stuck in this function forever.

Definition at line 113 of file cc3100.cpp.

int32_t establishConnectionWithAP ( void   ) [inherited]

Obtain the file from the server.

This function requests the file from the server and save it on serial flash. To request a different file for different user needs to modify the PREFIX_BUFFER and POST_BUFFER macros.

Parameters:
[in]None
Returns:
0 for success and negative for error

Connecting to a WLAN Access point

This function connects to the required AP (SSID_NAME). The function will return once we are connected and have acquired IP address

Parameters:
[in]None
Returns:
0 on success, negative error-code on error
Note:
Warning:
If the WLAN connection fails or we don't acquire an IP address, We will be stuck in this function forever.

Definition at line 711 of file cc3100.cpp.

int32_t getChunkSize ( int32_t *  len,
uint8_t **  p_Buff,
uint32_t *  chunk_size 
) [inherited]

Calculate the file chunk size.

Parameters:
[in]len- pointer to length of the data in the buffer
[in]p_Buff- pointer to pointer of buffer containing data
[out]chunk_size- pointer to variable containing chunk size
Returns:
0 for success, -ve for error

Definition at line 368 of file cc3100.cpp.

int32_t hexToi ( unsigned char *  ptr ) [inherited]

Convert hex to decimal base.

Parameters:
[in]ptr- pointer to string containing number in hex
Returns:
number in decimal base

Definition at line 318 of file cc3100.cpp.

int32_t initializeAppVariables (  ) [inherited]

This function initializes the application variables.

Parameters:
[in]None
Returns:
0 on success, negative error-code on error

Definition at line 85 of file cc3100.cpp.

int32_t sl_DevGet ( const uint8_t  DeviceGetId,
uint8_t *  pOption,
uint8_t *  pConfigLen,
uint8_t *  pValues 
) [inherited]

Internal function for getting device configurations.

Returns:
On success, zero is returned. On error, -1 is returned
Parameters:
[in]DeviceGetIdconfiguration id - example SL_DEVICE_STATUS
[out]pOptionGet configurations option, example for get status options

  • SL_EVENT_CLASS_GLOBAL
  • SL_EVENT_CLASS_DEVICE
  • SL_EVENT_CLASS_WLAN
  • SL_EVENT_CLASS_BSD
  • SL_EVENT_CLASS_NETAPP
  • SL_EVENT_CLASS_NETCFG
  • SL_EVENT_CLASS_FS
[out]pConfigLenThe length of the allocated memory as input, when the function complete, the value of this parameter would be the len that actually read from the device.
If the device return length that is longer from the input value, the function will cut the end of the returned structure and will return SL_ESMALLBUF
[out]pValuesGet configurations values
See also:
Note:
Warning:
Examples:
         Example for getting WLAN class status:
         uint32_t statusWlan;
         uint8_t pConfigOpt;
         uint8_t pConfigLen;
         pConfigLen = sizeof(_u32);
         pConfigOpt = SL_EVENT_CLASS_WLAN;
         sl_DevGet(SL_DEVICE_STATUS,&pConfigOpt,&pConfigLen,(uint8_t *)(&statusWlan));
         Example for getting version:
         SlVersionFull ver;
         pConfigLen = sizeof(ver);
         pConfigOpt = SL_DEVICE_GENERAL_VERSION;
         sl_DevGet(SL_DEVICE_GENERAL_CONFIGURATION,&pConfigOpt,&pConfigLen,(uint8_t *)(&ver));
         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",
                 ver.ChipFwAndPhyVersion.ChipId,
                 ver.ChipFwAndPhyVersion.FwVersion[0],ver.ChipFwAndPhyVersion.FwVersion[1],
                 ver.ChipFwAndPhyVersion.FwVersion[2],ver.ChipFwAndPhyVersion.FwVersion[3],
                 ver.ChipFwAndPhyVersion.PhyVersion[0],ver.ChipFwAndPhyVersion.PhyVersion[1],
                 ver.ChipFwAndPhyVersion.PhyVersion[2],ver.ChipFwAndPhyVersion.PhyVersion[3],
                 ver.NwpVersion[0],ver.NwpVersion[1],ver.NwpVersion[2],ver.NwpVersion[3],
                 ver.RomVersion,
                 SL_MAJOR_VERSION_NUM,SL_MINOR_VERSION_NUM,SL_VERSION_NUM,SL_SUB_VERSION_NUM);
             Getting Device time and date example:

             SlDateTime_t dateTime =  {0};
             int8_t configLen = sizeof(SlDateTime_t);
             int8_t configOpt = SL_DEVICE_GENERAL_CONFIGURATION_DATE_TIME;
             sl_DevGet(SL_DEVICE_GENERAL_CONFIGURATION,&configOpt, &configLen,(uint8_t *)(&dateTime));

             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
                     dateTime.sl_tm_hour,dateTime.sl_tm_min,dateTime.sl_tm_sec);

Definition at line 1197 of file cc3100.cpp.

int32_t sl_DevSet ( const uint8_t  DeviceSetId,
const uint8_t  Option,
const uint8_t  ConfigLen,
const uint8_t *  pValues 
) [inherited]

Internal function for setting device configurations.

Returns:
On success, zero is returned. On error, -1 is returned
Parameters:
[in]DeviceSetIdconfiguration id
[in]Optionconfigurations option
[in]ConfigLenconfigurations len
[in]pValuesconfigurations values
See also:
Note:
Warning:
Examples:
             Setting device time and date example:

             SlDateTime_t dateTime= {0};
             dateTime.sl_tm_day =   (uint32_t)23;          // Day of month (DD format) range 1-13
             dateTime.sl_tm_mon =   (uint32_t)6;           // Month (MM format) in the range of 1-12
             dateTime.sl_tm_year =  (uint32_t)2014;        // Year (YYYY format)
             dateTime.sl_tm_hour =  (uint32_t)17;          // Hours in the range of 0-23
             dateTime.sl_tm_min =   (uint32_t)55;          // Minutes in the range of 0-59
             dateTime.sl_tm_sec =   (uint32_t)22;          // Seconds in the range of  0-59
             sl_DevSet(SL_DEVICE_GENERAL_CONFIGURATION,
                       SL_DEVICE_GENERAL_CONFIGURATION_DATE_TIME,
                       sizeof(SlDateTime_t),
                       (uint8_t *)(&dateTime));

Definition at line 1252 of file cc3100.cpp.

int16_t sl_EventMaskGet ( const uint8_t  EventClass,
uint32_t *  pMask 
) [inherited]

Get current event mask of the device.

return the events bit mask from the device. In case that event is masked, the device is not sending this event.

Parameters:
[in]EventClassThe classification groups that the mask is referred to. Need to be one of the following:

  • SL_EVENT_CLASS_GLOBAL
  • SL_EVENT_CLASS_DEVICE
  • SL_EVENT_CLASS_WLAN
  • SL_EVENT_CLASS_BSD
  • SL_EVENT_CLASS_NETAPP
  • SL_EVENT_CLASS_NETCFG
  • SL_EVENT_CLASS_FS
[out]pMaskPointer to Mask bitmap where the value should be stored. Bitmasks are the same as in sl_EventMaskSet
Returns:
On success, zero is returned. On error, -1 is returned
See also:
sl_EventMaskSet
Note:
belongs to ext_api
Warning:
Example:
        An example of getting an event mask for WLAN class
        uint32_t maskWlan;
                       sl_StatusGet(SL_EVENT_CLASS_WLAN,&maskWlan);

Definition at line 1168 of file cc3100.cpp.

int16_t sl_EventMaskSet ( const uint8_t  EventClass,
const uint32_t  Mask 
) [inherited]

Set asynchronous event mask.

Mask asynchronous events from the device. Masked events do not generate asynchronous messages from the device. By default - all events are active

Parameters:
[in]EventClassThe classification groups that the mask is referred to. Need to be one of the following:

  • SL_EVENT_CLASS_GLOBAL
  • SL_EVENT_CLASS_DEVICE
  • SL_EVENT_CLASS_WLAN
  • SL_EVENT_CLASS_BSD
  • SL_EVENT_CLASS_NETAPP
  • SL_EVENT_CLASS_NETCFG
  • SL_EVENT_CLASS_FS
[in]MaskEvent Mask bitmap. Valid mask are (per group):

  • SL_EVENT_CLASS_WLAN user events
    • SL_WLAN_CONNECT_EVENT
    • SL_WLAN_DISCONNECT_EVENT
  • SL_EVENT_CLASS_DEVICE user events
    • SL_DEVICE_FATAL_ERROR_EVENT
  • SL_EVENT_CLASS_BSD user events
    • SL_SOCKET_TX_FAILED_EVENT
    • SL_SOCKET_ASYNC_EVENT
  • SL_EVENT_CLASS_NETAPP user events
    • SL_NETAPP_IPV4_IPACQUIRED_EVENT
    • SL_NETAPP_IPV6_IPACQUIRED_EVENT
Returns:
On success, zero is returned. On error, -1 is returned
See also:
sl_EventMaskGet
Note:
belongs to ext_api
Warning:
Example:
        An example of masking connection/disconnection async events from WLAN class:
                       sl_EventMaskSet(SL_EVENT_CLASS_WLAN, (SL_WLAN_CONNECT_EVENT | SL_WLAN_DISCONNECT_EVENT) );

Definition at line 1141 of file cc3100.cpp.

int16_t sl_Start ( const void *  pIfHdl,
int8_t *  pDevName,
const P_INIT_CALLBACK  pInitCallBack 
) [inherited]

Start the SimpleLink device.

This function initialize the communication interface, set the enable pin of the device, and call to the init complete callback.

Parameters:
[in]pIfHdlOpened Interface Object. In case the interface must be opened outside the SimpleLink Driver, the user might give the handler to be used in
any access of the communication interface with the device (UART/SPI).
The SimpleLink driver will open an interface port only if this parameter is null!
[in]pDevNameThe name of the device to open. Could be used when the pIfHdl is null, to transfer information to the open interface function
This pointer could be used to pass additional information to sl_IfOpen in case it is required (e.g. UART com port name)
[in]pInitCallBackPointer to function that would be called on completion of the initialization process.
If this parameter is NULL the function is blocked until the device initialization is completed, otherwise the function returns immediately.
Returns:
Returns the current active role (STA/AP/P2P) or an error code:
  • ROLE_STA, ROLE_AP, ROLE_P2P in case of success, otherwise in failure one of the following is return:
  • ROLE_STA_ERR (Failure to load MAC/PHY in STA role)
  • ROLE_AP_ERR (Failure to load MAC/PHY in AP role)
  • ROLE_P2P_ERR (Failure to load MAC/PHY in P2P role)
See also:
sl_Stop
Note:
belongs to basic_api
Warning:
This function must be called before any other SimpleLink API is used, or after sl_Stop is called for reinit the device
Example:
                       An example for open interface without callback routine. The interface name and handler are
                       handled by the sl_IfOpen routine:

                        if( sl_Start(NULL, NULL, NULL) < 0 )
                       {
                           LOG("Error opening interface to device\n");
                       }

Definition at line 982 of file cc3100.cpp.

int16_t sl_Stop ( const uint16_t  timeout ) [inherited]

Stop the SimpleLink device.

This function clears the enable pin of the device, closes the communication
interface and invokes the stop complete callback

Parameters:
[in]timeoutStop timeout in msec. Should be used to give the device time to finish
any transmission/reception that is not completed when the function was called.
Additional options:

  • 0 Enter to hibernate immediately
  • 0xFFFF Host waits for device's response before
    hibernating, without timeout protection
  • 0 < Timeout[msec] < 0xFFFF Host waits for device's response before
    hibernating, with a defined timeout protection
    This timeout defines the max time to wait. The NWP
    response can be sent earlier than this timeout.
Returns:
On success, zero is returned. On error, -1 is returned
See also:
sl_Start
Note:
This API will shutdown the device and invoke the "i/f close" function regardless
if it was opened implicitly or explicitly.
It is up to the platform interface library to properly handle interface close
routine
belongs to basic_api
Warning:

Definition at line 1078 of file cc3100.cpp.

void sl_Task ( void   ) [inherited]

the simple link task entry

This function must be called from the main loop or from dedicated thread in the following cases:

  • Non-Os Platform - should be called from the mail loop
  • Multi Threaded Platform when the user does not implement the external spawn functions - should be called from dedicated thread allocated to the simplelink driver. In this mode the function never return.
Returns:
None
See also:
sl_Stop
Note:
belongs to basic_api
Warning:
This function must be called from a thread that is start running before any call to other simple link API

Definition at line 969 of file cc3100.cpp.

int16_t sl_UartSetMode ( const SlUartIfParams_t *  pUartParams ) [inherited]

Setting the internal uart mode.

Parameters:
[in]pUartParamsPointer to the uart configuration parameter set: baudrate - up to 711 Kbps flow control - enable/disable comm port - the comm port number
Returns:
On success zero is returned, otherwise - Failed.
See also:
sl_Stop
Note:
belongs to basic_api
Warning:
This function must consider the host uart capability

Definition at line 1290 of file cc3100.cpp.