2011-02-28 13:49:08 +01:00
|
|
|
#ifndef WiFi_h
|
|
|
|
#define WiFi_h
|
|
|
|
|
|
|
|
#include <inttypes.h>
|
|
|
|
|
|
|
|
extern "C" {
|
2011-03-08 22:13:54 +01:00
|
|
|
#include "utility/wl_definitions.h"
|
2011-02-28 13:49:08 +01:00
|
|
|
}
|
|
|
|
|
2011-03-05 00:02:04 +01:00
|
|
|
#include "IPAddress.h"
|
2011-02-28 13:49:08 +01:00
|
|
|
#include "Client.h"
|
|
|
|
#include "Server.h"
|
|
|
|
|
|
|
|
class WiFiClass
|
|
|
|
{
|
|
|
|
private:
|
|
|
|
// this data are stored in EEPROM and loaded at begin
|
|
|
|
// The next connect overwrite these values
|
2011-03-08 22:13:54 +01:00
|
|
|
static char _ssid[WL_SSID_MAX_LENGTH];
|
|
|
|
static char _key[WL_WEP_KEY_MAX_LENGTH];
|
|
|
|
static char _passph[WL_WPA_KEY_MAX_LENGTH];
|
2011-03-01 19:38:14 +01:00
|
|
|
static wl_status_t _status;
|
2011-02-28 13:49:08 +01:00
|
|
|
|
|
|
|
void init();
|
|
|
|
public:
|
2011-03-08 22:13:54 +01:00
|
|
|
static int16_t _state[MAX_SOCK_NUM];
|
2011-02-28 13:49:08 +01:00
|
|
|
static uint16_t _server_port[MAX_SOCK_NUM];
|
2011-03-01 19:38:14 +01:00
|
|
|
|
2011-02-28 13:49:08 +01:00
|
|
|
WiFiClass();
|
|
|
|
|
2011-03-08 22:13:54 +01:00
|
|
|
// Get thefirst socket available
|
|
|
|
static uint8_t getSocket();
|
|
|
|
|
2011-03-05 00:02:04 +01:00
|
|
|
// Start Wifi connection with latest settings
|
|
|
|
int begin();
|
2011-02-28 13:49:08 +01:00
|
|
|
|
2011-03-05 00:02:04 +01:00
|
|
|
// Start Wifi connection with no encryption
|
2011-03-08 22:13:54 +01:00
|
|
|
int begin(char* ssid);
|
2011-02-28 13:49:08 +01:00
|
|
|
|
2011-03-05 00:02:04 +01:00
|
|
|
// Start Wifi connection with WEP encryption
|
2011-03-08 22:13:54 +01:00
|
|
|
int begin(char* ssid, uint8_t key_idx, const char* key);
|
2011-02-28 13:49:08 +01:00
|
|
|
|
2011-03-05 00:02:04 +01:00
|
|
|
// Start Wifi connection with passphrase
|
|
|
|
// the most secure supported mode will be automatically selected
|
2011-03-08 22:13:54 +01:00
|
|
|
int begin(char* ssid, const char *passphrase);
|
2011-02-28 13:49:08 +01:00
|
|
|
|
|
|
|
// Disconnect from the network
|
2011-03-05 00:02:04 +01:00
|
|
|
int disconnect(void);
|
2011-02-28 13:49:08 +01:00
|
|
|
|
|
|
|
//Get the interface MAC address.
|
2011-03-08 22:13:54 +01:00
|
|
|
uint8_t* macAddress(uint8_t* mac);
|
2011-02-28 13:49:08 +01:00
|
|
|
|
2011-03-01 19:38:14 +01:00
|
|
|
//Get the DHCP information related to IP
|
2011-03-05 00:02:04 +01:00
|
|
|
IPAddress localIp();
|
2011-02-28 13:49:08 +01:00
|
|
|
|
2011-03-05 00:02:04 +01:00
|
|
|
//Get the DHCP information related to subnetMask
|
|
|
|
IPAddress subnetMask();
|
2011-02-28 13:49:08 +01:00
|
|
|
|
2011-03-05 00:02:04 +01:00
|
|
|
//Get the DHCP information related to gateway IP
|
|
|
|
IPAddress gatewayIP();
|
2011-02-28 13:49:08 +01:00
|
|
|
|
|
|
|
// Return the current SSID associated with the network
|
2011-03-05 00:02:04 +01:00
|
|
|
char* SSID();
|
2011-02-28 13:49:08 +01:00
|
|
|
|
|
|
|
// Return the current BSSID associated with the network
|
2011-03-08 22:13:54 +01:00
|
|
|
uint8_t* BSSID(uint8_t* bssid);
|
2011-02-28 13:49:08 +01:00
|
|
|
|
2011-03-08 22:13:54 +01:00
|
|
|
// Return the current RSSI /Received Signal Strength in dBm) associated with the network
|
|
|
|
int32_t RSSI();
|
2011-03-05 00:02:04 +01:00
|
|
|
|
2011-03-08 22:13:54 +01:00
|
|
|
// Return the Encryption Type associated with the network
|
|
|
|
uint8_t encryptionType();
|
2011-02-28 13:49:08 +01:00
|
|
|
|
2011-03-08 22:13:54 +01:00
|
|
|
// Start scan WiFi networks available and return the discovered number
|
|
|
|
uint8_t scanNetworks();
|
2011-03-05 00:02:04 +01:00
|
|
|
|
2011-03-08 22:13:54 +01:00
|
|
|
// Return SSID item associated with the network identified with networkItem
|
|
|
|
char* SSID(uint8_t networkItem);
|
|
|
|
|
|
|
|
// Return the Encryption Type associated with the network identified with networkItem
|
|
|
|
uint8_t encryptionType(uint8_t networkItem);
|
|
|
|
|
|
|
|
// Return the current RSSI /Received Signal Strength in dBm) associated with the network identified with networkItem
|
|
|
|
int32_t RSSI(uint8_t networkItem);
|
2011-02-28 13:49:08 +01:00
|
|
|
|
2011-04-05 23:24:17 +02:00
|
|
|
// Return Connection status
|
|
|
|
uint8_t status();
|
|
|
|
|
2011-05-18 08:39:47 +02:00
|
|
|
// function used for test
|
|
|
|
uint8_t test();
|
|
|
|
|
2011-02-28 13:49:08 +01:00
|
|
|
friend class Client;
|
|
|
|
friend class Server;
|
|
|
|
};
|
|
|
|
|
|
|
|
extern WiFiClass WiFi;
|
|
|
|
|
|
|
|
#endif
|