did somebody manage to connect the nxtOsek in bluetooth mode to the rfcomm interface in Linux systems.
I tried hard with python and bluez both in client and server mode but it doesn't work. I can discover the device but cannot associate.
- Code: Select all
print "performing inquiry..."
nearby_devices = bluetooth.discover_devices(lookup_names = True)
print "found %d devices" % len(nearby_devices)
for name, addr in nearby_devices:
print " %s - %s" % (addr, name)
server_sock=bluetooth.BluetoothSocket( bluetooth.RFCOMM )
bd_addr = "00:16:53:0A:8B:E4"
server_sock.bind((bd_addr,PORT_ANY))
server_sock.listen(1)
print "Waiting for NXT connection "
client_sock,address = server_sock.accept()
print "Accepted connection from ",address
if wm.connect() and wm.setup():
cycles = wm.main_loop()
# The NXT_G sends 34 byte of data for every BT packet
data = client_sock.recv(34)
print "received [%s]" % data
gives me
performing inquiry...
found 1 devices
NXT - 00:16:53:0A:8B:E4
I get only a poor:
Waiting for NXT connection
and
- Code: Select all
print "performing inquiry..."
nearby_devices = bluetooth.discover_devices(lookup_names = True)
print "found %d devices" % len(nearby_devices)
for name, addr in nearby_devices:
print " %s - %s" % (addr, name)
nxt_addr = "00:16:53:0A:8B:E4"
service_matches = bluetooth.find_service(address = nxt_addr )
first_match = service_matches[0]
port = first_match["port"]
name = first_match["name"]
host = first_match["host"]
print "connecting to \"%s\" on %s" % (name, host)
# Create the client socket
sock=bluetooth.BluetoothSocket( RFCOMM )
sock.connect((host, port))
print "connected. type stuff"
while True:
data = raw_input()
if len(data) == 0: break
sock.send(data)
sock.close()
gives me
performing inquiry...
found 1 devices
NXT - 00:16:53:0A:8B:E4
Traceback (most recent call last):
File "WMDclient.py", line 88, in <module>
wmd = WMD()
File "WMDclient.py", line 45, in __init__
first_match = service_matches[0]
IndexError: list index out of range
HEEEEEEEEEEEEELP!
