1
0
Fork 0
mirror of https://github.com/albfan/miraclecast.git synced 2025-03-09 23:38:56 +00:00

polish device tester script

closes #22
This commit is contained in:
albfan 2015-05-01 21:57:28 +02:00
parent c51ec02aa9
commit f24bcb8ae9
3 changed files with 170 additions and 3 deletions

View file

@ -1,6 +1,6 @@
# MiracleCast - Wifi-Display/Miracast Implementation
The MiracleCast project provides software to connect external monitors to your system via Wifi. It is compatible to the Wifi-Display specification also known as Miracast. MiracleCast implements the Display-Source as well as Display-Sink side.
The MiracleCast project provides software to connect external monitors to your system via Wi-Fi. It is compatible to the Wifi-Display specification also known as Miracast. MiracleCast implements the Display-Source as well as Display-Sink side.
The Display-Source side allows you to connect external displays to your system and stream local content to the device. A lot of effort is put into making this as easy as connecting external displays via HDMI.
@ -22,6 +22,8 @@ The MiracleCast projects requires the following software to be installed:
- **gstreamer**: MiracleCast relay on gstreamer to show cast its output. You can test if all needed is installed launching [res/test-viewer.sh](https://github.com/albfan/miraclecast/blob/master/res/test-viewer.sh)
- **P2P Wi-Fi device** Although widespread this days, there are some devices not compatible with [Wi-Fi Direct](http://en.wikipedia.org/wiki/Wi-Fi_Direct) (prior know as Wi-Fi P2P). Test yours with [res/test-wifi-capabilities.sh](https://github.com/albfan/miraclecast/blob/master/res/test_wifi-capabilities.sh)
- copy the dbus policy **res/org.freedesktop.miracle.conf** to `/etc/dbus-1/system.d/`
## Install

125
res/miracle-utils.sh Executable file
View file

@ -0,0 +1,125 @@
#http://lxr.linux.no/linux+v3.0/include/linux/if_arp.h#L67
ARPHRD_LOOPBACK=772
#
# Find all interfaces except loopback one
#
function find_choosable_networknames {
for i in $( ls /sys/class/net )
do
if [ $( cat /sys/class/net/$i/type ) != $ARPHRD_LOOPBACK ]
then
echo $i
fi
done
}
#
# find wireless interfaces
#
function find_wireless_network_interfaces {
for i in $( find_choosable_networknames )
do
if [ -d /sys/class/net/$i/wireless ]
then
echo $i
fi
done
}
#
# test if interface is connected
#
function is_interface_connected {
test x$( cat /sys/class/net/$1/carrier 2>/dev/null) = x1
}
#
# find wireless connected interfaces
#
function find_wireless_connected_network_interfaces {
for i in $( find_wireless_network_interfaces )
do
if is_interface_connected $i
then
echo $i
fi
done
}
#
# find physical for interface if exists
#
function find_physical_for_network_interface {
PHY_INDEX=$(iw dev $1 info | grep wiphy | awk '{print $2}')
if [ -n $PHY_INDEX ]
then
echo phy$PHY_INDEX
fi
}
#
# Check interface for P2P capabilities
#
function search_p2p_capabilities {
WI_DEVICE=$1
PHY_DEVICE=$(find_physical_for_network_interface $WI_DEVICE)
if iw phy $PHY_DEVICE info | grep -Pzo "(?s)Supported interface modes.*Supported commands" | grep "P2P" &> /dev/null
then
echo $WI_DEVICE supports P2P
else
echo Sorry, $WI_DEVICE do not support P2P
exit 1
fi
}
#
# show wpa_supplicant command
#
function show_wpa_supplicant_process {
ps -ef | grep wpa_supplican[t]
}
#
# show wpa_supplicant command
#
function show_wpa_supplicant_command {
show_wpa_supplicant_process | awk '{print substr($0, index($0,$8))}'
}
#
# find wpa_supplicant pid
#
function find_wpa_supplicant_pid {
show_wpa_supplicant_process | awk '{print $2}'
}
#
# checking if distro is ubuntu
#
function check_ubuntu_distro {
cat /proc/version | grep -i ubuntu
}
#
# ubuntu manager restarts automatically wpa_supplicant
#
function kill_ubuntu_network_manager {
if check_ubuntu_distro
then
echo stopping NetworkManager
sudo service NetworkManager stop
fi
}
#
# start ubuntu manager
#
function start_ubuntu_network_manager {
if check_ubuntu_distro
then
echo starting NetworkManager
sudo service NetworkManager start
fi
}

44
res/test-wifi-capabilities.sh Normal file → Executable file
View file

@ -1,5 +1,45 @@
#/bin/bash
echo You must see P2P-Go and P2P-Client below this line for a valid miraclecast device:
. miracle-utils.sh
WIFI_NAMES=$(find_wireless_network_interfaces)
WIFI_COUNT=$(echo "$WIFI_NAMES" | wc -l)
if [ 0 = $WIFI_COUNT ]
then
echo There is no wireless devices avaliable
exit 1
elif [ 1 = $WIFI_COUNT ]
then
WIFI_NAME="$WIFI_NAMES"
elif [ 2 -ge $WIFI_COUNT ]
then
echo Choose wireless device:
PS3="device: "
QUIT="exit"
select wi_name in $WIFI_NAMES $QUIT
do
case $wi_name
in
"$QUIT")
exit
;;
"")
if [ "$REPLY" = $QUIT ]
then
exit
else
echo unknow $REPLY
fi
;;
*)
WIFI_NAME=$wi_name
break
;;
esac
done
fi
search_p2p_capabilities $WIFI_NAME
iw list | grep -P "(?s)Supported interface.*Supported commands" | grep "P2P"