first attempts with pybluez on Win XP fail

G

Gelonida

Hi,

My post from Google groups doesn't sem to get through. SO here once more
posted from gmane.


Wanted to write a first simple example with pybluez and offer
a serial connection service with a given name.

What I tried (being inspired by
http://people.csail.mit.edu/albert/bluez-intro/x290.html
) is:

server_sock=bluetooth.BluetoothSocket( bluetooth.RFCOMM )
port = bluetooth.PORT_ANY # original example used get_available_port()
# buy this seems obsolete
server_sock.bind(("",port))
server_sock.listen(1)
print "listening on port %d" % port

loc_host, loc_port = server_sock.getsockname()
print "HOST", loc_host, "PORT??", loc_port

uuid = "1e0ca4ea-299d-4335-93eb-27fcfe7fa848"
bluetooth.advertise_service( server_sock, "FooBar Service", uuid )

The error message, that I get is:
listening on port 0
HOST XX:XX:XX:XX:XX:XX PORT?? 1
Traceback (most recent call last):
File "XXX\bt_01.py", line 94, in <module>
cmd(args)
File "XXX\bt_01.py", line 71, in srvr
srvr = BTSerService()
File "XXX\bt_01.py", line 51, in __init__
bluetooth.advertise_service( server_sock, "FooBar Service", uuid )
File "C:\Python26\lib\site-packages\bluetooth\msbt.py", line 173, in
advertise
_service
sock._sdp_handle = bt.set_service_raw (sock._raw_sdp_record, True)
IOError: An invalid argument was supplied.

What might I be doing wrong?

I got rid of the obsolete get_available_port() and wonder what else
might have changed?

Thanks a lot for your help.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,009
Latest member
GidgetGamb

Latest Threads

Top