public inbox for linux-bluetooth@vger.kernel.org
 help / color / mirror / Atom feed
From: Johan Hedberg <johan.hedberg@gmail.com>
To: linux-bluetooth@vger.kernel.org
Subject: Re: bluetooth SPP link to Nokia phone
Date: Tue, 21 Jul 2009 13:02:39 +0300	[thread overview]
Message-ID: <20090721100239.GA19048@jh-x301> (raw)
In-Reply-To: <1248169540.7048.52.camel@whg21-laptop>

Hi Henry,

On Tue, Jul 21, 2009, Henry Gomersall wrote:
> import dbus
> 
> bus = dbus.SystemBus();
> manager = dbus.Interface(bus.get_object('org.bluez', '/'),
> 'org.bluez.Manager')
> obj = bus.get_object('org.bluez', manager.DefaultAdapter())
> adapter = dbus.Interface(obj, 'org.bluez.Adapter')
> 
> phone = dbus.Interface(bus.get_object('org.bluez',
> adapter.ListDevices()[0]), 'org.bluez.Device')
> 
> phone_serial = dbus.Interface(phone, 'org.bluez.Serial')
> phone_serial.Connect('spp')

That looks fine to me, though you might want to use FindDevice with the
address of your phone in case you at some point configure more than one
device.

> At this stage, I have the device /dev/rfcomm0, but I cannot write data
> to it without breaking the link.

Do you open the device node and try to write to it from the same python
script that you created the connection with? At the very least the process
that calls Serial.Connect() needs to stay alive for the duration of the
connection. This is because bluetoothd will track the D-Bus client and
automatically disconnect if the client disconnects (e.g. when your script
exits).

Another potential issue that comes to mind is that the protocol you're
supposed to speak to the phone could be binary in which case you'll need
to set the tty into raw mode before doing anything with it (in C you'd use
cfmakeraw and tcsetattr for that and python probably provides something
similar).

Johan

  reply	other threads:[~2009-07-21 10:02 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-07-21  9:45 bluetooth SPP link to Nokia phone Henry Gomersall
2009-07-21 10:02 ` Johan Hedberg [this message]
2009-07-21 11:51   ` Henry Gomersall
2009-07-22 11:14     ` Henry Gomersall

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20090721100239.GA19048@jh-x301 \
    --to=johan.hedberg@gmail.com \
    --cc=linux-bluetooth@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox