unable to connect bluetooth nxtosek on rfcomm

Post your NXJ projects, project ideas, etc here!

Moderators: 99jonathan, roger, imaqine

unable to connect bluetooth nxtosek on rfcomm

Postby epokh » Sat Apr 18, 2009 5:44 pm

Hi guys,
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! :oops:
epokh
Novice
 
Posts: 26
Joined: Wed Feb 21, 2007 5:46 pm

Postby epokh » Sun Apr 19, 2009 1:19 pm

Even using rfcomm commands I cannot get it to work:
rfcomm bind
rfcomm connect
rfcomm listen
none of them works
epokh
Novice
 
Posts: 26
Joined: Wed Feb 21, 2007 5:46 pm


Return to NXJ Projects

Who is online

Users browsing this forum: Baidu [Spider] and 2 guests

more stuff