Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
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
4 changes: 2 additions & 2 deletions examples/companion_radio/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ static uint32_t _atoi(const char* sp) {
ArduinoSerialInterface serial_interface;
#endif
#elif defined(NRF52_PLATFORM)
#ifdef BLE_PIN_CODE
#if defined(BLE_PIN_CODE)
#include <helpers/nrf52/SerialBLEInterface.h>
SerialBLEInterface serial_interface;
#elif defined(ETHERNET_ENABLED)
Expand Down Expand Up @@ -162,7 +162,7 @@ void setup() {
#endif
);

#ifdef BLE_PIN_CODE
#if defined(BLE_PIN_CODE)
serial_interface.begin(BLE_NAME_PREFIX, the_mesh.getNodePrefs()->node_name, the_mesh.getBLEPin());
the_mesh.startInterface(serial_interface);
#elif defined(ETHERNET_ENABLED)
Expand Down
14 changes: 14 additions & 0 deletions examples/simple_repeater/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,14 @@ static unsigned long userBtnDownAt = 0;

void setup() {
Serial.begin(115200);
#ifdef WITH_W5100S_POE
// PoE cold-start: get to board.begin() (which activates the W5100S load)
// ASAP, before the RAK19018/Silvertel converter folds back. Skip the 1 s
// serial-settle delay β€” there is no operator on the serial port on PoE.
delay(20);
#else
delay(1000);
#endif

board.begin();

Expand Down Expand Up @@ -195,6 +202,12 @@ void loop() {
#ifdef HAS_EXTERNAL_WATCHDOG
external_watchdog.loop();
#endif

#ifdef WITH_W5100S_POE
// PoE-powered (RAK19018/Silvertel): the device must NEVER sleep. CPU sleep
// drops the current draw below the converter's ~125 mA hold threshold,
// making it fold back and reset. Skip the powersaving/sleep path entirely.
#else
if (the_mesh.getNodePrefs()->powersaving_enabled && !the_mesh.hasPendingWork()) {
#if defined(NRF52_PLATFORM)
board.sleep(0); // nrf ignores seconds param, sleeps whenever possible
Expand All @@ -204,4 +217,5 @@ void loop() {
}
#endif
}
#endif // WITH_W5100S_POE
}
43 changes: 42 additions & 1 deletion src/helpers/nrf52/EthernetCLI.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,26 @@ static SPIClass ETHERNET_SPI_PORT(NRF_SPIM1, PIN_SPI1_MISO, PIN_SPI1_SCK, PIN_SP

#define ETHERNET_RETRY_INTERVAL_MS 30000

#ifdef WITH_W5100S_POE
// Give the RAK19018 (Silvertel) PoE converter time to latch on the current
// the W5100S is already drawing (board.begin()'s early RST release +
// bit-bang soft-reset) before doing the *disruptive* Ethernet-library
// bring-up (another PHY soft-reset + blocking DHCP) β€” doing that
// immediately reliably collapsed the marginal PoE supply.
#ifndef ETH_POE_DEFER_MS
#define ETH_POE_DEFER_MS 6000
#endif
#ifndef ETH_STATIC_IP
#define ETH_STATIC_IP 192,168,1,50
#endif
#ifndef ETH_GATEWAY
#define ETH_GATEWAY 192,168,1,1
#endif
#ifndef ETH_SUBNET
#define ETH_SUBNET 255,255,255,0
#endif
#endif

static EthernetServer ethernet_server(ETHERNET_TCP_PORT);
static EthernetClient ethernet_client;
static volatile bool ethernet_running = false;
Expand All @@ -35,6 +55,10 @@ static volatile bool ethernet_running = false;
static void ethernet_task(void* param) {
(void)param;

#ifdef WITH_W5100S_POE
vTaskDelay(pdMS_TO_TICKS(ETH_POE_DEFER_MS));
#endif

Serial.println("ETH: Initializing hardware");
// WB_IO2 (power enable) is already driven HIGH by early constructor
// in RAK4631Board.cpp to support POE boot.
Expand All @@ -51,6 +75,22 @@ static void ethernet_task(void* param) {
Serial.printf("ETH: MAC: %02X:%02X:%02X:%02X:%02X:%02X\n",
mac[0], mac[1], mac[2], mac[3], mac[4], mac[5]);

#ifdef WITH_W5100S_POE
// Bounded DHCP with a static-IP fallback, so the node stays reachable even
// without a DHCP server (no infinite retry β€” this build has no battery and
// must always come up somewhere).
Serial.println("ETH: Attempting DHCP...");
if (Ethernet.begin(mac, 10000, 2000) == 0) {
Serial.println("ETH: DHCP failed -> static IP fallback");
IPAddress ip(ETH_STATIC_IP), gw(ETH_GATEWAY), sn(ETH_SUBNET);
Ethernet.begin(mac, ip, gw, gw, sn);
}
IPAddress ip = Ethernet.localIP();
Serial.printf("ETH: IP: %u.%u.%u.%u\n", ip[0], ip[1], ip[2], ip[3]);
Serial.printf("ETH: Listening on TCP port %d\n", ETHERNET_TCP_PORT);
ethernet_server.begin();
ethernet_running = true;
#else
// Retry loop: keep trying until we get an IP
while (!ethernet_running) {
Serial.println("ETH: Attempting DHCP...");
Expand All @@ -75,8 +115,9 @@ static void ethernet_task(void* param) {
ethernet_server.begin();
ethernet_running = true;
}
#endif

// DHCP succeeded, task is done
// DHCP succeeded (or static fallback applied), task is done
vTaskDelete(NULL);
}

Expand Down
Loading