ACKme Logo WiConnect Host Library- API Reference Guide
 
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Groups Pages
wiconnect::Wiconnect Class Reference

The root WiConnect library class. This class inheriets all WiConnect functionality. More...

#include <WiconnectInterface.h>

Inherits wiconnect::NetworkInterface, wiconnect::SocketInterface, and wiconnect::FileInterface.

Public Member Functions

 Wiconnect (const SerialConfig &serialConfig, Pin reset=PIN_NC, Pin wake=PIN_NC, bool nonBlocking=WICONNECT_DEFAULT_NONBLOCKING WICONNECT_MALLOC_ARGS)
 WiConnect class constructor. More...
 
 Wiconnect (const SerialConfig &serialConfig, int internalBufferSize, void *internalBuffer=NULL, Pin reset=PIN_NC, Pin wake=PIN_NC, bool nonBlocking=WICONNECT_DEFAULT_NONBLOCKING WICONNECT_MALLOC_ARGS)
 WiConnect class constructor. More...
 
WiconnectResult init (bool bringNetworkUp=false)
 Initialize library and communication link with WiConnect WiFi module. More...
 
void deinit ()
 De-initialize library.
 
bool isInitialized ()
 Return TRUE if library is able to communicated with WiConnect WiFi module. FALSE else. More...
 
WiconnectResult reset ()
 Toggle the WiConnect WiFi module reset signal. More...
 
WiconnectResult wakeup ()
 Toggle the WiConnect WiFi moduel wakeup signal. More...
 
void flush (int delayMs=500)
 Flush any received data in serial RX buffer and terminate any commands on WiConnect WiFi module. More...
 
WiconnectResult getVersion (char *versionBuffer=NULL, int versionBufferSize=0, const Callback &completeCallback=Callback())
 Return current version of WiConnect WiFi module. More...
 
WiconnectResult updateFirmware (bool forced=false, const char *versionStr=NULL, const Callback &completeCallback=Callback())
 Update the wifi module's internal firmware. More...
 
WiconnectResult sendCommand (const Callback &completeCallback, char *responseBuffer, int responseBufferLen, int timeoutMs, const ReaderFunc &reader, void *user, const char *cmd, va_list vaList)
 Send command to WiConnect WiFi module. More...
 
WiconnectResult sendCommand (char *responseBuffer, int responseBufferLen, int timeoutMs, const ReaderFunc &reader, void *user, const char *cmd, va_list vaList)
 Send command to WiConnect WiFi module. More...
 
WiconnectResult sendCommand (char *responseBuffer, int responseBufferLen, int timeoutMs, const ReaderFunc &reader, void *user, const char *cmd,...)
 Send command to WiConnect WiFi module. More...
 
WiconnectResult sendCommand (int timeoutMs, const ReaderFunc &reader, void *user, const char *cmd,...)
 Send command to WiConnect WiFi module. More...
 
WiconnectResult sendCommand (const ReaderFunc &reader, void *user, const char *cmd,...)
 Send command to WiConnect WiFi module. More...
 
WiconnectResult sendCommand (char *responseBuffer, int responseBufferLen, int timeoutMs, const char *cmd,...)
 Send command to WiConnect WiFi module. More...
 
WiconnectResult sendCommand (const Callback &completeCallback, char *responseBuffer, int responseBufferLen, const char *cmd,...)
 Send command to WiConnect WiFi module. More...
 
WiconnectResult sendCommand (char *responseBuffer, int responseBufferLen, const char *cmd,...)
 Send command to WiConnect WiFi module. More...
 
WiconnectResult sendCommand (const Callback &completeCallback, const char *cmd,...)
 Send command to WiConnect WiFi module. More...
 
WiconnectResult sendCommand (const char *cmd,...)
 Send command to WiConnect WiFi module. More...
 
WiconnectResult sendCommand (const Callback &completeCallback, int timeoutMs, const char *cmd,...)
 
WiconnectResult sendCommand (int timeoutMs, const char *cmd,...)
 Send command to WiConnect WiFi module. More...
 
WiconnectResult sendCommand (const char *cmd, va_list vaList)
 
WiconnectResult checkCurrentCommand ()
 Check the status of the currently executing command. More...
 
void stopCurrentCommand ()
 Stop the currently executing command. More...
 
const char * getLastCommandResponseCodeStr ()
 When the WiConnect WiFi module returns a response, it contains a response code in the header. This function converts the previous response code to a readable string. More...
 
uint16_t getLastCommandResponseLength ()
 Return the length in bytes of the previous response. More...
 
char * getResponseBuffer ()
 Return pointer to internal response buffer. More...
 
WiconnectResult responseToUint32 (uint32_t *uint32Ptr)
 Helper method to convert previous response to uint32. More...
 
WiconnectResult responseToInt32 (int32_t *int32Ptr)
 Helper method to convert previous response to int32. More...
 
WiconnectResult setSetting (const char *settingStr, uint32_t value)
 Set a module setting. More...
 
WiconnectResult setSetting (const char *settingStr, const char *value)
 Set a module setting. More...
 
WiconnectResult getSetting (const char *settingStr, uint32_t *valuePtr)
 Get a module setting. More...
 
WiconnectResult getSetting (const char *settingStr, char **valuePtr)
 Get a module setting. More...
 
WiconnectResult getSetting (const char *settingStr, char *valueBuffer, uint16_t valueBufferLen)
 Get a module setting. More...
 
void setCommandDefaultTimeout (int timeoutMs)
 Sets the default maximum time an API method may execute before terminating and return a timeout error code. More...
 
int getCommandDefaultTimeout ()
 Returns the current default maximum API execution time. More...
 
void setPinToGpioMapper (PinToGpioMapper mapper)
 Sets a mapping function used to convert from a host Pin to WiConnect WiFi module GPIO. More...
 
void setDebugLogger (LogFunc logFunc)
 Sets callback function used to debug WiConnect WiFi module RX/TX serial data. More...
 
void setAssertLogger (LogFunc assertLogFunc)
 Sets callback used when Wiconnect Library hits and internal assertion. More...
 
- Public Member Functions inherited from wiconnect::NetworkInterface
WiconnectResult startWebSetup (const char *ssid=NULL, const char *password=NULL, const Callback &completeHandler=Callback())
 Start the WiConnect WiFi module 'web setup' feature. More...
 
WiconnectResult stopWebSetup ()
 Stop the WiConnect WiFi module 'web setup' feature. More...
 
WiconnectResult isWebSetupRunning (bool *isRunningPtr)
 Return status of WiConnect WiFi module 'web setup' feature. More...
 
WiconnectResult join (const char *ssid=NULL, const char *password=NULL, const Callback &completeHandler=Callback())
 Join a WiFi network. More...
 
WiconnectResult leave ()
 Leave a WiFi network. More...
 
WiconnectResult getNetworkStatus (NetworkStatus *statusPtr)
 Get connection status to WiFi network. More...
 
WiconnectResult getNetworkJoinResult (NetworkJoinResult *joinResultPtr)
 Get the result of joining the network. More...
 
WiconnectResult scan (ScanResultList &resultList, const uint8_t *channelList=NULL, const char *ssid=NULL)
 Scan for available WiFi networks. More...
 
WiconnectResult ping (const char *domain=NULL, uint32_t *timeMsPtr=NULL)
 Ping a WiFi network. More...
 
WiconnectResult lookup (const char *domain, uint32_t *ipAddressPtr)
 Resolve domain name into IP address. More...
 
WiconnectResult setDhcpEnabled (bool enabled)
 Set DHCP enabled. More...
 
WiconnectResult getDhcpEnabled (bool *enabledPtr)
 Get if DHCP enabled.
 
WiconnectResult setIpSettings (uint32_t ip, uint32_t netmask, uint32_t gateway)
 Set static IP settings.
 
WiconnectResult setIpSettings (const char *ip, const char *netmask, const char *gateway)
 Set static IP settings (with string parameters)
 
WiconnectResult getIpSettings (uint32_t *ip, uint32_t *netmask, uint32_t *gateway)
 Get network IP settings.
 
WiconnectResult getSignalStrength (NetworkSignalStrength *signalStrengthPtr)
 Get signal strength to WiFi network.
 
const char * getIpAddress (char *buffer=NULL)
 Return the current IP address of the module if possible, else return 0.0.0.0. More...
 
- Public Member Functions inherited from wiconnect::SocketInterface
WiconnectResult closeAllSockets ()
 Close all opened sockets. More...
 
WiconnectResult registerSocketIrqHandler (Pin irqPin, const Callback &handler)
 Register a host pin as an external interrupt. When the external interrupt is triggered, the supplied callback is executed. More...
 
WiconnectResult unregisterSocketIrqHandler (Pin irqPin)
 Unregister a previously registered IRQ pin. More...
 
WiconnectResult connect (WiconnectSocket &socket, SocketType type, const char *host, uint16_t remortPort, uint16_t localPort, const void *args, Pin irqPin)
 Connect to remote server. More...
 
WiconnectResult tcpConnect (WiconnectSocket &socket, const char *host, uint16_t remortPort, Pin irqPin=PIN_NC)
 Connect to remote TCP server. More...
 
WiconnectResult tcpListen (uint16_t listeningPort, int maxClients=0, Pin irqPin=PIN_NC)
 Start internal TCP server and listen on specified port. More...
 
WiconnectResult tcpAccept (WiconnectSocket &socket, int timeoutMs=WICONNECT_WAIT_FOREVER)
 Wait for next client to connect to TCP server. More...
 
WiconnectResult tcpServerStop (void)
 Stop TCP server from listening on port. Close all connected clients. More...
 
WiconnectResult tlsConnect (WiconnectSocket &socket, const char *host, uint16_t remortPort, const char *certFilename=NULL, Pin irqPin=PIN_NC)
 Connect to remote TLS server. More...
 
WiconnectResult udpConnect (WiconnectSocket &socket, const char *host, uint16_t remortPort, uint16_t localPort=SOCKET_ANY_PORT, Pin irqPin=PIN_NC)
 Connect to remote UDP server. More...
 
WiconnectResult httpConnect (WiconnectSocket &socket, const char *url, const HttpSocketArgs *args)
 Connect to remote HTTP server. More...
 
WiconnectResult httpGet (WiconnectSocket &socket, const char *url, bool openOnly=false, const char *certFilename=NULL)
 Issue HTTP GET Request. More...
 
WiconnectResult httpPost (WiconnectSocket &socket, const char *url, const char *contextType, bool openOnly=true, const char *certFilename=NULL)
 Issue HTTP POST Request. More...
 
WiconnectResult httpHead (WiconnectSocket &socket, const char *url, const char *certFilename=NULL)
 Issue HTTP HEAD Request. More...
 
WiconnectResult httpAddHeader (WiconnectSocket &socket, const char *key, const char *value)
 Add HTTP header key/value pair to opened HTTP request. More...
 
WiconnectResult httpGetStatus (WiconnectSocket &socket, uint32_t *statusCodePtr)
 Get the HTTP status code from HTTP request. More...
 
- Public Member Functions inherited from wiconnect::FileInterface
WiconnectResult createFile (const ReaderFunc &reader, void *user, const char *name, uint32_t size, uint32_t version=0, FileType type=FILE_TYPE_ANY, bool isEssential=false, int32_t checksum=-1)
 Create a file on the Wiconnect WiFi module filesystem. More...
 
WiconnectResult openFile (WiconnectFile &file, const char *name)
 Open a file on the Wiconnect WiFi module filesystem for reading. More...
 
WiconnectResult deleteFile (const char *name)
 Delete a file for the Wiconnect WiFi module filesystem. More...
 
WiconnectResult deleteFile (const WiconnectFile &file)
 Delete a file for the Wiconnect WiFi module filesystem. More...
 
WiconnectResult listFiles (FileList &list, const char *name=NULL, FileType type=FILE_TYPE_ANY, uint32_t version=0)
 List the files on the Wiconnect WiFi module filesystem. More...
 

Static Public Member Functions

static WiconnectgetInstance ()
 Get instance of previously instantiated Wiconnect Library. More...
 
static const char * getWiconnectResultStr (WiconnectResult wiconnectResult)
 Converts a WiconnectResult to string representation. More...
 
- Static Public Member Functions inherited from wiconnect::NetworkInterface
static bool strToIp (const char *str, uint32_t *intPtr)
 Convert string to IP address.
 
static const char * ipToStr (uint32_t ip, char *ipStrBuffer=NULL)
 Convert IP address to string.
 
static const char * networkStatusToStr (NetworkStatus status)
 Convert NetworkStatus to string.
 
static const char * networkJoinResultToStr (NetworkJoinResult joinResult)
 Convert NetworkJoinResult to string.
 
static const char * signalStrengthToStr (NetworkSignalStrength signalStrenth)
 Convert NetworkSignalStrength to string.
 
static NetworkSignalStrength rssiToSignalStrength (int rssi)
 Convert RSSI (in dBm) to NetworkSignalStrength.
 
static NetworkSecurity strToNetworkSecurity (const char *str)
 Convert string to NetworkSecurity.
 
static const char * networkSecurityToStr (NetworkSecurity security)
 Convert NetworkSecurity to string.
 
static bool strToSsid (const char *str, Ssid *ssid)
 Convert string Ssid.
 
static const char * ssidToStr (const Ssid *ssid, char *ssidStrBuffer=NULL)
 Convert Ssid to string.
 
static bool strToMacAddress (const char *str, MacAddress *macAddress)
 Convert string MacAddress.
 
static const char * macAddressToStr (const MacAddress *macAddress, char *macStrBuffer=NULL)
 Convert MacAddress to string.
 
- Static Public Member Functions inherited from wiconnect::FileInterface
static const char * fileVersionIntToStr (uint32_t version, bool verbose=true, char *buffer=NULL)
 Convert file version uint32 to string.
 
static bool fileVersionStrToInt (const char *versionStr, uint32_t *versionIntPtr)
 Convert string to file version uint32.
 
static const char * fileTypeToStr (FileType type)
 
static const char * fileFlagsToStr (FileFlags flags, char *buffer=NULL)
 Convert FileFlags to string.
 

Detailed Description

The root WiConnect library class. This class inheriets all WiConnect functionality.

This class is implemented as a 'singleton'. This means it only needs to be instantiated once. Subsequent class may either use the class instance or the static function: Wiconnect::getInstance()

Definition at line 74 of file WiconnectInterface.h.

Constructor & Destructor Documentation

wiconnect::Wiconnect::Wiconnect ( const SerialConfig serialConfig,
Pin  reset = PIN_NC,
Pin  wake = PIN_NC,
bool  nonBlocking = WICONNECT_DEFAULT_NONBLOCKING WICONNECT_MALLOC_ARGS 
)

WiConnect class constructor.

Note
This should only be called once within a program as the WiConnect library is implemented as a singleton.
If this constructor is used, then all commands must be supplied with an external response buffer. This means most the API functions will not work as they use the internal buffer. It's recommended to use the other constructor that supplies an internal buffer. See Dynamic / Static Allocation
Parameters
[in]serialConfigThe serial (i.e. UART) configuration connected to a WiConnect module.
[in]resetOptional, The pin connected to the WiConnect module reset signal. Default: No connection
[in]wakeOptional, The pin connected to the WiConnect module wake signal. Default: No connection
[in]nonBlockingOptional, indicates if the API blocking mode. See Blocking / Non-blocking Modes
wiconnect::Wiconnect::Wiconnect ( const SerialConfig serialConfig,
int  internalBufferSize,
void *  internalBuffer = NULL,
Pin  reset = PIN_NC,
Pin  wake = PIN_NC,
bool  nonBlocking = WICONNECT_DEFAULT_NONBLOCKING WICONNECT_MALLOC_ARGS 
)

WiConnect class constructor.

Note
This should only be called once within a program as the WiConnect library is implemented as a singleton.
This is the recommended construstor as it supplies the WiConnect library with an internal buffer. Most API calls require the internal buffer.
Parameters
[in]serialConfigThe serial (i.e. UART) configuration connected to a WiConnect module.
[in]internalBufferSizeThe size of the internal buffer. If internalBuffer is NULL, then this size will be dynamically allocated. See Dynamic / Static Allocation
[in]internalBufferOptional, a user allocated buffer. See Dynamic / Static Allocation
[in]resetOptional, The pin connected to the WiConnect module reset signal. Default: No connection
[in]wakeOptional, The pin connected to the WiConnect module wake signal. Default: No connection
[in]nonBlockingOptional, indicates if the API blocking mode. See Blocking / Non-blocking Modes

The documentation for this class was generated from the following file: