I'm a newbie in python programming and I got a serious problem.
I try to make a client-server bluetooth connection using PC as server and mobile phone (symbian S60) as client.
I'm using PyBluez to develop my server and should be like this:
from bluetooth import *
server_sock=BluetoothSocket( RFCOMM )
port = 9
server_sock.bind(("",port))
server_sock.listen(1)
print "listening on port %d" % port
uuid = "c3453417-9a0f-4cae-a380-e70fc41818b7"
advertise_service( server_sock, uuid, u'FooBar Service',
service_classes = [ uuid, SERIAL_PORT_CLASS ],
profiles = [ SERIAL_PORT_PROFILE ])
client_sock,address = server_sock.accept()
print "Accepted connection from ",address
client_sock.close()
server_sock.close()
That script runs normally on my desktop, but the main problem is occured when I tried to discover the advertised service from my mobile phone (Nokia 6600) using python script like this:
import socket
addr,serv = socket.bt_discover()
print addr,serv
conn = socket.socket(sock.AF_BT, sock.SOCK_STREAM)
if 'FooBar Service' in serv:
try:
conn.connect((addr, serv[u'FooBar Service']))
except:
print 'connection failed'
else:
print 'service not found'
When I run this script and reach the 'socket.bt_discover()' statement my mobile phone starting discover nearby device like usual, but when I select the bluetooth device according to my server device (desktop) the application even the python interpreter it self runs down/exit/crash (i don't know how to mention it) by it's own to phone's main menu.
I've tried to using any exception to get error information, but it useless 'cause it still crashes the interpreter.
I also tried using J2ME to check if the server is working properly, and I got it connected perfectly.
Could anybody help me with this problem, please?

Reply With Quote

