Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Multipeer Bluetooth Connection to non-iOS device

I am currently trying to connect a Raspberry Pi and an iOS device via Bluetooth. Using BTLE and the CBCentralManager I am able to do this - I can connect to the Pi and share data.

My problem is that for my purpose I need the devices to have an IP - which, as far as I know, is only possible using a PAN (Personal Area Network) bluetooth profile. iOS does support this with the new Multipeer Connectivity Framework and it works when connecting two iOS devices, one using MCNearbyServiceBrowser and the other using MCNearbyServiceAdvertiser. After the connection was made both devices have a network interface with an IP. But now I have to get the Rasperry Pi into that scenario - and I cannot find any way to make the Pi join the PAN.

Does anyone have any clues if this is somehow possible, where to start looking, if there is a good explanation about the communication in a PAN or something similar? Could there maybe even be a framework that does something like that? I am happy for any leads and advices.

like image 236
BlackWolf Avatar asked Mar 18 '14 11:03

BlackWolf


1 Answers

The Multipeer Connectivity Framework probably is probably based on a proprietary protocol as I have nowhere seen that it implements PAN. It's only similar to it. As you mention, the list of supported profiles contains PAN as well with the following note:

Depending on the Bluetooth accessory, you may experience slight variations in profile functionality. These variations are governed by the accessory manufacturer, not the iOS device.

So in theory PAN is supported as is, and you should be able to connect with an arbitrary device that supports this profile. I connected my Android phone to my iPhone with the Personal Hotspot on the iPhone and the Android could use the shared internet connection without any issues.

I found the Raspberry Pi Bluetooth iPhone Tethering tutorial that seems to describe exactly what you are trying to do. For future reference I copy the steps here:

Install the bluetooth packages

sudo aptitude install bluetooth bluez-utils bluez-compat

Pair the devices, this is the tricky part

pi@raspberrypi ~ $ hcitool scan
Scanning ...
    18:34:51:55:B0:D8   Fanboy ][
pi@raspberrypi ~ $
pi@raspberrypi ~ $ grep KeyboardDisplay /usr/bin/bluez-simple-agent 
    capability = "KeyboardDisplay"
pi@raspberrypi ~ $ sudo perl -i -pe 's/KeyboardDisplay/DisplayYesNo/' /usr/bin/bluez-simple-agent
pi@raspberrypi ~ $ grep DisplayYesNo /usr/bin/bluez-simple-agent
    capability = "DisplayYesNo"
pi@raspberrypi ~ $ 
pi@raspberrypi ~ $ sudo bluez-simple-agent hci0 18:34:51:55:B0:D8
RequestConfirmation (/org/bluez/18868/hci0/dev_18_34_51_55_B0_D8, 160178)
Confirm passkey (yes/no): yes
Release
New device (/org/bluez/18868/hci0/dev_18_34_51_55_B0_D8)
pi@raspberrypi ~ $
pi@raspberrypi ~ $ sudo bluez-test-device trusted 18:34:51:55:B0:D8 yes

Turn on the Personal Hotspot

pi@raspberrypi ~ $ echo "echo 'iface bnep0 inet dhcp' >> /etc/network/interfaces" | sudo sh
pi@raspberrypi ~ 

$ sudo pand -c 18:34:51:55:B0:D8 -role PANU --persist 30

Enjoy

pi@raspberrypi ~ $ ifconfig bnep0
bnep0     Link encap:Ethernet  HWaddr e0:91:53:61:0f:74  
          inet addr:172.20.10.10  Bcast:172.20.10.15  Mask:255.255.255.240
      UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
      RX packets:14 errors:0 dropped:0 overruns:0 frame:0
      TX packets:7 errors:0 dropped:0 overruns:0 carrier:0
      collisions:0 txqueuelen:1000 
      RX bytes:4426 (4.3 KiB)  TX bytes:802 (802.0 B)

All credits go to http://www.wolfteck.com/ for providing these detailed instructions.

like image 72
allprog Avatar answered Sep 19 '22 06:09

allprog