Public Member Functions | |
boolean | begin (Stream *serialdev, Stream *debugPrint=NULL) |
char * | getSSID (char *buf, int size) |
uint8_t | getJoin () |
char * | getDeviceID (char *buf, int size) |
char * | getIP (char *buf, int size) |
uint16_t | getPort () |
char * | getNetmask (char *buf, int size) |
char * | getGateway (char *buf, int size) |
char * | getDNS (char *buf, int size) |
char * | getMAC (char *buf, int size) |
int8_t | getDHCPMode () |
uint32_t | getRate () |
uint8_t | getTxPower () |
uint16_t | getConnection () |
int8_t | getRSSI () |
bool | setJoin (uint8_t join) |
boolean | setDeviceID (const char *buf) |
boolean | setBaud (uint32_t baud) |
uint32_t | getBaud () |
uint8_t | getUartMode () |
uint8_t | getIpFlags () |
uint8_t | getProtocol () |
uint8_t | getFlushChar () |
uint16_t | getFlushSize () |
uint16_t | getFlushTimeout () |
char | getSpaceReplace (void) |
char * | getHostIP (char *buf, int size) |
uint16_t | getHostPort () |
boolean | setSSID (const char *buf) |
boolean | setIP (const char *buf) |
boolean | setIP (const __FlashStringHelper *buf) |
boolean | setPort (const uint16_t port) |
boolean | setNetmask (const char *buf) |
boolean | setNetmask (const __FlashStringHelper *buf) |
boolean | setGateway (const char *buf) |
boolean | setDNS (const char *buf) |
boolean | setChannel (uint8_t channel) |
boolean | setKey (const char *buf) |
boolean | setPassphrase (const char *buf) |
boolean | setSpaceReplace (char ch) |
boolean | setDHCP (const uint8_t mode) |
boolean | setRate (uint32_t rate) |
boolean | setTxPower (uint8_t dBm) |
boolean | setHostIP (const char *buf) |
boolean | setHostIP (const __FlashStringHelper *buf) |
boolean | setHostPort (const uint16_t port) |
boolean | setHost (const char *buf, uint16_t port) |
boolean | setProtocol (const uint8_t protocol) |
boolean | setIpProtocol (const uint8_t protocol) |
boolean | setIpFlags (const uint8_t flags) |
boolean | setUartMode (const uint8_t mode) |
boolean | setBroadcastInterval (const uint8_t seconds) |
boolean | setTimeAddress (const char *buf) |
boolean | setTimePort (const uint16_t port) |
boolean | setTimezone (const uint8_t zone) |
boolean | setTimeEnable (const uint16_t enable) |
boolean | setAdhocBeacon (const uint16_t msecs) |
boolean | setAdhocProbe (const uint16_t secs) |
uint16_t | getAdhocBeacon () |
uint16_t | getAdhocProbe () |
uint16_t | getAdhocReboot () |
boolean | setFlushTimeout (const uint16_t timeout) |
boolean | setFlushChar (const char flushChar) |
boolean | setFlushSize (uint16_t size) |
boolean | enableDataTrigger (const uint16_t flushtime=10, const char flushChar=0, const uint16_t flushSize=64) |
boolean | disableDataTrigger () |
boolean | enableUdpAutoPair () |
boolean | disableUdpAutoPair () |
boolean | setIOFunc (const uint8_t func) |
char * | getTime (char *buf, int size) |
uint32_t | getUptime () |
uint8_t | getTimezone () |
uint32_t | getRTC () |
bool | getHostByName (const char *hostname, char *buf, int size) |
boolean | ping (const char *host) |
boolean | enableDHCP () |
boolean | disableDHCP () |
boolean | createAdhocNetwork (const char *ssid, uint8_t channel) |
boolean | join (const char *ssid, uint16_t timeout=20000) |
boolean | join (uint16_t timeout=20000) |
boolean | join (const char *ssid, const char *password, bool dhcp=true, uint8_t mode=WIFLY_MODE_WPA, uint16_t timeout=20000) |
boolean | leave () |
boolean | isAssociated () |
boolean | save () |
boolean | reboot () |
boolean | factoryRestore () |
boolean | sendto (const uint8_t *data, uint16_t size, const char *host, uint16_t port) |
boolean | sendto (const uint8_t *data, uint16_t size, IPAddress host, uint16_t port) |
boolean | sendto (const char *data, const char *host, uint16_t port) |
boolean | sendto (const char *data, IPAddress host, uint16_t port) |
boolean | sendto (const __FlashStringHelper *data, const char *host, uint16_t port) |
boolean | sendto (const __FlashStringHelper *data, IPAddress host, uint16_t port) |
void | enableHostRestore () |
void | disableHostRestore () |
boolean | open (const char *addr, int port=80, boolean block=true) |
boolean | open (IPAddress addr, int port=80, boolean block=true) |
boolean | close () |
boolean | openComplete () |
boolean | isConnected () |
boolean | isInCommandMode () |
virtual size_t | write (uint8_t byte) |
virtual int | read () |
virtual int | available () |
virtual void | flush () |
virtual int | peek () |
char * | iptoa (IPAddress addr, char *buf, int size) |
IPAddress | atoip (char *buf) |
boolean | isDotQuad (const char *addr) |
void | sendChunk (const char *str) |
void | sendChunk (const __FlashStringHelper *str) |
void | sendChunkln (const char *str) |
void | sendChunkln (const __FlashStringHelper *str) |
void | sendChunkln (void) |
int | getFreeMemory () |
void | terminal () |
void | dbgBegin (int size=256) |
void | dbgDump () |
void | dbgEnd () |
boolean | match (const char *str, uint16_t timeout=WIFLY_DEFAULT_TIMEOUT) |
boolean | match (const __FlashStringHelper *str, uint16_t timeout=WIFLY_DEFAULT_TIMEOUT) |
int | multiMatch_P (uint16_t timeout, uint8_t count,...) |
int | gets (char *buf, int size, uint16_t timeout=WIFLY_DEFAULT_TIMEOUT) |
int | getsTerm (char *buf, int size, char term, uint16_t timeout=WIFLY_DEFAULT_TIMEOUT) |
void | flushRx (int timeout=WIFLY_DEFAULT_TIMEOUT) |
boolean | setFtpDefaults (void) |
boolean | setFtpAddress (const char *addr) |
boolean | setFtpPort (uint16_t port) |
boolean | setFtpDirectory (const char *dir) |
boolean | setFtpUser (const char *user) |
boolean | setFtpPassword (const char *password) |
boolean | setFtpFilename (const char *filename) |
boolean | setFtpTimer (uint16_t msecs) |
boolean | setFtpMode (uint8_t mode) |
boolean | ftpGet (const char *addr, const char *dir, const char *user, const char *password, const char *filename) |
Public Attributes | |
boolean | debugOn |
uint8_t | tcp |
uint8_t | assoc |
uint8_t | authen |
uint8_t | dnsServer |
uint8_t | dnsFound |
uint8_t | channel |
IPAddress WiFly::atoip | ( | char * | buf | ) |
Convert a dotquad IP address string to an IPAddress. E.g. "192.168.1.100" -> { 192, 168, 1, 100 }.
buf | - the string to convert |
|
virtual |
Check to see if data is available to be read.
0 | - no data available |
-1 | - active TCP connection was closed, |
boolean WiFly::begin | ( | Stream * | serialdev, |
Stream * | debugPrint = NULL |
||
) |
boolean WiFly::close | ( | ) |
Close the TCP connection
true | - connection closed |
false | - failed to close |
boolean WiFly::createAdhocNetwork | ( | const char * | ssid, |
uint8_t | channel | ||
) |
void WiFly::dbgBegin | ( | int | size = 256 | ) |
Start a capture of all the characters recevied from the WiFly.
size | - the size of the capture buffer. This will be malloced. |
void WiFly::dbgDump | ( | ) |
Do a hex and ASCII dump of the capture buffer, and free the buffer.
void WiFly::dbgEnd | ( | ) |
Stop debug capture and free buffer
void WiFly::disableHostRestore | ( | ) |
boolean WiFly::enableDataTrigger | ( | const uint16_t | flushTimeout = 10 , |
const char | flushChar = 0 , |
||
const uint16_t | flushSize = 64 |
||
) |
Enable data trigger mode. This mode will automatically send a new packet based on several conditions:
flushTimeout | Send a packet if no more characters are sent within this many milliseconds. Set to 0 to disable. |
flushChar | Send a packet when this character is sent to the WiFly. Set to 0 to disable. |
flushSize | Send a packet when this many characters have been sent to the WiFly. |
void WiFly::enableHostRestore | ( | ) |
boolean WiFly::enableUdpAutoPair | ( | ) |
Enable the UDP auto-pair functionality. The WiFly will automatically set the Host IP and port to match the sender of the last UDP packet.
boolean WiFly::factoryRestore | ( | ) |
Restore factory default settings
void WiFly::flushRx | ( | int | timeout = WIFLY_DEFAULT_TIMEOUT | ) |
Flush the incoming data from the WiFly.
timeout | - the number of milliseconds to wait for additional data to flush. Default is 500msecs. |
int WiFly::getFreeMemory | ( | ) |
Return number of bytes of memory available.
bool WiFly::getHostByName | ( | const char * | hostname, |
char * | buf, | ||
int | size | ||
) |
Do a DNS lookup to find the ip address of the specified hostname
hostname | - host to lookup |
buf | - buffer to return the ip address in |
size | - size of the buffer |
char * WiFly::getHostIP | ( | char * | buf, |
int | size | ||
) |
Get remote IP address
uint16_t WiFly::getHostPort | ( | ) |
Get remote port
char * WiFly::getIP | ( | char * | buf, |
int | size | ||
) |
Get local IP address
uint16_t WiFly::getPort | ( | ) |
Get local port
uint32_t WiFly::getRate | ( | ) |
Return the current WiFi data rate in bits/sec
int WiFly::gets | ( | char * | buf, |
int | size, | ||
uint16_t | timeout = WIFLY_DEFAULT_TIMEOUT |
||
) |
Read characters into the buffer until a carriage-return and newline is reached. If the buffer is too small, the remaining characters in the line are discarded.
buf | - the buffer to read into. If this is NULL then all characters in the line are discarded. |
size | - the size of the buffer (max number of characters it can store) |
timeout | - the number of milliseconds to wait for a new character to arrive |
0 | - timeout reading newline |
uint8_t WiFly::getTxPower | ( | ) |
Get the current transmit power.
char * WiFly::iptoa | ( | IPAddress | addr, |
char * | buf, | ||
int | size | ||
) |
Convert an IPAdress to an ASCIIZ string
addr | - the IP Address to convert |
buf | - the buffer to write the result to |
size | - the size of the buffer |
boolean WiFly::isAssociated | ( | ) |
Check to see if the WiFly is connected to a wireless network
boolean WiFly::isConnected | ( | ) |
Check to see if there is a tcp connection.
true | connected |
false | not connected |
boolean WiFly::isDotQuad | ( | const char * | addr | ) |
See if the string is a valid dot quad IP address
boolean WiFly::join | ( | const char * | ssid, |
uint16_t | timeout = 20000 |
||
) |
join a wireless network
boolean WiFly::join | ( | uint16_t | timeout = 20000 | ) |
join a wireless network
boolean WiFly::join | ( | const char * | ssid, |
const char * | password, | ||
bool | dhcp = true , |
||
uint8_t | mode = WIFLY_MODE_WPA , |
||
uint16_t | timeout = 20000 |
||
) |
Join a wireless network.
ssid | The SSID of the network to join |
password | The WPA passphrase or WEP hex key. |
dhcp | set to true to enable DHCP |
mode | WIFLY_MODE_WPA for WPA security, or WIFLY_MODE_WEP for WEP security. |
timeout | number of milliseconds to try connecting before timing out. |
boolean WiFly::leave | ( | ) |
leave the wireless network
boolean WiFly::match | ( | const char * | str, |
uint16_t | timeout = WIFLY_DEFAULT_TIMEOUT |
||
) |
Read characters from the WiFly and match them against the string. Ignore any leading characters that don't match. Keep reading, discarding the input, until the string is matched or until no characters are received for the timeout duration.
str | The string to match |
timeout | fail if no data received for this period (in milliseconds). |
true | - a match was found |
false | - no match found, timeout reached |
boolean WiFly::match | ( | const __FlashStringHelper * | str, |
uint16_t | timeout = WIFLY_DEFAULT_TIMEOUT |
||
) |
Read characters from the WiFly and match them against the flash string. Ignore any leading characters that don't match. Keep reading, discarding the input, until the string is matched or until no characters are received for the timeout duration.
str | The string to match (in flash memory) fail if no data received for this period (in milliseconds). |
true | - a match was found |
false | - no match found, timeout reached |
int WiFly::multiMatch_P | ( | uint16_t | timeout, |
uint8_t | count, | ||
... | |||
) |
Read characters from the WiFly and match them against the set of progmem strings. Ignore any leading characters that don't match. Keep reading, discarding the input, until one of the strings is matched or until no characters are received for the timeout duration.
Example: res = multiMatch_P(500, 3, F("first="), F("second="), F("closed"));
Will return 0 if "first=" is matched, 1 if "second=" is matched, 2 if "closed" is matched, or -1 if nothing is matched and no data is received for 500 milliseconds.
timeout | - fail if no data received for this period (in milliseconds). |
count | - the number of strings in the str array |
... | A list of count progmem strings to match |
-1 | - no match found, timeout reached |
boolean WiFly::open | ( | const char * | addr, |
int | port = 80 , |
||
boolean | block = true |
||
) |
Open a TCP connection. If there is already an open connection then that is closed first.
addr | - the IP address or hostname to connect. A DNS lookup will be peformed for the hostname. |
port | - the TCP port to connect to |
block | - true = wait for the connection to complete false = start the connection and return. Use openComplete() to determine the result. |
true | - success, the connection is open |
false | - failed, or connection already in progress |
boolean WiFly::open | ( | IPAddress | addr, |
int | port = 80 , |
||
boolean | block = true |
||
) |
Open a TCP connection. If there is already an open connection then that is closed first.
addr | - the IP address to connect to |
port | - the TCP port to connect to |
block | - true = wait for the connection to complete false = start the connection and return. Use openComplete() to determine the result. |
true | - success, the connection is open |
false | - failed, or connection already in progress |
boolean WiFly::openComplete | ( | ) |
Check to see if the non-blocking open has completed. When this returns true the open has finished with either success or failure. You can use isConnected() to see if the open was successful.
true | - the open operation has completed |
false | - the open is still in progress |
|
virtual |
Return the next byte that a read() would return, but leave the byte in the receive buffer.
-1 | - no data in receive buffer |
boolean WiFly::ping | ( | const char * | host | ) |
Ping the specified host. Return true if a ping response is received, else false.
host | the host or IP address to ping |
true | - received ping response |
false | - no response from host |
|
virtual |
Read the next byte from the WiFly.
-1 | - nothing in the receive buffer to read |
boolean WiFly::reboot | ( | ) |
Reboots the WiFly.
void WiFly::sendChunk | ( | const char * | str | ) |
Send a string as an HTTP chunk without a newline An HTTP chunk is the length of the string in HEX followed by the string.
str | the string to send |
void WiFly::sendChunk | ( | const __FlashStringHelper * | str | ) |
Send a progmem string as an HTTP chunk without a newline. An HTTP chunk is the length of the string in HEX followed by the string.
str | the string to send |
void WiFly::sendChunkln | ( | const char * | str | ) |
Send a string as an HTTP chunk with newline An HTTP chunk is the length of the string in HEX followed by the string.
str | the string to send |
void WiFly::sendChunkln | ( | const __FlashStringHelper * | str | ) |
Send a progmame string as an HTTP chunk with newline An HTTP chunk is the length of the string in HEX followed by the string.
str | the string to send |
void WiFly::sendChunkln | ( | void | ) |
Send final chunk, end of HTTP message
boolean WiFly::sendto | ( | const uint8_t * | data, |
uint16_t | size, | ||
const char * | host, | ||
uint16_t | port | ||
) |
Send binary data as a UDP packet to a host.
data | - pointer to an array of data to send |
size | - then number of bytes of data to send |
host | - the IP or hostname to send the packet to. If this is a hostname then a DNS lookup will be performed to find the IP address. |
port | - the UDP port to send the packet to |
true | - packet send successfully |
false | - failed to send packet |
boolean WiFly::sendto | ( | const uint8_t * | data, |
uint16_t | size, | ||
IPAddress | host, | ||
uint16_t | port | ||
) |
Send binary data as a UDP packet to a host.
data | - pointer to an array of data to send |
size | - then number of bytes of data to send |
host | - the IP address to send the packet to. |
port | - the UDP port to send the packet to |
true | - packet send successfully |
false | - failed to send packet |
boolean WiFly::sendto | ( | const char * | data, |
const char * | host, | ||
uint16_t | port | ||
) |
Send a string as a UDP packet to a host.
data | - the null terminated string to send |
host | - the IP or hostname to send the packet to. If this is a hostname then a DNS lookup will be performed to find the IP address. |
port | - the UDP port to send the packet to |
true | - packet send successfully |
false | - failed to send packet |
boolean WiFly::sendto | ( | const char * | data, |
IPAddress | host, | ||
uint16_t | port | ||
) |
Send a string as a UDP packet to a host.
data | - the null terminated string to send |
host | - the IP address to send the packet to. |
port | - the UDP port to send the packet to |
true | - packet send successfully |
false | - failed to send packet |
boolean WiFly::sendto | ( | const __FlashStringHelper * | flashData, |
const char * | host, | ||
uint16_t | port | ||
) |
Send a string as a UDP packet to a host.
data | - the null terminated flash string to send |
host | - the IP or hostname to send the packet to. If this is a hostname then a DNS lookup will be performed to find the IP address. |
port | - the UDP port to send the packet to |
true | - packet send successfully |
false | - failed to send packet |
boolean WiFly::sendto | ( | const __FlashStringHelper * | flashData, |
IPAddress | host, | ||
uint16_t | port | ||
) |
Send a string as a UDP packet to a host.
data | - the null terminated flash string to send |
host | - the IP address to send the packet to. |
port | - the UDP port to send the packet to |
true | - packet send successfully |
false | - failed to send packet |
boolean WiFly::setAdhocBeacon | ( | const uint16_t | msecs | ) |
Set the ad hoc beacon period in milliseconds. The beacon is a management frame needed to keep the network alive. Default is 100 milliseconds.
msecs | the number of milliseconds between beacon |
boolean WiFly::setAdhocProbe | ( | const uint16_t | secs | ) |
Set the ad hoc network probe period. When this number of seconds passes since last receiving a beacon then the network is declared lost. Default is 5 seconds..
secs | the number of seconds in the probe period. |
boolean WiFly::setBroadcastInterval | ( | const uint8_t | seconds | ) |
Set the UDP broadcast time interval.
seconds | the number of seconds between broadcasts. Set this to zero to disable broadcasts. |
boolean WiFly::setChannel | ( | uint8_t | channel | ) |
Set the WiFi channel.
channel | the wifi channel from 0 to 13. 0 means auto channel scan. |
boolean WiFly::setFlushChar | ( | const char | flushChar | ) |
Set the comms flush character. 0 disables the feature. A packet will be sent whenever this character is sent to the WiFly. Used for auto connect mode or UDP packet sending.
flushChar | send a packet when this character is sent. Set to 0 to disable character based flush. |
boolean WiFly::setFlushSize | ( | uint16_t | size | ) |
Set the comms flush size. A packet will be sent whenever this many characters are sent.
size | number of characters to buffer before sending a packet |
boolean WiFly::setFlushTimeout | ( | const uint16_t | timeout | ) |
Set comms flush timeout. When using data trigger mode, this timer defines how long the WiFly will wait for the next character from the sketch before sending what it has collected so far as a packet.
timeout | number of milliseconds to wait before flushing the packet. |
boolean WiFly::setFtpDefaults | ( | void | ) |
Restore the default ftp settings. These are the settings needed to upgrade the firmware. Is this needed? Why not just use factory defaults?
boolean WiFly::setIOFunc | ( | const uint8_t | func | ) |
Set the WiFly IO function option
boolean WiFly::setKey | ( | const char * | buf | ) |
Set WEP key
boolean WiFly::setPassphrase | ( | const char * | buf | ) |
Set WPA passphrase. Spaces are automatically replaced with the current space substitution character ('$' is the default). : If your passphrase contains a '$' then use setSpaceReplace() to change the replacement character to something you're not using.
boolean WiFly::setPort | ( | const uint16_t | port | ) |
Set local port
boolean WiFly::setRate | ( | uint32_t | rate | ) |
Set WiFi data rate
rate | the data rate to set in bits per second. valid values are 1000000, 2000000, 5500000, 6000000, 9000000, 11000000, 12000000, 18000000, 24000000, 36000000, 48000000, 54000000. |
boolean WiFly::setSpaceReplace | ( | char | ch | ) |
Set the space replacement character in WPA passphrase. Default is '$'.
boolean WiFly::setTimeAddress | ( | const char * | buf | ) |
Set NTP server IP address
boolean WiFly::setTimeEnable | ( | const uint16_t | period | ) |
Set the NTP update period
boolean WiFly::setTimePort | ( | const uint16_t | port | ) |
Set NTP server port
boolean WiFly::setTimezone | ( | const uint8_t | zone | ) |
Set timezone for calculating local time based on NTP time.
boolean WiFly::setTxPower | ( | uint8_t | dBm | ) |
Set the transmit power level.
dBm | power level from 1 to 12 dBm |
void WiFly::terminal | ( | ) |
|
virtual |
Write a byte to the WiFly.
byte | - the byte to write. |