Page 1 of 1

Bluetooth connection without pairing

Posted: Thu Jul 21, 2016 10:53 am
by anaswar
I would like to establish a bluetooth connection from an android device to a Raspberry Pi without pairing. The language used in RPi is Python. I am connecting using createInsecureRfcommSocketToServiceRecord from android.

However the connection is established only when the two devices are paired. Is there an equivalent of listenUsingInsecureRfcommWithServiceRecord in Python?

My OS is Raspbian GNU/Linux 8 (jessie)

Raspberry Pi code

Code: Select all

server_sock=BluetoothSocket( RFCOMM )
server_sock.bind(("",PORT_ANY))
server_sock.listen(1)
port = server_sock.getsockname()[1]

uuid = "f3c74f47-1d38-49ed-8bbc-0369b3eb277c"

advertise_service( server_sock, "PiServer",
                   service_id = uuid,
                   service_classes = [ uuid, SERIAL_PORT_CLASS ],
                   profiles = [ SERIAL_PORT_PROFILE ], 
                   )

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

Code: Select all

BluetoothDevice device = blueAdapter.getRemoteDevice(RPi_MAC);
BluetoothSocket socket = device.createInsecureRfcommSocketToServiceRecord(UUID.fromString("f3c74f47-1d38-49ed-8bbc-0369b3eb277c"));
blueAdapter.cancelDiscovery();
socket.connect();

Re: Bluetooth connection without pairing

Posted: Thu Jul 21, 2016 11:16 am
by MarkHaysHarris777
oh, trying to make a blue tooth sniffer are we ... ?

marcus

Re: Bluetooth connection without pairing

Posted: Thu Jul 21, 2016 11:47 am
by anaswar
MarkHaysHarris777 wrote:oh, trying to make a blue tooth sniffer are we ... ?

marcus
I'm trying to create an intelligent server using RPi. Each connected client's MAC address will be registered.
There will be lots of clients so pairing is not feasible.

Re: Bluetooth connection without pairing

Posted: Thu Jul 21, 2016 12:14 pm
by Douglas6
As far as I know, you cannot create an RFCOMM connection without being paired. It's Bluetooth security.

Re: Bluetooth connection without pairing

Posted: Thu Jul 21, 2016 12:20 pm
by anaswar
we don't have anything like insecureRFCOMM in Pi?

Re: Bluetooth connection without pairing

Posted: Thu Jul 21, 2016 12:32 pm
by Douglas6
You can have an unencrypted connection, but still need the pairing, to the best of my knowledge.

Re: Bluetooth connection without pairing

Posted: Thu Jul 21, 2016 12:35 pm
by anaswar
Douglas6 wrote:You can have an unencrypted connection, but still need the pairing, to the best of my knowledge.
meaning we can pair without the pin code/ authentication ?

Re: Bluetooth connection without pairing

Posted: Thu Jul 21, 2016 12:38 pm
by Douglas6
No, meaning that once the connection is established via the link keys, data is transferred without encrypting it first.

Re: Bluetooth connection without pairing

Posted: Tue Jul 26, 2016 2:31 pm
by anaswar
I was able to connect to the Raspberry Pi without pairing. For this I had to make the RPi discoverable. Then I used socket.connect() from my Nexus running on Marshmallow. By doing this I was able to get the MAC address of my Nexus in the RPi. Only problem is that I get a pairing request every time I connect but the MAC address was what I wanted.

Thanks for all your inputs guys!!