Skip to content

Add RAK13800 Ethernet Companion targets with multi-client TCP support#2972

Open
mathisono wants to merge 8 commits into
meshcore-dev:devfrom
mathisono:feat/rak13800-multiclient-ethernet-companion
Open

Add RAK13800 Ethernet Companion targets with multi-client TCP support#2972
mathisono wants to merge 8 commits into
meshcore-dev:devfrom
mathisono:feat/rak13800-multiclient-ethernet-companion

Conversation

@mathisono

Copy link
Copy Markdown

This PR is a follow-up to the Ethernet support merged in #1983.

It adds the RAK13800 Ethernet Companion board-support layer and upgrades the Companion Ethernet transport from single-client behavior to multi-client framed Companion TCP.

Headline changes

Multi-client framed Companion TCP

This PR updates SerialEthernetInterface so multiple Companion TCP clients can remain connected at the same time.

The transport now supports:

  • MAX_ETH_CLIENTS, defaulting to 3
  • per-client connection slots
  • per-client receive parser state
  • round-robin receive polling
  • _last_rx tracking for command response routing
  • broadcast delivery for push frames
  • slot-only disconnect cleanup
  • rejection of only the new client when all slots are full

This avoids the old failure mode where a second connection or incoming packet could close the live Companion socket.

Framed Companion API preserved

This is still MeshCore Companion framing, not CLI/raw-line mode:

client -> radio: '<' + uint16_le(length) + payload
radio -> client: '>' + uint16_le(length) + payload

This PR intentionally does not enable raw line mode for the Companion target.

RAK13800 board-support targets

Adds canonical RAK13800 Ethernet Companion targets:

  • RAK_RAK13800_companion_radio_eth
  • RAK_RAK13800_companion_radio_eth_static_diag

Keeps compatibility aliases for older names:

  • RAK_4631_companion_radio_eth_clean
  • RAK_4631_companion_radio_eth_static_diag
  • RAK_4631_companion_radio_ethernet

Crow / gateway settings

The RAK13800 Companion target uses:

  • ETHERNET_ENABLED=1
  • ETHERNET_TCP_PORT=4403
  • FORCE_CLIENT_REPEAT=0
  • MAX_CONTACTS=128
  • framed Companion packets
  • no raw-line CLI mode

The static diagnostic target adds:

  • IP: 10.245.94.47
  • gateway: 10.245.94.33
  • DNS: 10.245.94.33
  • subnet: 255.255.255.224
  • debug logging enabled

Device model

Ethernet builds report:

RAK 4631 / RAK13800 + W5100S

Normal RAK4631 builds continue to report the normal RAK4631 model string.

What this is not

  • Not the repeater CLI target
  • Not raw-line Ethernet CLI
  • Not MQTT
  • Not Meshtastic

This is the framed MeshCore Companion API over Ethernet TCP, with multi-client support for RAK4631 + RAK13800/W5100S hardware.

Validation

Added Companion TCP smoke-test scripts for:

  • normal framed Companion TCP
  • multi-client Companion TCP behavior

Expected validation:

pio run -e RAK_RAK13800_companion_radio_eth
pio run -e RAK_RAK13800_companion_radio_eth_static_diag

python3 scripts/meshcore_companion_tcp_smoke_test.py 10.245.94.47 4403
python3 scripts/meshcore_companion_multi_client_test.py 10.245.94.47 4403

Expected static diagnostic hardware result:

  • device reachable at 10.245.94.47/27
  • TCP 4403 open
  • APP_START receives a response
  • DEVICE_QUERY receives response code 0x0d
  • two Companion TCP clients can remain connected simultaneously

@mathisono

Copy link
Copy Markdown
Author

Progress summary:

This PR replaces the earlier target-name-only framing from #2929 with a clearer branch and PR scope: RAK13800 Ethernet Companion board support with multi-client framed Companion TCP.

What has been completed:

  • Rebased onto dev after Support for RAK ethernet module #1983 merged.

  • Built on top of the merged RAK Ethernet foundation from Support for RAK ethernet module #1983.

  • Added canonical RAK13800 Ethernet Companion targets:

  • RAK_RAK13800_companion_radio_eth

  • RAK_RAK13800_companion_radio_eth_static_diag

  • Kept compatibility aliases for the older RAK_4631_* companion Ethernet target names.

  • Preserved framed MeshCore Companion TCP packets.

  • Did not enable raw-line CLI mode for the Companion target.

  • Updated the Companion Ethernet transport to support multiple simultaneous clients.

  • Kept new TCP client acceptance on server.accept(), not server.available().

  • Set the RAK13800 Companion TCP target to ETHERNET_TCP_PORT=4403 for Crow/gateway compatibility.

  • Added static diagnostic networking at 10.245.94.47/27.

  • Set FORCE_CLIENT_REPEAT=0 for gateway stability.

  • Updated Ethernet build manufacturer/model reporting to RAK 4631 / RAK13800 + W5100S.

  • Added Companion TCP smoke-test scripts, including a multi-client test.

  • Updated README, flashing, validation, and FAQ docs.

Transport verification completed:

  • server.available in src/helpers/nrf52, examples, and variants: no hits.
  • server.accept is present in SerialEthernetInterface.cpp and separately in EthernetCLI.h.
  • ETHERNET_RAW_LINE is not defined in variants/rak4631/platformio.ini.
  • FORCE_CLIENT_REPEAT is present in both examples/companion_radio/MyMesh.cpp and variants/rak4631/platformio.ini.
  • Both canonical RAK13800 Companion targets include helpers/nrf52/SerialEthernetInterface.cpp.
  • Both canonical RAK13800 Companion targets include the RAKWireless/RAK13800-W5100S dependency.

The standout functional change is multi-client framed Companion TCP: multiple Companion clients can stay connected at the same time, push frames can be broadcast, and command responses route back to the client that sent the command.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants