Skip to content

Commit

Permalink
Use mdnsresponder for openthread-br by default
Browse files Browse the repository at this point in the history
The new openthread-br-avahi variant of the package continues to use Avahi.

Also tweak a few build options and default the UART baud rate to 460800; USB
RCPs generally support this baud rate and it avoids the UART interface being
the bottleneck for the border router.
  • Loading branch information
ksperling-apple committed Nov 20, 2024
1 parent acdefa4 commit ae02f13
Show file tree
Hide file tree
Showing 2 changed files with 68 additions and 23 deletions.
87 changes: 66 additions & 21 deletions third_party/openthread-br/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
include $(TOPDIR)/rules.mk

PKG_NAME:=openthread-br
PKG_RELEASE:=1
PKG_RELEASE:=2
PKG_SOURCE_URL:=https://github.com/openthread/ot-br-posix.git
PKG_SOURCE_PROTO:=git
PKG_SOURCE_MIRROR:=0 # don't try OpenWrt mirror
Expand All @@ -44,38 +44,75 @@ PKG_LICENSE_FILES:=LICENSE
include $(INCLUDE_DIR)/package.mk
include $(INCLUDE_DIR)/cmake.mk

define Package/openthread-br/Default
SECTION:=net
CATEGORY:=Network
TITLE:=OpenThread Border Router
URL:=https://github.com/openthread/ot-br-posix
DEPENDS:=+libstdcpp +libjson-c +libubus +libblobmsg-json +kmod-usb-acm +kmod-tun
endef

define Package/openthread-br/Default/description
The OpenThread Border Router daemon connects a Thread Network to the
Wi-Fi / Ethernet infrastructure network. Requires a Radio Co-Processor
(RCP) with appropriate firmware connected via UART / USB.
endef


define Package/openthread-br
$(call Package/openthread-br/Default)
VARIANT:=default
DEPENDS+= +libdnssd
endef

define Package/openthread-br/description
$(call Package/openthread-br/Default/description)

This default variant of the package uses mDNSResponder for mDNS / DNS-SD.
endef


define Package/openthread-br-avahi
$(call Package/openthread-br/Default)
VARIANT:=avahi
PROVIDES:=openthread-br
CONFLICTS:=openthread-br
DEPENDS+= +libavahi-client
endef

define Package/openthread-br-avahi/description
$(call Package/openthread-br/Default/description)

This variant of the package uses Avahi for mDNS / DNS-SD.
endef


# Disable firewall integration due to https://github.com/openthread/ot-br-posix/issues/1675
CMAKE_OPTIONS+= \
-DBUILD_TESTING=OFF \
-DCMAKE_BUILD_TYPE=$(if $(CONFIG_DEBUG),Debug,Release) \
-DCMAKE_INSTALL_PREFIX=/usr \
-DBUILD_TESTING=OFF \
-DOTBR_OPENWRT=ON \
-DOTBR_BORDER_AGENT=ON \
-DOTBR_BORDER_ROUTING=ON \
-DOTBR_INFRA_IF_NAME=br-lan \
-DOTBR_MDNS="avahi" \
-DOTBR_OPENWRT=ON \
-DOTBR_SRP_ADVERTISING_PROXY=ON \
-DOTBR_NAT64=OFF \
-DOT_FIREWALL=OFF \
-DOT_POSIX_SETTINGS_PATH=\"/etc/openthread\" \
-DOT_READLINE=OFF \
-DOTBR_NAT64=OFF \
-DNAT64_SERVICE=\"openthread\"
-DOT_READLINE=OFF

# OpenWrt uses /var/run instead of /run
TARGET_CFLAGS += -DOPENTHREAD_POSIX_CONFIG_DAEMON_SOCKET_BASENAME=\\\"/var/run/openthread-%s\\\"

define Package/openthread-br
SECTION:=net
CATEGORY:=Network
TITLE:=OpenThread Border Router
URL:=https://github.com/openthread/ot-br-posix
DEPENDS:=+libstdcpp +libjson-c +libubus +libblobmsg-json +libavahi-client +avahi-daemon +kmod-usb-acm +kmod-tun
endef
TARGET_CFLAGS += \
-DOPENTHREAD_POSIX_CONFIG_DAEMON_SOCKET_BASENAME=\\\"/var/run/openthread-%s\\\" \
-DOPENTHREAD_CONFIG_LOG_PREPEND_UPTIME=0 \
-DOPENTHREAD_CONFIG_LOG_PREPEND_LEVEL=0

define Package/openthread-br/description
OpenThread Border Router
Connects a Thread Network to the Wi-Fi / Ethernet infrastructure network.
Requires a Radio Co-Processor (RCP) with appropriate firmware connected via UART / USB.
endef
ifeq ($(BUILD_VARIANT),avahi)
CMAKE_OPTIONS+= -DOTBR_MDNS="avahi"
else
CMAKE_OPTIONS+= -DOTBR_MDNS="mDNSResponder"
endif

define Package/openthread-br/install
$(INSTALL_DIR) $(1)/usr/sbin
Expand All @@ -98,4 +135,12 @@ define Package/openthread-br/install
$(CP) $(PKG_BUILD_DIR)/src/openwrt/handle_error.js $(1)/www/luci-static/resources
endef

define Package/openthread-br/conffiles
/etc/openthread/
endef

Package/openthread-br-avahi/install=$(Package/openthread-br/install)
Package/openthread-br-avahi/conffiles=$(Package/openthread-br/conffiles)

$(eval $(call BuildPackage,openthread-br))
$(eval $(call BuildPackage,openthread-br-avahi))
4 changes: 2 additions & 2 deletions third_party/openthread-br/patches/010-init-script.patch
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ index 46505ff434..e942234fb9 100755
+ 'thread_if_name:string' \
+ 'infra_if_name:string' \
+ 'uart_device:string' \
+ 'uart_baudrate:uinteger:115200' \
+ 'uart_baudrate:uinteger:460800' \
+ 'uart_flow_control:bool:1'
+}
+
Expand Down Expand Up @@ -117,5 +117,5 @@ index 855d708852..d80d91b5ff 100644
+config otbr-agent 'wpan0'
+ option infra_if_name '@OTBR_INFRA_IF_NAME@'
+ option uart_device '/dev/ttyACM0'
+ option uart_baudrate '115200'
+ option uart_baudrate '460800'
+ option uart_flow_control '1'

0 comments on commit ae02f13

Please sign in to comment.