Skip to content

Commit 2a88f72

Browse files
committed
Merge branch 'idf-4.0-prep' of https://github.com/espressif/arduino-esp32 into idf-release/v4.0
2 parents 5d9a22e + 354e485 commit 2a88f72

File tree

4 files changed

+51
-9
lines changed

4 files changed

+51
-9
lines changed

Diff for: libraries/WiFi/src/ETH.cpp

+2-1
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ extern void tcpipInit();
6969
//}
7070

7171

72+
7273
// Event handler for Ethernet
7374
void ETHClass::eth_event_handler(void *arg, esp_event_base_t event_base, int32_t event_id, void *event_data)
7475
{
@@ -118,6 +119,7 @@ static void _eth_phy_power_enable(bool enable)
118119
ETHClass::ETHClass()
119120
:initialized(false)
120121
,staticIP(false)
122+
,eth_handle(NULL)
121123
,started(false)
122124
,eth_link(ETH_LINK_DOWN)
123125
{
@@ -131,7 +133,6 @@ bool ETHClass::begin(uint8_t phy_addr, int power, int mdc, int mdio, eth_phy_typ
131133

132134
tcpipInit();
133135

134-
esp_event_loop_create_default();
135136
tcpip_adapter_set_default_eth_handlers();
136137
esp_event_handler_register(ETH_EVENT, ESP_EVENT_ANY_ID, eth_event_handler, this);
137138
//ESP_ERROR_CHECK(esp_event_handler_register(IP_EVENT, IP_EVENT_ETH_GOT_IP, &got_ip_event_handler, NULL));

Diff for: libraries/WiFi/src/WiFiGeneric.cpp

+1
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,7 @@ void tcpipInit(){
107107
if(esp_efuse_mac_get_default(mac) == ESP_OK){
108108
esp_base_mac_addr_set(mac);
109109
}
110+
esp_event_loop_create_default();
110111
#endif
111112
tcpip_adapter_init();
112113
}

Diff for: libraries/WiFi/src/WiFiSTA.cpp

+41-8
Original file line numberDiff line numberDiff line change
@@ -693,6 +693,7 @@ bool WiFiSTAClass::beginSmartConfig() {
693693

694694
esp_err_t err;
695695
#ifdef ESP_IDF_VERSION_MAJOR
696+
esp_event_handler_register(SC_EVENT, ESP_EVENT_ANY_ID, _smartConfigCallback, this);
696697
smartconfig_start_config_t conf = SMARTCONFIG_START_CONFIG_DEFAULT();
697698
err = esp_smartconfig_start(&conf);
698699
#else
@@ -727,6 +728,45 @@ bool WiFiSTAClass::smartConfigDone() {
727728
return _smartConfigDone;
728729
}
729730

731+
#if ARDUHAL_LOG_LEVEL >= ARDUHAL_LOG_LEVEL_DEBUG
732+
const char * sc_type_strings[] = {
733+
"ESPTOUCH",
734+
"AIRKISS",
735+
"ESPTOUCH_AIRKISS"
736+
};
737+
#endif
738+
739+
740+
#ifdef ESP_IDF_VERSION_MAJOR //todo
741+
void WiFiSTAClass::_smartConfigCallback(void *arg, esp_event_base_t event_base, int32_t event_id, void *event_data){
742+
smartconfig_event_t event = (smartconfig_event_t)event_id;
743+
switch(event){
744+
case SC_EVENT_SCAN_DONE:
745+
log_d("smartconfig has finished to scan for APs");
746+
break;
747+
case SC_EVENT_FOUND_CHANNEL:
748+
log_d("smartconfig has found the channel of the target AP");
749+
break;
750+
case SC_EVENT_GOT_SSID_PSWD:
751+
{
752+
log_d("smartconfig got the SSID and password");
753+
smartconfig_event_got_ssid_pswd_t * data = (smartconfig_event_got_ssid_pswd_t*)event_data;
754+
log_d("Type: %s", sc_type_strings[data->type]);
755+
log_d("SSID: %s", (const char *)data->ssid);
756+
log_d("Password: %s", (const char *)data->password);
757+
log_d("Sender IP: " IPSTR, data->cellphone_ip[3], data->cellphone_ip[2], data->cellphone_ip[1], data->cellphone_ip[0]);
758+
WiFi.begin((const char *)data->ssid, (const char *)data->password);
759+
}
760+
break;
761+
case SC_EVENT_SEND_ACK_DONE:
762+
log_d("smartconfig has sent ACK to the sender");
763+
WiFi.stopSmartConfig();
764+
break;
765+
default: break;
766+
}
767+
}
768+
#else
769+
730770
#if ARDUHAL_LOG_LEVEL >= ARDUHAL_LOG_LEVEL_DEBUG
731771
const char * sc_status_strings[] = {
732772
"WAIT",
@@ -735,16 +775,9 @@ const char * sc_status_strings[] = {
735775
"LINK",
736776
"LINK_OVER"
737777
};
738-
739-
const char * sc_type_strings[] = {
740-
"ESPTOUCH",
741-
"AIRKISS",
742-
"ESPTOUCH_AIRKISS"
743-
};
744778
#endif
745779

746780
void WiFiSTAClass::_smartConfigCallback(uint32_t st, void* result) {
747-
#ifndef ESP_IDF_VERSION_MAJOR //todo
748781
smartconfig_status_t status = (smartconfig_status_t) st;
749782
log_d("Status: %s", sc_status_strings[st % 5]);
750783
if (status == SC_STATUS_GETTING_SSID_PSWD) {
@@ -768,5 +801,5 @@ void WiFiSTAClass::_smartConfigCallback(uint32_t st, void* result) {
768801
}
769802
WiFi.stopSmartConfig();
770803
}
771-
#endif
772804
}
805+
#endif

Diff for: libraries/WiFi/src/WiFiSTA.h

+7
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,9 @@
2626

2727
#include "WiFiType.h"
2828
#include "WiFiGeneric.h"
29+
#ifdef ESP_IDF_VERSION_MAJOR
30+
#include "esp_event.h"
31+
#endif
2932

3033

3134
class WiFiSTAClass
@@ -98,7 +101,11 @@ class WiFiSTAClass
98101
protected:
99102
static bool _smartConfigStarted;
100103
static bool _smartConfigDone;
104+
#ifdef ESP_IDF_VERSION_MAJOR //todo
105+
static void _smartConfigCallback(void *arg, esp_event_base_t event_base, int32_t event_id, void *event_data);
106+
#else
101107
static void _smartConfigCallback(uint32_t status, void* result);
108+
#endif
102109

103110
};
104111

0 commit comments

Comments
 (0)