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

mail at adrianschmutzler.de mail at adrianschmutzler.de
Di Jul 11 19:40:29 CEST 2017


Hallo Christian,

LEDE setzt den ganzen Spaß selbst mit folgendem Skript:

https://github.com/lede-project/source/blob/4f272dd0323151a1390a8675bafebead
0e2a69ad/package/base-files/files/etc/init.d/gpio_switch

Du musst also tatsächlich nur option value auf '1' setzen, wie von dir
vermutet.

Bei mir war es so, dass ich die files in /sys/class/gpio... nicht manuell
ändern konnte. Weder echo > noch vi ließ ein speichern/schreiben zu. Das war
der einzige Grund, warum ich damals nach einer alternativen Lösung gesucht
habe.

Mit der /etc/config/system funktioniert das auch wunderbar, ist halt nur
nicht updatesicher. Ich bin allerdings gerade am Basteln für einen RFC
patch, um die relevanten Freifunk Settings in eine eigene Datei auszulagern,
sodass dann nur die beim Upgrade gesichert werden muss. Die
Bitratenbeschränkung wird ja z.B. z.Zt. auch nicht übertragen.

Grüße und entschuldige die Abschweifung

Adrian

-----Original Message-----
From: franken-dev [mailto:franken-dev-bounces at freifunk.net] On Behalf Of
Christian Dresel
Sent: Dienstag, 11. Juli 2017 15:41
To: Adrian Schmutzler <freifunk at adrianschmutzler.de>;
franken-dev at freifunk.net
Subject: Re: [RFC PATCH v2] fff-support: Update PoE passthrough code for CPE
210

hi

um die Diskussion mal noch weiter zu "verkomplizieren" (und ich hab sie nur
überflogen und nicht richtig mit verfolgt, also verzeiht wenn ich was
Vorschlage was eh nicht tut). Meine Nanostation M2 hat ebenfalls 2
Ethernetanschlüsse. Dort ist der GPIO8 für PoE Passthrough. Ich hab mir dazu
dieses Script Snippet welches auch unter LEDE tut:

echo 8 > /sys/class/gpio/export (bringt zwar einen Fehler scheint aber
ansonsten problemlos zu laufen, evtl. ist das schon Standartmäßig gesetzt
und deshalb der Fehler, hab da nicht genauer geguckt) echo out >
/sys/class/gpio/gpio8/direction echo 1 > /sys/class/gpio/gpio8/value

Jetzt hab ich eben mal in die /etc/config/system geguckt und festgestellt
ich könnte es wohl dort auch aktivieren:

...
config gpio_switch 'poe_passthrough'
        option name 'PoE Passthrough'
        option gpio_pin '8'
        option value '0'
...

Einfacher und meines erachtens schöner ist es aber einfach den GPIO zu
setzen und gut. Kann man das bei der CPE nicht auch "einfach so" machen?

mfg

Christian

On 10.07.2017 15:12, Adrian Schmutzler wrote:
> 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-mig
> ration  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_activat
> e_poe_passthrough.sh  create mode 100755 
> src/packages/fff/fff-support/ar71xx/usr/lib/fff-support/cpe210_permane
> nt_poe_passthrough.sh
> 
> diff --git 
> a/src/packages/fff/fff-support/ar71xx/etc/uci-defaults/50-config-poe-m
> igration 
> b/src/packages/fff/fff-support/ar71xx/etc/uci-defaults/50-config-poe-m
> igration
> new file mode 100644
> index 0000000..7abff58
> --- /dev/null
> +++ b/src/packages/fff/fff-support/ar71xx/etc/uci-defaults/50-config-p
> +++ oe-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-sysupgra
> de-poe 
> b/src/packages/fff/fff-support/ar71xx/etc/uci-defaults/98-fff-sysupgra
> de-poe
> new file mode 100644
> index 0000000..2d1cc8d
> --- /dev/null
> +++ b/src/packages/fff/fff-support/ar71xx/etc/uci-defaults/98-fff-sysu
> +++ pgrade-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_activ
> ate_poe_passthrough.sh 
> b/src/packages/fff/fff-support/ar71xx/usr/lib/fff-support/cpe210_activ
> ate_poe_passthrough.sh
> old mode 100644
> new mode 100755
> index cb3508f..dc3ccd0
> --- 
> a/src/packages/fff/fff-support/ar71xx/usr/lib/fff-support/cpe210_activ
> ate_poe_passthrough.sh
> +++ b/src/packages/fff/fff-support/ar71xx/usr/lib/fff-support/cpe210_a
> +++ ctivate_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_perma
> nent_poe_passthrough.sh 
> b/src/packages/fff/fff-support/ar71xx/usr/lib/fff-support/cpe210_perma
> nent_poe_passthrough.sh
> new file mode 100755
> index 0000000..34698f6
> --- /dev/null
> +++ b/src/packages/fff/fff-support/ar71xx/usr/lib/fff-support/cpe210_p
> +++ ermanent_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
> 




Mehr Informationen über die Mailingliste franken-dev