View Single Post
Posts: 804 | Thanked: 1,598 times | Joined on Feb 2010 @ Gdynia, Poland
#4
Originally Posted by Joorin View Post
Are you running the N900 script as root?

If not, how are you able to bind to a socket < 1024 which should be reserved for root processes?
Well, that's quite simple and it works. I have no idea why I didn't think of running script as root, I just thought that bluetooth port numeration has nothing to do with unix/linux overall port numeration... stupid me :P

Thank you very much.

Now, I have a working setup:
Nokia N900
Code:
import bluetooth

server_sock=bluetooth.BluetoothSocket( bluetooth.RFCOMM )

port = 3
server_sock.bind(("",port))
server_sock.listen(1)
print "listening on port %d" % port

uuid = "A55665EE-9F91-4610-9085-C2055C888B39"
bluetooth.advertise_service( server_sock, "btsppEcho", uuid )

print "Waiting for connections"

client_sock,address = server_sock.accept()
print "Accepted connection from ",address

while True:
    data = client_sock.recv(1024)
    print "received [%s]" % data

client_sock.close()
server_sock.close()
And final connection string in MIDlet is:
Code:
"btspp://" + myRemoteDevice.getBluetoothAddress() + ":3;authenticate=true;encrypt=true;master=false";
Thank you once again, you saved existance of my app

Last edited by misiak; 2011-04-27 at 02:17.
 

The Following User Says Thank You to misiak For This Useful Post: