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

Re: Bluetooth Access Point

Thu Dec 19, 2013 5:30 pm

Heh, a sacrificial beta tester! I've got the code pretty well completed...and it works, most of the time....still experiencing some strangeness to do with re-pairing, and I still need to write up instructions, mostly for setting up a network bridge.
If you can create your bridge, using Howdy's tutorial, i can put up some code on dropbox that you can try and tell me how it goes. Basically it's one daemon (and init.d script) to make sure connections are added to the bridge, and one interactive script to make pairing and trusting easy. Eventually I'll figure out GitHub.

Oh, it's still using python 2.7 and dbus - Did you get that sorted?

I'll see if I can get it posted tonight, meanwhile, see how it goes setting up the network bridge. To follow Howdy's tutorial, I believe you'll need to

Code: Select all

sudo apt-get install bridge-utils

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

Re: Bluetooth Access Point

Fri Dec 20, 2013 4:35 pm

Strangely enough i was following the tutorial well, and remarkably (i am always surprised when things work!) the bridge worked 1st time. In fact after a couple of reboots i still see the bridge when i do an ifconfig. It was the import of dbus in test-nap when it fell over.

No i haven't tried the clean restart of Wheezy because i was hoping your fix would avoid the need. But if it is essential i will give it a go, although will it simply update to Python 3.2 and leave me back where i currently am?

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

Re: Bluetooth Access Point

Fri Dec 20, 2013 5:32 pm

Yeah, the 'preferred' way to talk to Bluez involves using dbus, so that's the approach I took. What I don't understand, is how apt-get knows whether you have Python 2 or 3 (or both?) installed, so it knows how to install say, python-dbus. My scripts should work with both, but it requires the appropriate dbus module in the appropriate distribution location (/usr/local/lib/python2.7/dist-packages or /usr/local/lib/python3.2/dist-packages, depending)

A clean install of Raspian will get you Python 2, and everything should work there, if you don't have anything else that requires 3. But you might want to try keeping 3 first. Have you tried removing python-dbus and re-installing?

I didn't get the scripts finished, but did manage to solve my pairing problems. I'll get something posted this week-end. A couple of important caveats: 1) I'm experiencing frequent network crashes when using the NAP. I'm bridging to a wan0 device instead of eth0, that may be my problem, or I may have networking configured wrong. 2) Even when it works, it's not fast. Best download speeds I've seen are about 0.5 Mbps. That could also be due in part to wlan0 and/or my configuration. Bridging bluetooth to wireless is admittedly kinda crazy. I'll do some tests with a wired connection this weekend. But I'm not sure I would expect to be able to stream YouTube over bluetooth and miracast it at the same time. 3) I can only test with a Nexus 4 running KitKat. i have no clue about other devices / Android versions.

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

Re: Bluetooth Access Point

Mon Dec 23, 2013 1:39 am

After further testing, using a wired connection, the problems with the network crashing still remain. It seems to work alright for browsing web pages, like this forum, but as soon as I try anything intensive, like a speed test, or a YouTube video, the connection drops. I don't have the networking chops to figure this out just yet, but I'll post another topic here and see if the experts can help.

If anyone is interested in trying this out, I've put my scripts up on GitHub, at https://github.com/Douglas6/pinaple I'd appreciate anybody that can give it a try and report results.

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

Re: Bluetooth Access Point

Mon Dec 23, 2013 2:36 am

Greetings Douglas,

Regarding the 0.5 Mbps issue, I have faced the issue once - although I didn't find the cause of it but it was resolved when I changed the Bluetooth dongle to a newer CSR 4.0 USB Bluetooth dongle... it was written/printed CSR 4.0 on the dongle it self. Then I can get the optimum 1.7 Mbps (max) on the speedtest.net app - that was on a Sony Xperia V (LT25i) phone... I also tested it with a Nexus 4 prior to Kitkat and seemed to work well.

However, on a Nexus 5 with Kitkat/Android_4.4 (I understand that Kitkat uses "bluedroid" bluetooth stack by Broadcom + Google instead of the Linux default BlueZ) - I'm having connection "freezes" (no data sent/received) for Bluetooth internet access, and even Bluetooth tethering and file transfer with my friend's Nexus 5! I didn't upgrade to the latest "software update" yet but Bluetooth on Kitkat has been quite a bad experience! Will try to update sometime soon...

(Although I'm not a linux network export by any means!) Upon a connection drop/crash, you can try a dmesg on the Kitkat Android phone (via ADB) - I did once and found lines like:
<3>[ 2497.198350] Bluetooth RESET HIGH!!

At the same time, the on the computer's dmesg, I get
[ 1395.166910] Bluetooth: hci0 link tx timeout
[ 1395.166924] Bluetooth: hci0 killing stalled connection bc:f5:ac:5c:79:ec

So, in my view, the Bluetooth NAP problems could be coming from either the Kitkat's Bluedroid or the USB Bt dongle - or both... My brother used his Tablet (running CyanogenMod10) watching Youtube HQ at the same time as me watching Youtube HQ on my Sony for long whiles without issues... I even had success testing BT vs WIFI internet power consumption for more than 6 hours of Youtube HQ with no connection problems... but the Nexus 5 was a very different story.

I just hope the new Kitkat update would fix this... but no time to upgrade/test yet since I need to revert the kernel...
Last edited by ykasidit on Mon Dec 23, 2013 3:01 am, edited 1 time in total.

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

Re: Bluetooth Access Point

Mon Dec 23, 2013 2:59 am

Douglas6 wrote: If anyone is interested in trying this out, I've put my scripts up on GitHub, at https://github.com/Douglas6/pinaple I'd appreciate anybody that can give it a try and report results.
Thanks for sharing! The python code looks clean and the connection callback hooks look like a good notification idea! I don't have a Raspbian installed yet... but would try when I can.

Amazingly, I've just shared my EcoDroidLink code yesterday night (Sunday night here in Thailand) but didn't have the energy to write/post it here!

The EcoDroidLink code originally worked on BlueZ 5.7 compiled from source and installed on ArchlinuxARM - having seen this thread here - most are on Raspbian - but I was coding it that it can handle/run on older BlueZs like the 4.98 on my Ubuntu 12.04 - now it works on my Ubuntu... I also added new "auto bridging" code so it would create a bridge over eth0 and set dhcp on the bridge automatically.

Hopefully it would work on a Raspbian too but didn't have time to test yet... So I humbly invite everyone interested to give it a try on Raspbian - full setup and running instructions are provided in the README of the link below:
https://github.com/ykasidit/ecodroidlink

Note: The edl_main script would create it's own bridge over eth0, so to test it - please restore your network configs to the original dhcp on eth0 without a bridge (and restart it).

(I'm normally a C programmer and just tried Python recently - please forgive my Python code... any comments welcome.)
Last edited by ykasidit on Mon Dec 23, 2013 4:10 am, edited 1 time in total.

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

Re: Bluetooth Access Point

Mon Dec 23, 2013 3:37 am

Kasidit,

That's a ton of good information, thank you.

I'm not seeing the dmesg error you mentioned, but it looks suspiciously like what I'm seeing in /var/log/messages (NETDEV WATCHDOG: bnep0 (): transmit queue 0 timed out). The only other BT dongle I have is an IOGear 2.1 based on the Broadcom chip that I've had problems with before, and sure enough, I can't even get it to connect. I noticed that Adafruit has a 4.0 CSR dongle http://www.adafruit.com/products/1327, so it looks like my next monthly tithe to Adafruit will include a new BT dongle.

I think I have the latest KitKat on my Nexus 4, so if the problem is there, they apparently haven't fixed it yet.

I'll have a look at the EcoDroidLink code, thank you for sharing that. Not having to mess with the network config makes it simpler on users, I'm sure.

I was thinking of trying out Bluez 5 on Raspian, it looks to be a fairly simple build, but most of my Python will have to change, looks like, not that there's much yet. Briefly, what new goodies does BT 4.0/Bluez 5 provide?

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

Re: Bluetooth Access Point

Mon Dec 23, 2013 12:03 pm

Douglas6 wrote:Kasidit,

That's a ton of good information, thank you.

I'm not seeing the dmesg error you mentioned, but it looks suspiciously like what I'm seeing in /var/log/messages (NETDEV WATCHDOG: bnep0 (): transmit queue 0 timed out). The only other BT dongle I have is an IOGear 2.1 based on the Broadcom chip that I've had problems with before, and sure enough, I can't even get it to connect. I noticed that Adafruit has a 4.0 CSR dongle http://www.adafruit.com/products/1327, so it looks like my next monthly tithe to Adafruit will include a new BT dongle.

I think I have the latest KitKat on my Nexus 4, so if the problem is there, they apparently haven't fixed it yet.

I'll have a look at the EcoDroidLink code, thank you for sharing that. Not having to mess with the network config makes it simpler on users, I'm sure.

I was thinking of trying out Bluez 5 on Raspian, it looks to be a fairly simple build, but most of my Python will have to change, looks like, not that there's much yet. Briefly, what new goodies does BT 4.0/Bluez 5 provide?
Greetings Douglas,

Thanks for your kind words. :D

It would be nice to see the dmesg from your Nexus (via 'adb shell' into it) once the connection problem occurs - I think ROOT/su on the Nexus 4 is required for this though.

Yes, the USB Bluetooth dongle sold by Adafruit there looks similar to the one I'm using and I hope that it works well for you (I got mine from eBay though).

Regarding BlueZ 4 vs 5 I really don't know about the main feature differences since I'm using mainly old features but I saw the BlueZ.org site quite active releasing many new releases and the latest release I see from checking the site today is 5.12! Yes, there are dbus code changes but fortunately most are well demonstrated by python examples in the 'test' folder.

What I did find different between BlueZ 4.x and 5.x was that I can't successfully use BlueZ (probably 4.98) on my Ubuntu 12.04 to connect to a Bluetooth LE 'Sensor Tag' (by Texas Instruments) but when I plugged the same CSR BT 4.0 USB Donlge into my ArchLinux Pi with BlueZ 5.7 compiled/installed - it had success in connecting, enabling and reading sensor values! It did had some problems like after the disconnect, I needed to do use hciconfig down and up again to connect again otherwise it wouldn't conenect again! But I'm not aware of practical ideas/projects to use it yet - was just curious/mad about Bluetooth and Pis and trying things out in hope to make a practical project someday, maybe for agricultural or anything useful/interesting... Sorry - going off-topic here!

All the best!

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

Re: Bluetooth Access Point

Mon Dec 23, 2013 12:42 pm

ykasidit wrote:was just curious/mad about Bluetooth and Pis and trying things out in hope to make a practical project someday, maybe for agricultural or anything useful/interesting...
Yup, I agree, the Pi and Bluetooth seem like a good match. Next, I'm thinking a mash-up to make a wireless AVR programmer might be within my meager skills. And the Sensor Tag looks promising for wireless datalogging etc. But yes, those are future topics.

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

Re: Bluetooth Access Point

Fri Dec 27, 2013 9:52 pm

Kasidit & Douglas

Much apparent development work on this project with the added confusion created by Android Kit-Kat!

I ave had a go at following the ecodroidlink method as it appears simpler for a noob such as myself, but unfortunately it falls over onn the line:-

edl_bridge_init: Attempt call: sudo ifconfig eth0 0.0.0.0 0.0.0.0

Which follows the bridge setup commands. The script execution halts, and my SSH session drops out because eth0 appears to go down. Connecting by the Wi-Fi dongle and running IFCONFIG reveals the eth0 data minus the IP address. i restart the network and re-connect via the cable. Checking INTERFACES reveals no changes have been made to the setup (in case that is part of the ecodroidlink process). I have run the procdure twice with the same result.

My setup has both eth0 and wlan0 set to DHCP adress allocation, even though my router allocates them fixed addresses, in case that is relevant. i have thought having both Wi-Fi & BT dongles side by side in the hub might be an issue but then I believe Douglas was running his NAP that way.

Best regards, and happy holidays

Baz

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

Re: Bluetooth Access Point

Sat Dec 28, 2013 10:31 am

Dear Baz,

Thanks for trying it out! Thanks, happy new year and happy holidays too!

Normally I develop by using a serial interface, or running autostart/headless or running directly as a computer (not via SSH over eth0 - I normally disable SSH, for security, for the SD-Card order/releases of EcoDroidLink too...) so that's probably the cause, I guess...

The problem you faced is likely caused by the statement was removing the ip of eth0 before adding to the bridge - but that eth0 was used for your SSH so everything stopped at that time - so the edl_main process was probably stopped/terminated from there too, I guess.

I suggest/guess two solutions:

- Please try testing 'sudo ./edl_main' again from directly connecting a keyboard and display (via HDMI or video port) to the Pi. However, If you don't have a display/screen and have only ssh - you can try ssh into the wifi's ip instead of eth0 which would be temporarily disabled while adding to the bridge for bluetooth.

OR

- If you can only ssh via the eth0 which would be cut during the process, try run it in background by adding an '&' to the end of the command (so it *might* not be ended when the SSH gets cut during the pre-bridging stage - your SSH would still get cut, but when you SSH back in again, the edl_main might stil be running - check by 'ps -A | grep edl') - so run this like: sudo ./edl_main &

(Unfortunately, as I'm taking my family travelling in this holiday - I still didn't have time to get/test/develop on a Raspbian or even make the auto-start script for it yet... Moreover, I'm having to travel overseas for my real job soon until at least the second week of Jan of next year... so I might be slower to respond from now...)

All the best!

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

Re: Bluetooth Access Point

Thu Jan 02, 2014 1:07 pm

Kasidit

Your first hunch was correct because connecting to the Pi via the WiFi enabled the script to run to the very last line, when the following message appeared:-

"End user might be on a Graphical Desktop with......user can run killall bluetooth-applet anytime..........."

I ran the "killall bluetooth-applet" but no such process was found. As a keen to learn noob I don't throw in the towel easily and had a trawl round Google & the Pi forums for other methods of disabling the GUI bluetooth manager. sudo service bluetooth stop effectively halted the bluetooth service, but then ./edl_main fell over in a bigger way.

I'm sure the workaround for this issue isn't particularly difficult but for the time being it has beaten me. Anyway I'll look forward to your advice when you return from your travels. btw a check on /etc/network/interfaces revealed the bridge had been established correctly, an I can reconnect the SSH session on the eth0 once setup.

Regards

Baz

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

Re: Bluetooth Access Point

Thu Jan 02, 2014 1:54 pm

That error is caused by another bluetooth agent running. You'll need to kill just that agent, not the bluetooth service itself. It might be called 'blueman'. Or you can try listing all running bluetooth processes with

Code: Select all

ps aux | grep blue
and killing anything that looks like it might be a Bluetooth agent, or manager.

Or it looks like you can just use the existing agent for pairing, in which case there should be a desktop menu option for Bluetooth that you can use to pair your device.

HashNinja
Posts: 27
Joined: Fri Dec 27, 2013 4:30 am

Re: Bluetooth Access Point

Sun Jan 05, 2014 8:52 pm

Hey guys, so I got EcoDroidLink up and running and have successfully paired and used internet on my android device over bluetooth. But I was wondering if it would be possible to assign a static ip address to eth0. I have attempted but the script fails to fully run. Is it possible? Also, how can I make ecodroidlink start automatically at boot, so that all I have to do is connect to it using bluetooth? Thanks

ashtonmarkson
Posts: 8
Joined: Sun Dec 22, 2013 1:17 am

Re: Bluetooth Access Point

Sun Jan 12, 2014 1:45 am

I'm about to start this myself after having just started with the bluetooth and Pi. Question though, would bonjour still work a-la my hostapd config? If Pi is my Access point and I set it up as per the tutorial, would I still be able to get to it via pi.local? Do I need a local DHCP and iptables config?

Thanks all for this.

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

Re: Bluetooth Access Point

Mon Jan 13, 2014 8:57 am

Douglas6 wrote:That error is caused by another bluetooth agent running. You'll need to kill just that agent, not the bluetooth service itself. It might be called 'blueman'. Or you can try listing all running bluetooth processes with

Code: Select all

ps aux | grep blue
and killing anything that looks like it might be a Bluetooth agent, or manager.

Or it looks like you can just use the existing agent for pairing, in which case there should be a desktop menu option for Bluetooth that you can use to pair your device.
Thanks Douglas! Very well explained, totally agreed. :D

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

Re: Bluetooth Access Point

Mon Jan 13, 2014 9:05 am

HashNinja wrote:Hey guys, so I got EcoDroidLink up and running and have successfully paired and used internet on my android device over bluetooth. But I was wondering if it would be possible to assign a static ip address to eth0. I have attempted but the script fails to fully run. Is it possible? Also, how can I make ecodroidlink start automatically at boot, so that all I have to do is connect to it using bluetooth? Thanks
Greetings, I'm excited to see that it works on your Pi! Until now, I regret that I still didn't have a chance to test on a real Raspbian yet - mainly developing from a Ubuntu but it is essentially the same for most cases...

I just added some simple code to handle the 2 things you mentioned: autostart, static ip (by using an existing/manually_created_bridge). As in the latest EcoDroidLink github page at https://github.com/ykasidit/ecodroidlink

To update your local clone - in your local ecodroidlink folder. Please do:
git pull origin master

After it completes, please see the new sections 'Make EcoDroidLink autostart-on-boot', and 'Recommended: Manually create your own bridge' (to set a static ip for your Pi).

All the best.

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

Re: Bluetooth Access Point

Mon Jan 13, 2014 9:59 am

ashtonmarkson wrote:I'm about to start this myself after having just started with the bluetooth and Pi. Question though, would bonjour still work a-la my hostapd config? If Pi is my Access point and I set it up as per the tutorial, would I still be able to get to it via pi.local? Do I need a local DHCP and iptables config?

Thanks all for this.
Hello. I personally have no idea or experience in such features so I can't comment on that. However, since all the 3 tutorials in this thread (to summarize there are: 1. howdy's tutorial at http://www.hkepc.com/forum/viewthread.php?tid=1710030, 2. 'pinaple' at https://github.com/Douglas6/pinaple, 3. 'ecodroidlink' at https://github.com/ykasidit/ecodroidlink) are essentially using BlueZ's NAP feature that adds bluetooth network connections onto a linux 'bridge' - which in theory is a smarter 'hub' - a 'switch' - it is likely that it *might* work the same way.

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

Re: Bluetooth Access Point

Wed Jan 15, 2014 9:37 pm

Many many thanks to ykasidit, for cracking this problem. Got it all up and working, and tested the system out by 'throwing' a Hangouts video chat with our two boys onto the living room TV (even the wife was impressed!). First impressions are that the Bluetooth NAP is plenty fast enough for the relatively low res. video of that service, but I will try it with other video sources. The manual bridge settings and auto start will be sorted in the future as well.

Thanks again Baz

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

Re: Bluetooth Access Point

Wed Jan 15, 2014 11:49 pm

Glad you got it working Baz, and thanks for reporting your success. For my benefit and other's, could you post the make and model of the BT dongle you're using?

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

Re: Bluetooth Access Point

Thu Jan 16, 2014 7:46 pm

This was the dongle I bought http://www.amazon.co.uk/gp/product/B00A ... UTF8&psc=1, but I suspect it is a generic Bluetooth 4.0 CSR (Cambridge Silicon Radio) compatible device.

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

Re: Bluetooth Access Point

Thu Jan 16, 2014 8:07 pm

Thanks, my CSR 4.0 dongle arrives tomorrow, it will be interesting to see what problems it solves.

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

Re: Bluetooth Access Point

Thu Jan 16, 2014 8:32 pm

Going through the process of autostarting the ecodroidlink and I have to run

Code: Select all

sudo killall blueman-applet
for the ecodroid script to complete. If possible the simplest approach would be to prevent the blueman-applet starting during boot in the first place, but I don't have the knowledge to go poking around in /etc/init.d or rc.local. If i simply remove blueman via

Code: Select all

sudo apt-get blueman remove
, will that impact on the ability of ecodroidlink to run?

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

Re: Bluetooth Access Point

Thu Jan 16, 2014 8:59 pm

That will remove the Blueman desktop manager application (well, actually 'sudo apt-get remove blueman'), but you might just want to disable it from starting automatically. I'm not familiar with the desktop in Linux (LXDE, in this case), but see if you have a directory in your home by the name of '~/.config/autostart/', and does it contain a .desktop file that corresponds to Blueman (blueman.desktop or similar)? Try moving that away first, and restarting X.

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

Re: Bluetooth Access Point

Sun Jan 19, 2014 9:34 am

Thanks Douglas, Baz - I did the same for my computer - sudo apt-get remove blueman - that should be enough.

As for my Ubuntu - I also did: sudo apt-get remove gnome-bluetooth (for anyone trying on Ubuntu - but the Raspbian with Graphics is unrelated - LXDE).

Return to “Networking and servers”