Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

openthread_border_router: Add support for network RCP radio #3532

Merged
merged 10 commits into from
Apr 26, 2024
4 changes: 4 additions & 0 deletions openthread_border_router/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Changelog

## 2.6.0

- Add support for network sockets using socat

## 2.5.1
- Support Home Assistant Connect ZBT-1.

Expand Down
3 changes: 2 additions & 1 deletion openthread_border_router/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ RUN \
python3-pip \
lsb-release \
netcat-openbsd \
socat \
sudo \
git \
nodejs \
Expand Down Expand Up @@ -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
5 changes: 3 additions & 2 deletions openthread_border_router/config.yaml
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -37,9 +37,10 @@ ports_description:
8080/tcp: OpenThread Web port
8081/tcp: OpenThread REST API port
schema:
device: device(subsystem=tty)
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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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=""

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/sh

test -c /tmp/ttyOTBR
exit
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
3
Original file line number Diff line number Diff line change
@@ -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}"
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
longrun
Original file line number Diff line number Diff line change
Expand Up @@ -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
5 changes: 5 additions & 0 deletions openthread_border_router/translations/en.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,11 @@ configuration:
flow_control:
name: Hardware flow control
description: Enable hardware flow control for serial port.
network_device:
name: Network Device
description: >-
<host:port> when connecting to a device via sockets (takes precedence
over above configuration). Not suitable for Wifi connections.
autoflash_firmware:
name: Automatically flash firmware
description: >-
Expand Down