¿RFCOMM sin emparejamiento utilizando PyBluez en Debian?

Estoy tratando de crear un proceso de servidor RFCOMM con Python que pueda usarse sin la necesidad de emparejamiento. Inicialmente, tomé los dos scripts de ejemplo de la documentación de PyBluez:

Servidor:

# file: rfcomm-server.py

# auth: Albert Huang <[email protected]>
# desc: simple demonstration of a server application that uses RFCOMM sockets
#
# $Id: rfcomm-server.py 518 2007-08-10 07:20:07Z albert $

from bluetooth import *

server_sock=BluetoothSocket( RFCOMM )
server_sock.bind(("",PORT_ANY))
server_sock.listen(1)

port = server_sock.getsockname()[1]

uuid = "94f39d29-7d6d-437d-973b-fba39e49d4ee"

advertise_service( server_sock, "SampleServer",
                   service_id = uuid,
                   service_classes = [ uuid, SERIAL_PORT_CLASS ],
                   profiles = [ SERIAL_PORT_PROFILE ], 
#                   protocols = [ OBEX_UUID ] 
                    )

print "Waiting for connection on RFCOMM channel %d" % port

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

try:
    while True:
        data = client_sock.recv(1024)
        if len(data) == 0: break
        print "received [%s]" % data
except IOError:
    pass

print "disconnected"

client_sock.close()
server_sock.close()
print "all done"

Cliente:

# file: rfcomm-client.py
# auth: Albert Huang <[email protected]>
# desc: simple demonstration of a client application that uses RFCOMM sockets
#       intended for use with rfcomm-server
#
# $Id: rfcomm-client.py 424 2006-08-24 03:35:54Z albert $

from bluetooth import *
import sys

addr = None

if len(sys.argv) < 2:
    print "no device specified.  Searching all nearby bluetooth devices for"
    print "the SampleServer service"
else:
    addr = sys.argv[1]
    print "Searching for SampleServer on %s" % addr

# search for the SampleServer service
uuid = "94f39d29-7d6d-437d-973b-fba39e49d4ee"
service_matches = find_service( uuid = uuid, address = addr )

if len(service_matches) == 0:
    print "couldn't find the SampleServer service =("
    sys.exit(0)

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=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()

Cuando ejecuté el script del servidor en Windows, todo funcionó exactamente como esperaba, sin necesidad de vinculación. En esta etapa todo se veía muy prometedor.

Sin embargo, necesito que el proceso del servidor se ejecute bajo Debian Squeeze. Cuando pruebo en Debian, la conexión del cliente es rechazada. En el syslog hay mensajes de bluetoothd para una solicitud de clave de enlace y solicitud de PIN fallidos.

Información de versión:

PyBluez 0.18Python 2.6Bluez 4.66Hardware Bluetooth v2.0 en ambos extremos de la conexión

Esta discusion Parece sugerir que si puedo ajustar el nivel de seguridad en el socket del servidor, el emparejamiento se deshabilitará y todo funcionará como se esperaba. No me parece claro cómo hacer esto con PyBluez, o incluso si es posible.

He experimentado con llamadas a setsockopt () usando varias constantes BT_SECURITY *, además de tomar el último PyBluez y llamar a setl2capsecurity () pero no he podido hacer ningún progreso.

¿Esto será posible con PyBluez?

Respuestas a la pregunta(1)

Su respuesta a la pregunta