0
votes

I have a Bluetooth client on Android that must connect to my computer by RFCOMM and using the UUID 00001101-0000-1000-8000-00805F9B34FB

The PyBluez library is used, as well as Python 2.6. I used the following code from the PyBluez Documentation

from bluetooth import *

server_sock=BluetoothSocket( RFCOMM )
server_sock.bind(("",PORT_ANY))
server_sock.listen(1)

port = server_sock.getsockname()[1]
uuid = "00001101-0000-1000-8000-00805F9B34FB"
advertise_service( server_sock, "SampleServer",
                   service_id = uuid,
                   service_classes = [ uuid, SERIAL_PORT_CLASS ],
                   profiles = [ SERIAL_PORT_PROFILE ], 
                   )

print "Waiting for connection on RFCOMM channel %d" % port
client_sock, client_info = server_sock.accept()
print "Accepted connection from ", client_info

try:
    while True:
        data = client_sock.recv(1024)
        if len(data) == 0: break
        print "received [%s]" % data
except IOError:
    pass

print "disconnected"
client_sock.close()
server_sock.close()
print "all done"

It works perfectly fine under Windows 7.

But I have no reaction with another computer on Windows XP, i.e. my code stays at the line "Waiting for connection on RFCOMM channel". My Bluetooth client warns me it is connected, though.

This Windows XP computer Bluetooth configuration allows me to set-up a COM port for serial communications with Bluetooth. If I listen on this configured COM port, I can see my data from the Bluetooth client.

I prefer to have a code working on any Windows computer, and I do not want to configure virtual COM port on these computers. So I would like the above program also working with the Windows XP computer.

What do I miss? It is as if the Windows XP computer do not forward Bluetooth data to my program, even if I disable its capability of reproducing data on a virtual serial port. It seems the UUID I use is a well known one, but I must use this one to have my program compatible with another specific platform.

The Bluetooth stack on the Windows 7 computer is from Atheros Communications, the one on the Windows XP computer is from Widcomm.

1
Sounds like your windows driver is taking over the connection and using it for the virtual COM port. Have you tried disabling (or uninstalling) the virtual COM port/ bluetooth serial port devices in windows device manager?TJD
I have the same feeling. Yes, I uninstalled it, I even removed the virtual port service capability in my Bluetooth manager and rebooted just in case: I can still connect my Bluetooth client but nothing happens. Something interesting to know: if the virtual port is enabled and if I launch my program, the Bluetooth client cannot connect (as if the driver and my program were conflicting).Vincent Hiribarren

1 Answers

0
votes

The Widcomm Bluetooth stack installed on your XP has its own API and driver; this API is totally incompatible with the MS Bluetooth stack! (furthermore, you need XP SP2 to use MS Stack, with a compatible dongle too... I've never found one)

So, on Win7, you can use 'sockets' with the MS Stack (even a Broadcom/Widcomm will work, using the MS stack and not the specific API!) On XP, you need to use another code, compatible with the Widcomm stack... You can eventually use COMports on XP, connected to the virtual COMs...but you'll get no notification from the stack...