1
0
mirror of https://github.com/esp8266/Arduino.git synced 2025-06-15 00:02:49 +03:00

ESP8266WiFi extended functions

- begin changes
     allow setting BSSID/MAC and Channel of an AP for faster connection (#261)
     now checks if ssid and passphrase to big
     selecting Wifi mode in better way (fix for #28)

 - ESP8266WiFiMulti uses the new functions to auto select best AP even in a multi AP WiFi network (more the one AP has same SSID)

 - add new functions to get current Connected AP:
     uint8_t * BSSID(void);
     int32_t Channel(void);

 - add new functions to get infos from scanned networks:
     uint8_t * BSSID(uint8_t networkItem);
     int32_t Channel(uint8_t networkItem);
     bool isHidden(uint8_t networkItem);
     bool getNetworkInfo(uint8_t networkItem, const char** ssid, uint8_t * encryptionType, int32_t * RSSI, uint8_t ** BSSID, int32_t * channel, bool * isHidden);
This commit is contained in:
Markus Sattler
2015-05-21 21:10:45 +02:00
parent a34edc8990
commit bc37b9ea68
3 changed files with 188 additions and 51 deletions

View File

@ -42,21 +42,18 @@ public:
void mode(WiFiMode);
/* Start Wifi connection for OPEN networks
*
* param ssid: Pointer to the SSID string.
/**
* Start Wifi connection
* if passphrase is set the most secure supported mode will be automatically selected
* @param ssid const char* Pointer to the SSID string.
* @param passphrase const char * Optional. Passphrase. Valid characters in a passphrase must be between ASCII 32-126 (decimal).
* @param bssid uint8_t[6] Optional. BSSID / MAC of AP
* @param channel Optional. Channel of AP
* @return
*/
int begin(const char* ssid);
int begin(const char* ssid, const char *passphrase = NULL, int32_t channel = 0, uint8_t bssid[6] = NULL);
int begin(char* ssid, char *passphrase = NULL, int32_t channel = 0, uint8_t bssid[6] = NULL);
/* Start Wifi connection with passphrase
* the most secure supported mode will be automatically selected
*
* param ssid: Pointer to the SSID string.
* param passphrase: Passphrase. Valid characters in a passphrase
* must be between ASCII 32-126 (decimal).
*/
int begin(const char* ssid, const char *passphrase);
/* Wait for Wifi connection to reach a result
* returns the status reached or disconnect if STA is off
@ -151,6 +148,20 @@ public:
*/
char* SSID();
/*
* Return the current bssid / mac associated with the network if configured
*
* return: bssid string
*/
uint8_t * BSSID(void);
/*
* Return the current channel associated with the network
*
* return: channel
*/
int32_t Channel(void);
/*
* Return the current network RSSI. Note: this is just a stub, there is no way to
* get the RSSI in the Espressif SDK yet.
@ -194,6 +205,42 @@ public:
*/
int32_t RSSI(uint8_t networkItem);
/**
* return MAC / BSSID of scanned wifi
* @param networkItem specify from which network item want to get the information
* @return uint8_t * to MAC / BSSID of scanned wifi
*/
uint8_t * BSSID(uint8_t networkItem);
/**
* return Channel of scanned wifi
* @param networkItem specify from which network item want to get the information
* @return uint32_t Channel of scanned wifi
*/
int32_t Channel(uint8_t networkItem);
/**
* return if the scanned wifi is Hidden (no SSID)
* @param networkItem specify from which network item want to get the information
* @return bool (true == hidden)
*/
bool isHidden(uint8_t networkItem);
/**
* loads all infos from a scanned wifi in to the ptr parameters
* @param networkItem uint8_t
* @param ssid const char**
* @param encryptionType uint8_t *
* @param RSSI int32_t *
* @param BSSID uint8_t **
* @param channel int32_t *
* @param isHidden bool *
* @return (true if ok)
*/
bool getNetworkInfo(uint8_t networkItem, const char** ssid, uint8_t * encryptionType, int32_t * RSSI, uint8_t ** BSSID, int32_t * channel, bool * isHidden);
/*
* Return Connection status.
*
@ -243,6 +290,9 @@ protected:
static void _smartConfigDone(void* result);
bool _smartConfigStarted = false;
bool useApMode;
bool useClientMode;
static size_t _scanCount;
static void* _scanResult;