bluez-tools: Add package bluezetools 17303/head
authorKarl Osterseher <karli_o@gmx.at>
Fri, 10 Dec 2021 14:18:34 +0000 (15:18 +0100)
committerKarl Osterseher <karli_o@gmx.at>
Thu, 14 Apr 2022 13:41:56 +0000 (15:41 +0200)
Signed-off-by: Karl Osterseher <karli_o@gmx.at>
utils/bluez-tools/Makefile [new file with mode: 0644]
utils/bluez-tools/files/btagent.cfg [new file with mode: 0755]
utils/bluez-tools/files/btagent.init [new file with mode: 0644]

diff --git a/utils/bluez-tools/Makefile b/utils/bluez-tools/Makefile
new file mode 100644 (file)
index 0000000..886b831
--- /dev/null
@@ -0,0 +1,55 @@
+#
+# Copyright (C) 2021 Karl Osterseher <karli_o@gmx.at>
+#
+# This is free software, licensed under the GNU General Public License v2.
+#
+
+include $(TOPDIR)/rules.mk
+
+PKG_NAME:=bluez-tools
+PKG_VERSION:=20201025.f653217
+PKG_RELEASE:=$(AUTORELEASE)
+
+PKG_MAINTAINER:=Karl Osterseher <karli_o@gmx.at>
+
+PKG_LICENSE:=GPL-2.0-only
+PKG_LICENSE_FILES:=COPYING
+
+PKG_SOURCE_PROTO:=git
+PKG_SOURCE_URL:=https://github.com/khvzak/bluez-tools.git
+PKG_SOURCE_DATE:=2020-10-25
+PKG_SOURCE_VERSION:=f65321736475429316f07ee94ec0deac8e46ec4a
+PKG_MIRROR_HASH:=a0a7856738fcee12df8894239608d8cc4a7af92574d9bdb5a0b68a8a5455214b
+
+PKG_BUILD_DIR:=$(BUILD_DIR)/bluez-tools-$(PKG_VERSION)
+
+PKG_FIXUP:=autoreconf
+
+include $(INCLUDE_DIR)/package.mk
+
+define Package/bluez-tools
+  SECTION:=Utilities
+  CATEGORY:=Utilities
+  DEPENDS:=+bluez-daemon +glib2
+  TITLE:=Bluetooth tools
+  URL:=https://github.com/khvzak/bluez-tools
+endef
+
+define Package/bluez-tools/description
+  Bluetooth tools for bluez daemon. This will install bt-agent only!
+endef
+
+define Package/bluez-tools/conffiles
+  /etc/config/btagent
+endef
+
+define Package/bluez-tools/install
+       $(INSTALL_DIR) $(1)/etc/init.d
+       $(INSTALL_BIN) ./files/btagent.init $(1)/etc/init.d/btagent
+       $(INSTALL_DIR) $(1)/etc/config
+       $(CP) ./files/btagent.cfg $(1)/etc/config/btagent
+       $(INSTALL_DIR) $(1)/usr/bin
+       $(INSTALL_BIN) $(PKG_BUILD_DIR)/src/bt-agent $(1)/usr/bin/
+endef
+
+$(eval $(call BuildPackage,bluez-tools))
diff --git a/utils/bluez-tools/files/btagent.cfg b/utils/bluez-tools/files/btagent.cfg
new file mode 100755 (executable)
index 0000000..d82c312
--- /dev/null
@@ -0,0 +1,3 @@
+config btagent
+       option mac '*'
+       option pin '0000'
diff --git a/utils/bluez-tools/files/btagent.init b/utils/bluez-tools/files/btagent.init
new file mode 100644 (file)
index 0000000..c6c0f38
--- /dev/null
@@ -0,0 +1,37 @@
+#!/bin/sh /etc/rc.common
+
+USE_PROCD=1
+
+START=90
+
+SERVICE_NAME=bt-agent
+SERVICE_PID_FILE=/var/run/$SERVICE_NAME.pid
+
+DAEMON=/usr/bin/$SERVICE_NAME
+
+AGENT_PIN_FILE=/tmp/btagent.cfg
+AGENT_CAPABILITIES=NoInputNoOutput
+
+handle_bt_agent() {
+       local config="$1"
+       local custom="$2"
+       
+       local macAdr
+       local pinCode   
+       config_get macAdr "$config" mac
+       config_get pinCode "$config" pin
+       echo "$macAdr, $pinCode" >> $AGENT_PIN_FILE
+}
+
+start_service()
+{
+       config_load btagent
+       config_foreach handle_bt_agent btagent
+       
+       procd_open_instance
+       procd_set_param command "$DAEMON"
+       procd_append_param command "-c" "$AGENT_CAPABILITIES"
+       procd_append_param command "-p" "$AGENT_PIN_FILE"
+       procd_set_param pidfile $SERVICE_PID_FILE
+       procd_close_instance
+}