* Bluetooth SPP on Nokia N900 (Maemo 5)
@ 2010-03-02 16:26 Henry Owens
2010-03-02 17:14 ` Vinicius Gomes
0 siblings, 1 reply; 3+ messages in thread
From: Henry Owens @ 2010-03-02 16:26 UTC (permalink / raw)
To: linux-bluetooth
Hi All,
My first mail to this list. I am currently trying to get a bluetooth
SPP connection going on my Nokia N900, but I'm having some
difficulties using the examples on the HOWTO Wiki.
Specifically, I get an error related to the ActivateService call in
the example - I have seen reference to this being obselete in Bluez
4.x, is this the problem in the example code?
If so, how could the code be rewritten to allow a connection (I have
no prior experience with BT programming, but am comfortable in
Python).
The code at the moment is:
import dbus
import time
import sys
bus = dbus.SystemBus()
bmgr = dbus.Interface(bus.get_object('org.bluez', '/org/bluez'),
'org.bluez.Manager')
bus_id = bmgr.ActivateService('serial')
serial = dbus.Interface(bus.get_object(bus_id, '/org/bluez/serial'),
'org.bluez.serial.Manager')
# Service connection, read the serial API to check the available patterns
if (len(sys.argv) < 2):
print "Usage: %s <address> [service]" % (sys.argv[0])
sys.exit(1)
address = sys.argv[1]
if (len(sys.argv) < 3):
service = "spp"
else:
service = sys.argv[2]
# Bind to the default local adapter
device = serial.ConnectService(address, service)
print "Connected %s to %s" % (device, address)
print "Press CTRL-C to disconnect"
try:
time.sleep(1000)
print "Terminating connection"
except:
pass
serial.DisconnectService(device)
Regards,
Henry.
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: Bluetooth SPP on Nokia N900 (Maemo 5) 2010-03-02 16:26 Bluetooth SPP on Nokia N900 (Maemo 5) Henry Owens @ 2010-03-02 17:14 ` Vinicius Gomes 2010-03-05 10:52 ` Henry Owens 0 siblings, 1 reply; 3+ messages in thread From: Vinicius Gomes @ 2010-03-02 17:14 UTC (permalink / raw) To: Henry Owens; +Cc: linux-bluetooth Hi Henry, On Tue, Mar 2, 2010 at 1:26 PM, Henry Owens <owens.henry@googlemail.com> wrote: > Hi All, > > My first mail to this list. I am currently trying to get a bluetooth > SPP connection going on my Nokia N900, but I'm having some > difficulties using the examples on the HOWTO Wiki. > > Specifically, I get an error related to the ActivateService call in > the example - I have seen reference to this being obselete in Bluez > 4.x, is this the problem in the example code? > Yeah, the example code in the wiki is outdated, take a look at the example in the sources [1], for a working one. Also, in that same directory there are a few more examples that could be useful. Cheers, -- Vinicius Gomes INdT - Instituto Nokia de Tecnologia [1] http://git.kernel.org/?p=bluetooth/bluez.git;a=blob;f=test/test-serial;hb=HEAD ^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: Bluetooth SPP on Nokia N900 (Maemo 5) 2010-03-02 17:14 ` Vinicius Gomes @ 2010-03-05 10:52 ` Henry Owens 0 siblings, 0 replies; 3+ messages in thread From: Henry Owens @ 2010-03-05 10:52 UTC (permalink / raw) To: Vinicius Gomes; +Cc: linux-bluetooth Vinicius, Many thanks for your help - I used the example script, and it is now connecting correctly to my device. I am having a slight issue, however, with the fact that the "SetSerialParameters" method is experimental, and thus I can not use it - could anyone point me to where I can set the parameters correctly so that it can receive packets from the device? FYI, the device is simplex - it sends a packet once per second, and ignores any commands, so I simply want to receive the packets and parse them. At present, when I use the code below, I do not get any output, which I assume is because my serial settings are incorrect. Many thanks again for your help, Henry. test.py: import sys import dbus bus = dbus.SystemBus() manager = dbus.Interface(bus.get_object("org.bluez", "/"), "org.bluez.Manager") adapter = dbus.Interface(bus.get_object("org.bluez", manager.DefaultAdapter()), "org.bluez.Adapter") address = "00:07:80:88:F4:E9" service = "spp" path = adapter.FindDevice(address) serial = dbus.Interface(bus.get_object("org.bluez", path), "org.bluez.Serial") node = serial.Connect(service) print "Connected %s to %s" % (node, address) print "Press CTRL-C to disconnect" a = open("/dev/rfcomm0","r") w = a.readline() print w serial.Disconnect(node) On Tue, Mar 2, 2010 at 5:14 PM, Vinicius Gomes <vinicius.gomes@openbossa.org> wrote: > Hi Henry, > > On Tue, Mar 2, 2010 at 1:26 PM, Henry Owens <owens.henry@googlemail.com> wrote: >> Hi All, >> >> My first mail to this list. I am currently trying to get a bluetooth >> SPP connection going on my Nokia N900, but I'm having some >> difficulties using the examples on the HOWTO Wiki. >> >> Specifically, I get an error related to the ActivateService call in >> the example - I have seen reference to this being obselete in Bluez >> 4.x, is this the problem in the example code? >> > > Yeah, the example code in the wiki is outdated, take a look at the > example in the sources [1], > for a working one. > > Also, in that same directory there are a few more examples that could be useful. > > > Cheers, > -- > Vinicius Gomes > INdT - Instituto Nokia de Tecnologia > > [1] http://git.kernel.org/?p=bluetooth/bluez.git;a=blob;f=test/test-serial;hb=HEAD > -- > To unsubscribe from this list: send the line "unsubscribe linux-bluetooth" in > the body of a message to majordomo@vger.kernel.org > More majordomo info at http://vger.kernel.org/majordomo-info.html > ^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2010-03-05 10:52 UTC | newest] Thread overview: 3+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2010-03-02 16:26 Bluetooth SPP on Nokia N900 (Maemo 5) Henry Owens 2010-03-02 17:14 ` Vinicius Gomes 2010-03-05 10:52 ` Henry Owens
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox