summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--bigclown-control-tools/Makefile15
-rwxr-xr-xbigclown-control-tools/files/bch9
-rw-r--r--bigclown-gateway/Makefile20
-rwxr-xr-xbigclown-gateway/files/bcg9
-rw-r--r--bigclown-gateway/files/config (renamed from bigclown-gateway/files/bc-gateway-usb-dongle.config)0
-rwxr-xr-xbigclown-gateway/files/init57
-rw-r--r--bigclown-gateway/files/udev1
-rw-r--r--bigclown-mqtt2influxdb/Makefile28
-rw-r--r--[-rwxr-xr-x]bigclown-mqtt2influxdb/files/init (renamed from bigclown-gateway/files/bc-gateway-usb-dongle.init)12
-rwxr-xr-xbigclown-mqtt2influxdb/files/mqtt2influxdb9
10 files changed, 134 insertions, 26 deletions
diff --git a/bigclown-control-tools/Makefile b/bigclown-control-tools/Makefile
index c11aea7..723e29a 100644
--- a/bigclown-control-tools/Makefile
+++ b/bigclown-control-tools/Makefile
@@ -1,14 +1,7 @@
-#
-## Copyright (C) 2016-2017 CZ.NIC z.s.p.o. (http://www.nic.cz/)
-#
-## This is free software, licensed under the GNU General Public License v2.
-# See /LICENSE for more information.
-# #
-#
include $(TOPDIR)/rules.mk
PKG_NAME:=bigclown-control-tools
-PKG_RELEASE:=1
+PKG_RELEASE:=2
PKG_SOURCE_URL:=https://github.com/bigclownlabs/bch-control-tool.git
PKG_MAINTAINER:=Karel Kočí <cynerd@email.cz>
@@ -21,7 +14,13 @@ define Package/$(PKG_NAME)
DEPENDS:=+python3
endef
+define Py3Package/$(PKG_NAME)/install
+ $(INSTALL_DIR) $(1)/usr/bin
+ $(INSTALL_BIN) ./files/bch $(1)/usr/bin/bch
+endef
+
define Build/Compile
+ sed -i 's/@@VERSION@@/$(PKG_VERSION)/' "$(PKG_BUILD_DIR)/setup.py"
$(call Build/Compile/Py3Mod,,install --prefix="/usr" --root=$(PKG_INSTALL_DIR))
endef
diff --git a/bigclown-control-tools/files/bch b/bigclown-control-tools/files/bch
new file mode 100755
index 0000000..a473b30
--- /dev/null
+++ b/bigclown-control-tools/files/bch
@@ -0,0 +1,9 @@
+#!/usr/bin/python3.6
+import bch
+import sys
+from pkg_resources import load_entry_point
+
+if __name__ == '__main__':
+ sys.exit(
+ load_entry_point('bch', 'console_scripts', 'bch')()
+ )
diff --git a/bigclown-gateway/Makefile b/bigclown-gateway/Makefile
index 60f659a..1fb8937 100644
--- a/bigclown-gateway/Makefile
+++ b/bigclown-gateway/Makefile
@@ -1,14 +1,7 @@
-#
-## Copyright (C) 2016-2017 CZ.NIC z.s.p.o. (http://www.nic.cz/)
-#
-## This is free software, licensed under the GNU General Public License v2.
-# See /LICENSE for more information.
-# #
-#
include $(TOPDIR)/rules.mk
PKG_NAME:=bigclown-gateway
-PKG_RELEASE:=1
+PKG_RELEASE:=2
PKG_SOURCE_URL:=https://github.com/bigclownlabs/bch-gateway.git
PKG_MAINTAINER:=Karel Kočí <cynerd@email.cz>
@@ -22,17 +15,22 @@ define Package/$(PKG_NAME)
endef
define Py3Package/$(PKG_NAME)/install
+ $(INSTALL_DIR) $(1)/usr/bin
+ $(INSTALL_BIN) ./files/bcg $(1)/usr/bin/bcg
$(INSTALL_DIR) $(1)/etc/config
- $(INSTALL_CONF) ./files/bc-gateway-usb-dongle.config $(1)/etc/config/bc-gateway-usb-dongle
+ $(INSTALL_CONF) ./files/config $(1)/etc/config/bigclown-gateway
$(INSTALL_DIR) $(1)/etc/init.d
- $(INSTALL_BIN) ./files/bc-gateway-usb-dongle.init $(1)/etc/init.d/bc-gateway-usb-dongle.init
+ $(INSTALL_BIN) ./files/init $(1)/etc/init.d/bigclown-gateway
+ $(INSTALL_DIR) $(1)/etc/udev/rules.d
+ $(INSTALL_DATA) ./files/udev $(1)/etc/udev/rules.d/58-bigclown-usb-dongle.rules
endef
define Package/$(PKG_NAME)/conffiles
-/etc/config/bc-gateway-usb-dongle
+/etc/config/bigclown-gateway
endef
define Build/Compile
+ sed -i 's/@@VERSION@@/$(PKG_VERSION)/' "$(PKG_BUILD_DIR)/setup.py"
$(call Build/Compile/Py3Mod,,install --prefix="/usr" --root=$(PKG_INSTALL_DIR))
endef
diff --git a/bigclown-gateway/files/bcg b/bigclown-gateway/files/bcg
new file mode 100755
index 0000000..fe261f4
--- /dev/null
+++ b/bigclown-gateway/files/bcg
@@ -0,0 +1,9 @@
+#!/usr/bin/python3.6
+import bcg
+import sys
+from pkg_resources import load_entry_point
+
+if __name__ == '__main__':
+ sys.exit(
+ load_entry_point('bcg', 'console_scripts', 'bcg')()
+ )
diff --git a/bigclown-gateway/files/bc-gateway-usb-dongle.config b/bigclown-gateway/files/config
index 7fa3977..7fa3977 100644
--- a/bigclown-gateway/files/bc-gateway-usb-dongle.config
+++ b/bigclown-gateway/files/config
diff --git a/bigclown-gateway/files/init b/bigclown-gateway/files/init
new file mode 100755
index 0000000..090cc06
--- /dev/null
+++ b/bigclown-gateway/files/init
@@ -0,0 +1,57 @@
+#!/bin/sh /etc/rc.common
+
+START=98
+STOP=1
+
+USE_PROCD=1
+
+PROG=/usr/bin/bcg
+CONF=/tmp/etc/bigclown-gateway.conf
+
+append() {
+ local cfg="$1"
+ local uci_name="$2"
+ local out_name="$3"
+ local default="$4"
+ config_get val $cfg $uci_name $default
+ if [ -n "$val" ]; then
+ echo "$out_name $val" >> $CONF
+ fi
+}
+
+start_service() {
+ config_load bigclown-gateway
+
+ rm -rf $CONF
+ echo "Generating bigclown-gateway config file in $CONF"
+
+ append gateway name 'name:' usb-dongle
+ # TODO add udev rules and use different default here
+ append gateway device 'device:' /dev/ttyUSB0
+ append gateway automatic_rename_kit_nodes 'automatic_rename_kit_nodes:' 1
+ append gateway base_topic_prefix 'base_topic_prefix:'
+
+ echo "mqtt:" >> $CONF
+ append mqtt host ' host:' localhost
+ append mqtt port ' port:' 1883
+ append mqtt cafile ' cafile:'
+ append mqtt certfile ' certfile:'
+ append mqtt keyfile ' keyfile:'
+
+ procd_open_instance
+ procd_set_param respawn
+ procd_set_param command "$PROG" -c "$CONF" -W
+ procd_set_param stdout 1
+ procd_set_param stderr 1
+ procd_close_instance
+}
+
+stop_service() {
+ service_stop "$PROG"
+ ps | grep "$PROG" | grep -v grep | sed -e 's/^\s*\([0-9]\+\)\s.*$/\1/' | xargs -r -- kill -9
+}
+
+service_triggers()
+{
+ procd_add_reload_trigger 'bc-gateway-usb-dongle'
+}
diff --git a/bigclown-gateway/files/udev b/bigclown-gateway/files/udev
new file mode 100644
index 0000000..d7a854b
--- /dev/null
+++ b/bigclown-gateway/files/udev
@@ -0,0 +1 @@
+SUBSYSTEMS=="usb", ACTION=="add", KERNEL=="ttyUSB*", ATTRS{idVendor}=="0403", ATTRS{idProduct}=="6015", ATTRS{serial}=="bc-usb-dongle*", SYMLINK+="bcUD%n", TAG+="systemd", ENV{SYSTEMD_ALIAS}="/dev/bcUD%n"
diff --git a/bigclown-mqtt2influxdb/Makefile b/bigclown-mqtt2influxdb/Makefile
new file mode 100644
index 0000000..760751f
--- /dev/null
+++ b/bigclown-mqtt2influxdb/Makefile
@@ -0,0 +1,28 @@
+include $(TOPDIR)/rules.mk
+
+PKG_NAME:=bigclown-mqtt2influxdb
+PKG_RELEASE:=1
+PKG_SOURCE_URL:=https://github.com/bigclownlabs/bch-mqtt2influxdb.git
+PKG_MAINTAINER:=Karel Kočí <cynerd@email.cz>
+
+include $(TOPDIR)/package/autopkg-tag.mk
+include $(INCLUDE_DIR)/package.mk
+$(call include_mk, python3-package.mk)
+
+define Package/$(PKG_NAME)
+ TITLE:=BigCLown MQTT to Influxdb bridge
+ DEPENDS:=+python3 +python3-paho-mqtt
+endef
+
+define Py3Package/$(PKG_NAME)/install
+ $(INSTALL_DIR) $(1)/usr/bin
+ $(INSTALL_BIN) ./files/mqtt2influxdb $(1)/usr/bin/mqtt2influxdb
+endef
+
+define Build/Compile
+ sed -i 's/@@VERSION@@/$(PKG_VERSION)/' "$(PKG_BUILD_DIR)/setup.py"
+ $(call Build/Compile/Py3Mod,,install --prefix="/usr" --root=$(PKG_INSTALL_DIR))
+endef
+
+$(eval $(call Py3Package,$(PKG_NAME)))
+$(eval $(call BuildPackage,$(PKG_NAME)))
diff --git a/bigclown-gateway/files/bc-gateway-usb-dongle.init b/bigclown-mqtt2influxdb/files/init
index bae6d11..f9efc0e 100755..100644
--- a/bigclown-gateway/files/bc-gateway-usb-dongle.init
+++ b/bigclown-mqtt2influxdb/files/init
@@ -5,12 +5,8 @@ STOP=1
USE_PROCD=1
-PROG=/usr/bin/bcg
-
-CONF=/tmp/bc-gateway-usb-dongle.generated.conf
-
-UCI_STARTED=
-UCI_DISABLED=
+PROG=/usr/bin/mqtt2influxdb
+CONF=/tmp/etc/bc-mqtt2influxdb.conf
append() {
local cfg="$1"
@@ -44,7 +40,9 @@ start_service() {
procd_open_instance
procd_set_param respawn
- procd_set_param command "$PROG" -c "$CONF" -W
+ procd_set_param command "$PROG" -c "$CONF" --debug
+ procd_set_param stdout 1
+ procd_set_param stderr 1
procd_close_instance
}
diff --git a/bigclown-mqtt2influxdb/files/mqtt2influxdb b/bigclown-mqtt2influxdb/files/mqtt2influxdb
new file mode 100755
index 0000000..22f9f8c
--- /dev/null
+++ b/bigclown-mqtt2influxdb/files/mqtt2influxdb
@@ -0,0 +1,9 @@
+#!/usr/bin/python3.6
+import mqtt2influxdb
+import sys
+from pkg_resources import load_entry_point
+
+if __name__ == '__main__':
+ sys.exit(
+ load_entry_point('mqtt2influxdb', 'console_scripts', 'mqtt2influxdb')()
+ )