Developing lightweight computation at the DSG edge

Commit 4d8a2263 authored by hitz's avatar hitz
Browse files

New version of qmp_wireless_config, and new templates

parent 5e4bd1be
......@@ -29,7 +29,7 @@ define Package/qmp-small-node
+iputils-arping +iputils-clockdiff +iputils-ping +iputils-tracepath \
+ahcpd \
+radvd \
+wireless-tools +iw \
+wireless-tools +iw +hostapd \
+wide-dhcpv6-client +wide-dhcpv6-control +wide-dhcpv6-server \
+bmx6-qmp +bmx6-qmp-uci-config +bmx6-qmp-json +bmx6-luci \
+olsrd +olsrd-mod-txtinfo +olsrd-mod-httpinfo +olsrd-mod-watchdog \
......
......@@ -34,18 +34,21 @@ config qmp networks
option babel_mesh_prefix48 'fd03:0:0'
#This is only a prototype, not implemented!
config qmp wireless
option driver madwifi
option country 8000
config wireless
option channel 44
option mode mesh
option mac AA:BB:CC:DD:EE:FF
config wireless
option channel 10
option mode ap
option mac 00:11:22:33:44:55
option driver mac80211
option country 800
option bssid 02:CA:FF:EE:BA:BE
config wireless
option channel 10
option mode ap
option mac 00:80:48:6B:25:b6
option name AP-qmp
config wireless
option channel 44
option mode adhoc
option mac 00:80:48:6b:25:b5
option name qmp
......@@ -29,3 +29,15 @@ restart() {
start
}
enable()
{
rm "$CONTROL_FILE" 2>/dev/null
echo "Autoconfiguration enabled..."
}
dissable()
{
touch "$CONTROL_FILE"
echo "Autoconfiguration dissabled..."
}
......@@ -4,5 +4,8 @@ qmp_uci_get() {
echo "$(uci get qmp.$1)" 2>/dev/null
}
qmp_error() {
echo "Error: $1"
exit 1
}
#!/bin/sh
QMP_PATH="/etc/qmp"
OWRT_WIRELESS_CONFIG="/etc/config/wireless"
TEMPLATE_BASE="$QMP_PATH/templates/wireless"
. $QMP_PATH/qmp_common.sh
qmp_configure_wifi_device() {
echo "Configuring device $1"
mac="$(qmp_uci_get @wireless[$1].mac)"
channel="$(qmp_uci_get @wireless[$1].channel)"
mode="$(qmp_uci_get @wireless[$1].mode)"
name="$(qmp_uci_get @wireless[$1].name)"
driver="$(qmp_uci_get wireless.driver)"
country="$(qmp_uci_get wireless.country)"
bssid="$(qmp_uci_get wireless.bssid)"
echo "------------------------"
echo "Mac: $mac"
echo "Mode: $mode"
echo "Driver: $driver"
echo "Channel: $channel"
echo "Country: $country"
echo "Name: $name"
echo "------------------------"
template="$TEMPLATE_BASE.$driver.$mode"
[ ! -f "$template" ] && qmp_error "Template $template not found"
cat $template | sed -e s/"#QMP_DEVICE"/"wifi$1"/ \
-e s/"#QMP_TYPE"/"$driver"/ \
-e s/"#QMP_MAC"/"$mac"/ \
-e s/"#QMP_CHANNEL"/"$channel"/ \
-e s/"#QMP_COUNTRY"/"$country"/ \
-e s/"#QMP_SSID"/"$name"/ \
-e s/"#QMP_BSSID"/"$bssid"/ \
-e s/"#QMP_MODE"/"$mode"/ >> $OWRT_WIRELESS_CONFIG
}
qmp_configure_wifi() {
echo "Backuping wireless config file to: $OWRT_WIRELESS_CONFIG.qmp_backup"
cp $OWRT_WIRELESS_CONFIG $OWRT_WIRELESS_CONFIG.qmp_backup
echo "" > $OWRT_WIRELESS_CONFIG
devices="$(ip link | grep -E ": (wifi|wlan).: "| cut -d: -f2)"
macs="$(ip link | grep -A1 -E ": (wifi|wlan).: " | grep link | cut -d' ' -f6)"
i=1
for d in $devices; do
m=$(echo $macs | cut -d' ' -f$i)
j=0
configured_mac="$(qmp_uci_get @wireless[$j].mac)"
configured_mac="$(qmp_uci_get @wireless[$j].mac | tr [A-Z] [a-z])"
while [ ! -z "$configured_mac" ]; do
[ "$configured_mac" == "$m" ] && { qmp_configure_wifi_device $j; break; }
[ "$configured_mac" == "$m" ] && { qmp_configure_wifi_device $j ; break; }
j=$(( $j + 1 ))
configured_mac="$(qmp_uci_get @wireless[$j].mac)"
configured_mac="$(qmp_uci_get @wireless[$j].mac | tr [A-Z] [a-z])"
done
i=$(( $i + 1 ))
done
echo "Done. All devices configured according qmp configuration"
}
config wifi-device #QMP_DEVICE
option type mac80211
option macaddr #QMP_MAC
option channel #QMP_CHANNEL
option diversity 0 # 0:off, 1:on
option txantenna 0 # 0:auto, 1:main, 2:aux
option rxantenna 0 # 0:auto, 1:main, 2:aux
option country #QMP_COUNTRY
option outdoor 1
# option txpower 1
config wifi-iface
option device #QMP_DEVICE
option mode adhoc
option ssid #QMP_SSID
option bssid #QMP_BSSID
option encryption none
config wifi-device #QMP_DEVICE
option type mac80211
option macaddr #QMP_MAC
option channel #QMP_CHANNEL
option hwmode 11na
option htmode HT40+
list ht_capab SHORT-GI-40
list ht_capab TX-STBC
list ht_capab RX-STBC1
list ht_capab DSSS_CCK-40
option country #QMP_COUNTRY
option outdoor 1
config wifi-iface
option device #QMP_DEVICE
option mode adhoc
option ssid #QMP_SSID
option bssid #QMP_BSSID
option encryption none
config wifi-device #QMP_DEVICE
option type mac80211
option macaddr #QMP_MAC
option channel #QMP_CHANNEL
option diversity 0 # 0:off, 1:on
option txantenna 0 # 0:auto, 1:main, 2:aux
option rxantenna 0 # 0:auto, 1:main, 2:aux
option country #QMP_COUNTRY
option outdoor 1
# option txpower 1
config wifi-iface
option device #QMP_DEVICE
option mode ap
option ssid #QMP_SSID
option encryption none
config wifi-device #QMP_DEVICE
option type mac80211
option macaddr #QMP_MAC
option channel #QMP_CHANNEL
option hwmode 11na
option htmode HT40+
list ht_capab SHORT-GI-40
list ht_capab TX-STBC
list ht_capab RX-STBC1
list ht_capab DSSS_CCK-40
option country #QMP_COUNTRY
option outdoor 1
config wifi-iface
option device #QMP_DEVICE
option mode ap
option ssid #QMP_SSID
option encryption none
config wifi-device #QMP_DEVICE
option type atheros
option macaddr #QMP_MAC
option channel #QMP_CHANNEL
option diversity 0 # 0:off, 1:on
option txantenna 0 # 0:auto, 1:main, 2:aux
option rxantenna 0 # 0:auto, 1:main, 2:aux
option country #QMP_COUNTRY
option outdoor 1
# option txpower 1
config wifi-iface
option device #QMP_DEVICE
option mode adhoc
option ssid #QMP_SSID
option bssid #QMP_BSSID
option encryption none
config wifi-device #QMP_DEVICE
option type atheros
option macaddr #QMP_MAC
option channel #QMP_CHANNEL
option diversity 0 # 0:off, 1:on
option txantenna 0 # 0:auto, 1:main, 2:aux
option rxantenna 0 # 0:auto, 1:main, 2:aux
option country #QMP_COUNTRY
option outdoor 1
# option txpower 1
config wifi-iface
option device #QMP_DEVICE
option mode ap
option ssid #QMP_SSID
option encryption none
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment