Bluez 5.46 and Personal Area Network PAN connectivity with RPI3
For all purposes PAN connection should work with a lot of revisions of Bluez. This is really focused on 5.46 but the changes to get PAN connection from 5.23 should still work.
#Check the version of your software first;
bluetoothctl -v
5.46
Paring serves multiple purposes;
1.Being able to connect by PAN with established services.
In order for PAN to become an option, your smart phone must have Hot Spot for bluetooth enabled.
To do it properly for a PAN connection to an iPhone;
a. Turn on “hotspot” on your iPhone
b. Ensure its only set to bluetooth and USB.
c. Begin the Pair process from the linux side.
pi@billspi3:/usr/src $ bluetoothctl
[NEW] Controller B8:27:EB:1E:EF:45 billspi3 [default]
[NEW] Device 64:A5:C3:DC:F7:1C Bills iPhone6+
Agent registered
[bluetooth]# remove 64:A5:C3:DC:F7:1C
[DEL] Device 64:A5:C3:DC:F7:1C Bills iPhone6+
Device has been removed
[bluetooth]# pairable on
Changing pairable on succeeded
[bluetooth]# scan on
Discovery started
[CHG] Controller B8:27:EB:1E:EF:45 Discovering: yes
[NEW] Device 64:A5:C3:DC:F7:1C Bills iPhone6+
[bluetooth]# scan off
[CHG] Controller B8:27:EB:1E:EF:45 Discovering: no
Discovery stopped
[bluetooth]# trust 64:A5:C3:DC:F7:1C
[CHG] Device 64:A5:C3:DC:F7:1C Trusted: yes
Changing 64:A5:C3:DC:F7:1C trust succeeded
[bluetooth]# pair 64:A5:C3:DC:F7:1C
Attempting to pair with 64:A5:C3:DC:F7:1C
[CHG] Device 64:A5:C3:DC:F7:1C Connected: yes
Request confirmation
[agent] Confirm passkey 675499 (yes/no): yes
[CHG] Device 64:A5:C3:DC:F7:1C Modalias: bluetooth:v004Cp6F01d0A30
[CHG] Device 64:A5:C3:DC:F7:1C UUIDs: 00000000-deca-fade-deca-deafdecacafe
[CHG] Device 64:A5:C3:DC:F7:1C UUIDs: 00001000-0000-1000-8000-00805f9b34fb
[CHG] Device 64:A5:C3:DC:F7:1C UUIDs: 0000110a-0000-1000-8000-00805f9b34fb
[CHG] Device 64:A5:C3:DC:F7:1C UUIDs: 0000110c-0000-1000-8000-00805f9b34fb
[CHG] Device 64:A5:C3:DC:F7:1C UUIDs: 0000110e-0000-1000-8000-00805f9b34fb
[CHG] Device 64:A5:C3:DC:F7:1C UUIDs: 00001116-0000-1000-8000-00805f9b34fb
[CHG] Device 64:A5:C3:DC:F7:1C UUIDs: 0000111f-0000-1000-8000-00805f9b34fb
[CHG] Device 64:A5:C3:DC:F7:1C UUIDs: 0000112f-0000-1000-8000-00805f9b34fb
[CHG] Device 64:A5:C3:DC:F7:1C UUIDs: 00001132-0000-1000-8000-00805f9b34fb
[CHG] Device 64:A5:C3:DC:F7:1C UUIDs: 00001200-0000-1000-8000-00805f9b34fb
[CHG] Device 64:A5:C3:DC:F7:1C ServicesResolved: yes
[CHG] Device 64:A5:C3:DC:F7:1C Paired: yes
Pairing successful
[CHG] Device 64:A5:C3:DC:F7:1C ServicesResolved: no
[CHG] Device 64:A5:C3:DC:F7:1C Connected: no
[bluetooth]#
Once Paired this way, you can use PAN to connect;
Bluez makes extensive use of Dbus, so the best way to get that connection rolling is to send this NAP command thru the dbus at the proper device.
Connect;
sudo dbus-send --system --print-reply --type=method_call --dest=org.bluez /org/bluez/hci0/dev_64_A5_C3_DC_F7_1C org.bluez.Network1.Connect string:"nap"
Successful Output;
method return sender=:1.28 -> dest=:1.45 reply_serial=2
string “bnep0”
Disconnect;
sudo dbus-send –system –print-reply –type=method_call –dest=org.bluez /org/bluez/hci0/dev_64_A5_C3_DC_F7_1C org.bluez.Network1.Disconnect
You can form a second PAN connection from your PC/MAC.
Note: PAN allows multiple devices to connect to it.
After about 1 minute for the connection to settle, you can then ssh to the PI so long as you are on the same PAN connection.
Turn off all other connections temporarily;
sudo ifdown wlan0
sudo ifdown eth0
sudo ifconfig wlan0 down
sudo ifconfig eth0 down
NOTE: when you turn off WLAN0 or ETH0, and you were SSH’d, expect large long delays and disconnect. Simply reconnect after waiting about 1 minute for the PAN connection to settle.
Raspbian on the Pi3 comes setup with mDNS so you simply just look for it by <name>.local
Williams-iMac:Downloads speccy67$ ping billspi3.local
PING billspi3.local (172.20.10.4): 56 data bytes
64 bytes from 172.20.10.4: icmp_seq=0 ttl=64 time=26.763 ms
64 bytes from 172.20.10.4: icmp_seq=1 ttl=64 time=77.890 ms
64 bytes from 172.20.10.4: icmp_seq=2 ttl=64 time=31.794 ms
64 bytes from 172.20.10.4: icmp_seq=3 ttl=64 time=31.039 ms
Introspecting the Dbus to find the Network Device Name;
You can use d-feet and inspect the /org/bluez/hci0 interface to find the PAN device.
sudo dbus-send --system --print-reply --type=method_call --dest=org.bluez /org/bluez/hci0 org.freedesktop.Dbus.Introspectable.Introspect
sudo dbus-send –system –print-reply –type=method_call –dest=org.bluez /org/bluez/hci0 org.freedesktop.Dbus.Introspectable.Introspect | grep “node name”
</method></interface><node name=”dev_64_A5_C3_DC_F7_1C”/></node>”
To compose your dbus send command;
1. sudo dbus-send --system --print-reply --type=method_call --dest=org.bluez /org/bluez/hci0
2. /dev_64_A5_C3_DC_F7_1C
3. org.bluez.Network1.Connect string:"nap"
results;
sudo dbus-send –system –print-reply –type=method_call –dest=org.bluez /org/bluez/hci0/dev_64_A5_C3_DC_F7_1C org.bluez.Network1.Connect string:”nap”
Measuring the speed and time
LTE 2 bars; 13 feet away from RPI3, 1 foot next to OSX
pi@billspi3:~ $
time wget http://www.blog.willandnora.com/downloads/gatt-service
--2017-08-05 19:16:42-- http://www.blog.willandnora.com/downloads/gatt-service
Resolving www.blog.willandnora.com (www.blog.willandnora.com)... 208.113.170.218
Connecting to www.blog.willandnora.com (www.blog.willandnora.com)|208.113.170.218|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 221880 (217K)
Saving to: ‘gatt-service’
gatt-service 100%[====================================================================================>] 216.68K 62.7KB/s in 3.5s
2017-08-05 19:16:46 (62.7 KB/s) – ‘gatt-service’ saved [221880/221880]
real 0m4.459s
user 0m0.040s
sys 0m0.020s
Splitting the difference; iPhone between both devices
LTE 2 bars; 6 feet from OSX, 7 feet from RPI3.
pi@billspi3:~ $ time wget http://www.blog.willandnora.com/downloads/bluez-5.46-deb-src.tar.gz
–2017-08-05 19:18:55– http://www.blog.willandnora.com/downloads/bluez-5.46-deb-src.tar.gz
Resolving www.blog.willandnora.com (www.blog.willandnora.com)… 208.113.170.218
Connecting to www.blog.willandnora.com (www.blog.willandnora.com)|208.113.170.218|:80… connected.
HTTP request sent, awaiting response… 200 OK
Length: 2369419 (2.3M) [application/x-tar]
Saving to: ‘bluez-5.46-deb-src.tar.gz’
bluez-5.46-deb-src.tar.gz 100%[====================================================================================>] 2.26M 84.9KB/s in 27s
2017-08-05 19:19:23 (84.3 KB/s) – ‘bluez-5.46-deb-src.tar.gz’ saved [2369419/2369419]
real 0m27.911s
user 0m0.050s
sys 0m0.140s
Hi,
I was able to pair to 70:BB:E9:1B:C1:64 usign bluetootctl commands given by this guide.
But I am trying the same I i am getting the following error while sending the dbus-send command
dbus-send –system –print-reply –type=method_call –dest=org.bluez /org/bluez/hci0/dev_70_BB_E9_1B_C1_64 org.bluez.Network1.Connect string:”nap”
Error org.freedesktop.DBus.Error.UnknownMethod: Method “Connect” with signature “s” on interface “org.bluez.Network1” doesn’t exist
Kindly help me. My mail id is lsundararajan@vocera.com