diff --git a/openthread_border_router/CHANGELOG.md b/openthread_border_router/CHANGELOG.md index 0e89831e56c..a86c4ee987b 100644 --- a/openthread_border_router/CHANGELOG.md +++ b/openthread_border_router/CHANGELOG.md @@ -1,5 +1,9 @@ # Changelog +## 2.6.0 + +- Add support for network sockets using socat + ## 2.5.1 - Support Home Assistant Connect ZBT-1. diff --git a/openthread_border_router/Dockerfile b/openthread_border_router/Dockerfile index 69f7d257faf..af5c9ba6d05 100644 --- a/openthread_border_router/Dockerfile +++ b/openthread_border_router/Dockerfile @@ -43,6 +43,7 @@ RUN \ python3-pip \ lsb-release \ netcat-openbsd \ + socat \ sudo \ git \ nodejs \ @@ -104,4 +105,4 @@ RUN \ COPY rootfs / ENV \ - S6_STAGE2_HOOK=/etc/s6-overlay/scripts/otbr-web-enable-check.sh + S6_STAGE2_HOOK=/etc/s6-overlay/scripts/enable-check.sh diff --git a/openthread_border_router/config.yaml b/openthread_border_router/config.yaml index 275a0ab66bf..2a9d33a8cc7 100644 --- a/openthread_border_router/config.yaml +++ b/openthread_border_router/config.yaml @@ -1,5 +1,5 @@ --- -version: 2.5.1 +version: 2.6.0 slug: openthread_border_router name: OpenThread Border Router description: OpenThread Border Router add-on @@ -40,6 +40,7 @@ schema: device: device(subsystem=tty) baudrate: list(57600|115200|230400|460800|921600) flow_control: bool + network_device: str? autoflash_firmware: bool otbr_log_level: list(debug|info|notice|warning|error|critical|alert|emergency) firewall: bool diff --git a/openthread_border_router/rootfs/etc/s6-overlay/s6-rc.d/otbr-agent/run b/openthread_border_router/rootfs/etc/s6-overlay/s6-rc.d/otbr-agent/run index 41dea6a24f4..f2e7bd0c32a 100755 --- a/openthread_border_router/rootfs/etc/s6-overlay/s6-rc.d/otbr-agent/run +++ b/openthread_border_router/rootfs/etc/s6-overlay/s6-rc.d/otbr-agent/run @@ -16,6 +16,11 @@ declare otbr_rest_listen_port backbone_if="$(bashio::api.supervisor 'GET' '/network/info' '' 'first(.interfaces[] | select (.primary == true)) .interface')" device=$(bashio::config 'device') + +if bashio::config.has_value 'network_device'; then + device="/tmp/ttyOTBR" +fi + baudrate=$(bashio::config 'baudrate') flow_control="" diff --git a/openthread_border_router/rootfs/etc/s6-overlay/s6-rc.d/socat-otbr-tcp/data/check b/openthread_border_router/rootfs/etc/s6-overlay/s6-rc.d/socat-otbr-tcp/data/check new file mode 100755 index 00000000000..b41abdafe79 --- /dev/null +++ b/openthread_border_router/rootfs/etc/s6-overlay/s6-rc.d/socat-otbr-tcp/data/check @@ -0,0 +1,4 @@ +#!/bin/sh + +test -c /tmp/ttyOTBR +exit diff --git a/openthread_border_router/rootfs/etc/s6-overlay/s6-rc.d/socat-otbr-tcp/notification-fd b/openthread_border_router/rootfs/etc/s6-overlay/s6-rc.d/socat-otbr-tcp/notification-fd new file mode 100644 index 00000000000..00750edc07d --- /dev/null +++ b/openthread_border_router/rootfs/etc/s6-overlay/s6-rc.d/socat-otbr-tcp/notification-fd @@ -0,0 +1 @@ +3 diff --git a/openthread_border_router/rootfs/etc/s6-overlay/s6-rc.d/socat-otbr-tcp/run b/openthread_border_router/rootfs/etc/s6-overlay/s6-rc.d/socat-otbr-tcp/run new file mode 100755 index 00000000000..9ae7451c100 --- /dev/null +++ b/openthread_border_router/rootfs/etc/s6-overlay/s6-rc.d/socat-otbr-tcp/run @@ -0,0 +1,13 @@ +#!/usr/bin/with-contenv bashio +# ============================================================================== +# Start socat TCP client for OTBR agent daemon +# ============================================================================== + +declare network_device + +network_device=$(bashio::config 'network_device') + +bashio::log.info "Starting socat TCP client for OTBR daemon..." +exec s6-notifyoncheck -d -s 300 -w 300 \ + "/usr/bin/socat" -d pty,raw,echo=0,link=/tmp/ttyOTBR,ignoreeof \ + "tcp:${network_device}" diff --git a/openthread_border_router/rootfs/etc/s6-overlay/s6-rc.d/socat-otbr-tcp/type b/openthread_border_router/rootfs/etc/s6-overlay/s6-rc.d/socat-otbr-tcp/type new file mode 100644 index 00000000000..5883cff0cd1 --- /dev/null +++ b/openthread_border_router/rootfs/etc/s6-overlay/s6-rc.d/socat-otbr-tcp/type @@ -0,0 +1 @@ +longrun diff --git a/openthread_border_router/rootfs/etc/s6-overlay/scripts/otbr-web-enable-check.sh b/openthread_border_router/rootfs/etc/s6-overlay/scripts/enable-check.sh similarity index 55% rename from openthread_border_router/rootfs/etc/s6-overlay/scripts/otbr-web-enable-check.sh rename to openthread_border_router/rootfs/etc/s6-overlay/scripts/enable-check.sh index 8bd256fd9f1..072b3ff21f2 100755 --- a/openthread_border_router/rootfs/etc/s6-overlay/scripts/otbr-web-enable-check.sh +++ b/openthread_border_router/rootfs/etc/s6-overlay/scripts/enable-check.sh @@ -10,3 +10,13 @@ else rm /etc/s6-overlay/s6-rc.d/user/contents.d/otbr-web bashio::log.info "The otbr-web is disabled." fi + +# ============================================================================== +# Enable socat-otbr-tcp service if needed +# ============================================================================== + +if bashio::config.has_value 'network_device'; then + touch /etc/s6-overlay/s6-rc.d/user/contents.d/socat-otbr-tcp + touch /etc/s6-overlay/s6-rc.d/otbr-agent/dependencies.d/socat-otbr-tcp + bashio::log.info "Enabled socat-otbr-tcp." +fi diff --git a/openthread_border_router/translations/en.yaml b/openthread_border_router/translations/en.yaml index 22d67e1e332..46ecb6930d5 100644 --- a/openthread_border_router/translations/en.yaml +++ b/openthread_border_router/translations/en.yaml @@ -10,6 +10,12 @@ configuration: flow_control: name: Hardware flow control description: Enable hardware flow control for serial port. + network_device: + name: Network Device + description: >- + when connecting to a device via sockets (takes precedence + over above configuration). Not suitable for WiFi or other high latency + connections. autoflash_firmware: name: Automatically flash firmware description: >-