diff --git a/net/openthread-br/Makefile b/net/openthread-br/Makefile new file mode 100644 index 000000000..7c7422ec2 --- /dev/null +++ b/net/openthread-br/Makefile @@ -0,0 +1,80 @@ +# SPDX-FileCopyrightText: 2022 Stijn Tintel +# SPDX-License-Identifier: GPL-2.0-only + +include $(TOPDIR)/rules.mk + +PKG_NAME:=openthread-br +PKG_SOURCE_DATE:=2022-08-12 +PKG_SOURCE_VERSION:=7a1bb4df86f9ce0fc26a16b8a5adaa16bf8d1e99 +PKG_RELEASE:=1 + +PKG_SOURCE_PROTO:=git +PKG_SOURCE_URL=https://github.com/openthread/ot-br-posix.git +PKG_MIRROR_HASH:=3c517762943b192c50be34cac218133253a16596f711520b552b724822770c6e + +#PKG_BUILD_DIR:=$(BUILD_DIR)/ot-br-posix-thread-br-certified-$(PKG_VERSION) + +PKG_MAINTAINER:=Stijn Tintel +PKG_LICENSE:=BSD-3-Clause +PKG_LICENSE_FILES:=LICENSE + +include $(INCLUDE_DIR)/package.mk +include $(INCLUDE_DIR)/cmake.mk + +define Package/openthread-br + SECTION:=net + CATEGORY:=Network + TITLE:=OpenThread Border Router + DEPENDS:= \ + +libavahi-client \ + +libblobmsg-json \ + +libjson-c \ + +libncurses \ + +libreadline \ + +libstdcpp \ + +libubox \ + +libubus +endef + +define Package/openthread-br/description + A Thread border router for POSIX-based platforms. +endef + +define Package/openthread-br/conffiles +/etc/config/openthread +endef + +CMAKE_OPTIONS += \ + -DOT_BACKBONE_ROUTER:BOOL=ON \ + -DOT_BORDER_ROUTER:BOOL=ON \ + -DOT_BORDER_ROUTING:BOOL=ON \ + -DOT_BORDER_ROUTING_NAT64:BOOL=ON \ + -DOT_CHANNEL_MANAGER:BOOL=ON \ + -DOT_CHANNEL_MONITOR:BOOL=ON \ + -DOT_COMMISSIONER:BOOL=ON \ + -DOT_SERVICE:BOOL=ON \ + -DOT_TREL:BOOL=ON \ + -DOTBR_OPENWRT:BOOL=ON + +define Package/openthread-br/install + $(INSTALL_DIR) \ + $(1)/etc/config $(1)/etc/init.d \ + $(1)/usr/lib/lua/luci/controller/admin \ + $(1)/usr/lib/lua/luci/view/admin_thread $(1)/usr/sbin \ + $(1)/www/luci-static/resources + $(INSTALL_CONF) ./files/openthread.conf $(1)/etc/config/openthread + $(INSTALL_BIN) ./files/otbr-agent.init $(1)/etc/init.d/otbr-agent + $(INSTALL_DATA) \ + $(PKG_BUILD_DIR)/src/openwrt/controller/thread.lua \ + $(1)/usr/lib/lua/luci/controller/admin + $(INSTALL_DATA) \ + $(PKG_BUILD_DIR)/src/openwrt/view/admin_thread/* \ + $(1)/usr/lib/lua/luci/view/admin_thread + $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/sbin/* $(1)/usr/sbin + $(INSTALL_DATA) \ + $(PKG_BUILD_DIR)/src/openwrt/handle_error.js \ + $(1)/www/luci-static/resources +endef + + +$(eval $(call BuildPackage,openthread-br)) diff --git a/net/openthread-br/files/openthread.conf b/net/openthread-br/files/openthread.conf new file mode 100644 index 000000000..6b19ce548 --- /dev/null +++ b/net/openthread-br/files/openthread.conf @@ -0,0 +1,8 @@ +config otbr 'agent' + option enabled '0' + option auto_attach '0' + option iface_lan 'eth0' + option iface_wpan 'wpan0' + list radio_url 'spinel+hdlc+uart:///dev/ttyACM0' + list radio_url 'trel://eth0' + option verbose '0' diff --git a/net/openthread-br/files/otbr-agent.init b/net/openthread-br/files/otbr-agent.init new file mode 100644 index 000000000..caadd8131 --- /dev/null +++ b/net/openthread-br/files/otbr-agent.init @@ -0,0 +1,47 @@ +#!/bin/sh /etc/rc.common + +START=99 +USE_PROCD=1 +PROG=/usr/sbin/otbr-agent + +validate_section_otbr_agent() { + logger -t otbr-agent "validating agent section" + uci_load_validate openthread otbr "$1" "$2" \ + 'auto_attach:bool:0' \ + 'enabled:bool:0' \ + 'iface_lan:string' \ + 'iface_wpan:string' \ + 'radio_url:list(string)' \ + 'verbose:bool:0' +} + +start_otbr_agent() { + [ "$2" -eq 0 ] || { + echo "validation failed" + return 1 + } + + [ "$enabled" -eq 1 ] || return 0 + + + procd_open_instance + + procd_set_param command $PROG + + procd_append_param command --auto-attach="$auto_attach" + [ "$iface_lan" ] && procd_append_param command -B "$iface_lan" + [ "$iface_wpan" ] && procd_append_param command -I "$iface_wpan" + [ "$verbose" -eq 1 ] && procd_append_param command -v + + for url in $radio_url; do + procd_append_param command "$url" + done + + procd_set_param respawn + + procd_close_instance +} + +start_service() { + validate_section_otbr_agent agent start_otbr_agent +} diff --git a/net/openthread-br/patches/999-fixes.patch b/net/openthread-br/patches/999-fixes.patch new file mode 100644 index 000000000..4fd4a6332 --- /dev/null +++ b/net/openthread-br/patches/999-fixes.patch @@ -0,0 +1,105 @@ +--- a/src/openwrt/view/admin_thread/thread_add.htm ++++ b/src/openwrt/view/admin_thread/thread_add.htm +@@ -64,7 +64,6 @@ + + + +-<%+footer%> + + ++<%+footer%> +--- a/src/openwrt/view/admin_thread/thread_join.htm ++++ b/src/openwrt/view/admin_thread/thread_join.htm +@@ -42,7 +42,6 @@ + + + +-<%+footer%> + ++<%+footer%> +--- a/src/openwrt/view/admin_thread/thread_overview.htm ++++ b/src/openwrt/view/admin_thread/thread_overview.htm +@@ -76,7 +76,6 @@ +
<%:Collecting data...%>
+ + +-<%+footer%> + + + ++<%+footer%> +--- a/src/openwrt/view/admin_thread/thread_setting.htm ++++ b/src/openwrt/view/admin_thread/thread_setting.htm +@@ -73,16 +73,16 @@ + + PAN ID: + <%=threadget("panid").PanId%> +-
++
+ Extended PAN ID: + <%=threadget("extpanid").ExtPanId%> +-
++
+ State: + <%=state%> +-
++
+ Channel: + <%=threadget("channel").Channel%> +- ++ +
+ + +@@ -103,7 +103,7 @@ + +
+ +
+ +@@ -269,7 +269,6 @@ + + + +-<%+footer%> + + + ++<%+footer%> +--- a/src/openwrt/view/admin_thread/thread_view.htm ++++ b/src/openwrt/view/admin_thread/thread_view.htm +@@ -114,7 +114,6 @@ + + + +-<%+footer%> + + + +@@ -388,3 +387,4 @@ + else return "Pending"; + } + //]]> ++<%+footer%>