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

add function begin without any parameters and add functin psk to return current pre shared kex form sdk config

This commit is contained in:
Pascal Gollor
2015-09-28 16:48:06 +02:00
parent fb2545f72f
commit b13095763d
3 changed files with 29 additions and 0 deletions

View File

@ -41,6 +41,7 @@ localIP KEYWORD2
subnetMask KEYWORD2 subnetMask KEYWORD2
gatewayIP KEYWORD2 gatewayIP KEYWORD2
SSID KEYWORD2 SSID KEYWORD2
psk KEYWORD2
BSSID KEYWORD2 BSSID KEYWORD2
RSSI KEYWORD2 RSSI KEYWORD2
encryptionType KEYWORD2 encryptionType KEYWORD2

View File

@ -145,6 +145,17 @@ int ESP8266WiFiClass::begin(const char* ssid, const char *passphrase, int32_t ch
return status(); return status();
} }
int ESP8266WiFiClass::begin()
{
ETS_UART_INTR_DISABLE();
wifi_station_connect();
ETS_UART_INTR_ENABLE();
if(!_useStaticIp)
wifi_station_dhcpc_start();
return status();
}
uint8_t ESP8266WiFiClass::waitForConnectResult(){ uint8_t ESP8266WiFiClass::waitForConnectResult(){
if ((wifi_get_opmode() & 1) == 0)//1 and 3 have STA enabled if ((wifi_get_opmode() & 1) == 0)//1 and 3 have STA enabled
return WL_DISCONNECTED; return WL_DISCONNECTED;
@ -366,6 +377,13 @@ char* ESP8266WiFiClass::SSID()
return reinterpret_cast<char*>(conf.ssid); return reinterpret_cast<char*>(conf.ssid);
} }
const char* ESP8266WiFiClass::psk()
{
static struct station_config conf;
wifi_station_get_config(&conf);
return reinterpret_cast<const char*>(conf.password);
}
uint8_t* ESP8266WiFiClass::BSSID(void) uint8_t* ESP8266WiFiClass::BSSID(void)
{ {
static struct station_config conf; static struct station_config conf;

View File

@ -58,6 +58,9 @@ public:
int begin(const char* ssid, const char *passphrase = NULL, int32_t channel = 0, uint8_t bssid[6] = NULL); 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); int begin(char* ssid, char *passphrase = NULL, int32_t channel = 0, uint8_t bssid[6] = NULL);
// Use sdk config to connect.
int begin();
/* Wait for Wifi connection to reach a result /* Wait for Wifi connection to reach a result
* returns the status reached or disconnect if STA is off * returns the status reached or disconnect if STA is off
@ -172,6 +175,13 @@ public:
*/ */
char* SSID(); char* SSID();
/*
* Return the current pre shared key associated with the network
*
* return: psk string
*/
const char* psk();
/* /*
* Return the current bssid / mac associated with the network if configured * Return the current bssid / mac associated with the network if configured
* *