Apply automatic code formatting
This commit is contained in:
parent
7746d01fc0
commit
a18e298cdd
@ -1,11 +1,11 @@
|
|||||||
// SPDX-License-Identifier: GPL-2.0-or-later
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#include "W5500.h"
|
||||||
#include <DNSServer.h>
|
#include <DNSServer.h>
|
||||||
#include <TaskSchedulerDeclarations.h>
|
#include <TaskSchedulerDeclarations.h>
|
||||||
#include <WiFi.h>
|
#include <WiFi.h>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include "W5500.h"
|
|
||||||
|
|
||||||
enum class network_mode {
|
enum class network_mode {
|
||||||
WiFi,
|
WiFi,
|
||||||
|
|||||||
@ -1,19 +1,19 @@
|
|||||||
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <esp_netif.h>
|
|
||||||
|
|
||||||
#include <Arduino.h>
|
#include <Arduino.h>
|
||||||
|
#include <esp_netif.h>
|
||||||
|
|
||||||
class W5500 {
|
class W5500 {
|
||||||
public:
|
public:
|
||||||
explicit W5500(int8_t pin_mosi, int8_t pin_miso, int8_t pin_sclk, int8_t pin_cs, int8_t pin_int, int8_t pin_rst);
|
explicit W5500(int8_t pin_mosi, int8_t pin_miso, int8_t pin_sclk, int8_t pin_cs, int8_t pin_int, int8_t pin_rst);
|
||||||
W5500(const W5500&) = delete;
|
W5500(const W5500&) = delete;
|
||||||
W5500 &operator=(const W5500&) = delete;
|
W5500& operator=(const W5500&) = delete;
|
||||||
~W5500();
|
~W5500();
|
||||||
|
|
||||||
String macAddress();
|
String macAddress();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
esp_eth_handle_t eth_handle;
|
esp_eth_handle_t eth_handle;
|
||||||
esp_netif_t *eth_netif;
|
esp_netif_t* eth_netif;
|
||||||
};
|
};
|
||||||
|
|||||||
@ -7,10 +7,10 @@
|
|||||||
#include "MessageOutput.h"
|
#include "MessageOutput.h"
|
||||||
#include "PinMapping.h"
|
#include "PinMapping.h"
|
||||||
#include "Utils.h"
|
#include "Utils.h"
|
||||||
|
#include "__compiled_constants.h"
|
||||||
#include "defaults.h"
|
#include "defaults.h"
|
||||||
#include <ESPmDNS.h>
|
#include <ESPmDNS.h>
|
||||||
#include <ETH.h>
|
#include <ETH.h>
|
||||||
#include "__compiled_constants.h"
|
|
||||||
|
|
||||||
NetworkSettingsClass::NetworkSettingsClass()
|
NetworkSettingsClass::NetworkSettingsClass()
|
||||||
: _loopTask(TASK_IMMEDIATE, TASK_FOREVER, std::bind(&NetworkSettingsClass::loop, this))
|
: _loopTask(TASK_IMMEDIATE, TASK_FOREVER, std::bind(&NetworkSettingsClass::loop, this))
|
||||||
@ -404,8 +404,9 @@ String NetworkSettingsClass::macAddress() const
|
|||||||
{
|
{
|
||||||
switch (_networkMode) {
|
switch (_networkMode) {
|
||||||
case network_mode::Ethernet:
|
case network_mode::Ethernet:
|
||||||
if (_w5500)
|
if (_w5500) {
|
||||||
return _w5500->macAddress();
|
return _w5500->macAddress();
|
||||||
|
}
|
||||||
return ETH.macAddress();
|
return ETH.macAddress();
|
||||||
break;
|
break;
|
||||||
case network_mode::WiFi:
|
case network_mode::WiFi:
|
||||||
|
|||||||
@ -1,16 +1,20 @@
|
|||||||
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||||
|
/*
|
||||||
|
* Copyright (C) 2024 Thomas Basler and others
|
||||||
|
*/
|
||||||
|
|
||||||
#include "W5500.h"
|
#include "W5500.h"
|
||||||
|
|
||||||
#include <SpiManager.h>
|
#include <SpiManager.h>
|
||||||
|
|
||||||
#include <driver/spi_master.h>
|
#include <driver/spi_master.h>
|
||||||
|
|
||||||
// Internal Arduino functions from WiFiGeneric
|
// Internal Arduino functions from WiFiGeneric
|
||||||
void tcpipInit();
|
void tcpipInit();
|
||||||
void add_esp_interface_netif(esp_interface_t interface, esp_netif_t *esp_netif);
|
void add_esp_interface_netif(esp_interface_t interface, esp_netif_t* esp_netif);
|
||||||
|
|
||||||
W5500::W5500(int8_t pin_mosi, int8_t pin_miso, int8_t pin_sclk, int8_t pin_cs, int8_t pin_int, int8_t pin_rst) :
|
W5500::W5500(int8_t pin_mosi, int8_t pin_miso, int8_t pin_sclk, int8_t pin_cs, int8_t pin_int, int8_t pin_rst)
|
||||||
eth_handle(nullptr),
|
: eth_handle(nullptr)
|
||||||
eth_netif(nullptr)
|
, eth_netif(nullptr)
|
||||||
{
|
{
|
||||||
gpio_reset_pin(static_cast<gpio_num_t>(pin_rst));
|
gpio_reset_pin(static_cast<gpio_num_t>(pin_rst));
|
||||||
gpio_set_level(static_cast<gpio_num_t>(pin_rst), 0);
|
gpio_set_level(static_cast<gpio_num_t>(pin_rst), 0);
|
||||||
@ -26,8 +30,7 @@ W5500::W5500(int8_t pin_mosi, int8_t pin_miso, int8_t pin_sclk, int8_t pin_cs, i
|
|||||||
auto bus_config = std::make_shared<SpiBusConfig>(
|
auto bus_config = std::make_shared<SpiBusConfig>(
|
||||||
static_cast<gpio_num_t>(pin_mosi),
|
static_cast<gpio_num_t>(pin_mosi),
|
||||||
static_cast<gpio_num_t>(pin_miso),
|
static_cast<gpio_num_t>(pin_miso),
|
||||||
static_cast<gpio_num_t>(pin_sclk)
|
static_cast<gpio_num_t>(pin_sclk));
|
||||||
);
|
|
||||||
|
|
||||||
spi_device_interface_config_t device_config {
|
spi_device_interface_config_t device_config {
|
||||||
.command_bits = 16, // actually address phase
|
.command_bits = 16, // actually address phase
|
||||||
@ -65,11 +68,11 @@ W5500::W5500(int8_t pin_mosi, int8_t pin_miso, int8_t pin_sclk, int8_t pin_cs, i
|
|||||||
|
|
||||||
eth_mac_config_t mac_config = ETH_MAC_DEFAULT_CONFIG();
|
eth_mac_config_t mac_config = ETH_MAC_DEFAULT_CONFIG();
|
||||||
mac_config.rx_task_stack_size = 4096;
|
mac_config.rx_task_stack_size = 4096;
|
||||||
esp_eth_mac_t *mac = esp_eth_mac_new_w5500(&w5500_config, &mac_config);
|
esp_eth_mac_t* mac = esp_eth_mac_new_w5500(&w5500_config, &mac_config);
|
||||||
|
|
||||||
eth_phy_config_t phy_config = ETH_PHY_DEFAULT_CONFIG();
|
eth_phy_config_t phy_config = ETH_PHY_DEFAULT_CONFIG();
|
||||||
phy_config.reset_gpio_num = -1;
|
phy_config.reset_gpio_num = -1;
|
||||||
esp_eth_phy_t *phy = esp_eth_phy_new_w5500(&phy_config);
|
esp_eth_phy_t* phy = esp_eth_phy_new_w5500(&phy_config);
|
||||||
|
|
||||||
esp_eth_config_t eth_config = ETH_DEFAULT_CONFIG(mac, phy);
|
esp_eth_config_t eth_config = ETH_DEFAULT_CONFIG(mac, phy);
|
||||||
ESP_ERROR_CHECK(esp_eth_driver_install(ð_config, ð_handle));
|
ESP_ERROR_CHECK(esp_eth_driver_install(ð_config, ð_handle));
|
||||||
@ -90,18 +93,19 @@ W5500::W5500(int8_t pin_mosi, int8_t pin_miso, int8_t pin_sclk, int8_t pin_cs, i
|
|||||||
ESP_ERROR_CHECK(esp_eth_start(eth_handle));
|
ESP_ERROR_CHECK(esp_eth_start(eth_handle));
|
||||||
}
|
}
|
||||||
|
|
||||||
W5500::~W5500() {
|
W5500::~W5500()
|
||||||
|
{
|
||||||
// TODO(LennartF22): support cleanup at some point?
|
// TODO(LennartF22): support cleanup at some point?
|
||||||
}
|
}
|
||||||
|
|
||||||
String W5500::macAddress() {
|
String W5500::macAddress()
|
||||||
|
{
|
||||||
uint8_t mac_addr[6] = {};
|
uint8_t mac_addr[6] = {};
|
||||||
esp_eth_ioctl(eth_handle, ETH_CMD_G_MAC_ADDR, mac_addr);
|
esp_eth_ioctl(eth_handle, ETH_CMD_G_MAC_ADDR, mac_addr);
|
||||||
|
|
||||||
char mac_addr_str[18];
|
char mac_addr_str[18];
|
||||||
snprintf(
|
snprintf(
|
||||||
mac_addr_str, sizeof(mac_addr_str), "%02X:%02X:%02X:%02X:%02X:%02X",
|
mac_addr_str, sizeof(mac_addr_str), "%02X:%02X:%02X:%02X:%02X:%02X",
|
||||||
mac_addr[0], mac_addr[1], mac_addr[2], mac_addr[3], mac_addr[4], mac_addr[5]
|
mac_addr[0], mac_addr[1], mac_addr[2], mac_addr[3], mac_addr[4], mac_addr[5]);
|
||||||
);
|
|
||||||
return String(mac_addr_str);
|
return String(mac_addr_str);
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user