[RFC PATCH v3 8/8] Configures wireless with parameter from Hood-Files

Jan Kraus mayosemmel at googlemail.com
So Jun 12 14:17:27 CEST 2016


Signed-off-by: Jan Kraus <mayosemmel at gmail.com>
---
 community/aux.cfg                                  |  8 +--
 community/franken.cfg                              |  8 +--
 .../fff/fff-hoods/files/usr/sbin/configurehood     | 69 ++++++++++++----------
 src/packages/fff/fff-wireless/Makefile             |  4 +-
 .../fff/fff-wireless/files/etc/config/wireless     |  0
 .../files/etc/uci-defaults/60-fff-wireless         | 43 --------------
 .../fff-wireless/files/lib/functions/fff/wireless  |  7 ++-
 7 files changed, 46 insertions(+), 93 deletions(-)
 delete mode 100644 src/packages/fff/fff-wireless/files/etc/config/wireless
 delete mode 100644 src/packages/fff/fff-wireless/files/etc/uci-defaults/60-fff-wireless

diff --git a/community/aux.cfg b/community/aux.cfg
index b1b921f..1a54400 100644
--- a/community/aux.cfg
+++ b/community/aux.cfg
@@ -1,8 +1,2 @@
-BATMAN_CHANNEL=1
-BATMAN_CHANNEL_5GHZ=36
-ESSID_AP=aux.franken.freifunk.net
-ESSID_MESH=batman.franken.freifunk.net
-BSSID_MESH=CA:FF:EE:BA:BE:01
-VPN_PROJECT=fffaux
 NTPD_IP=fe80::ff:feee:1%br-mesh
-UPGRADE_PATH=http://[fe80::ff:feee:1%br-mesh]/dev/firmware/aux/current
+UPGRADE_PATH=http://[fe80::ff:feee:1%br-mesh]/dev/firmware/aux/current
\ No newline at end of file
diff --git a/community/franken.cfg b/community/franken.cfg
index 833e98e..b5ad7e1 100644
--- a/community/franken.cfg
+++ b/community/franken.cfg
@@ -1,8 +1,2 @@
-BATMAN_CHANNEL=1
-BATMAN_CHANNEL_5GHZ=36
-ESSID_AP=franken.freifunk.net
-ESSID_MESH=batman.franken.freifunk.net
-BSSID_MESH=02:CA:FF:EE:BA:BE
-VPN_PROJECT=fff
 NTPD_IP=fe80::ff:feee:1%br-mesh
-UPGRADE_PATH=http://[fe80::ff:feee:1%br-mesh]/dev/firmware/current
+UPGRADE_PATH=http://[fe80::ff:feee:1%br-mesh]/dev/firmware/current
\ No newline at end of file
diff --git a/src/packages/fff/fff-hoods/files/usr/sbin/configurehood b/src/packages/fff/fff-hoods/files/usr/sbin/configurehood
index 46b0807..5251be1 100755
--- a/src/packages/fff/fff-hoods/files/usr/sbin/configurehood
+++ b/src/packages/fff/fff-hoods/files/usr/sbin/configurehood
@@ -3,6 +3,7 @@
 HOODDIR=/etc/hoods
 
 . /usr/share/libubox/jshn.sh
+. /lib/functions/fff/wireless
 
 myLat=$(uci get 'system. at system[0].latitude')
 myLon=$(uci get 'system. at system[0].longitude')
@@ -78,42 +79,48 @@ json_get_var meshessid mesh_essid
 json_get_var essid essid
 json_get_var channel2 channel2
 json_get_var mode2 mode2
-json_get_var protocol protocol
 json_get_var type2 type2
+json_get_var channel5 channel5
+json_get_var mode5 mode5
+json_get_var type5 type5
+json_get_var protocol protocol
 
 echo "Setting hood name: $hood"
-echo "Setting channel 2.4 Ghz: $channel2"
-echo "Setting mode 2.4 GHz: $mode2"
-echo "Setting mesh 2.4 GHz type: $type2"
+uci set system. at system[0].hood=$hood
 
-#echo "Shutting down wifi"
-#wifi down
+if ! wifiDelAll; then
+  echo "Can't delete current wifi setup"
+  exit 1
+fi
 
-uci set system. at system[0].hood=$hood
-uci set wireless.radio0=wifi-device
-uci set wireless.radio0.type=mac80211
-uci set wireless.radio0.channel=$channel2
-uci set wireless.radio0.phy=phy0
-uci set wireless.radio0.hwmode=11g
-uci set wireless.radio0.htmode=$mode2
-uci set wireless.radio0.country=DE
-uci set wireless. at wifi-iface[0]=wifi-iface
-uci set wireless. at wifi-iface[0].device=radio0
-uci set wireless. at wifi-iface[0].network=w2mesh
-uci set wireless. at wifi-iface[0].ifname=w2mesh
-uci set wireless. at wifi-iface[0].mode=$type2
-uci set wireless. at wifi-iface[0].bssid=$bssid
-uci set wireless. at wifi-iface[0].ssid=$meshessid
-uci set wireless. at wifi-iface[0].mcast_rate=6000
-uci set wireless. at wifi-iface[0].encryption=none
-uci set wireless. at wifi-iface[1]=wifi-iface
-uci set wireless. at wifi-iface[1].device=radio0
-uci set wireless. at wifi-iface[1].network=mesh
-uci set wireless. at wifi-iface[1].ifname=w2ap
-uci set wireless. at wifi-iface[1].mode=ap
-uci set wireless. at wifi-iface[1].ssid=$essid
-uci set wireless. at wifi-iface[1].encryption=none
-uci commit
+for phy in $(iw phy | awk '/^Wiphy/{ print $2 }'); do
+  if iw phy "$phy" info | grep -q -m1 "2... MHz"; then
+    echo "$phy is 2.4 GHz"
+    radio=$(wifiAddPhy "$phy" "$channel2" "$mode2")
+    if [ -z "$radio" ]; then
+      echo "Can't create radio for $phy"
+      exit 1
+    fi
+  fi
+  if iw phy "$phy" info | grep -q -m1 "5... MHz"; then
+    echo "$phy is 5 GHz"
+    radio=$(wifiAddPhy "$phy" "$channel5" "mode5")
+    if [ -z "$radio" ]; then
+      echo "Can't create radio for $phy"
+      exit 1
+    fi
+  fi
+
+  if ! wifiAddAP "$radio" "$essid"; then
+    echo "Can't add AP interface on $radio0."
+    exit 1
+  fi
+
+  if ! wifiAddAdHocMesh "$radio" "$mesh_essid" "$mesh_bssid"; then
+    echo "Can't add AP interface on $radio0."
+    exit 1
+  fi
+done
 
 echo "Loading wifi"
 wifi
diff --git a/src/packages/fff/fff-wireless/Makefile b/src/packages/fff/fff-wireless/Makefile
index 12456e5..046d932 100644
--- a/src/packages/fff/fff-wireless/Makefile
+++ b/src/packages/fff/fff-wireless/Makefile
@@ -1,8 +1,8 @@
 include $(TOPDIR)/rules.mk
 
 PKG_NAME:=fff-wireless
-PKG_VERSION:=0.0.1
-PKG_RELEASE:=1
+PKG_VERSION:=0.0.2
+PKG_RELEASE:=2
 
 PKG_BUILD_DIR:=$(BUILD_DIR)/fff-wireless
 
diff --git a/src/packages/fff/fff-wireless/files/etc/config/wireless b/src/packages/fff/fff-wireless/files/etc/config/wireless
deleted file mode 100644
index e69de29..0000000
diff --git a/src/packages/fff/fff-wireless/files/etc/uci-defaults/60-fff-wireless b/src/packages/fff/fff-wireless/files/etc/uci-defaults/60-fff-wireless
deleted file mode 100644
index 59239b3..0000000
--- a/src/packages/fff/fff-wireless/files/etc/uci-defaults/60-fff-wireless
+++ /dev/null
@@ -1,43 +0,0 @@
-#!/bin/sh
-# Copyright 2016 Tim Niemeyer
-# License GPLv3
-
-. /lib/functions/fff/wireless
-
-. /etc/community.cfg
-
-if ! wifiDelAll; then
-	echo "Can't delete current wifi setup"
-	exit 1
-fi
-
-for phy in $(iw phy | awk '/^Wiphy/{ print $2 }'); do
-	if iw phy "$phy" info | grep -q -m1 "2... MHz"; then
-		echo "$phy is 2.4 GHz"
-		radio=$(wifiAddPhy "$phy" "$BATMAN_CHANNEL")
-		if [ -z "$radio" ]; then
-			echo "Can't create radio for $phy"
-			exit 1
-		fi
-	fi
-	if iw phy "$phy" info | grep -q -m1 "5... MHz"; then
-		echo "$phy is 5 GHz"
-		radio=$(wifiAddPhy "$phy" "$BATMAN_CHANNEL_5GHZ")
-		if [ -z "$radio" ]; then
-			echo "Can't create radio for $phy"
-			exit 1
-		fi
-	fi
-
-	if ! wifiAddAP "$radio" "$ESSID_AP"; then
-		echo "Can't add AP interface on $radio0."
-		exit 1
-	fi
-
-	if ! wifiAddAdHocMesh "$radio" "$ESSID_MESH" "$BSSID_MESH"; then
-		echo "Can't add AP interface on $radio0."
-		exit 1
-	fi
-done
-
-# vim: set noexpandtab:tabstop=4
diff --git a/src/packages/fff/fff-wireless/files/lib/functions/fff/wireless b/src/packages/fff/fff-wireless/files/lib/functions/fff/wireless
index 59c8ce2..69bc000 100644
--- a/src/packages/fff/fff-wireless/files/lib/functions/fff/wireless
+++ b/src/packages/fff/fff-wireless/files/lib/functions/fff/wireless
@@ -15,14 +15,15 @@ wifiDelAll() {
 }
 
 wifiAddPhy() {
-	if [ $# -ne "2" ]
+	if [ $# -ne "3" ]
 	then
-		echo "Usage: wifiAddPhy <phy> <channel>"
+		echo "Usage: wifiAddPhy <phy> <channel> <htmode>"
 		return 1
 	fi
 
 	local phy=$1
 	local channel=$2
+	local htmode=$3
 	local radio="radio$(echo $phy | tr -d -C [0-9])"
 	local hwmode="11g"
 	if [ "$channel" -gt "14" ]; then
@@ -35,7 +36,7 @@ wifiAddPhy() {
 		set wireless.${radio}.channel='${channel}'
 		set wireless.${radio}.phy='${phy}'
 		set wireless.${radio}.hwmode='${hwmode}'
-		set wireless.${radio}.htmode='HT20'
+		set wireless.${radio}.htmode='${htmode}'
 		set wireless.${radio}.country='DE'
 		commit wireless
 	__EOF__
-- 
2.1.4



Mehr Informationen über die Mailingliste franken-dev