Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions libraries/Ethernet/src/ETH.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ ETHClass::ETHClass(uint8_t eth_index)
_pin_mcd(-1), _pin_mdio(-1), _pin_power(-1), _pin_rmii_clock(-1)
#endif /* CONFIG_ETH_USE_ESP32_EMAC */
,
_task_stack_size(4096) {
_task_stack_size(4096), _eth_connected_event_handle(0) {
}

ETHClass::~ETHClass() {}
Expand Down Expand Up @@ -359,7 +359,7 @@ bool ETHClass::begin(eth_phy_type_t type, int32_t phy_addr, int mdc, int mdio, i
/* attach to receive events */
initNetif((Network_Interface_ID)(ESP_NETIF_ID_ETH + _eth_index));

Network.onSysEvent(onEthConnected, ARDUINO_EVENT_ETH_CONNECTED);
_eth_connected_event_handle = Network.onSysEvent(onEthConnected, ARDUINO_EVENT_ETH_CONNECTED);

ret = esp_eth_start(_eth_handle);
if (ret != ESP_OK) {
Expand Down Expand Up @@ -849,7 +849,7 @@ bool ETHClass::beginSPI(
perimanSetPinBusExtraType(_pin_rst, "ETH_RST");
}

Network.onSysEvent(onEthConnected, ARDUINO_EVENT_ETH_CONNECTED);
_eth_connected_event_handle = Network.onSysEvent(onEthConnected, ARDUINO_EVENT_ETH_CONNECTED);

return true;

Expand Down Expand Up @@ -885,7 +885,8 @@ static bool empty_ethDetachBus(void *bus_pointer) {

void ETHClass::end(void) {

Network.removeEvent(onEthConnected, ARDUINO_EVENT_ETH_CONNECTED);
Network.removeEvent(_eth_connected_event_handle);
_eth_connected_event_handle = 0;

if (_eth_handle != NULL) {
if (esp_eth_stop(_eth_handle) != ESP_OK) {
Expand Down
1 change: 1 addition & 0 deletions libraries/Ethernet/src/ETH.h
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,7 @@ class ETHClass : public NetworkInterface {
int8_t _pin_rmii_clock;
#endif /* CONFIG_ETH_USE_ESP32_EMAC */
size_t _task_stack_size;
network_event_handle_t _eth_connected_event_handle;

static bool ethDetachBus(void *bus_pointer);
bool beginSPI(
Expand Down
8 changes: 5 additions & 3 deletions libraries/PPP/src/PPP.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,8 @@ esp_modem_dce_t *PPPClass::handle() const {

PPPClass::PPPClass()
: _dce(NULL), _pin_tx(-1), _pin_rx(-1), _pin_rts(-1), _pin_cts(-1), _flow_ctrl(ESP_MODEM_FLOW_CONTROL_NONE), _pin_rst(-1), _pin_rst_act_low(true),
_pin_rst_delay(200), _pin(NULL), _apn(NULL), _rx_buffer_size(4096), _tx_buffer_size(512), _mode(ESP_MODEM_MODE_COMMAND), _uart_num(UART_NUM_1) {}
_pin_rst_delay(200), _pin(NULL), _apn(NULL), _rx_buffer_size(4096), _tx_buffer_size(512), _mode(ESP_MODEM_MODE_COMMAND), _uart_num(UART_NUM_1),
_ppp_event_handle(0) {}

PPPClass::~PPPClass() {}

Expand Down Expand Up @@ -360,7 +361,7 @@ bool PPPClass::begin(ppp_modem_model_t model, uint8_t uart_num, int baud_rate) {
}
}

Network.onSysEvent(onPppArduinoEvent);
_ppp_event_handle = Network.onSysEvent(onPppArduinoEvent);

setStatusBits(ESP_NETIF_STARTED_BIT);
arduino_event_t arduino_event;
Expand Down Expand Up @@ -402,7 +403,8 @@ void PPPClass::end(void) {
}
_esp_modem = NULL;

Network.removeEvent(onPppArduinoEvent);
Network.removeEvent(_ppp_event_handle);
_ppp_event_handle = 0;

if (_dce != NULL) {
esp_modem_destroy(_dce);
Expand Down
1 change: 1 addition & 0 deletions libraries/PPP/src/PPP.h
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ class PPPClass : public NetworkInterface {
int _tx_buffer_size;
esp_modem_dce_mode_t _mode;
uint8_t _uart_num;
network_event_handle_t _ppp_event_handle;

static bool pppDetachBus(void *bus_pointer);
};
Expand Down
7 changes: 4 additions & 3 deletions libraries/WiFi/src/AP.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ void APClass::_onApEvent(int32_t event_id, void *event_data) {
}
}

APClass::APClass() {
APClass::APClass(): _wifi_ap_event_handle(0) {
_ap_network_if = this;
}

Expand All @@ -163,7 +163,7 @@ bool APClass::onEnable() {
return false;
}
if (_esp_netif == NULL) {
Network.onSysEvent(_onApArduinoEvent);
_wifi_ap_event_handle = Network.onSysEvent(_onApArduinoEvent);
_esp_netif = get_esp_interface_netif(ESP_IF_WIFI_AP);
/* attach to receive events */
initNetif(ESP_NETIF_ID_AP);
Expand All @@ -172,7 +172,8 @@ bool APClass::onEnable() {
}

bool APClass::onDisable() {
Network.removeEvent(_onApArduinoEvent);
Network.removeEvent(_wifi_ap_event_handle);
_wifi_ap_event_handle = 0;
// we just set _esp_netif to NULL here, so destroyNetif() does not try to destroy it.
// That would be done by WiFi.enableAP(false) if STA is not enabled, or when it gets disabled
_esp_netif = NULL;
Expand Down
8 changes: 5 additions & 3 deletions libraries/WiFi/src/STA.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,8 @@ void STAClass::_onStaEvent(int32_t event_id, void *event_data) {
}

STAClass::STAClass()
: _minSecurity(WIFI_AUTH_WPA2_PSK), _scanMethod(WIFI_FAST_SCAN), _sortMethod(WIFI_CONNECT_AP_BY_SIGNAL), _autoReconnect(true), _status(WL_STOPPED) {
: _minSecurity(WIFI_AUTH_WPA2_PSK), _scanMethod(WIFI_FAST_SCAN), _sortMethod(WIFI_CONNECT_AP_BY_SIGNAL), _autoReconnect(true), _status(WL_STOPPED),
_wifi_sta_event_handle(0) {
_sta_network_if = this;
}

Expand Down Expand Up @@ -276,14 +277,15 @@ bool STAClass::onEnable() {
return false;
}
/* attach to receive events */
Network.onSysEvent(_onStaArduinoEvent);
_wifi_sta_event_handle = Network.onSysEvent(_onStaArduinoEvent);
initNetif(ESP_NETIF_ID_STA);
}
return true;
}

bool STAClass::onDisable() {
Network.removeEvent(_onStaArduinoEvent);
Network.removeEvent(_wifi_sta_event_handle);
_wifi_sta_event_handle = 0;
// we just set _esp_netif to NULL here, so destroyNetif() does not try to destroy it.
// That would be done by WiFi.enableSTA(false) if AP is not enabled, or when it gets disabled
_esp_netif = NULL;
Expand Down
2 changes: 2 additions & 0 deletions libraries/WiFi/src/WiFiAP.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,8 @@ class APClass : public NetworkInterface {
void _onApEvent(int32_t event_id, void *event_data);

protected:
network_event_handle_t _wifi_ap_event_handle;

size_t printDriverInfo(Print &out) const;

friend class WiFiGenericClass;
Expand Down
1 change: 1 addition & 0 deletions libraries/WiFi/src/WiFiSTA.h
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ class STAClass : public NetworkInterface {
wifi_sort_method_t _sortMethod;
bool _autoReconnect;
wl_status_t _status;
network_event_handle_t _wifi_sta_event_handle;

size_t printDriverInfo(Print &out) const;

Expand Down
Loading