ShunFan Yang
Posts: 2
Joined: Thu Sep 20, 2018 7:29 am

Sharing internet by Bluetooth

Thu Sep 20, 2018 8:11 am

Hello all,
I would like to use iPhone to share the internet to raspberry pi via bluetooth. I google some information and try it, but it don't apply.
Does anyone have experience for this? Thanks a lot.

My device is listed as follow:
Raspberry Pi 3B
OS: Raspbian 2018-06-27
iphone 6s plus

k-pi
Posts: 646
Joined: Sun Feb 12, 2017 1:46 pm
Location: Upper Hale, Surrey, UK.

Re: Sharing internet by Bluetooth

Thu Sep 20, 2018 9:28 am

Google 'tethering' - I think that's what you're looking for.

fruitoftheloom
Posts: 17838
Joined: Tue Mar 25, 2014 12:40 pm

Re: Sharing internet by Bluetooth

Thu Sep 20, 2018 9:49 am

Regards Apple iOS Tethering see:

https://support.apple.com/en-gb/HT204023


Regards RPi Bluetooth you need to setup a PAN (Personal Area Network), unfortunately have not yet found a good guide for Raspbian Stretch...
Adieu

Federico
Posts: 2
Joined: Mon Jul 16, 2012 9:10 am

Re: Sharing internet by Bluetooth

Wed Dec 05, 2018 1:40 am

Steps (11) to be done to automatically enable RPi Bluetooth connection with my phone using a static IP address.

On my Raspberry is installed the Raspbian release that can be known running from its terminal:

[email protected] ~ $cat /etc/os-release

and in this case is the last one ( Dec 2018)

VERSION = '9 (stretch )'

Precondition - Bluetooth pairing:
0- pair your raspberry pi with your mobile device

Steps from 1 to 5 are described ( and reported here) in README.md file in github repository at point 1-

1-
from :
https://github.com/WayneKeenan/Raspberr ... utoConnect

download this files:
bt-pan
check-and-connect-bt-pan.sh

2-
After cloning this repository copy the 2 scripts bt-pan and check-and-connect-bt-pan.sh into ~pi/bin
(create the folder if necessary)
and from the pi terminal change theirs attribute :
[email protected] ~ $chmod +x /bin/bt-pan
[email protected] ~ $chmod +x /bin/check-and-connect-bt-pan.sh


3-
Find your Mac/PC /Mobile Device MAC Address
We need the Bluetooth MAC address of your Mac/PC or Mobile Device that is providing the Bluetooth network.

On the Pi run hcitool scan:

[email protected] ~ $hcitool scan
Scanning ...
F4:5C:89:8B:10:E8 Wayne’s

4-
Edit check-and-connect-bt-pan.sh and replace the exisitng MAC address assigned to BT_MAC_ADDR with the one found by hcitool scan for your computer.

BT_MAC_ADDR=<Your MAC address>

5- (***)
ref https://www.raspberrypi.org/documentati ... ge/cron.md
CRON job
In order for the Pi to automatically (re)connect create a cron job to run a script every minute.

Type:

[email protected] ~ $crontab -e
Add this line:

* * * * * /home/pi/bin/check-and-connect-bt-pan.sh
Then save the file.


6- Activate on your mobile device the Bluetooth tethering entering in Setting/Tethering and Mobile hotspot

7- from the Raspbian terminal run :

[email protected] ~ $/home/pi/bin/check-and-connect-bt-pan.sh

to enable the bluetooth connection.


8- With a static(****) IP, you’ll be able to use the same IP address every time you connect to your Pi. Run from the terminal :
[email protected] ~ $ifconfig bnep0
and take note of Raspberry IP address that is like 192.168.44.49 (*)that will be used for static ip_address in dhcpcd.conf file

9- Run from the terminal :
[email protected] ~ $route -en

and take note of gateway IP address that is like 192.168.44.1 It will be used for the static routers and enter

[email protected] ~ cat /etc/resolv.conf

at the command prompt to find the domain name servers that will be used for the static domain_name_servers
in dhcpcd.conf file

10- from the Raspbian terminal run :
[email protected] ~ $sudo leafpad /etc/dhcpcd.conf
and add (at the end) the following 4 lines and then save the file

interface bnep0
static ip_address=192.168.44.49/24
static routers=192.168.44.1
static domain_name_servers=192.168.44.1

11- Reboot your Pi and verify the automatic Bluetooth connection with your mobile device

(*) 192.168.44.<x> where x can be your choice :
2<= x <= 254

(**) the same procedure can be used for USB tethering substituting bnep0 connection with usb0 connection .

interface usb0
static ip_address=192.168.42.39/24
static routers=192.168.42.129
static domain_name_servers=192.168.42.129

(***) As simple solution ( 5-) , to test the process, you can place the following script command in /etc/rc.local file before the exit(0) row

./home/pi/bin/check-and-connect-bt-pan.sh &

(****)
By default the Pi is configured with a dynamic IP address. To assign it a static IP address, you need to add your static IP, default gateway IP, and domain name servers to the dhcpcd.conf file.

ericcooper
Posts: 112
Joined: Sat Apr 08, 2017 6:23 pm

Re: Sharing internet by Bluetooth

Wed Dec 05, 2018 2:04 am

network-manager knows how to setup Bluetooth (PAN) network connections. Just discover, pair, and trust your phone from your Pi, using bluetoothctl, and if your phone's BT hotspot is enabled, it should show up as one of network-manager's connection options.

Return to “Networking and servers”