summaryrefslogtreecommitdiff
path: root/recipes-kernel/rs9113/files/immunity/tworadio.sh
blob: 1ce364045454f80bf92364a06d8b31d6c04b62d4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
#!/bin/bash
#
# Environmental variables:
# BTADDR     Bluetooth MAC address
# BTCHAN     Bluetooth Channel
# WIFIURL    WiFi test Address
# WIFIFILE   WiFi
# WPA_CONFIG Config file for wpa_supplicant.
#
BTPIDFILE=/opt/immunity/btpid
PGRP=$(ps --no-headings -o pgrp $$ | sed -r 's/[[:space:]]//g')
trap "kill -15 -${PGRP}" EXIT
HOME=/home/root
INTERFACES=/etc/network/interfaces

if [[ $1 == wifisetup ]] ; then
	wifisetup=true
else
	wifisetup=false
fi
.  /etc/default/rs9113

if [[ $COEX_MODE != 5 ]] ; then
  sed -i 's/^COEX_MODE=[0-9]*/COEX_MODE=5/' /etc/default/rs9113
fi
if ! egrep 'auto[[:space:]]+wifi0' $INTERFACES ; then
  echo '# Added for wifi testing -- tworadio.sh' >> $INTERFACES
  echo 'auto wifi0' >> $INTERFACES
fi

if ! egrep 'iface[[:space:]]+wifi0' $INTERFACES ; then
  echo '# Added for wifi testing -- tworadio.sh' >> $INTERFACES
  echo 'iface wifi0 inet dhcp' >> $INTERFACES
fi

/etc/init.d/rs9113 restart
rm -f btpid
sleep 5

echo 'Starting bluetooth -- this may take a while'
if ! $wifisetup ; then
	/opt/immunity/bluetoothXfer.sh $BTADDR $BTCHAN &
fi
BTPID=$!
while [[ $BTPID != $(cat $BTPIDFILE 2>/dev/null) ]] ; do
	sleep 1
done
echo
echo 'Bluetooth set up, now set up WiFi'
if $wifisetup ; then
        /opt/immunity/wifiXfer.sh wifisetup
else
	/opt/immunity/wifiXfer.sh "$WIFIURL" "$WIFIFILE" &
fi
WIFIPID=$!
wait $BTPID
wait $WIFIPID