mirror of
https://github.com/paparazzi/paparazzi.git
synced 2026-06-02 05:17:03 +08:00
[bebop2] Pullrequest bebop2 tools wifi tools (#2146)
* added scripts to connect to wifi for bebop 2 * added all necessary files * changed readme * changed txt readme to md
This commit is contained in:
committed by
Christophe De Wagter
parent
fcf972fd44
commit
38a106f3e7
@@ -0,0 +1,16 @@
|
||||
# Description
|
||||
These scripts can be used to connect Bebop 2 drones to a Wi-Fi router, so that (for instance) they may be used in a swarm via a central hub.
|
||||
|
||||
The drone will then function as follows:
|
||||
Upon starting up, it will search for the router. If the router is found, it will connect to it.
|
||||
If the router is not found within a specific time, the drone will become the access point, as "normal".
|
||||
The "4 button press" will also be removed, so this will not have to be done before loading Paparazzi on the drone.
|
||||
|
||||
# How to set it up
|
||||
To connect the Bebop 2 to a router:
|
||||
1. Open pprz_swarmhub.conf
|
||||
2. Write the name of the router after WIFI_SSID
|
||||
3. Start up the Bebop2 and connect to it normally with your computer's WiFi
|
||||
4. Start up the router
|
||||
5. Run connect2ssid.sh
|
||||
6. The Bebop2 should now turn off and connect to the router. To check that this happened, you can connect to the router and try to ping to it/see all connections.
|
||||
+16
@@ -0,0 +1,16 @@
|
||||
#!/bin/bash
|
||||
|
||||
if [ -z "$1" ]
|
||||
then
|
||||
IP="192.168.42.1"
|
||||
echo "No drone ID specified, using ($IP)"
|
||||
else
|
||||
IP="$1"
|
||||
echo "Drone ID specified, using ($IP)"
|
||||
fi
|
||||
|
||||
wput -nc -u ./pprz_swarmhub.conf ftp://$IP/internal_000/scripts/pprz.conf
|
||||
wput -nc -u ./scripts/config_network.script ftp://$IP/internal_000/scripts/config_network.script
|
||||
wput -nc -u ./scripts/button_switch ftp://$IP/internal_000/scripts/button_switch
|
||||
wput -nc -u ./scripts/connect2hub ftp://$IP/internal_000/scripts/connect2hub
|
||||
{ echo "mount -o remount,rw /"; echo "sed -i 's|^exit 0|/data/ftp/internal_000/scripts/connect2hub \& exit 0|' /etc/init.d/rcS"; echo "chmod a+x /etc/init.d/rcS"; echo "chmod a+x /data/ftp/internal_000/scripts/connect2hub"; echo "chmod a+x /data/ftp/internal_000/scripts/button_switch"; echo "chmod a+x /data/ftp/internal_000/scripts/config_network.script"; echo "dos2unix /data/ftp/internal_000/scripts/button_switch"; echo "dos2unix /data/ftp/internal_000/scripts/connect2hub"; echo "dos2unix /data/ftp/internal_000/scripts/pprz.conf"; echo "echo '#!/bin/sh' > /bin/onoffbutton/shortpress_3.sh"; echo "echo '' >> /bin/onoffbutton/shortpress_3.sh"; echo "echo '/data/ftp/internal_000/scripts/button_switch' >> /bin/onoffbutton/shortpress_3.sh"; echo "/sbin/reboot"; sleep 10; } | telnet $IP
|
||||
@@ -0,0 +1,5 @@
|
||||
# Config file for PPRZ init script
|
||||
START_PPRZ=0
|
||||
START_TELNET=1
|
||||
START_ADB=1
|
||||
JOIN_WIFI=0
|
||||
@@ -0,0 +1,7 @@
|
||||
# Config file for PPRZ init script
|
||||
START_PPRZ=1
|
||||
START_TELNET=1
|
||||
START_ADB=1
|
||||
JOIN_WIFI=1
|
||||
WIFI_SSID=linksys388
|
||||
WIFI_AMODE=none
|
||||
+12
@@ -0,0 +1,12 @@
|
||||
#!/bin/bash
|
||||
|
||||
if [ -z "$1" ]
|
||||
then
|
||||
IP="192.168.42.1"
|
||||
echo "No drone ID specified, using ($IP)"
|
||||
else
|
||||
IP="$1"
|
||||
echo "Drone ID specified, using ($IP)"
|
||||
fi
|
||||
|
||||
{ echo "mount -o remount,rw /"; echo "sed -i 's|^/data/ftp/internal_000/scripts/connect2hub \& exit 0|exit 0|' /etc/init.d/rcS"; echo "chmod a+x /etc/init.d/rcS"; echo "/sbin/reboot"; sleep 10; } | telnet $IP
|
||||
+15
@@ -0,0 +1,15 @@
|
||||
#!/bin/bash
|
||||
|
||||
if [ -z "$1" ]
|
||||
then
|
||||
IP="192.168.42.1"
|
||||
echo "No drone ID specified, using ($IP)"
|
||||
else
|
||||
IP="$1"
|
||||
echo "Drone ID specified, using ($IP)"
|
||||
fi
|
||||
|
||||
wput -u ./pprz.conf ftp://$IP/internal_000/scripts/pprz.conf
|
||||
wput -u ./scripts/config_network.script ftp://$IP/internal_000/scripts/config_network.script
|
||||
wput -u ./scripts/connect2hub ftp://$IP/internal_000/scripts/connect2hub
|
||||
{ echo "mount -o remount,rw /"; echo "sed -i 's|^exit 0|/data/ftp/internal_000/scripts/connect2hub \& exit 0|' /etc/init.d/rcS"; echo "chmod a+x /etc/init.d/rcS"; echo "chmod a+x /data/ftp/internal_000/scripts/connect2hub"; echo "chmod a+x /data/ftp/internal_000/scripts/config_network.script"; echo "dos2unix /data/ftp/internal_000/scripts/pprz.conf"; echo "/sbin/reboot"; sleep 10; } | telnet $IP
|
||||
@@ -0,0 +1,16 @@
|
||||
#!/bin/sh
|
||||
|
||||
BLDC_Test_Bench -n -M 1
|
||||
if [ $(bcmwl ap) -eq 1 ]
|
||||
then
|
||||
if [ -r /data/ftp/internal_000/scripts/connect2hub ]; then
|
||||
/data/ftp/internal_000/scripts/connect2hub
|
||||
else
|
||||
echo "Button activating..." | ulogger -t "ShortPressDebug" -p I
|
||||
/bin/usbnetwork.sh
|
||||
echo "Button activated" | ulogger -t "ShortPressDebug" -p I
|
||||
fi
|
||||
else
|
||||
/sbin/broadcom_reset.sh
|
||||
BLDC_Test_Bench -n -M 2
|
||||
fi
|
||||
@@ -0,0 +1,39 @@
|
||||
#!/bin/sh
|
||||
|
||||
#udhcpc script edited by Tim Riker <Tim@Rikers.org>
|
||||
|
||||
[ -z "$1" ] && echo "Error: should be called from udhcpc" && exit 1
|
||||
|
||||
RESOLV_CONF="/etc/resolv.conf"
|
||||
[ -n "$broadcast" ] && BROADCAST="broadcast $broadcast"
|
||||
[ -n "$subnet" ] && NETMASK="netmask $subnet"
|
||||
|
||||
case "$1" in
|
||||
deconfig)
|
||||
/sbin/ifconfig $interface 0.0.0.0
|
||||
;;
|
||||
|
||||
renew|bound)
|
||||
/sbin/ifconfig $interface $ip $BROADCAST $NETMASK
|
||||
|
||||
if [ -n "$router" ] ; then
|
||||
echo "deleting routers"
|
||||
while route del default gw 0.0.0.0 dev $interface ; do
|
||||
:
|
||||
done
|
||||
|
||||
for i in $router ; do
|
||||
route add default gw $i dev $interface
|
||||
done
|
||||
fi
|
||||
|
||||
echo -n > $RESOLV_CONF
|
||||
[ -n "$domain" ] && echo search $domain >> $RESOLV_CONF
|
||||
for i in $dns ; do
|
||||
echo adding dns $i
|
||||
echo nameserver $i >> $RESOLV_CONF
|
||||
done
|
||||
;;
|
||||
esac
|
||||
|
||||
exit 0
|
||||
@@ -0,0 +1,75 @@
|
||||
#!/bin/sh
|
||||
# on startup the system is not quite ready when called, so lets play it safe and wait a while
|
||||
sleep 4
|
||||
if [ -r /data/ftp/internal_000/scripts/pprz.conf ]; then
|
||||
source /data/ftp/internal_000/scripts/pprz.conf
|
||||
echo "Read config"
|
||||
else
|
||||
echo "No config found, using default"
|
||||
START_TELNET=1
|
||||
START_ADB=1
|
||||
JOIN_WIFI=0
|
||||
START_PPRZ=0
|
||||
fi
|
||||
if [ "$JOIN_WIFI" -gt "0" ]
|
||||
then
|
||||
echo "Scanning WiFi networks..."
|
||||
# see if wifi network with SSID swarmhub is available
|
||||
if (bcmwl escanresults | grep "$WIFI_SSID")
|
||||
then
|
||||
# disable wifi and bring back up again
|
||||
ifconfig eth0 down
|
||||
bcmwl down
|
||||
bcmwl band auto
|
||||
bcmwl autocountry 1
|
||||
bcmwl up
|
||||
ifconfig eth0 up
|
||||
# set AP mode to 0 (parrot default is 1 for ad-hoc host)
|
||||
bcmwl ap 0
|
||||
# join wifi network
|
||||
if [ "$WIFI_AMODE" == "none" ]; then
|
||||
echo "No Authentication"
|
||||
wificmd="bcmwl join $WIFI_SSID"
|
||||
else
|
||||
echo "$WIFI_AMODE Authentication"
|
||||
wificmd="bcmwl join $WIFI_SSID key $WIFI_KEY amode $WIFI_AMODE"
|
||||
fi
|
||||
eval $wificmd
|
||||
sleep 2
|
||||
# from the udhcpc message clip the leased IP address
|
||||
dhcpmsg=`udhcpc -n -b -i eth0 -s /data/ftp/internal_000/scripts/config_network.script -x hostname:$(hostname)`
|
||||
echo $dhcpmsg > /data/ftp/internal_000/scripts/MSG_latest_DHCP
|
||||
# check if previous command returned a valid IP address
|
||||
if (echo $dhcpmsg | egrep "[[:digit:]]{1,3}\.[[:digit:]]{1,3}\.[[:digit:]]{1,3}\.[[:digit:]]{1,3}" -o)
|
||||
then
|
||||
dhcpip=`echo $dhcpmsg | egrep "[[:digit:]]{1,3}\.[[:digit:]]{1,3}\.[[:digit:]]{1,3}\.[[:digit:]]{1,3}" -o | head -1`
|
||||
echo DHCP success, using IP $dhcpip
|
||||
BLDC_Test_Bench -n -M 2
|
||||
else
|
||||
echo DHCP failed, reverting back to default
|
||||
/sbin/broadcom_reset.sh
|
||||
BLDC_Test_Bench -n -M -2
|
||||
fi
|
||||
else
|
||||
# print wifi status
|
||||
echo "SSID $WIFI_SSID not found"
|
||||
fi
|
||||
fi
|
||||
ifconfig > /data/ftp/internal_000/scripts/MSG_latest_ifconfig
|
||||
|
||||
# Telnet & adb
|
||||
echo "Starting telnet & adb" | ulogger -t "NetworkUSB" -p I
|
||||
if [ "$START_TELNET" -gt "0" ]
|
||||
then
|
||||
/usr/sbin/telnetd -l /bin/login.sh
|
||||
fi
|
||||
if [ "$START_ADB" -gt "0" ]
|
||||
then
|
||||
/usr/bin/pstart adbd
|
||||
fi
|
||||
if [ "$START_PPRZ" -gt "0" ]
|
||||
then
|
||||
if [ -r /data/ftp/internal_000/paparazzi/ap.elf ]; then
|
||||
/data/ftp/internal_000/paparazzi/ap.elf > /dev/null 2>&1 &
|
||||
fi
|
||||
fi
|
||||
@@ -0,0 +1,8 @@
|
||||
# Config file for PPRZ init script
|
||||
START_PPRZ=0
|
||||
START_TELNET=1
|
||||
START_ADB=0
|
||||
JOIN_WIFI=1
|
||||
WIFI_SSID=huphub
|
||||
WIFI_AMODE=none
|
||||
WIFI_KEY=
|
||||
Reference in New Issue
Block a user