fix(net): Use network_event_handle_t for internal callbacks (#11179)
* fix(net): Use network_event_handle_t for internal callbacks * ci(pre-commit): Apply automatic fixes --------- Co-authored-by: pre-commit-ci-lite[bot] <117423508+pre-commit-ci-lite[bot]@users.noreply.github.com>
This commit is contained in:
parent
cd7f4218e7
commit
9dddc142fc
8 changed files with 24 additions and 13 deletions
|
|
@ -136,7 +136,7 @@ ETHClass::ETHClass(uint8_t eth_index)
|
||||||
_pin_mcd(-1), _pin_mdio(-1), _pin_power(-1), _pin_rmii_clock(-1)
|
_pin_mcd(-1), _pin_mdio(-1), _pin_power(-1), _pin_rmii_clock(-1)
|
||||||
#endif /* CONFIG_ETH_USE_ESP32_EMAC */
|
#endif /* CONFIG_ETH_USE_ESP32_EMAC */
|
||||||
,
|
,
|
||||||
_task_stack_size(4096) {
|
_task_stack_size(4096), _eth_connected_event_handle(0) {
|
||||||
}
|
}
|
||||||
|
|
||||||
ETHClass::~ETHClass() {}
|
ETHClass::~ETHClass() {}
|
||||||
|
|
@ -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 */
|
/* attach to receive events */
|
||||||
initNetif((Network_Interface_ID)(ESP_NETIF_ID_ETH + _eth_index));
|
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);
|
ret = esp_eth_start(_eth_handle);
|
||||||
if (ret != ESP_OK) {
|
if (ret != ESP_OK) {
|
||||||
|
|
@ -849,7 +849,7 @@ bool ETHClass::beginSPI(
|
||||||
perimanSetPinBusExtraType(_pin_rst, "ETH_RST");
|
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;
|
return true;
|
||||||
|
|
||||||
|
|
@ -885,7 +885,8 @@ static bool empty_ethDetachBus(void *bus_pointer) {
|
||||||
|
|
||||||
void ETHClass::end(void) {
|
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 (_eth_handle != NULL) {
|
||||||
if (esp_eth_stop(_eth_handle) != ESP_OK) {
|
if (esp_eth_stop(_eth_handle) != ESP_OK) {
|
||||||
|
|
|
||||||
|
|
@ -247,6 +247,7 @@ private:
|
||||||
int8_t _pin_rmii_clock;
|
int8_t _pin_rmii_clock;
|
||||||
#endif /* CONFIG_ETH_USE_ESP32_EMAC */
|
#endif /* CONFIG_ETH_USE_ESP32_EMAC */
|
||||||
size_t _task_stack_size;
|
size_t _task_stack_size;
|
||||||
|
network_event_handle_t _eth_connected_event_handle;
|
||||||
|
|
||||||
static bool ethDetachBus(void *bus_pointer);
|
static bool ethDetachBus(void *bus_pointer);
|
||||||
bool beginSPI(
|
bool beginSPI(
|
||||||
|
|
|
||||||
|
|
@ -152,7 +152,8 @@ esp_modem_dce_t *PPPClass::handle() const {
|
||||||
|
|
||||||
PPPClass::PPPClass()
|
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),
|
: _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() {}
|
PPPClass::~PPPClass() {}
|
||||||
|
|
||||||
|
|
@ -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);
|
setStatusBits(ESP_NETIF_STARTED_BIT);
|
||||||
arduino_event_t arduino_event;
|
arduino_event_t arduino_event;
|
||||||
|
|
@ -402,7 +403,8 @@ void PPPClass::end(void) {
|
||||||
}
|
}
|
||||||
_esp_modem = NULL;
|
_esp_modem = NULL;
|
||||||
|
|
||||||
Network.removeEvent(onPppArduinoEvent);
|
Network.removeEvent(_ppp_event_handle);
|
||||||
|
_ppp_event_handle = 0;
|
||||||
|
|
||||||
if (_dce != NULL) {
|
if (_dce != NULL) {
|
||||||
esp_modem_destroy(_dce);
|
esp_modem_destroy(_dce);
|
||||||
|
|
|
||||||
|
|
@ -108,6 +108,7 @@ private:
|
||||||
int _tx_buffer_size;
|
int _tx_buffer_size;
|
||||||
esp_modem_dce_mode_t _mode;
|
esp_modem_dce_mode_t _mode;
|
||||||
uint8_t _uart_num;
|
uint8_t _uart_num;
|
||||||
|
network_event_handle_t _ppp_event_handle;
|
||||||
|
|
||||||
static bool pppDetachBus(void *bus_pointer);
|
static bool pppDetachBus(void *bus_pointer);
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -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;
|
_ap_network_if = this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -163,7 +163,7 @@ bool APClass::onEnable() {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (_esp_netif == NULL) {
|
if (_esp_netif == NULL) {
|
||||||
Network.onSysEvent(_onApArduinoEvent);
|
_wifi_ap_event_handle = Network.onSysEvent(_onApArduinoEvent);
|
||||||
_esp_netif = get_esp_interface_netif(ESP_IF_WIFI_AP);
|
_esp_netif = get_esp_interface_netif(ESP_IF_WIFI_AP);
|
||||||
/* attach to receive events */
|
/* attach to receive events */
|
||||||
initNetif(ESP_NETIF_ID_AP);
|
initNetif(ESP_NETIF_ID_AP);
|
||||||
|
|
@ -172,7 +172,8 @@ bool APClass::onEnable() {
|
||||||
}
|
}
|
||||||
|
|
||||||
bool APClass::onDisable() {
|
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.
|
// 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
|
// That would be done by WiFi.enableAP(false) if STA is not enabled, or when it gets disabled
|
||||||
_esp_netif = NULL;
|
_esp_netif = NULL;
|
||||||
|
|
|
||||||
|
|
@ -228,7 +228,8 @@ void STAClass::_onStaEvent(int32_t event_id, void *event_data) {
|
||||||
}
|
}
|
||||||
|
|
||||||
STAClass::STAClass()
|
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;
|
_sta_network_if = this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -276,14 +277,15 @@ bool STAClass::onEnable() {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
/* attach to receive events */
|
/* attach to receive events */
|
||||||
Network.onSysEvent(_onStaArduinoEvent);
|
_wifi_sta_event_handle = Network.onSysEvent(_onStaArduinoEvent);
|
||||||
initNetif(ESP_NETIF_ID_STA);
|
initNetif(ESP_NETIF_ID_STA);
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool STAClass::onDisable() {
|
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.
|
// 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
|
// That would be done by WiFi.enableSTA(false) if AP is not enabled, or when it gets disabled
|
||||||
_esp_netif = NULL;
|
_esp_netif = NULL;
|
||||||
|
|
|
||||||
|
|
@ -60,6 +60,8 @@ public:
|
||||||
void _onApEvent(int32_t event_id, void *event_data);
|
void _onApEvent(int32_t event_id, void *event_data);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
network_event_handle_t _wifi_ap_event_handle;
|
||||||
|
|
||||||
size_t printDriverInfo(Print &out) const;
|
size_t printDriverInfo(Print &out) const;
|
||||||
|
|
||||||
friend class WiFiGenericClass;
|
friend class WiFiGenericClass;
|
||||||
|
|
|
||||||
|
|
@ -95,6 +95,7 @@ protected:
|
||||||
wifi_sort_method_t _sortMethod;
|
wifi_sort_method_t _sortMethod;
|
||||||
bool _autoReconnect;
|
bool _autoReconnect;
|
||||||
wl_status_t _status;
|
wl_status_t _status;
|
||||||
|
network_event_handle_t _wifi_sta_event_handle;
|
||||||
|
|
||||||
size_t printDriverInfo(Print &out) const;
|
size_t printDriverInfo(Print &out) const;
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue