Android Peripheral Requires Pairing - android

I am writing an Android app that acts as a BLE peripheral.
When I connect to it using another device it always requests pairing. How do I make it so that it won't require pairing?
I have a single service and single characteristic and the permission on it are just normal read and write. I am not requesting any encrypted version of those.

Every device has mac address, connection is made by using mac addresss.
Connect to device and Save connected device mac address in shread preference so every time it will connect to that save device only.
So it will not ask pairing every time.
If you want to disconnect that device , in disconnect method clear mac address from shread preference.
I hope this will work for you.

Related

Can I connect bluetooth device automatically with the device which already paired without showing choose dialog

I am developing a solution for connection between OBD2(Vehicle ECU scanner) with the mobile app.
I want that when ever that OBD device is found and it is already paired then the application automatically connect with the device and create a socket for transmission of data . without showing the dialog box to choose a paired device.
You can connect to any paired Bluetooth device, to do so, you have to know device's address and UUID. Embedded devices may have some defined uuid (for example, hc05 adapter), you can get that uuid from documentation.
The tricky part here is that you have to monitor failure and loss of connection so you can retry again. I'm implementing that feature in my home project, fell free to see code: https://github.com/AlexShutov/LEDLights

Bluetooth+arduino and android authentication

I have a device. I use microcontroller arduino. I have connected my device with my android application via bluetooth. And I want to do that only my application can connect to my device. What is the best way to do this authentification? Can I do this with bluetooth's special AT commands? If yes how? Or must I send some key to the arduino from the application and check it?
By defaukt bluetooth adapters accept all connections (no binding), so you have tobcheck if this is the right device explicitly. You can store data persistently in eeprom on microcontroller, where you should keep your app key. When new phone try to connect to your device you should check if device passed that key and if not, do nothing in response.

How to check a Bluetooth remote device has been connected with a different phone in Android?

My android application has to connect to a remote Bluetooth device whose Bluetooth address is known to the app. The application will not be able to connect to the device if it is already connected with a different phone as the remote device can accept connection from a single phone at atime. In such cases, the app has to display an alert of "device is already paired with a different phone". My question is how the app can detect whether the remote device is already connected to a different phone ? I know BluetoothAdapter.startDiscovery() can be used to check whether the device is discoverable. But I am not using this as the app knows the bluetooth address of the device, also I don't want to use it as it is a time consuming process. So is there an alternative method to detect it?

Connect Android to another device on bluetooth and send data

I want to create a connection between my Android and a PC (or another device) just like in the Bluetooth menu from settings.
I have manage to get the list of all bt devices in my range and get their MAC addresses.
So, I have the BluetoothDevice, how can i connect to it or pair with it? I saw a lot of stuff about creating a server on PC, but I don't want that, i just wanna connect with the device.
My attempt were to get the UUID of the device and use createRfcommSocketToServiceRecord...but when i try socket.connect() it cannot connect (because I don't have a server). So practically I need to make the same structure that the OS is doing (connect with the device, if the connected device is trying to send i can receive the info and so on).
If I managed to connect with the device, I want to listen all that it is emitting, no matter the data...I haven't researched this topic, but any advice will be nice.
The connection must be made with any device that supports bluetooth, and I don't have access to it (of course the device is giving me the permission to connect).
Grab the Android sample projects by doing this http://developer.android.com/tools/samples/index.html
They have an app called BluetoothChat that pretty much does just what you want.
The thing about the 'server' is just in the connection, one side needs to open a listening port and that side is arbitrarily the 'server'. Once they are connected they are merely peers and you can write/read data till the cows come home.

Bluetooth communication between an Android phone and a hardware device supporting bluetooth

I'am trying to make an app that receives some binary data from a other device which is not running android. The Android phone should not transfer any data to this device. So over to my questions:
Should the phone act as the server which establishes the RCOMM channel?
Is it possible to connect the phone and this device without paring, as long as I know the MAC-address of the device? If so, how?
And yes, I have read http://developer.android.com/guide/topics/connectivity/bluetooth.html so no need to only answer with that link. :)
Thanks in advance!
1)
Phone should act as a receiver.
I found that the tricky part is to use correct UUID.
If you connect two phones you should be generating those and everything work fine, but on your hardware you can't change UUID that easily.
Take a look at these reserved UUIDs.
For a Serial Port Profile's (SPP) communication use UUID 00001101-0000-1000-8000-00805F9B34FB.
2)
You can connect to a device without pairing if you already know the MAC address, you don't even need to use BlueTooth discovery.
To get device using MAC address call getRemoteDevice(String)
and then createRfcommSocketToServiceRecord(UUID) to get BlueToothSocket.
Also take a look at checkBluetoothAddress(String) to validate MAC address.

Categories

Resources