maemo.org - Talk

maemo.org - Talk (https://talk.maemo.org/index.php)
-   Maemo 5 / Fremantle (https://talk.maemo.org/forumdisplay.php?f=40)
-   -   Controlling Bluetooth DUN with Upstart (https://talk.maemo.org/showthread.php?t=36027)

philipl 2009-12-06 00:42

Controlling Bluetooth DUN with Upstart
 
Hi all,

I spent some time today writing a suitable upstart script to control bluetooth DUN. This will let it start automatically and generally act seamlessly.

You can read the details and get the script from my blog post

RinoG 2009-12-06 11:06

Re: Controlling Bluetooth DUN with Upstart
 
Thank you for sharing!
I was searching for somethinig like this since long time!
I'll try it in the next week and will post the results. :)

jsa 2009-12-06 11:30

Re: Controlling Bluetooth DUN with Upstart
 
Quote:

Originally Posted by philipl (Post 412346)
Hi all,

I spent some time today writing a suitable upstart script to control bluetooth DUN. This will let it start automatically and generally act seamlessly.

You can read the details and get the script from my blog post

Is there a way to package this into a .deb and push it into extras or otherwise make it simple for users to do? I'd hate that a cool thing like this that could benefit a lot of people and demonstrate the benefits of an open source platform ends up being exclusive to users who actually know what bluetooth DUN, upstart etc. are.

debernardis 2009-12-06 12:49

Re: Controlling Bluetooth DUN with Upstart
 
Great! I don't have the device yet but your script is going to be one of the first things I'll install. So, thanks :)

One thing I'd like to know - if there are any symbian experts around - is *if* and *how* a symbian phone can connect to the internet by tethering to another phone through bluetooth dun. This is because I am going to have my voice sim in a symbian phone and my data sim into the N900. Occasionally I'd like to use some symbian apps that go online, and the simplest way could be to tether. Any hint?

DaSilva 2009-12-07 08:14

Re: Controlling Bluetooth DUN with Upstart
 
What happens if Bluetooth is disabled at startup and is enabled manually after that? I only want to enable Bluetooth when I need it and then it should be already possible to connect my notebook to the N900 and use the 3G connection from the N900.

philipl 2009-12-07 16:21

Re: Controlling Bluetooth DUN with Upstart
 
So, when you disable bluetooth in the UI, the hardware is turned off but all the software keeps running, so that doesn't cause any issues.

No!No!No!Yes! 2009-12-07 16:46

Re: Controlling Bluetooth DUN with Upstart
 
Hi ... I tried to setup the upstart script as per your suggestion:
Code:

Nokia-N900-42-11:~# cat /etc/event.d/bluetooth-dun
description "DUN over Bluetooth"
author "Philip Langdale"

respawn
console none

start on started bluetoothd
stop on stopping bluetoothd

pre-start script
sdptool add --channel 1 DUN
end script

exec rfcomm -S -- listen -1 1 /usr/bin/pnatd '{}'

post-stop script
sdptool del `sdptool browse local | grep Dial-Up -A 1 -m 1 | tail -n 1 | cut -d ' ' -f 3`
sleep 1
end script
Nokia-N900-42-11:~#

However the job doesn't seem to automatically start after rebooting the N900:
Code:

Nokia-N900-42-11:~# ps -eaf | grep rfcomm
  933 root        0 SW<  [krfcommd]
 1845 root      2092 S    grep rfcomm
Nokia-N900-42-11:~#

I need to start it manually via:
Code:

Nokia-N900-42-11:~# initctl start bluetooth-dun
bluetooth-dun (start) waiting
bluetooth-dun (start) starting
bluetooth-dun (start) pre-start, process 1851
bluetooth-dun (start) spawned, process 1853
bluetooth-dun (start) post-start, (main) process 1853
bluetooth-dun (start) running, process 1853
Nokia-N900-42-11:~#
Nokia-N900-42-11:~# ps -eaf | grep rfcomm
  933 root        0 SW<  [krfcommd]
 1853 root      1552 S    rfcomm -S -- listen -1 1 /usr/bin/pnatd {}
 1857 root      2092 S    grep rfcomm
Nokia-N900-42-11:~#

Do you have any idea?

philipl 2009-12-07 22:33

Re: Controlling Bluetooth DUN with Upstart
 
Quote:

Originally Posted by No!No!No!Yes! (Post 414760)
Do you have any idea?

Looks like I underspecified the starting constraints. It probably needs something that could start after bluetoothd. I'll have to investigate and find out what it is.

mikkov 2009-12-07 22:53

Re: Controlling Bluetooth DUN with Upstart
 
Has anybody got DUN connection working with Windows Vista?

in-maemo 2009-12-08 00:57

Re: Controlling Bluetooth DUN with Upstart
 
I too had a problem with bluetooth-dun not starting after a clean boot.

I'm also going to document, for posterity, the steps I had to go through to get DUN running between a Gentoo Linux laptop and T-Mobile, using the N900 as the relay.

The N900 setup was more or less what you specified (specifically putting http://intr.overt.org/misc/bluetooth-dun into /etc/event.d and running `start bluetooth-dun`) except that I kept getting "spawning too fast" messages when testing.

For my laptop, I first had problems pairing--I'm sure this is some bug with the bluez version I was using, but I eventually gave up and put the line "34:7E:39:24:88:FC 9339" in /var/lib/bluetooth/*/pincodes where the "34:..." is the bluetooth address (from `hciconfig -a` on n900) and 9339 is the pin I wanted. A `rfcomm connect 0 34:7E:39:24:88:FC` then forced a pairing attempt and I was able to enter the pin 9339 on the n900. Also, the n900 was unable to see the laptop during discovery until I ran `hciconfig hci0 piscan` I don't think this was important to my efforts because the rfcomm explictly requested the pairing.

I have, more or less, the following contents of my /etc/bluetooth/hcid.conf:
------------------------------------
options {
autoinit yes;
security user;
pairing multi;
}
device {
name "BlueZ@%h (%d)";
class 0x3e0100;
iscan enable; pscan enable;
lm accept;
lp rswitch,hold,sniff,park;
}
------------------------------------

/etc/bluetooth/rfcomm.conf
------------------------------------
rfcomm0 {
bind yes;
device 34:7E:39:24:88:FC;
channel 1;
comment "N900 connection";
}
------------------------------------

/etc/conf.d/net
------------------------------------
config_ppp0=( "ppp" )
link_ppp0="/dev/rfcomm0"
username_ppp0='guest'
password_ppp0='guest'
pppd_ppp0=(
"debug"
"ipcp-accept-remote"
"ipcp-accept-local"
"holdoff 3"
"defaultroute"
"usepeerdns"
"noauth"
"noipdefault noaccomp noccp nobsdcomp nodeflate nopcomp novj novjccomp local"
"921600"
"modem crtscts"
)
phone_number_ppp0=( "*99#" )
chat_ppp0=(
'ABORT' 'BUSY'
'ABORT' 'ERROR'
'ABORT' 'NO ANSWER'
'ABORT' 'NO CARRIER'
'ABORT' 'NO DIALTONE'
'ABORT' 'Invalid Login'
'ABORT' 'Login incorrect'
'TIMEOUT' '5'
'' 'ATZ'
'OK' 'ATM0'
'OK' 'ATQ0 V1 E1 S0=0 &C1 &D2 +FCLASS=0'
'OK' 'AT+CGDCONT=1,"IP","internet2.voicestream.com"'
'OK' 'ATDT\T'
'TIMEOUT' '60'
'CONNECT' ''
'TIMEOUT' '5'
'~--' ''
)

preup() {
case "${IFACE}" in
ppp*) modprobe ppp_generic; modprobe ppp_async;;
esac
return 0
}
postdown() {
case "${IFACE}" in
ppp*) rmmod ppp_async; rmmod ppp_generic;;
esac
return 0
}

------------------------------------

Note my use of internet2.voicestream.com and the username/password of guest/guest. One of those two changes (from internet3.voicestream.com and no username/password) was what I had to do to get DUN working over and above what has been documented here to date.

philipl 2009-12-08 05:17

Re: Controlling Bluetooth DUN with Upstart
 
I've got a fix for the failure to start automatically and updated the script. Details on my blog.

DaSilva 2009-12-08 08:33

Re: Controlling Bluetooth DUN with Upstart
 
Great. Do you know how to connect the N900 with Windows 7 and use the 3G internet connection from the phone? Do I need any specific drivers or programs? With my Nokia 5800 and Windows 7 it was very easy. Just connect the phone via Bluetooth, go to the device control panel and click on "Connect". No program or additional driver was needed. Is it the same for the N900 with this script?

RinoG 2009-12-08 09:43

Re: Controlling Bluetooth DUN with Upstart
 
Now it starts correctly but i still have issues in connecting.
In windows7 i get error 734, PPP connection terminated.
I'm using the same dial-up connection i use with n900 & usb cable.
Any idea?

DaSilva: once the script is running and device is pared, right click on n900 in bluetoooth devices, you will find dial-up or remote connection in contextual menu.
I'm unsure how to set the dialup as it is not working for me...

No!No!No!Yes! 2009-12-08 10:11

Re: Controlling Bluetooth DUN with Upstart
 
Quote:

Originally Posted by philipl (Post 415893)
I've got a fix for the failure to start automatically and updated the script. Details on my blog.

You are the Man!!!
It is starting/working like charm for me too.(WinXP+PC Suite Drivers)


(OT: I still have some issues with other tools - proftpd ftp server - trying to automatically start them on boot and maybe same cause applies there)

Could you please suggest the best way to troubleshoot/monitor upstart execution?

autodrivel 2009-12-08 10:31

Re: Controlling Bluetooth DUN with Upstart
 
This is sort of going in the reverse direction.
Does anyone have any experience tips on Bluetooth PAN between N900 and Windows 7?

The 3G reception in the Office is rubbish and we don't have wireless, so I'm thinking that connecting to my office PC via bluetooth and then using its Internet connection might be the best thing.

mikkov 2009-12-08 16:40

Re: Controlling Bluetooth DUN with Upstart
 
Quote:

Originally Posted by No!No!No!Yes! (Post 416147)
It is starting/working like charm for me too.(WinXP+PC Suite Drivers)

It started working for me too with Windows Vista after installing PC Suite, couldn't get it working before that. Works with Ubuntu&blueman without any tricks.

I'll say it's ready for packaging as 'Bluetooth DUN support'

That One Guy 2009-12-08 16:51

Re: Controlling Bluetooth DUN with Upstart
 
Thank you, Philipl.

As another poster mentioned, what are the chances of packaging it for us code idiots?

philipl 2009-12-09 00:28

Re: Controlling Bluetooth DUN with Upstart
 
Quote:

Originally Posted by That One Guy (Post 416844)
Thank you, Philipl.

As another poster mentioned, what are the chances of packaging it for us code idiots?

I expect to have time to put a package together this weekend.

I'm glad people are finding it useful!

philipl 2009-12-09 05:02

Re: Controlling Bluetooth DUN with Upstart
 
Packaging was easier than expected. It's now available from the extras-devel repository. I will be beginning the promotion process but for the impatient, you can turn on extras-devel to access it. Please take the warnings about this repository seriously and exercise caution over any packages you do install, including mine!

http://wiki.maemo.org/Extras-devel

mikkov 2009-12-09 07:13

Re: Controlling Bluetooth DUN with Upstart
 
quick comments:

use XB-Maemo-Display-Name field
use XB-Maemo-Icon-26 filed (48x48 icon)
Use more user oriented description. Do not mention upstart script in description. It is Bluetooth DUN support, that people might even understand.

Soulfarmer 2009-12-09 13:49

Re: Controlling Bluetooth DUN with Upstart
 
Thank you very many, although just after I got this working I remembered Joikuspot :)

RinoG 2009-12-09 14:48

Re: Controlling Bluetooth DUN with Upstart
 
Quote:

Originally Posted by RinoG (Post 416102)
Now it starts correctly but i still have issues in connecting.
In windows7 i get error 734, PPP connection terminated.
I'm using the same dial-up connection i use with n900 & usb cable.

Quoting myself as this is still not working in windows 7 nor win xp. :(

philipl 2009-12-30 19:41

Re: Controlling Bluetooth DUN with Upstart
 
The bluetooth-dun package is now in the main extras repository


All times are GMT. The time now is 06:18.

vBulletin® Version 3.8.8