Open Model Railroad Network (OpenMRN)
Loading...
Searching...
No Matches
CC32xxWiFi.cxx File Reference
#include "CC32xxWiFi.hxx"
#include "CC32xxSocket.hxx"
#include "freertos_drivers/common/WifiDefs.hxx"
#include "freertos_drivers/ti/CC32xxHelper.hxx"
#include "utils/format_utils.hxx"
#include "utils/logging.h"
#include <unistd.h>
#include <ti/drivers/net/wifi/simplelink.h>
#include <ti/drivers/net/wifi/source/protocol.h>

Go to the source code of this file.

Classes

struct  CC32xxWiFi::WlanEvent
 CC32xx forward declaration Helper. More...
 
struct  CC32xxWiFi::NetAppEvent
 CC32xx forward declaration Helper. More...
 
struct  CC32xxWiFi::SockEvent
 CC32xx forward declaration Helper. More...
 
struct  CC32xxWiFi::SockTriggerEvent
 CC32xx forward declaration Helper. More...
 
struct  CC32xxWiFi::HttpServerEvent
 CC32xx forward declaration Helper. More...
 
struct  CC32xxWiFi::HttpServerResponse
 CC32xx forward declaration Helper. More...
 
struct  CC32xxWiFi::NetAppRequest
 CC32xx forward declaration Helper. More...
 
struct  CC32xxWiFi::NetAppResponse
 CC32xx forward declaration Helper. More...
 
struct  CC32xxWiFi::FatalErrorEvent
 CC32xx forward declaration Helper. More...
 

Macros

#define SUPPORT_SL_R1_API
 
#define CHANNEL_MASK_ALL   0x1FFF
 
#define RSSI_TH_MAX   -95
 

Functions

void new_highest ()
 Find the new highest fd to select on.
 
void add_socket (int16_t sd)
 Add an interesting socket.
 
void del_socket (int16_t sd)
 Delete an interesting socket.
 
static void append_num (std::string *s, uint32_t d)
 
template<class NUM >
static void append_ver_4 (std::string *s, NUM d[4])
 
void mdns_publish (const char *name, const char *service, uint16_t port)
 Publish an mDNS name.
 
void mdns_unpublish (const char *name, const char *service)
 Unpublish an mDNS name.
 
void SimpleLinkWlanEventHandler (SlWlanEvent_t *pSlWlanEvent)
 This function handles WLAN events.
 
void SimpleLinkNetAppEventHandler (SlNetAppEvent_t *pNetAppEvent)
 This function handles network events such as IP acquisition, IP leased, IP released etc.
 
void SimpleLinkGeneralEventHandler (SlDeviceEvent_t *pDevEvent)
 This function handles general events.
 
void SimpleLinkSockEventHandler (SlSockEvent_t *pSock)
 This function handles socket events indication.
 
void SimpleLinkHttpServerEventHandler (SlNetAppHttpServerEvent_t *pHttpServerEvent, SlNetAppHttpServerResponse_t *pHttpServerResponse)
 This function gets triggered when HTTP Server receives Application defined GET and POST HTTP Tokens.
 
void SimpleLinkNetAppRequestEventHandler (SlNetAppRequest_t *pNetAppRequest, SlNetAppResponse_t *pNetAppResponse)
 This function handles resource request.
 
void SimpleLinkNetAppRequestMemFreeEventHandler (uint8_t *buffer)
 This function handles resource release.
 
void SimpleLinkFatalErrorEventHandler (SlDeviceFatal_t *slFatalErrorEvent)
 This Function Handles the Fatal errors.
 
void SimpleLinkSocketTriggerEventHandler (SlSockTriggerEvent_t *event)
 Notifies the service about a wifi asynchronous socket event callback.
 
int slcb_SetErrno (int Errno)
 Helper function called by SimpleLink driver to set OS-specific errno value.
 

Variables

static SlFdSet_t rfds
 This is not a class members so that including CC32xxWiFi.hxx does not pollute the namespace with simplelink APIs.
 
static SlFdSet_t wfds
 This is not a class members so that including CC32xxWiFi.hxx does not pollute the namespace with simplelink APIs.
 
static SlFdSet_t efds
 This is not a class members so that including CC32xxWiFi.hxx does not pollute the namespace with simplelink APIs.
 
static int fdHighest
 the highest file descriptor to select on
 
static int16_t slSockets [SL_MAX_SOCKETS]
 This is not a class members so that including CC32xxWiFi.hxx does not pollute the namespace with simplelink APIs.
 

Detailed Description

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

  • Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
  • Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

This file instantiates and initializes the CC32xx Wi-Fi.

Author
Stuart W. Baker
Date
18 March 2016

Definition in file net_cc3220/CC32xxWiFi.cxx.

Macro Definition Documentation

◆ SUPPORT_SL_R1_API

#define SUPPORT_SL_R1_API

Definition at line 36 of file net_cc3220/CC32xxWiFi.cxx.

Function Documentation

◆ add_socket()

void add_socket ( int16_t  sd)

Add an interesting socket.

Parameters
sdnumber to add

Definition at line 138 of file net_cc3220/CC32xxWiFi.cxx.

◆ append_num()

static void append_num ( std::string *  s,
uint32_t  d 
)
static

Definition at line 1589 of file net_cc3220/CC32xxWiFi.cxx.

◆ append_ver_4()

template<class NUM >
static void append_ver_4 ( std::string *  s,
NUM  d[4] 
)
static

Definition at line 1597 of file net_cc3220/CC32xxWiFi.cxx.

◆ del_socket()

void del_socket ( int16_t  sd)

Delete an interesting socket.

@parqam sd number to delete

Definition at line 165 of file net_cc3220/CC32xxWiFi.cxx.

◆ mdns_publish()

void mdns_publish ( const char *  name,
const char *  service,
uint16_t  port 
)

Publish an mDNS name.

Parameters
namelocal "username" or "nodename" of the service
serviceservice name, example: "_openlcb._tcp"
portport number

Definition at line 1639 of file net_cc3220/CC32xxWiFi.cxx.

◆ mdns_unpublish()

void mdns_unpublish ( const char *  name,
const char *  service 
)

Unpublish an mDNS name.

Parameters
namelocal "username" or "nodename" of the service
serviceservice name, example: "_openlcb._tcp"

Definition at line 1653 of file net_cc3220/CC32xxWiFi.cxx.

◆ new_highest()

void new_highest ( )

Find the new highest fd to select on.

Definition at line 115 of file net_cc3220/CC32xxWiFi.cxx.

◆ SimpleLinkFatalErrorEventHandler()

void SimpleLinkFatalErrorEventHandler ( SlDeviceFatal_t *  slFatalErrorEvent)

This Function Handles the Fatal errors.

Parameters
slFatalErrorEvent- Contains the fatal error data
Returns
None

Definition at line 1752 of file net_cc3220/CC32xxWiFi.cxx.

◆ SimpleLinkGeneralEventHandler()

void SimpleLinkGeneralEventHandler ( SlDeviceEvent_t *  pDevEvent)

This function handles general events.

Parameters
pDevEventpointer to General Event Info

Definition at line 1687 of file net_cc3220/CC32xxWiFi.cxx.

◆ SimpleLinkHttpServerEventHandler()

void SimpleLinkHttpServerEventHandler ( SlNetAppHttpServerEvent_t *  pHttpServerEvent,
SlNetAppHttpServerResponse_t *  pHttpServerResponse 
)

This function gets triggered when HTTP Server receives Application defined GET and POST HTTP Tokens.

Parameters
pSlHttpServerEventpointer indicating http server event
pSlHttpServerResponsepointer indicating http server response

Definition at line 1706 of file net_cc3220/CC32xxWiFi.cxx.

◆ SimpleLinkNetAppEventHandler()

void SimpleLinkNetAppEventHandler ( SlNetAppEvent_t *  pNetAppEvent)

This function handles network events such as IP acquisition, IP leased, IP released etc.

Parameters
pNetAppEventpointer indicating device acquired IP

Definition at line 1678 of file net_cc3220/CC32xxWiFi.cxx.

◆ SimpleLinkNetAppRequestEventHandler()

void SimpleLinkNetAppRequestEventHandler ( SlNetAppRequest_t *  pNetAppRequest,
SlNetAppResponse_t *  pNetAppResponse 
)

This function handles resource request.

Parameters
[in]pNetAppRequest- Contains the resource requests
[in]pNetAppResponse- Should be filled by the user with the relevant response information
Returns
None

Definition at line 1722 of file net_cc3220/CC32xxWiFi.cxx.

◆ SimpleLinkNetAppRequestMemFreeEventHandler()

void SimpleLinkNetAppRequestMemFreeEventHandler ( uint8_t *  buffer)

This function handles resource release.

Parameters
[in]buffer- Contains the resource requests
[in]pNetAppResponse- Should be filled by the user with the relevant response information
Returns
None

Definition at line 1743 of file net_cc3220/CC32xxWiFi.cxx.

◆ SimpleLinkSocketTriggerEventHandler()

void SimpleLinkSocketTriggerEventHandler ( SlSockTriggerEvent_t *  event)

Notifies the service about a wifi asynchronous socket event callback.

This means that sl_Select needs to be re-run and certain sockets might need wakeup.

Parameters
eventparameters from the socket.

Definition at line 1762 of file net_cc3220/CC32xxWiFi.cxx.

◆ SimpleLinkSockEventHandler()

void SimpleLinkSockEventHandler ( SlSockEvent_t *  pSock)

This function handles socket events indication.

Parameters
pSockpointer to Socket Event Info

Definition at line 1695 of file net_cc3220/CC32xxWiFi.cxx.

◆ SimpleLinkWlanEventHandler()

void SimpleLinkWlanEventHandler ( SlWlanEvent_t *  pSlWlanEvent)

This function handles WLAN events.

Parameters
pSlWlanEventpointer to WLAN Event Info

Definition at line 1668 of file net_cc3220/CC32xxWiFi.cxx.

◆ slcb_SetErrno()

int slcb_SetErrno ( int  Errno)
extern

Helper function called by SimpleLink driver to set OS-specific errno value.

The implementation just forwards the errno value to the newlib_nano errno value.

Parameters
Errnois the new value to be written to errno.

Definition at line 1775 of file net_cc3220/CC32xxWiFi.cxx.

Variable Documentation

◆ efds

SlFdSet_t efds
static

This is not a class members so that including CC32xxWiFi.hxx does not pollute the namespace with simplelink APIs.

Definition at line 92 of file net_cc3220/CC32xxWiFi.cxx.

◆ fdHighest

int fdHighest
static

the highest file descriptor to select on

Definition at line 95 of file net_cc3220/CC32xxWiFi.cxx.

◆ rfds

SlFdSet_t rfds
static

This is not a class members so that including CC32xxWiFi.hxx does not pollute the namespace with simplelink APIs.

Definition at line 82 of file net_cc3220/CC32xxWiFi.cxx.

◆ slSockets

int16_t slSockets[SL_MAX_SOCKETS]
static

This is not a class members so that including CC32xxWiFi.hxx does not pollute the namespace with simplelink APIs.

slSockets keeps track of all the possible CC32x sockets. On the CC3200, SL_MAX_SOCKETS is 8. On the CC3220, SL_MAX_SOCKETS is 16. Unused slots will have a value of -1, which is initialized in the CC32xxWifi class constructor. If a socket becomes interesting (is added to a select() call list), it will be added to an open slot in slSockets by its CC32xx socket descriptor space value. When a socket is closed, it is removed from the from slSockets and the resulting empty slot is returned to a value of -1.

Note: not all socket descriptors will be added to slSockets for tracking. Only those sockets which are added to a select() call list will be tracked by slSockets.

Definition at line 111 of file net_cc3220/CC32xxWiFi.cxx.

◆ wfds

SlFdSet_t wfds
static

This is not a class members so that including CC32xxWiFi.hxx does not pollute the namespace with simplelink APIs.

Definition at line 87 of file net_cc3220/CC32xxWiFi.cxx.