1

I am working on a Bluetooth-based application.

GATT Server and Gatt Client, The above communication is working fine, I am not having an issue with it.

The problem is I am getting a connection from an unknown device, I want to allow connection from my app only if someone other tries to connect I want to reject that connection.

How can I implement that ?.

If a reject connection is not possible, how can I identify this connection is requested from my app, is there any way to add some security before connecting with my GATT server ?.

Thanks.

Ashvin solanki
  • 4,802
  • 3
  • 25
  • 65
  • You can achieve this with pairing/bonding and whitelisting. What device are you using as a GATT client and what device are you using as a GATT server? Are they both Android phones? – Youssif Saeed Aug 26 '22 at 06:16
  • One is using Gatt Server and Second is Using Gatt Client, actually both device will have same code, Client / Server will be closed and connect based on needs. – Ashvin solanki Aug 26 '22 at 06:35
  • @YoussifSaeed Are they both Android phones? yes – Ashvin solanki Aug 26 '22 at 07:39

1 Answers1

0

The best way to achieve this is to have an encrypted characteristic on your GATT server, and then have the GATT client attempt to read it right after service discovery. This way you trigger a bonding procedure (and therefore the pairing dialog will pop up), and you'll have the last say on who/what device can connect to your device. This is described in the links below:-

Youssif Saeed
  • 11,789
  • 4
  • 44
  • 72
  • I had problem paired devices, when i was opening opening gatt server, i am getting callback from the system the devices is connected but that was a normal device who paired with system. – Ashvin solanki Aug 31 '22 at 11:57