mirror of
https://github.com/meshcore-dev/MeshCore.git
synced 2026-04-20 22:13:47 +00:00
Address PR review feedback from liamcottle (second round)
- Rename eth command to eth.status for consistency with other commands - Rename generateDeviceMac to generateEthernetMac for clarity - Refactor ethernet_handle_command to return false by default - Allow new TCP clients to replace existing connections (repeater, room server, SerialEthernetInterface) - Boot companion radio without Ethernet on init failure (LoRa-only recovery mode) - Remove > prompt from ethernet CLI for consistency with serial interface - Fix variable redeclaration compile error in SerialEthernetInterface when ETHERNET_STATIC_IP is defined - Fix TCP socket leak when duplicate client detection fires - Remove dead recv_queue and adv_restart_time members from SerialEthernetInterface - Fix port numbers in docs (port 23 for repeater/room server CLI, port 5000 for companion radio) - Clarify eth.status command is only available in repeater and room server firmware Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
3e9ceba24a
commit
61ba79966b
8 changed files with 82 additions and 94 deletions
|
|
@ -44,7 +44,7 @@
|
|||
Ethernet.init(ETHERNET_SPI_PORT, PIN_ETHERNET_SS);
|
||||
|
||||
uint8_t mac[6];
|
||||
generateDeviceMac(mac);
|
||||
generateEthernetMac(mac);
|
||||
Serial.printf("ETH: MAC: %02X:%02X:%02X:%02X:%02X:%02X\n",
|
||||
mac[0], mac[1], mac[2], mac[3], mac[4], mac[5]);
|
||||
|
||||
|
|
@ -80,18 +80,20 @@
|
|||
}
|
||||
|
||||
static bool ethernet_handle_command(const char* command, char* reply) {
|
||||
if (strcmp(command, "eth") != 0) return false;
|
||||
if (!ethernet_running) {
|
||||
strcpy(reply, "ETH: not connected");
|
||||
} else {
|
||||
IPAddress ip = Ethernet.localIP();
|
||||
sprintf(reply, "ETH: %u.%u.%u.%u:%d", ip[0], ip[1], ip[2], ip[3], ETHERNET_TCP_PORT);
|
||||
if (strcmp(command, "eth.status") == 0) {
|
||||
if (!ethernet_running) {
|
||||
strcpy(reply, "ETH: not connected");
|
||||
} else {
|
||||
IPAddress ip = Ethernet.localIP();
|
||||
sprintf(reply, "ETH: %u.%u.%u.%u:%d", ip[0], ip[1], ip[2], ip[3], ETHERNET_TCP_PORT);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
// Check for new TCP client connections, replacing any existing connection
|
||||
static void ethernet_check_client() {
|
||||
if (ethernet_client && ethernet_client.connected()) return;
|
||||
auto newClient = ethernet_server.available();
|
||||
if (newClient) {
|
||||
if (ethernet_client) ethernet_client.stop();
|
||||
|
|
@ -99,7 +101,6 @@
|
|||
IPAddress ip = ethernet_client.remoteIP();
|
||||
Serial.printf("ETH: Client connected from %u.%u.%u.%u\n", ip[0], ip[1], ip[2], ip[3]);
|
||||
ethernet_client.println("MeshCore Room Server CLI");
|
||||
ethernet_client.print("> ");
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
|
@ -255,7 +256,6 @@ void loop() {
|
|||
if (reply[0]) {
|
||||
ethernet_client.print(" -> "); ethernet_client.println(reply);
|
||||
}
|
||||
ethernet_client.print("> ");
|
||||
ethernet_command[0] = 0;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue