danny
danny

Reputation: 510

Setup password on a Bluez BLE beacon

I am running a BLE beacon in bluez5.52 on a linux machine(ubuntu 14.04) using the default gatt-service and the beacon using the btmgmt provided in the tools folder. Following are the commands I run to setup the beacon:

Terminal 1:

./gatt-service

Terminal 2

sudo ./btmgmt
add-adv -u 180d -u 180f -d 080954657374204C45 1

I am easily able to connect and disconnect with the beacon using BLE scanner app in android. What I would like to do is setup a password for the beacon so that I am the only one who can connect to it. So far I have been unable to find any resources online that could help set that up. I have a decent understanding of the btmgmt and gatt-service code. I am looking for direction on what part of bluez code to look for to set up the password protection. Any leads, pseudo-code or partial code would help a lot.

Upvotes: 1

Views: 764

Answers (1)

Michael Kotzjan
Michael Kotzjan

Reputation: 2673

Emil already mentioned pairing and bonding in the comments. This would definetly serve your purpose as you would be able to control who could connect to your peripheral. A BLE characteristic can ask a connected device to authenticate before reading or writing which would result in a 'insufficient authentication error' if the device is not paired to your peripheral. A Android app is able to handle this error by displaying a pairing popup depending on the used pairing method. So it is possible to have characteristics without security right next to one's that require pairing.

In case you still want to implement something like your mentioned password safety you should look into a 'authorized read'. A characteristic which requires authorization first receives a read request and you can allow or deny it based on your own requirements. That means you can authorize yourself by sending a password to one characteristic and afterwards allow a read request on another characteristic. This would be even easier if you only accept one connection at a time.

Upvotes: 1

Related Questions