Basil_R
Posts: 16
Joined: Sun Oct 06, 2013 9:38 pm

Bluetooth Access Point

Sun Oct 06, 2013 9:49 pm

I have just used the Miracast feature on my Android tablet and discovered i lose Wi-Fi to my LAN when i do. A logical workaround would be to use my Pi as a Bluetooth Access Point to reconnect to the LAN, and back out onto the internet. Looking at various Pi forums i haven't found a precise description of whether this is possible or not. If it is an established application i would appreciate a steer in the right direction.

ykasidit
Posts: 21
Joined: Sun Jul 14, 2013 10:58 pm
Location: Thailand
Contact: Website

Re: Bluetooth Access Point

Sun Oct 20, 2013 9:08 am

I'm happy to see someone interested in a Bluetooth access point! - check this out: http://www.clearevo.com/ecodroidlink

Basil_R
Posts: 16
Joined: Sun Oct 06, 2013 9:38 pm

Re: Bluetooth Access Point

Sun Oct 20, 2013 12:15 pm

Many thanks ykasidit, that appears to be exactly what I need. As I have all the hardware (except the BT dongle), and I don't live in the USA, are the configuration instructions available? And would the Access point setup work on Raspbian Wheezy?

ykasidit
Posts: 21
Joined: Sun Jul 14, 2013 10:58 pm
Location: Thailand
Contact: Website

Re: Bluetooth Access Point

Tue Oct 22, 2013 1:08 am

Dear Basil_R,

Yes - please try follow this very detailed instruction/howto/tutorial at: http://www.hkepc.com/forum/viewthread.php?tid=1710030 (full credit to the poster named "howdy"). I did try it on a Raspbian many months back and it worked well.

A few notes I'd like to add:
1. Some bluetooth dongles don't work well - I had success with a Bluetooth 4.0 USB Dongle based on Cambridge Silicon Radio. (Try lsusb and it should show Cambridge Silicon Radio).
2. Make sure your power supply really does provide enough power - although Bluetooth dongles probably uses much less power than WIFI dongles - let's make sure we have enough amperes. I recommend/use the RS Electronics power supply for Raspberry Pi.
3. As already shown in the tutorial linked above - do not have a line to setup dhcp for eth0 otherwise it could cause strange behavior - only set ip/dhcp for the bridge as explained in http://www.linuxfoundation.org/collabor ... dge_device
4. If "hcitool dev" doesn't show a device - do a " sudo hciconfig -a hci0 up" then try again.
5. To make your Pi's Bluetooth discoverable - use "sudo hciconfig -a hci0 piscan".
6. Most linux Bluetooth NAP tutorials on the internet are outdated and won't work with the new BlueZ driver/stack installed on current Raspbian or other GNU/Linux distros - I personally avoid the bluetooth.conf and main.conf settings as they don't seem to work too - use hciconfig as shown above instead - it works.

All the best!

Best Sincere Regards,
Kasidit

Basil_R
Posts: 16
Joined: Sun Oct 06, 2013 9:38 pm

Re: Bluetooth Access Point

Sat Nov 30, 2013 5:43 pm

ykasidit

Right it has taken me a while to get back onto this project, and I have been following the instructions in the link http://www.hkepc.com/forum/viewthread.php?tid=1710030. However I have hit the buffers with the line 5 in test-nap!

import dbus

I get the error "No module named dbus". Things I've done to try & solve this include:-

sudo apt-get install python-dbus, but I have the newest version apparently.
sudo services dbus start, and I receive the message that it is already running

from the research I've done on Google this doesn't appear to be a very common problem, so I am struggling with other ideas. Being a Noob doesn't make things any easier but I am learning fast. So any suggestions (in reasonably simple English!) would be appreciated.

Regards

Baz

ykasidit
Posts: 21
Joined: Sun Jul 14, 2013 10:58 pm
Location: Thailand
Contact: Website

Re: Bluetooth Access Point

Sun Dec 01, 2013 12:45 am

Hello,

I'm not sure about this as I don't face it but lets try:
virtualenv --system-site-packages dbus-venv

as suggested by http://stackoverflow.com/questions/1336 ... virtualenv

User avatar
DougieLawson
Posts: 36331
Joined: Sun Jun 16, 2013 11:19 pm
Location: Basingstoke, UK
Contact: Website Twitter

Re: Bluetooth Access Point

Sun Dec 01, 2013 1:57 am

If you unexpectedly lose WiFi connectivity then check that you've not got ifplugd installed.
sudo apt-get purge ifplugd # that thing is a nuisance
Note: Having anything humorous in your signature is completely banned on this forum. Wear a tin-foil hat and you'll get a ban.

Any DMs sent on Twitter will be answered next month.

This is a doctor free zone.

Basil_R
Posts: 16
Joined: Sun Oct 06, 2013 9:38 pm

Re: Bluetooth Access Point

Thu Dec 05, 2013 9:17 pm

I read over the 'stackoverflow' post following a Google search on the subject and had to confess I didn't understand most of it! I did run:
sudo apt-get install python-virtualenv, and then run the command:
virtualenv --system-site-packages dbus-venv, and I notice the directory dbus-venv created off /home/pi, however this doesn't appear to have solved this problem.

To test the existence of the dbus module I open an Idle 3 Python Shell in a remote VNC viewer and then simply enter 'import dbus' command. The following error message is returned:-

Traceback (most recent call last):
File "<pyshell#2>", line 1, in <module>
import dbus
ImportError: No module named dbus

I used the debugger in the same Idle 3 to test run the 'test-nap' script and it fell over at the same line attempting the import dbus. Probably a daft question but I assume there is no need to include a "path" statement anywhere to tell the script where to find dbus?

User avatar
Douglas6
Posts: 4779
Joined: Sat Mar 16, 2013 5:34 am
Location: Chicago, IL

Re: Bluetooth Access Point

Thu Dec 05, 2013 10:49 pm

Basil_R wrote:I used the debugger in the same Idle 3 to test run the 'test-nap' script and it fell over at the same line attempting the import dbus. Probably a daft question but I assume there is no need to include a "path" statement anywhere to tell the script where to find dbus?
http://www.raspberrypi.org/phpBB3/viewt ... 97#p461897 [EDIT: With appropriate changes for Python 3]

Basil_R
Posts: 16
Joined: Sun Oct 06, 2013 9:38 pm

Re: Bluetooth Access Point

Fri Dec 06, 2013 10:18 pm

Right i've had a look at sys.path and attach contents below, along with the import dbus failure message. Looking at the sys.path entries on the link in your post, the missing ones aren't present in Python 3.2.

Code: Select all

>>> import sys
>>> from pprint import pprint as p
>>> p(sys.path)
['',
 '/home/pi',
 '/usr/bin',
 '/usr/lib/python3.2',
 '/usr/lib/python3.2/plat-linux2',
 '/usr/lib/python3.2/lib-dynload',
 '/usr/local/lib/python3.2/dist-packages',
 '/usr/lib/python3/dist-packages']
>>> import dbus
Traceback (most recent call last):
  File "<pyshell#3>", line 1, in <module>
    import dbus
ImportError: No module named dbus
>>> 

User avatar
Douglas6
Posts: 4779
Joined: Sat Mar 16, 2013 5:34 am
Location: Chicago, IL

Re: Bluetooth Access Point

Sat Dec 07, 2013 9:24 pm

I decided to give this a try, as I thought it would be a good learning experience. It is, but I clearly have a lot more to learn, as I could not get the reverse tethering over bluetooth to work. But I WAS able to get the test-nap.py program to run, using Python 2.7 as included with the latest Raspian. From a fresh install of the 2013-09-25 Wheezy, I checked first to find the Python dbus module:

Code: Select all

$ sudo find / -name dbus
/run/dbus
/var/lib/dbus
/usr/share/doc/dbus
/usr/share/lintian/overrides/dbus
/usr/share/pyshared/dbus
/usr/lib/python2.7/dist-packages/dbus
/usr/lib/python2.6/dist-packages/dbus
/usr/lib/cups/notifier/dbus
/usr/include/dbus-1.0/dbus
/etc/default/dbus
/etc/init.d/dbus
So it was right where it should be in /usr/lib/python2.7/dist-packages and I had no problem importing and using it in my Python script. SO....you might try with a new Raspian install and Python2.7, OR you'll need to figure out how to install the Python dbus module for Python3.2.

I'm off to write an epic post on my unsuccessful experience with bluetooth reverse tethering, perhaps it will be useful to you, or me, or others, although there seems to be little interest in getting a tablet/phone to tether to a Linux NAP; typically it's the other way 'round.

Basil_R
Posts: 16
Joined: Sun Oct 06, 2013 9:38 pm

Re: Bluetooth Access Point

Sun Dec 08, 2013 9:40 pm

I started this post because there appeared to be a real need to find a way round Miracast hogging the wifi of a tablet. As the uptake of tablets increases and the volume of Miracast TVs & boxes becomes ever larger, using the Pi as a Bluetooth access point seems the ideal workaround. So i will continue to look at a Python 3.2 solution to the dbus issue.

It would be of great value to hear from others with the same requirement, and their attempts to date. The lads here,http://www.clearevo.com/ecodroidlink/ , offer a specific package to do the job, so it ought to be possible to apply it to an existing Pi setup.

ykasidit
Posts: 21
Joined: Sun Jul 14, 2013 10:58 pm
Location: Thailand
Contact: Website

Re: Bluetooth Access Point

Mon Dec 09, 2013 9:16 am

Dear Basil_R,

Let's try Douglas's suggestion - let's try a fresh new Raspbian install and then try the test-nap to see if it passes this dbus issue.

I remember doing it on Raspbian too - let's try this and I'm happy to help - it should be simple once you pass this dbus import issue.

User avatar
Douglas6
Posts: 4779
Joined: Sat Mar 16, 2013 5:34 am
Location: Chicago, IL

Re: Bluetooth Access Point

Tue Dec 10, 2013 2:42 am

After catching a second wind and attacking this again, I think I licked it. In fact I'm typing this on my phone, connected via Bluetooth to a Raspberry Pi access point connected via WiFi to my router and out over the internet.

It's a bit of an awkward process but it works.Gonna see if I can automate some of it and I'll be posting a step-by-step tutorial. It's really not difficult for someone who can follow instructions better than me.

ykasidit
Posts: 21
Joined: Sun Jul 14, 2013 10:58 pm
Location: Thailand
Contact: Website

Re: Bluetooth Access Point

Tue Dec 10, 2013 2:22 pm

Douglas6 wrote:After catching a second wind and attacking this again, I think I licked it. In fact I'm typing this on my phone, connected via Bluetooth to a Raspberry Pi access point connected via WiFi to my router and out over the internet.

It's a bit of an awkward process but it works.Gonna see if I can automate some of it and I'll be posting a step-by-step tutorial. It's really not difficult for someone who can follow instructions better than me.
Congratulations Douglas6! Glad to hear that you got it working and typing that via Bluetooth Internet!

I'm sure that tutorial wasn't too complicated once you have the python-dbus working correctly.

User avatar
Douglas6
Posts: 4779
Joined: Sat Mar 16, 2013 5:34 am
Location: Chicago, IL

Re: Bluetooth Access Point

Thu Dec 12, 2013 9:10 pm

ykasidit wrote:I'm sure that tutorial wasn't too complicated once you have the python-dbus working correctly.
It's not really. Using wlan0 instead of eth0 is a bit different, and also when using Raspian, you'll need to 'sudo apt-get install bridge-utils' yourself.

And here's another tip that would have saved me 30 minutes or so. Don't try this by plugging in two different Bluetooth adapters, one of which looks VERY similar to the Wifi dongle you left lying on the desk. This will NOT work :)

I'm still polishing up a Python daemon that can be used to automate the connections on a headless Pi, and I'll be posting it with some instructions. It's been a great learning experience for network bridging and using d-bus with Bluez

ykasidit
Posts: 21
Joined: Sun Jul 14, 2013 10:58 pm
Location: Thailand
Contact: Website

Re: Bluetooth Access Point

Fri Dec 13, 2013 2:13 am

Douglas6 wrote:
ykasidit wrote:I'm sure that tutorial wasn't too complicated once you have the python-dbus working correctly.
It's not really. Using wlan0 instead of eth0 is a bit different, and also when using Raspian, you'll need to 'sudo apt-get install bridge-utils' yourself.

And here's another tip that would have saved me 30 minutes or so. Don't try this by plugging in two different Bluetooth adapters, one of which looks VERY similar to the Wifi dongle you left lying on the desk. This will NOT work :)

I'm still polishing up a Python daemon that can be used to automate the connections on a headless Pi, and I'll be posting it with some instructions. It's been a great learning experience for network bridging and using d-bus with Bluez
Glad to hear that! :D

ykasidit
Posts: 21
Joined: Sun Jul 14, 2013 10:58 pm
Location: Thailand
Contact: Website

Re: Bluetooth Access Point

Fri Dec 13, 2013 3:10 am

By the way, to continue the discussion of why one would want to use a Bluetooth Access Point... Apart from the miracast use-case suggested by Basil_R, another obvious use-case or benefit of using Bluetooth wireless internet (instead of WIFI) is its lower power-consumption.

In theory, Bluetooth consumes much less power than WIFI - although Bluetooth's *max* transfer speed is much lower than WIFI, but about 2 MBps is quite fast-enough for most use-cases.

In practice, I did a simple battery consumption comparison test (by opening a very long Youtube video from fully charged until phone powers-off) on a Android phone and found that it using Bluetooth would make the phone's battery last about 26% longer (about 80 minutes longer) than using WIFI for the same test. The test results are posted in detail in the link below:
http://www.clearevo.com/ecodroidlink/bl ... onsumption

The Android Youtube test above obviously has a lot of power spent in the phone's screen which would weight down the real power consumption saving ratio, if we use Bluetooth in a headless Pi - the power-saving impact would be even larger.

Therefore, I really think that Bluetooth internet provides a lower-power wireless internet access choice for Raspberry Pis too... so we can have a Raspberry Pi connected to LAN running as a Bluetooth Access Point that provides internet to other Raspberry Pis to use... especially for run-on-battery or solar-powered Pi projects that might need to access internet from outdoors but not too far away. Although I haven't tested using Bluetooth internet from another Pi - here's an interesting Blog post on that to start with:
http://blog.kugelfish.com/2012/10/look- ... tooth.html

maxwed
Posts: 8
Joined: Mon Apr 22, 2013 6:57 am

Re: Bluetooth Access Point

Mon Dec 16, 2013 3:21 am

A couple of months ago I posted a solution for using the PAN profile of bluetooth to be able to use a tablet as screen and input device... here: http://www.raspberrypi.org/phpBB3/viewt ... 36&t=37655

I remember faintly that I too initially had a problem running the nap script, and I had to install the following (in addition to "bluez"), which fixed it:

sudo apt-get install python-gobject

But I think this has nothing to do with dbus.

User avatar
Douglas6
Posts: 4779
Joined: Sat Mar 16, 2013 5:34 am
Location: Chicago, IL

Re: Bluetooth Access Point

Mon Dec 16, 2013 3:48 am

Thanks maxwed. These days, as of raspian 2013-09-25, dbus and gobject both seem to be included with python 2.7, but pand is deprecated at best. It's a moving target for sure.

ykasidit
Posts: 21
Joined: Sun Jul 14, 2013 10:58 pm
Location: Thailand
Contact: Website

Re: Bluetooth Access Point

Mon Dec 16, 2013 5:29 am

maxwed wrote:A couple of months ago I posted a solution for using the PAN profile of bluetooth to be able to use a tablet as screen and input device... here: http://www.raspberrypi.org/phpBB3/viewt ... 36&t=37655

I remember faintly that I too initially had a problem running the nap script, and I had to install the following (in addition to "bluez"), which fixed it:

sudo apt-get install python-gobject

But I think this has nothing to do with dbus.
Thanks for the link to your posts - it's a really great idea to use a tablet to ssh to the Pi via Bluetooth. I went to see the python test-nap code there and posted a humble suggestion (which you guys might have already done) in the test-nap script which I want to share in this thread for those who are following http://www.hkepc.com/forum/viewthread.php?tid=1710030 (which is using essentially the same code from the bluez release sameple/test code) in the test-nap python script - simply add a while loop to the line "time.sleep(1000)" or replace it like:

Code: Select all

while (1):
		time.sleep(30)
... although this is obvious, I'm just suggesting this because when I first tried this - the NAP would quit after sometime and that is the time.sleep(1000).

User avatar
chrisryall
Posts: 155
Joined: Wed Nov 27, 2013 11:45 am
Location: Wirral UK
Contact: Website

Re: Bluetooth Access Point

Tue Dec 17, 2013 9:41 am

This looks very useful. File editing is so much easier on my PC (windows 7) But its internet feed is LAN single point wired, and the room I work in gets feeble router wifi (nor is Pi strong in that dept, according to some posts here)! I have to workaround.

For big file transfers - apt-get updates and site folder clones etc - I have simply moved the cable plug across. Worked fine (fixed IO address) but don't want to do this every 5 minutes during development.

I use Pi headless via a UART cable. File transfer over UART doesn't seem to be an option. Seems the TTY interface hogs it (love to be corrected)! Trying to edit on the Pi itself over that has crashed it requiring an SD re-write.:oops:

So I was thinking to set up a wifi peer-peer link. But at the kit is only feet apart! Bluetooth sounds ideal? Low power another bonus, looking ahead.

Questions please: Can it practically FTP between PC and Pi; and is an internet 'share' (=heaven) possible?

Better to know before I invest in 2 USB dongles! ;) TIA Chris

ykasidit
Posts: 21
Joined: Sun Jul 14, 2013 10:58 pm
Location: Thailand
Contact: Website

Re: Bluetooth Access Point

Tue Dec 17, 2013 9:59 am

chrisryall wrote: Questions please: Can it practically FTP between PC and Pi; and is an internet 'share' (=heaven) possible?

Better to know before I invest in 2 USB dongles! ;) TIA Chris
Hello Chris,

Yes, it the test-nap script (in above tutorial) is actually a BlueZ example to set the Pi as a Bluetooth Access Point. So you can do internet and ftp.

By the way, I'm planning to release my "EcoDroidLink" bluetooth access point "management" python code and setup instructions on github (as GPL) once I have some more time... maybe starting with tutorials for ArchlinuxARM and BlueZ 5.7 manual compiling as used in my current system... (the current code doesn't run on my ubuntu computer with BlueZ... it likely needs some work to make compatible with the Raspbian releases...)

Although this sounds interesting, I've recently tested Bluetooth on Android Kitkat (Nexus 5) and it's not so stable both for tethering (giving mobile internet to a computer) or using internet from a Pi BT Access Point. They used to work very well in older Androids that were still using BlueZ. The new Kitkat droids, if I understand correctly, uses bluedroid from Broadcom + Google instead...

User avatar
chrisryall
Posts: 155
Joined: Wed Nov 27, 2013 11:45 am
Location: Wirral UK
Contact: Website

Re: Bluetooth Access Point

Tue Dec 17, 2013 11:32 am

Just a thought.

Am I being silly plugging 2 USB dongles into 2 machines .. when they are next to each other? Intuitively a simple double male ended cable "should" do the same job, but there seems no reference to peer-peer USB coupling either here or elsewhere. And I know things aren't always that simple.

Basil_R
Posts: 16
Joined: Sun Oct 06, 2013 9:38 pm

Re: Bluetooth Access Point

Thu Dec 19, 2013 4:34 pm

Hi Douglas. Just wondering how near you are to completing the work on your Bluetooth deamon? I have to say I am keen to give it a try, when ready.

Baz

Return to “Networking and servers”