first attempt with pybluez on XP fail

gelonida gelonida at gmail.com
Tue Nov 16 17:39:05 CET 2010


Hi,

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.




More information about the Python-list mailing list