nisargjhaveri / WirelessAndroidAutoDongle

Use Wireless Android Auto with a car that supports only wired Android Auto using a Raspberry Pi.
MIT License
658 stars 71 forks source link

A temporary workaround for start time of the headunit and reconnect of BT/wifi #36

Closed Ioniq3 closed 8 months ago

Ioniq3 commented 8 months ago

First of all, Nisarg thanks, thanks a lot for your work. Finally I get that my hunday can connect android auto and the usb memory thanks to the MTP profile, as the car only have one usb port. No other device in the market allow me this.

I have a crude external workaroud for these issue, the initial connection and reconecttion until a more sophisticated solution is available. This consist in two families of script, the (1) is for wait and restart until headunit and mobile is full available to connect (2) is for reconnect after wifi or bluetooth loss. In both cases this scripts avoid the restart or reconnect of the usb dongle (raspberry pi zero w in my case)

The four files need chmod +x for they will convert in executables

-------------------------- /usr/bin/checkaa1 :

!/bin/sh

b='00:00:00' c=0

while true do

sleep 1

a=cat /var/lib/misc/messages | grep 'buildroot user.info aawgd' | awk '{print $3}' | tail -1 | tr -d '\n'

if [[ $a = $b ]] then let c=c+10 sleep 10 else let c=0 fi

echo $a $b $c

b=$a

if [[ $c -eq '30' ]] then /etc/init.d/S92usb_gadget restart /etc/init.d/S93aawgd restart let c=0 fi

done

--------------------- /usr/bin/checkaa2

!/bin/sh

while true do a=cat /var/lib/misc/messages | tail -50 | grep '39 bytes' | wc -l

if [[ $a = '50' ]] then

/etc/init.d/S92usb_gadget restart

/etc/init.d/S93aawgd restart fi

sleep 20 done

-------------------------------- /etc/init.d/S94checkaa1

!/bin/sh

DAEMON="checkaa1" PIDFILE="/var/run/$DAEMON.pid"

RETVAL=0

case "$1" in start) printf "Starting $DAEMON: " start-stop-daemon -S -b -q -m -p "$PIDFILE" -x "/usr/bin/$DAEMON" RETVAL=$? [ $RETVAL = 0 ] && echo "OK" || echo "FAIL" ;; stop) printf "Stopping $DAEMON: " start-stop-daemon -K -q -p "$PIDFILE" RETVAL=$? [ $RETVAL = 0 ] && echo "OK" || echo "FAIL" ;; restart) $0 stop $0 start ;; *) echo "Usage: $0 {start|stop}" ;; esac

exit $RETVAL

----------------------- /etc/init.d/S94checkaa2

!/bin/sh

DAEMON="checkaa2" PIDFILE="/var/run/$DAEMON.pid"

RETVAL=0

case "$1" in start) printf "Starting $DAEMON: " start-stop-daemon -S -b -q -m -p "$PIDFILE" -x "/usr/bin/$DAEMON" RETVAL=$? [ $RETVAL = 0 ] && echo "OK" || echo "FAIL" ;; stop) printf "Stopping $DAEMON: " start-stop-daemon -K -q -p "$PIDFILE" RETVAL=$? [ $RETVAL = 0 ] && echo "OK" || echo "FAIL" ;; restart) $0 stop $0 start ;; *) echo "Usage: $0 {start|stop}" ;; esac

exit $RETVAL

Ioniq3 commented 8 months ago

files.zip

checkaa in /usr/bin/ S94checkaa in /etc/init.d/

chmod +x # for the four files