3333start_headunit ()
3434{
3535 rm -f /tmp/root/headunit-wireless.status
36- sed -i ' s."wifiTransport": true."wifiTransport": false.g' /tmp/root/headunit.json
3736 taskset 0xFFFFFFFF " ${SCRIPTPATH} /headunit" " $@ " >> ${LOGPATH} 2>&1 &
3837 sleep 2
3938 touch /tmp/root/headunit.status
@@ -42,25 +41,6 @@ start_headunit()
4241 echo " ====================" >> ${LOGPATH}
4342}
4443
45- start_AAwireless ()
46- {
47- rm -f /tmp/root/headunit.status
48- sed -i ' s."wifiTransport": false."wifiTransport": true.g' /tmp/root/headunit.json
49- PHONE_IP_ADDRESS=$1
50- shift
51- if [ ! -z $PHONE_IP_ADDRESS ]; then
52- sed -i " s/\" phoneIpAddress\" : \" .[^\" ]*\" /\" phoneIpAddress\" : \" $PHONE_IP_ADDRESS \" /g" /tmp/root/headunit.json
53- fi
54- sleep 2
55- echo " Phone IP: $PHONE_IP_ADDRESS " >> ${LOGPATH}
56- taskset 0xFFFFFFFF " ${SCRIPTPATH} /headunit" " $@ " >> ${LOGPATH} 2>&1 &
57- sleep 2
58- touch /tmp/root/headunit-wireless.status
59- echo " === headunit-wifi ===" >> ${LOGPATH}
60- cat /tmp/root/headunit.json >> ${LOGPATH}
61- echo " ====================" >> ${LOGPATH}
62- }
63-
6444iptables -A INPUT -p tcp --dport 30515 -m state --state NEW,ESTABLISHED -j ACCEPT
6545
6646rm -f /tmp/root/headunit.status /tmp/root/headunit-wireless.status
@@ -74,7 +54,6 @@ start_headunit
7454# loop forever. every 5 seconds,
7555while true
7656do
77- PHONE_IP_ADDRESS=` netstat -rn| awk ' $2~/192\.168\.43\.[0-9]{1,3}/ {print $2}' `
7857
7958 if [ -e /tmp/root/usb_connect ]; then
8059 USBCHECK=1
8463 # echo "USB detach" >> ${LOGPATH}
8564 fi
8665
87- if [ ! -z $PHONE_IP_ADDRESS ] && [ $USBCHECK == 0 ]; then
88- if [ -e /tmp/root/headunit.status ]; then
89- killall -q headunit
90- fi
91-
92- if ! [ -e /tmp/root/headunit-wireless.status ]; then
93- echo " WLAN Mode" >> ${LOGPATH}
94- echo " Start Headunit (WiFi Mode)"
95- echo " Phone IP: $PHONE_IP_ADDRESS "
96- start_AAwireless $PHONE_IP_ADDRESS
97- fi
98-
99- else
10066 # echo "USB Mode" >> ${LOGPATH}
10167 check_headunit=` ps| grep ' bin/headunit' | grep -v wrapper| grep -v grep| wc -l| awk ' {print $1}' `
10268 # echo "check_headunit = $check_headunit" >> ${LOGPATH}
10369
10470 [ $check_headunit -eq 0 ] && rm -f /tmp/root/headunit-wireless.status /tmp/root/headunit.status
10571
106- if [ -e /tmp/root/headunit-wireless.status ]; then
107- killall -q headunit
108- fi
10972 if ! [ -e /tmp/root/headunit.status ]; then
11073 echo " Start Headunit (USB Mode)"
11174 echo " Start USB" >> ${LOGPATH}
11275 start_headunit
11376 fi
114- fi
11577
11678 RAND=` expr $RANDOM % 5 + 3`
11779 # echo "go sleep $RAND"
0 commit comments