Hi all,
I need to make a Bluetooth RFCOMM connection on N95s running Python for S60 1.4.1 but for the N95 it doesn't work.Does anybody know why?
Script Server-side:
Script Client-side:Code:from socket import * import appuifw server_socket = socket(AF_BT, SOCK_STREAM) p = bt_rfcomm_get_available_server_channel(server_socket) server_socket.bind(("", p)) print "bind done" server_socket.listen(1) bt_advertise_service( u"jurgen", server_socket, True, RFCOMM) set_security(server_socket, AUTH) print "I am listening" # Note: Don't call .send or .recv on the server_socket! # Use the sock object returned by server_socket.accept(). (sock,peer_addr) = server_socket.accept() print "Connection from %s"%peer_addr test = appuifw.query(u"Type words", "text", u"") sock.send(test+'\n') print "sending done" import e32 # Allow time for data to be sent to work around a bug in the socket # module. e32.ao_sleep(1) sock.close()
I have also tried this code with some N71s(running Python for S60 1.4.1). it works in these cases:Code:import socket import appuifw import e32 class BTReader: def connect(self): self.sock=socket.socket(socket.AF_BT,socket.SOCK_STREAM) addr,services=socket.bt_discover() print "Discovered: %s, %s"%(addr,services) if len(services)>0: import appuifw choices=services.keys() choices.sort() choice=appuifw.popup_menu([unicode(services[x])+": "+x for x in choices],u'Choose port:') port=services[choices[choice]] else: port=services[services.keys()[0]] address=(addr,port) print "Connecting to "+str(address)+"...", self.sock.connect(address) print "OK." def readline(self): line=[] while 1: ch=self.sock.recv(1) if(ch=='\n'): break line.append(ch) return ''.join(line) def close(self): self.sock.close() bt=BTReader() bt.connect() print "Received: "+bt.readline() bt.close()
Server: N71 - Client N71
Server: N71 - Client N95
it doesn't work if:
Server: N95 - Client N95
Server: N95 - Client N71
In particular what happened is this: on the server side the script seems to be running; on the client side the application make the bt_discover but when i select the server-device on the list the application is turned off.
I hope you can help me
thank you, Chiara

Does anybody know why?

Reply With Quote




