0
votes

I have an android BLE client and an android BLE server.

After the initial connection, I want the server to allow only the previously connected client device to connect.

How to achieve this?

What I have considered so far:

1. Bond the devices via android Bluetooth settings

Is it possible to allow only bonded devices to connect to the server? If so, how?

2. Some sort of whitelist

  • Mac Address (problematic, as mac addresses are not static)
  • device name
  • IRK

Is it possible to implement such a whitelist? If so, how?

3. Only advertise for first connection

Only advertise for first connection, then remember the server device on the client side and try to connect to the server without advertising. This does not seem to work.

1

1 Answers

0
votes

Id recommend your second option. With ble to create a connection you scan devices and then after the scan you can make the GATT connection to them. So if you only want previously connected device to make this connection just filter then on the scan callback. As you can filter by MAC address. This can be done by storing your list of MAC addresses in the global settings so the data does not reset when the app reopens. Just add a list of strings with your devices and filter by that.

You will also need a one off state for the initial connection. So that if there are no entries in your list then scan freely without a filter.