[RFC PATCH v2] fff-support: Update PoE passthrough code for CPE 210

Adrian Schmutzler freifunk at adrianschmutzler.de
Mo Jul 10 15:12:44 CEST 2017


This implements Tim's suggestions for a persistent PoE script
(as far as I understood them). Please comment and inprove!

Signed-off-by: Adrian Schmutzler <freifunk at adrianschmutzler.de>
---
 .../ar71xx/etc/uci-defaults/50-config-poe-migration          |  7 +++++++
 .../ar71xx/etc/uci-defaults/98-fff-sysupgrade-poe            |  7 +++++++
 .../usr/lib/fff-support/cpe210_activate_poe_passthrough.sh   | 12 +++++++++---
 .../usr/lib/fff-support/cpe210_permanent_poe_passthrough.sh  | 12 ++++++++++++
 4 files changed, 35 insertions(+), 3 deletions(-)
 create mode 100644 src/packages/fff/fff-support/ar71xx/etc/uci-defaults/50-config-poe-migration
 create mode 100644 src/packages/fff/fff-support/ar71xx/etc/uci-defaults/98-fff-sysupgrade-poe
 mode change 100644 => 100755 src/packages/fff/fff-support/ar71xx/usr/lib/fff-support/cpe210_activate_poe_passthrough.sh
 create mode 100755 src/packages/fff/fff-support/ar71xx/usr/lib/fff-support/cpe210_permanent_poe_passthrough.sh

diff --git a/src/packages/fff/fff-support/ar71xx/etc/uci-defaults/50-config-poe-migration b/src/packages/fff/fff-support/ar71xx/etc/uci-defaults/50-config-poe-migration
new file mode 100644
index 0000000..7abff58
--- /dev/null
+++ b/src/packages/fff/fff-support/ar71xx/etc/uci-defaults/50-config-poe-migration
@@ -0,0 +1,7 @@
+#!/bin/sh
+
+UPGRADE_poe=$(uci -q get "fff-gpio.poe_passthrough.active")
+
+if test -n "$UPGRADE_poe" && [ "$UPGRADE_poe" -eq "1" ] ; then
+    . /usr/lib/fff-support/cpe210_activate_poe_passthrough.sh
+fi
diff --git a/src/packages/fff/fff-support/ar71xx/etc/uci-defaults/98-fff-sysupgrade-poe b/src/packages/fff/fff-support/ar71xx/etc/uci-defaults/98-fff-sysupgrade-poe
new file mode 100644
index 0000000..2d1cc8d
--- /dev/null
+++ b/src/packages/fff/fff-support/ar71xx/etc/uci-defaults/98-fff-sysupgrade-poe
@@ -0,0 +1,7 @@
+#!/bin/sh
+# Copyright 2017 Adrian Schmutzler
+# License GPLv3
+
+cat > /etc/sysupgrade.conf <<-__EOF__
+/etc/config/fff-gpio
+__EOF__
diff --git a/src/packages/fff/fff-support/ar71xx/usr/lib/fff-support/cpe210_activate_poe_passthrough.sh b/src/packages/fff/fff-support/ar71xx/usr/lib/fff-support/cpe210_activate_poe_passthrough.sh
old mode 100644
new mode 100755
index cb3508f..dc3ccd0
--- a/src/packages/fff/fff-support/ar71xx/usr/lib/fff-support/cpe210_activate_poe_passthrough.sh
+++ b/src/packages/fff/fff-support/ar71xx/usr/lib/fff-support/cpe210_activate_poe_passthrough.sh
@@ -1,5 +1,11 @@
+#!/bin/sh
+# This enables PoE passthrough and is not reset after reboot,
+# but after firmware upgrade
+
 if [ "$(cat /var/sysinfo/model)" = "TP-Link CPE210 v1.1" ] ; then
-  echo 20 > /sys/class/gpio/export
-  echo out > /sys/class/gpio/gpio20/direction
-  echo 1 > /sys/class/gpio/gpio20/value
+	uci set system.poe_passthrough=gpio_switch
+    uci set system.poe_passthrough.name='PoE Passthrough'
+    uci set system.poe_passthrough.gpio_pin='20'
+    uci set system.poe_passthrough.value='1'
+    uci commit system
 fi
diff --git a/src/packages/fff/fff-support/ar71xx/usr/lib/fff-support/cpe210_permanent_poe_passthrough.sh b/src/packages/fff/fff-support/ar71xx/usr/lib/fff-support/cpe210_permanent_poe_passthrough.sh
new file mode 100755
index 0000000..34698f6
--- /dev/null
+++ b/src/packages/fff/fff-support/ar71xx/usr/lib/fff-support/cpe210_permanent_poe_passthrough.sh
@@ -0,0 +1,12 @@
+#!/bin/sh
+# This enables PoE passthrough permanently, so it is persistent
+# after firmware upgrades
+
+if [ "$(cat /var/sysinfo/model)" = "TP-Link CPE210 v1.1" ] ; then
+    touch /etc/config/fff-gpio
+	uci set fff-gpio.poe_passthrough=poe
+	uci set fff-gpio.poe_passthrough.active=1
+	uci commit fff-gpio
+	
+	. /usr/lib/fff-support/cpe210_activate_poe_passthrough.sh
+fi
-- 
2.7.4



Mehr Informationen über die Mailingliste franken-dev