-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy paths60v3-tether
68 lines (59 loc) · 1.63 KB
/
s60v3-tether
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
59
60
61
62
63
64
65
66
67
68
#!/bin/bash
# Bluetooth tethering for s60v3 phones in Debian 12 (bookworm)
rfc_channel=0 # choose rfcomm channel to be used
# (it must be the same as in /etc/wvdial.conf)
devrfcomm="/dev/rfcomm$rfc_channel"
echo "Using $devrfcomm"
if [ $# -lt 1 ]; then
echo "Give as a parameter the bluetooth name of the (paired) phone you wish to tether"; exit
fi
function deactivate_bt() {
tmp=$(ls $devrfcomm 2> /dev/null);
if [ -z "$tmp" ]; then
echo "Deactivating bluetooth"
sudo rfkill block bluetooth
fi
}
function ctrl_c() {
echo "Releasing $devrfcomm"
sudo rfcomm release $rfc_channel
echo "Restarting NetworkManager"
sudo service NetworkManager start
deactivate_bt
exit
}
function ctrl_c0() {
echo ""
echo "Restarting NetworkManager"
sudo service NetworkManager start
deactivate_bt
exit
}
echo -n "Getting bluetooth address of $1: "
#tmp=$(bluetoothctl paired-devices|grep $1)
tmp=$(bluetoothctl devices Paired|grep $1)
tmp=${tmp#Device }
if [ "$tmp" == "" ]
then
echo "device not paired"
exit
fi
bt_address=${tmp%" $1"}
echo $bt_address
echo "Stopping NetworkManager"
sudo service NetworkManager stop
trap ctrl_c0 SIGINT
echo "Activating bluetooth"
sudo rfkill unblock bluetooth
echo -n "Getting dial-up channel: "
bt_channel=""
while [ "$bt_channel" == "" ]; do
tmp=$(sdptool search --bdaddr "$bt_address" DUN|grep Channel)
bt_channel=${tmp#*: }
done
echo $bt_channel
echo "Binding rfcomm $rfc_channel to $bt_address/$bt_channel"
sudo rfcomm bind "$rfc_channel" "$bt_address" "$bt_channel"
echo "Tethering $1 (CTRl-C to finish)"
trap ctrl_c SIGINT
sudo wvdial bluetooth