Developing lightweight computation at the DSG edge

Commit e6063022 authored by p4u's avatar p4u
Browse files

It solves a problem in the first boot, during autoconfiguration problem:

wifi device name cannot be fetch from mac address if it is inside br-lan
Also qmp_autoconf adapted to netifd functions
parent c65d9013
......@@ -19,44 +19,54 @@
# the file called "COPYING".
START=99
STOP=99
SERVICE_DAEMONIZE=1
CONTROL_FILE="/qmp_configured"
QMP_DIR="/etc/qmp"
QMP_KEY="/tmp/qmp_key"
log() {
echo "$@" > /dev/console
echo "$@"
echo "$@" > /tmp/qmp_autoconf.log
}
configure() {
echo "Starting qmp configuration..."
echo "Starting qmp configuration..." > /dev/console
log Starting qmp configuration...
echo "[Configuring wireless]"
log Waiting 10 seconds to be sure all is configured
sleep 10
log [Configuring wireless]
#Generating default wifi configuration
iw reg set $(uci get qmp.wireless.country) || iw reg set 00
sleep 1
country="$(uci get qmp.wireless.country 2>/dev/null)"
country="${country:-00}"
mv /etc/config/wireless /tmp/wireless.old
wifi detect | grep -v disabled > /etc/config/wireless
wifi
wifi detect | sed s/"disabled 1"/"country $country"/g > /etc/config/wireless
/etc/init.d/network reload
#To be sure channel is set...
iw reg set $country || iw reg set 00
#Configuring wifi using QMP
. $QMP_DIR/qmp_wireless.sh
qmp_configure_wifi_initial
qmp_configure_wifi
wifi
#Reloading network to avoid problems with next functions
/etc/init.d/network reload
#Configuring networking
echo "[Configuring networking]"
. $QMP_DIR/qmp_functions.sh
qmp_configure
#/etc/init.d/network restart
#sleep 3
#QMP_HOSTNAME=$(uci get system.@system[0].hostname)
#echo "Update hostname for: '$QMP_HOSTNAME'"
#echo "$QMP_HOSTNAME" > /proc/sys/kernel/hostname
#/etc/init.d/olsrd restart
#/etc/init.d/bmx6 restart
#ifup -a
#/etc/init.d/dnsmasq restart
touch "$CONTROL_FILE"
reboot
[ -f "$CONTROL_FILE" ] && reboot || log CRITICAL, cannot write file $CONTROL_FILE
}
#This function is executed in each boot
......@@ -70,22 +80,20 @@ startup() {
# Generate current qmp key
logread | md5sum | awk '{print $1}' > $QMP_KEY
# Hack to enable wifi when channel is not standar
wifi
}
start() {
startup
if [ ! -f "$CONTROL_FILE" ]; then
configure
else
echo "QMP configured. Remove $CONTROL_FILE to force reconfiguration"
log QMP configured. Remove $CONTROL_FILE to force reconfiguration
fi
startup
}
stop() {
echo "Nothing to do"
log Nothing to do
}
restart() {
......
......@@ -188,7 +188,7 @@ qmp_get_wifi_mac_devices() {
# Returns the device name that corresponds to the MAC address
# qmp_get_dev_from_mac 00:22:11:33:44:55
qmp_get_dev_from_mac() {
echo "$(ip link | grep $1 -i -B1 | grep -v \@ | egrep -v "ether|br|mon" | grep mtu | awk '{print $2}' | tr -d : | awk NR==1)"
echo "$(ip link | grep $1 -i -B1 | grep -v \@ | egrep -v "ether|mon" | grep mtu | awk '{print $2}' | tr -d : | awk NR==1)"
}
# Returns the mac address of the device
......
......@@ -21,7 +21,6 @@
##############################
# Global variables definition
##############################
QMP_PATH="/etc/qmp"
OWRT_WIRELESS_CONFIG="/etc/config/wireless"
TEMPLATE_BASE="$QMP_PATH/templates/wireless" # followed by .driver.mode (wireless.mac80211.adhoc)
......@@ -294,7 +293,8 @@ qmp_wifi_get_default() {
# we are using index var to put devices in different channels
index=$(echo $device | tr -d [A-z])
index=${index:-0}
# QMPINFO returns a list of avaiable channels in this format: 130 ht40+ adhoc
# this is the command line used to get available channels from a device
channels_cmd="$QMPINFO channels $device"
......@@ -407,7 +407,6 @@ qmp_configure_wifi_initial() {
qmp_uci_set @wireless[$j].device $device
id_configured="$id_configured $j"
done
#Finally we are going to configure default parameters if they are not present
[ -z "$(qmp_uci_get wireless)" ] && qmp_uci_set wireless qmp
[ -z "$(qmp_uci_get wireless.driver)" ] && qmp_uci_set wireless.driver $(qmp_wifi_get_default driver)
......
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