31 #include "WiconnectTypes.h"
34 #include "types/LogFunc.h"
35 #include "types/ReaderFunc.h"
36 #include "types/Callback.h"
37 #include "types/TimeoutTimer.h"
38 #include "types/PeriodicTimer.h"
39 #include "types/Gpio.h"
40 #include "types/WiconnectSerial.h"
42 #ifdef WICONNECT_ASYNC_TIMER_ENABLED
43 #include "types/QueuedCommand.h"
44 #include "types/CommandQueue.h"
47 #include "NetworkInterface.h"
48 #include "SocketInterface.h"
49 #include "FileInterface.h"
50 #include "GhmInterface.h"
53 #ifdef WICONNECT_ENABLE_MALLOC
54 #define WICONNECT_MALLOC_ARGS , void* (*malloc_)(size_t) = WICONNECT_DEFAULT_MALLOC, void (*free_)(void*) = WICONNECT_DEFAULT_FREE
57 #define WICONNECT_MALLOC_ARGS
268 void *user,
const char *cmd, va_list vaList);
287 void *user,
const char *cmd, ...);
678 #ifdef WICONNECT_ASYNC_TIMER_ENABLED
701 void setCommandProcessingPeriod(uint32_t periodMs);
717 #ifdef WICONNECT_ENABLE_MALLOC
718 void* (*_malloc)(size_t);
719 void (*_free)(
void *);
721 friend class WiconnectSerial;
725 wiconnect::WiconnectSerial serial;
726 wiconnect::Gpio resetGpio;
727 wiconnect::Gpio wakeGpio;
729 volatile bool commandExecuting;
735 char *internalBuffer;
736 int internalBufferSize;
737 bool internalBufferAlloc;
738 uint8_t internalProcessingState;
739 void *currentCommandId;
741 wiconnect::TimeoutTimer timeoutTimer;
744 uint8_t commandHeaderBuffer[32];
746 uint8_t commandContext[96];
748 void prepare(
void *internalBuffer,
int internalBufferSize,
bool nonBlocking);
749 bool configureModuleDataBus(
void);
754 #ifdef WICONNECT_ENABLE_DEBUGGING
759 void debugLog(
const char *msg, ...);
761 #ifdef WICONNECT_ASYNC_TIMER_ENABLED
762 wiconnect::PeriodicTimer commandProcessorTimer;
763 uint32_t commandProcessingPeriod;
764 CommandQueue commandQueue;
767 void commandProcessingTimerHandler(
void);
768 void processNextQueuedCommand();
769 void checkQueuedCommandTimeout();
787 #include "sdkTypes.h"
static const char * getWiconnectResultStr(WiconnectResult wiconnectResult)
Converts a WiconnectResult to string representation.
Contains single entry from goHACK.me message listing.
void setAssertLogger(LogFunc assertLogFunc)
Sets callback used when Wiconnect Library hits and internal assertion.
const char * getLastCommandResponseCodeStr()
When the WiConnect WiFi module returns a response, it contains a response code in the header...
int8_t(* PinToGpioMapper)(Pin pin)
Function pointer for mapping from a host pin to a WiConnect Module GPIO.
void setBlockingEnabled(bool blockingEnabled)
Sets if API calls are blocking or non-blocking.
UDP Server Listening socket.
The provides an interface for joining and/or creating a network. It provides other utilities such as ...
WiconnectResult
API Result code.
WiconnectResult reset()
Toggle the WiConnect WiFi module reset signal.
void flush(int delayMs=500)
Flush any received data in serial RX buffer and terminate any commands on WiConnect WiFi module...
Generic callback function.
WiconnectResult wakeup()
Toggle the WiConnect WiFi moduel wakeup signal.
Host<->Wiconnect Module serial configuration.
TimerTimeout getCommandDefaultTimeout()
Returns the current default maximum API execution time.
void setDebugLogger(LogFunc logFunc)
Sets callback function used to debug WiConnect WiFi module RX/TX serial data.
static Wiconnect * getInstance()
Get instance of previously instantiated Wiconnect Library.
WiconnectResult checkCurrentCommand()
Check the status of the currently executing command.
List of goHACK.me messages.
WiConnect WiFi module file object.
The provides an interface for http://goHACK.me.
void setCommandDefaultTimeout(TimerTimeout timeoutMs)
Sets the default maximum time an API method may execute before terminating and return a timeout error...
WiconnectResult responseToUint32(uint32_t *uint32Ptr)
Helper method to convert previous response to uint32.
Generic data reading callback function.
void deinit()
De-initialize library.
char * getResponseBuffer()
Return pointer to internal response buffer.
WiconnectResult setSetting(const char *settingStr, uint32_t value)
Set a module setting.
Class which contains command for asynchronous processing.
PinName Pin
Pin name on HOST.
WiconnectResult init(bool bringNetworkUp=false)
Initialize library and communication link with WiConnect WiFi module.
WiconnectResult getSetting(const char *settingStr, uint32_t *valuePtr)
Get a module setting.
void setPinToGpioMapper(PinToGpioMapper mapper)
Sets a mapping function used to convert from a host Pin to WiConnect WiFi module GPIO.
WiconnectResult sendCommand(const Callback &completeCallback, char *responseBuffer, int responseBufferLen, TimerTimeout timeoutMs, const ReaderFunc &reader, void *user, const char *cmd, va_list vaList)
Send command to WiConnect WiFi module.
Logging callback function.
void stopCurrentCommand()
Stop the currently executing command.
WiconnectResult responseToInt32(int32_t *int32Ptr)
Helper method to convert previous response to int32.
unsigned long TimerTimeout
Timeout type.
Connection object to remote server.
Wiconnect(const SerialConfig &serialConfig, Pin reset=PIN_NC, Pin wake=PIN_NC, bool nonBlocking=WICONNECT_DEFAULT_NONBLOCKING WICONNECT_MALLOC_ARGS)
WiConnect class constructor.
uint16_t getLastCommandResponseLength()
Return the length in bytes of the previous response.
List of WiFi network scan results.
The provides an interface for creating TCP/UDP/TLS/HTTP client sockets. A client socket connects to a...
The root WiConnect library class. This class inheriets all WiConnect functionality.
The provides an interface for creating TCP/UDP/TLS/HTTP client sockets. A client socket connects to a...
#define WICONNECT_DEFAULT_NONBLOCKING
The default blocking mode of the Library.
#define delayMs(ms)
Function to stop processor for specified number of milliseconds.
#define WICONNECT_MAX_CMD_SIZE
The maximum command size that may be sent to the WiConnect WiFi module.
#define PIN_NC
Default value for a pin, Not connected.
WiconnectResult getVersion(char *versionBuffer=NULL, int versionBufferSize=0, const Callback &completeCallback=Callback())
Return current version of WiConnect WiFi module.
bool isInitialized()
Return TRUE if library is able to communicated with WiConnect WiFi module. FALSE else.
Contains single entry from WiFi scan results.
WiconnectResult updateFirmware(bool forced=false, const char *versionStr=NULL, const Callback &completeCallback=Callback())
Update the wifi module's internal firmware.
bool getBlockingEnabled(void)
Gets if API calls are blocking or non-blocking.