anaswar
Posts: 5
Joined: Thu Jul 21, 2016 10:47 am

Bluetooth connection without pairing

Thu Jul 21, 2016 10:53 am

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

User avatar
MarkHaysHarris777
Posts: 1820
Joined: Mon Mar 23, 2015 7:39 am
Location: Rochester, MN
Contact: Website

Re: Bluetooth connection without pairing

Thu Jul 21, 2016 11:16 am

oh, trying to make a blue tooth sniffer are we ... ?

marcus
marcus
:ugeek:

anaswar
Posts: 5
Joined: Thu Jul 21, 2016 10:47 am

Re: Bluetooth connection without pairing

Thu Jul 21, 2016 11:47 am

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.

User avatar
Douglas6
Posts: 4672
Joined: Sat Mar 16, 2013 5:34 am
Location: Chicago, IL

Re: Bluetooth connection without pairing

Thu Jul 21, 2016 12:14 pm

As far as I know, you cannot create an RFCOMM connection without being paired. It's Bluetooth security.

anaswar
Posts: 5
Joined: Thu Jul 21, 2016 10:47 am

Re: Bluetooth connection without pairing

Thu Jul 21, 2016 12:20 pm

we don't have anything like insecureRFCOMM in Pi?

User avatar
Douglas6
Posts: 4672
Joined: Sat Mar 16, 2013 5:34 am
Location: Chicago, IL

Re: Bluetooth connection without pairing

Thu Jul 21, 2016 12:32 pm

You can have an unencrypted connection, but still need the pairing, to the best of my knowledge.

anaswar
Posts: 5
Joined: Thu Jul 21, 2016 10:47 am

Re: Bluetooth connection without pairing

Thu Jul 21, 2016 12:35 pm

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 ?

User avatar
Douglas6
Posts: 4672
Joined: Sat Mar 16, 2013 5:34 am
Location: Chicago, IL

Re: Bluetooth connection without pairing

Thu Jul 21, 2016 12:38 pm

No, meaning that once the connection is established via the link keys, data is transferred without encrypting it first.

anaswar
Posts: 5
Joined: Thu Jul 21, 2016 10:47 am

Re: Bluetooth connection without pairing

Tue Jul 26, 2016 2:31 pm

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!!

Return to “General discussion”