Developing lightweight computation at the DSG edge

Commit 2992b18f authored by Simó Albert i Beltran's avatar Simó Albert i Beltran
Browse files

Configure wifi devices with MAC address of physical device, closes #229.

parent aaba5ee6
...@@ -181,8 +181,17 @@ qmp_get_wifi_devices() { ...@@ -181,8 +181,17 @@ qmp_get_wifi_devices() {
} }
# Returns the MAC address of the wifi devices # Returns the MAC address of the wifi devices
# (get MAC addres of the physical wifi device, if exists)
qmp_get_wifi_mac_devices() { qmp_get_wifi_mac_devices() {
echo "$(ip link | grep -A1 -E ": (wifi|wlan).: " | grep link | cut -d' ' -f6)" for device in $(qmp_get_wifi_devices)
do
if [ -s "/sys/class/net/$device/phy80211/macaddress" ]
then
cat "/sys/class/net/$device/phy80211/macaddress"
else
qmp_get_mac_for_dev $device
fi
done
} }
# Returns the device name that corresponds to the MAC address # Returns the device name that corresponds to the MAC address
...@@ -202,9 +211,14 @@ qmp_get_mac_for_dev() { ...@@ -202,9 +211,14 @@ qmp_get_mac_for_dev() {
# Returns the mac addres for specific device,, only wifi devs are allowed. Useful when eth and wlan have same MAC # Returns the mac addres for specific device,, only wifi devs are allowed. Useful when eth and wlan have same MAC
# qmp_get_dev_from_wifi_mac 00:22:11:33:44:55 # qmp_get_dev_from_wifi_mac 00:22:11:33:44:55
qmp_get_dev_from_wifi_mac() { qmp_get_dev_from_wifi_mac() {
mac="$(ip link | grep -A1 -E ": (wifi|wlan|wl).: " | grep -i $1 -B1 | cut -d' ' -f2 | tr -d "\n",:)" for device in $(qmp_get_wifi_devices)
[ -z "$mac" ] && mac="00:00:00:00:00:00" do
echo "$mac" if grep -q -i "^$1$" "/sys/class/net/$device/phy80211/macaddress" "/sys/class/net/$device/address" 2> /dev/null
then
echo $device
return
fi
done
} }
######################### #########################
......
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