Skip to content

Commit

Permalink
add function begin without any parameters and add functin psk to …
Browse files Browse the repository at this point in the history
…return current pre shared kex form sdk config
  • Loading branch information
pgollor committed Sep 28, 2015
1 parent 6102e78 commit e179a01
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ localIP KEYWORD2
subnetMask KEYWORD2
gatewayIP KEYWORD2
SSID KEYWORD2
psk KEYWORD2
BSSID KEYWORD2
RSSI KEYWORD2
encryptionType KEYWORD2
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,17 @@ int ESP8266WiFiClass::begin(const char* ssid, const char *passphrase, int32_t ch
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(){
if ((wifi_get_opmode() & 1) == 0)//1 and 3 have STA enabled
return WL_DISCONNECTED;
Expand Down Expand Up @@ -366,6 +377,13 @@ char* ESP8266WiFiClass::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)
{
static struct station_config conf;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,9 @@ class ESP8266WiFiClass
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);

// Use sdk config to connect.
int begin();


/* Wait for Wifi connection to reach a result
* returns the status reached or disconnect if STA is off
Expand Down Expand Up @@ -172,6 +175,13 @@ class ESP8266WiFiClass
*/
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
*
Expand Down

0 comments on commit e179a01

Please sign in to comment.