Alex Rivera | Logout

Sending messages or datas with bluetooth via python

Asked 2011-09-20T13:15:15.513
11

How can i send messages over bluetooth via python without key authentification like type numbers ?

i used pybluez but i got this error:

File "./send", line 12, in <module>
    connect()
File "./send", line 8, in connect
    sock.connect((bd_addr, port))
File "<string>", line 5, in connect
    bluetooth.btcommon.BluetoothError: (111, 'Connection refused')

Here is the code

#!/usr/bin/python

import bluetooth

def connect ():
    bd_addr = "x:x:x:x:x:x"
    port = 1
    sock=bluetooth.BluetoothSocket(bluetooth.RFCOMM)
    sock.connect((bd_addr, port))
    sock.send("hello!!")
    sock.close()

connect()
Edit
Report

1 Answer

0

Have you tried starting with the basic rfcomm-client and rfcomm-server example code from pybluez?

http://code.google.com/p/pybluez/source/browse/trunk/examples/simple/rfcomm-client.py

It's basically what your code is doing, but it uses service discovery to ensure connection to proper port.

answered 2011-09-20T18:58:46.027

Your Answer