mirror of
https://github.com/meshtastic/firmware.git
synced 2025-04-23 09:06:02 +00:00
first murmurs of ethernet support
This commit is contained in:
parent
564feadc0d
commit
f3fee5f4fb
@ -3,7 +3,7 @@
|
||||
extends = arduino_base
|
||||
platform = platformio/espressif32@^5.2.0
|
||||
build_src_filter =
|
||||
${arduino_base.build_src_filter} -<platform/nrf52/> -<platform/stm32wl> -<platform/rp2040>
|
||||
${arduino_base.build_src_filter} -<platform/nrf52/> -<platform/stm32wl> -<platform/rp2040> -<mesh/eth/>
|
||||
upload_speed = 921600
|
||||
debug_init_break = tbreak setup
|
||||
monitor_filters = esp32_exception_decoder
|
||||
|
@ -2,7 +2,7 @@
|
||||
extends = arduino_base
|
||||
platform = platformio/espressif32@^5.2.0
|
||||
build_src_filter =
|
||||
${arduino_base.build_src_filter} -<platform/nrf52/> -<platform/stm32wl> -<platform/rp2040>
|
||||
${arduino_base.build_src_filter} -<platform/nrf52/> -<platform/stm32wl> -<platform/rp2040> -<mesh/eth/>
|
||||
upload_speed = 961200
|
||||
monitor_speed = 115200
|
||||
debug_init_break = tbreak setup
|
||||
|
@ -47,8 +47,6 @@ size_t RedirectablePrint::vprintf(const char *format, va_list arg)
|
||||
size_t len = vsnprintf(printBuf, sizeof(printBuf), format, copy);
|
||||
va_end(copy);
|
||||
|
||||
if (len < 0) return 0;
|
||||
|
||||
// If the resulting string is longer than sizeof(printBuf)-1 characters, the remaining characters are still counted for the return value
|
||||
|
||||
if (len > sizeof(printBuf) - 1) {
|
||||
|
@ -142,6 +142,9 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#ifndef HAS_WIFI
|
||||
#define HAS_WIFI 0
|
||||
#endif
|
||||
#ifndef HAS_ETHERNET
|
||||
#define ETHERNET 0
|
||||
#endif
|
||||
#ifndef HAS_SCREEN
|
||||
#define HAS_SCREEN 0
|
||||
#endif
|
||||
|
@ -30,6 +30,7 @@
|
||||
// #include <driver/rtc_io.h>
|
||||
|
||||
#include "mesh/http/WiFiAPClient.h"
|
||||
#include "mesh/eth/ethClient.h"
|
||||
|
||||
#ifdef ARCH_ESP32
|
||||
#include "mesh/http/WebServer.h"
|
||||
@ -440,6 +441,9 @@ void setup()
|
||||
// Initialize Wifi
|
||||
initWifi(forceSoftAP);
|
||||
|
||||
// Initialize Ethernet
|
||||
initEthernet();
|
||||
|
||||
#ifdef ARCH_ESP32
|
||||
// Start web server thread.
|
||||
webServerThread = new WebServerThread();
|
||||
|
55
src/mesh/eth/ethClient.cpp
Normal file
55
src/mesh/eth/ethClient.cpp
Normal file
@ -0,0 +1,55 @@
|
||||
#include "mesh/eth/ethClient.h"
|
||||
#include "NodeDB.h"
|
||||
#include <SPI.h>
|
||||
#include <RAK13800_W5100S.h>
|
||||
#include "target_specific.h"
|
||||
|
||||
// Startup Ethernet
|
||||
bool initEthernet()
|
||||
{
|
||||
if (config.network.eth_enabled) {
|
||||
|
||||
Ethernet.init( SS );
|
||||
|
||||
uint8_t mac[6];
|
||||
|
||||
getMacAddr(mac); // FIXME use the BLE MAC for now...
|
||||
|
||||
if (Ethernet.hardwareStatus() == EthernetNoHardware) {
|
||||
DEBUG_MSG("Ethernet shield was not found.\n");
|
||||
} else if (Ethernet.linkStatus() == LinkOFF) {
|
||||
DEBUG_MSG("Ethernet cable is not connected.\n");
|
||||
} else if (config.network.eth_mode == Config_NetworkConfig_EthMode_DHCP) {
|
||||
DEBUG_MSG("starting Ethernet DHCP\n");
|
||||
if (Ethernet.begin(mac) == 0) {
|
||||
DEBUG_MSG("DHCP failed\n");
|
||||
} else{
|
||||
DEBUG_MSG("DHCP assigned IP %s\n",Ethernet.localIP());
|
||||
}
|
||||
} else if (config.network.eth_mode == Config_NetworkConfig_EthMode_STATIC) {
|
||||
DEBUG_MSG("starting Ethernet Static\n");
|
||||
Ethernet.begin(mac, config.network.eth_config.ip, config.network.eth_config.dns, config.network.eth_config.subnet);
|
||||
} else {
|
||||
DEBUG_MSG("Ethernet Disabled\n");
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
|
||||
} else {
|
||||
|
||||
DEBUG_MSG("Not using Ethernet\n");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
bool isEthernetAvailable() {
|
||||
if (!config.network.eth_enabled) {
|
||||
return false;
|
||||
} else if (Ethernet.hardwareStatus() == EthernetNoHardware) {
|
||||
return false;
|
||||
} else if (Ethernet.linkStatus() == LinkOFF) {
|
||||
return false;
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
}
|
8
src/mesh/eth/ethClient.h
Normal file
8
src/mesh/eth/ethClient.h
Normal file
@ -0,0 +1,8 @@
|
||||
#pragma once
|
||||
|
||||
#include "configuration.h"
|
||||
#include <Arduino.h>
|
||||
#include <functional>
|
||||
|
||||
bool initEthernet();
|
||||
bool isEthernetAvailable();
|
27
src/network-stubs.cpp
Normal file
27
src/network-stubs.cpp
Normal file
@ -0,0 +1,27 @@
|
||||
#include "configuration.h"
|
||||
|
||||
#if (HAS_WIFI == 0)
|
||||
|
||||
bool initWifi(bool forceSoftAP) {
|
||||
return false;
|
||||
}
|
||||
|
||||
void deinitWifi() {}
|
||||
|
||||
bool isWifiAvailable() {
|
||||
return false;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
#if (HAS_ETHERNET == 0)
|
||||
|
||||
bool initEthernet() {
|
||||
return false;
|
||||
}
|
||||
|
||||
bool isEthernetAvailable() {
|
||||
return false;
|
||||
}
|
||||
|
||||
#endif
|
@ -1,19 +0,0 @@
|
||||
//#include "mesh/wifi/WebServer.h"
|
||||
#include "configuration.h"
|
||||
|
||||
#ifndef ARCH_ESP32
|
||||
|
||||
//#include "mesh/wifi/WiFiAPClient.h"
|
||||
|
||||
bool initWifi(bool forceSoftAP) {
|
||||
return false;
|
||||
}
|
||||
|
||||
void deinitWifi() {}
|
||||
|
||||
bool isWifiAvailable()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
#endif
|
@ -7,6 +7,7 @@ build_src_filter = ${nrf52_base.build_src_filter} +<../variants/rak4631>
|
||||
lib_deps =
|
||||
${nrf52840_base.lib_deps}
|
||||
melopero/Melopero RV3028@^1.1.0
|
||||
beegee-tokyo/RAK13800-W5100S@^1.0.1
|
||||
debug_tool = jlink
|
||||
; If not set we will default to uploading over serial (first it forces bootloader entry by talking 1200bps to cdcacm)
|
||||
;upload_protocol = jlink
|
@ -226,6 +226,8 @@ static const uint8_t SCK = PIN_SPI_SCK;
|
||||
|
||||
#define HAS_RTC 1
|
||||
|
||||
#define HAS_ETHERNET 1
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
Loading…
Reference in New Issue
Block a user