mbed official WiflyInterface (interface for Roving Networks Wifly modules)
Dependents: Wifly_HelloWorld Websocket_Wifly_HelloWorld RPC_Wifly_HelloWorld HTTPClient_Wifly_HelloWorld ... more
WiflyInterface Class Reference
Interface using Wifly to connect to an IP-based network. More...
#include <WiflyInterface.h>
Inherits Wifly.
Public Member Functions | |
WiflyInterface (PinName tx, PinName rx, PinName reset, PinName tcp_status, const char *ssid, const char *phrase, Security sec=NONE) | |
Constructor. | |
int | init () |
Initialize the interface with DHCP. | |
int | init (const char *ip, const char *mask, const char *gateway) |
Initialize the interface with a static IP address. | |
int | connect () |
Connect Bring the interface up, start DHCP if needed. | |
int | disconnect () |
Disconnect Bring the interface down. | |
char * | getIPAddress () |
Get IP address. | |
bool | join () |
Connect the wifi module to the ssid contained in the constructor. | |
bool | connect (const char *host, int port) |
Open a tcp connection with the specified host on the specified port. | |
bool | setProtocol (Protocol p) |
Set the protocol (UDP or TCP) | |
void | reset () |
Reset the wifi module. | |
bool | reboot () |
Reboot the wifi module. | |
int | readable () |
Check if characters are available. | |
int | writeable () |
Check if characters are available. | |
bool | is_connected () |
Check if a tcp link is active. | |
char | getc () |
Read a character. | |
void | flush () |
Flush the buffer. | |
int | putc (char c) |
Write a character. | |
bool | cmdMode () |
To enter in command mode (we can configure the module) | |
bool | exit () |
To exit the command mode. | |
bool | close () |
Close a tcp connection. | |
int | send (const char *str, int len, const char *ACK=NULL, char *res=NULL, int timeout=DEFAULT_WAIT_RESP_TIMEOUT) |
Send a string to the wifi module by serial port. | |
bool | sendCommand (const char *cmd, const char *ack=NULL, char *res=NULL, int timeout=DEFAULT_WAIT_RESP_TIMEOUT) |
Send a command to the wify module. | |
bool | isDHCP () |
Return true if the module is using dhcp. |
Detailed Description
Interface using Wifly to connect to an IP-based network.
Definition at line 28 of file WiflyInterface.h.
Constructor & Destructor Documentation
WiflyInterface | ( | PinName | tx, |
PinName | rx, | ||
PinName | reset, | ||
PinName | tcp_status, | ||
const char * | ssid, | ||
const char * | phrase, | ||
Security | sec = NONE |
||
) |
Constructor.
- Parameters:
-
tx mbed pin to use for tx line of Serial interface rx mbed pin to use for rx line of Serial interface reset reset pin of the wifi module () tcp_status connection status pin of the wifi module (GPIO 6) ssid ssid of the network phrase WEP or WPA key sec Security type (NONE, WEP_128 or WPA)
Definition at line 3 of file WiflyInterface.cpp.
Member Function Documentation
bool close | ( | ) | [inherited] |
bool cmdMode | ( | ) | [inherited] |
int connect | ( | ) |
Connect Bring the interface up, start DHCP if needed.
- Returns:
- 0 on success, a negative number on failure
Definition at line 30 of file WiflyInterface.cpp.
bool connect | ( | const char * | host, |
int | port | ||
) | [inherited] |
int disconnect | ( | ) |
Disconnect Bring the interface down.
- Returns:
- 0 on success, a negative number on failure
Reimplemented from Wifly.
Definition at line 35 of file WiflyInterface.cpp.
bool exit | ( | ) | [inherited] |
char getc | ( | ) | [inherited] |
char * getIPAddress | ( | ) |
int init | ( | const char * | ip, |
const char * | mask, | ||
const char * | gateway | ||
) |
Initialize the interface with a static IP address.
Initialize the interface and configure it with the following static configuration (no connection at this point).
- Parameters:
-
ip the IP address to use mask the IP address mask gateway the gateway to use
- Returns:
- 0 on success, a negative number on failure
Definition at line 17 of file WiflyInterface.cpp.
int init | ( | void | ) |
Initialize the interface with DHCP.
Initialize the interface and configure it to use DHCP (no connection at this point).
- Returns:
- 0 on success, a negative number on failure
Definition at line 10 of file WiflyInterface.cpp.
bool is_connected | ( | void | ) | [inherited] |
bool isDHCP | ( | ) | [inherited] |
bool join | ( | ) | [inherited] |
int putc | ( | char | c ) | [inherited] |
int readable | ( | ) | [inherited] |
int send | ( | const char * | str, |
int | len, | ||
const char * | ACK = NULL , |
||
char * | res = NULL , |
||
int | timeout = DEFAULT_WAIT_RESP_TIMEOUT |
||
) | [inherited] |
Send a string to the wifi module by serial port.
This function desactivates the user interrupt handler when a character is received to analyze the response from the wifi module. Useful to send a command to the module and wait a response.
- Parameters:
-
str string to be sent len string length ACK string which must be acknowledge by the wifi module. If ACK == NULL, no string has to be acknoledged. (default: "NO") res this field will contain the response from the wifi module, result of a command sent. This field is available only if ACK = "NO" AND res != NULL (default: NULL)
- Returns:
- true if ACK has been found in the response from the wifi module. False otherwise or if there is no response in 5s.
bool sendCommand | ( | const char * | cmd, |
const char * | ack = NULL , |
||
char * | res = NULL , |
||
int | timeout = DEFAULT_WAIT_RESP_TIMEOUT |
||
) | [inherited] |
Send a command to the wify module.
Check if the module is in command mode. If not enter in command mode
- Parameters:
-
str string to be sent ACK string which must be acknowledge by the wifi module. If ACK == NULL, no string has to be acknoledged. (default: "NO") res this field will contain the response from the wifi module, result of a command sent. This field is available only if ACK = "NO" AND res != NULL (default: NULL)
- Returns:
- true if successful
bool setProtocol | ( | Protocol | p ) | [inherited] |
Generated on Tue Jul 12 2022 18:24:22 by 1.7.2