#!/bin/sh # this assumes you've used bluetooth_tether_setup and that the # service name is the one in the parameter here: svc="vzw" # # What we're going to do is... # if not bound bind # if bound and closed, release and bind # if bound and open, dial # config=`grep $svc /etc/wvdial.conf` if [ -z "$config" ]; then echo "This procedure is only meant to be used if you've used" echo "the $0_setup procedure first." echo " " echo "To use this, setup /etc/wvdial.conf, /etc/bluetooth/rfcomm.conf" echo "and hcid.conf... and then edit the \"svc\" variable in $0..." exit fi stat=`rfcomm -a` if [ -z "$stat" ]; then stat=`rfcomm bind` if [ ! -z "$stat" ]; then echo "Unable to bind rfcomm. Status was $stat." exit fi fi stat=`rfcomm -a` if [ -z "$stat" ]; then echo "We should be bound but we are not." exit fi stat=`rfcomm -a | grep hannel\ 4 | awk -F4 '{print $2}' | sed -e "s/ //g"` if [ -z "$stat" ]; then echo "Invalid status received from rfcomm -a..." exit fi if [ "$stat" = "closed" ]; then stat=`rfcomm release rfcomm0` if [ ! -z "$stat" ]; then echo "Tried to release but could not: $stat" exit fi stat=`rfcomm bind rfcomm0` if [ ! -z "$stat" ]; then echo "I released it but could not re-bind: $stat" exit fi fi # # Have to reacquire stat because we could have overwritten it with the # release command... stat=`rfcomm -a | grep hannel\ 4 | awk -F4 '{print $2}' | sed -e "s/ //g"` if [ "$stat" = "clean" ]; then echo "Dialing... use ^C to disconnect." wvdial $svc exit else echo "After all that and still no good binding: $stat" fi exit