Skip to content

Commit

Permalink
fix(net): Update pin naming and log levels
Browse files Browse the repository at this point in the history
  • Loading branch information
me-no-dev committed May 28, 2024
1 parent cdf0acb commit a856b26
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 11 deletions.
24 changes: 17 additions & 7 deletions libraries/Ethernet/src/ETH.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -535,7 +535,11 @@ bool ETHClass::beginSPI(
if (_spi != NULL) {
pinMode(_pin_cs, OUTPUT);
digitalWrite(_pin_cs, HIGH);
perimanSetPinBusExtraType(_pin_cs, "ETH_CS");
char cs_num_str[3];
itoa(_eth_index, cs_num_str, 10);
strcat(strcpy(_cs_str, "ETH_CS["), cs_num_str);
strcat(_cs_str, "]");
perimanSetPinBusExtraType(_pin_cs, _cs_str);
}
#endif

Expand Down Expand Up @@ -742,40 +746,46 @@ bool ETHClass::beginSPI(
#if ETH_SPI_SUPPORTS_CUSTOM
if (_spi == NULL) {
#endif
if (!perimanSetPinBus(_pin_cs, ESP32_BUS_TYPE_ETHERNET_SPI, (void *)(this), -1, -1)) {
if (!perimanSetPinBus(_pin_cs, ESP32_BUS_TYPE_ETHERNET_SPI, (void *)(this), _eth_index, -1)) {
goto err;
}
perimanSetPinBusExtraType(_pin_cs, "ETH_SPI_CS");
#if ETH_SPI_SUPPORTS_CUSTOM
}
#endif
#if ETH_SPI_SUPPORTS_NO_IRQ
if (_pin_irq != -1) {
#endif
if (!perimanSetPinBus(_pin_irq, ESP32_BUS_TYPE_ETHERNET_SPI, (void *)(this), -1, -1)) {
if (!perimanSetPinBus(_pin_irq, ESP32_BUS_TYPE_ETHERNET_SPI, (void *)(this), _eth_index, -1)) {
goto err;
}
perimanSetPinBusExtraType(_pin_irq, "ETH_IRQ");
#if ETH_SPI_SUPPORTS_NO_IRQ
}
#endif
if (_pin_sck != -1) {
if (!perimanSetPinBus(_pin_sck, ESP32_BUS_TYPE_ETHERNET_SPI, (void *)(this), -1, -1)) {
if (!perimanSetPinBus(_pin_sck, ESP32_BUS_TYPE_ETHERNET_SPI, (void *)(this), _eth_index, -1)) {
goto err;
}
perimanSetPinBusExtraType(_pin_sck, "ETH_SPI_SCK");
}
if (_pin_miso != -1) {
if (!perimanSetPinBus(_pin_miso, ESP32_BUS_TYPE_ETHERNET_SPI, (void *)(this), -1, -1)) {
if (!perimanSetPinBus(_pin_miso, ESP32_BUS_TYPE_ETHERNET_SPI, (void *)(this), _eth_index, -1)) {
goto err;
}
perimanSetPinBusExtraType(_pin_miso, "ETH_SPI_MISO");
}
if (_pin_mosi != -1) {
if (!perimanSetPinBus(_pin_mosi, ESP32_BUS_TYPE_ETHERNET_SPI, (void *)(this), -1, -1)) {
if (!perimanSetPinBus(_pin_mosi, ESP32_BUS_TYPE_ETHERNET_SPI, (void *)(this), _eth_index, -1)) {
goto err;
}
perimanSetPinBusExtraType(_pin_mosi, "ETH_SPI_MOSI");
}
if (_pin_rst != -1) {
if (!perimanSetPinBus(_pin_rst, ESP32_BUS_TYPE_ETHERNET_SPI, (void *)(this), -1, -1)) {
if (!perimanSetPinBus(_pin_rst, ESP32_BUS_TYPE_ETHERNET_SPI, (void *)(this), _eth_index, -1)) {
goto err;
}
perimanSetPinBusExtraType(_pin_rst, "ETH_RST");
}

Network.onSysEvent(onEthConnected, ARDUINO_EVENT_ETH_CONNECTED);
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 @@ -188,6 +188,7 @@ class ETHClass : public NetworkInterface {
esp_eth_phy_t *_phy;
#if ETH_SPI_SUPPORTS_CUSTOM
SPIClass *_spi;
char _cs_str[10];
#endif
uint8_t _spi_freq_mhz;
int8_t _pin_cs;
Expand Down
1 change: 1 addition & 0 deletions libraries/PPP/src/PPP.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -283,6 +283,7 @@ bool PPPClass::begin(ppp_modem_model_t model, uint8_t uart_num, int baud_rate) {
} else {
pinMode(_pin_rst, OUTPUT);
}
perimanSetPinBusExtraType(_pin_rst, "PPP_MODEM_RST");
digitalWrite(_pin_rst, !_pin_rst_act_low);
delay(200);
digitalWrite(_pin_rst, _pin_rst_act_low);
Expand Down
2 changes: 1 addition & 1 deletion libraries/WiFi/src/AP.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ static void _onApArduinoEvent(arduino_event_t *ev) {
if (_ap_network_if == NULL || ev->event_id < ARDUINO_EVENT_WIFI_AP_START || ev->event_id > ARDUINO_EVENT_WIFI_AP_GOT_IP6) {
return;
}
log_d("Arduino AP Event: %d - %s", ev->event_id, Network.eventName(ev->event_id));
log_v("Arduino AP Event: %d - %s", ev->event_id, Network.eventName(ev->event_id));
if (ev->event_id == ARDUINO_EVENT_WIFI_AP_START) {
if (_ap_network_if->getStatusBits() & ESP_NETIF_WANT_IP6_BIT) {
esp_err_t err = esp_netif_create_ip6_linklocal(_ap_network_if->netif());
Expand Down
6 changes: 3 additions & 3 deletions libraries/WiFi/src/STA.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ static void _onStaArduinoEvent(arduino_event_t *ev) {
return;
}
static bool first_connect = true;
log_d("Arduino STA Event: %d - %s", ev->event_id, Network.eventName(ev->event_id));
log_v("Arduino STA Event: %d - %s", ev->event_id, Network.eventName(ev->event_id));

if (ev->event_id == ARDUINO_EVENT_WIFI_STA_START) {
_sta_network_if->_setStatus(WL_DISCONNECTED);
Expand Down Expand Up @@ -162,11 +162,11 @@ static void _onStaArduinoEvent(arduino_event_t *ev) {
_sta_network_if->connect();
}
} else if (ev->event_id == ARDUINO_EVENT_WIFI_STA_GOT_IP) {
#if ARDUHAL_LOG_LEVEL >= ARDUHAL_LOG_LEVEL_DEBUG
#if ARDUHAL_LOG_LEVEL >= ARDUHAL_LOG_LEVEL_VERBOSE
uint8_t *ip = (uint8_t *)&(ev->event_info.got_ip.ip_info.ip.addr);
uint8_t *mask = (uint8_t *)&(ev->event_info.got_ip.ip_info.netmask.addr);
uint8_t *gw = (uint8_t *)&(ev->event_info.got_ip.ip_info.gw.addr);
log_d(
log_v(
"STA IP: %u.%u.%u.%u, MASK: %u.%u.%u.%u, GW: %u.%u.%u.%u", ip[0], ip[1], ip[2], ip[3], mask[0], mask[1], mask[2], mask[3], gw[0], gw[1], gw[2], gw[3]
);
#endif
Expand Down

0 comments on commit a856b26

Please sign in to comment.