0

I'm trying to create an application in which I want to connect a Bluetooth Low Energy device with my android application by either scanning the bar code of the device or the 6 digit code of that device.

Any suggestions or code (github also) are welcomed.

Thanks in advance

Vikash Sharma
  • 60
  • 2
  • 9
  • What's the meaning of the bar code? Do you want it to contain the Bluetooth Device Address of the peripheral so the central should know which device to connect to, or do you want it to be some kind of pairing passkey to avoid MITM-attacks? – Emil Jul 05 '18 at 11:36
  • Yes it has both MAC address in bar code and pairing passkey printed on the device. – Vikash Sharma Jul 05 '18 at 12:07

1 Answers1

1

For discovering a device with a particular Bluetooth Device Address, just follow the BLE Scan documentation and use a filter with the address. Use a separate Android barcode scanner library to scan the barcode. About static passkey in BLE pairing, the security is not so good, read https://devzone.nordicsemi.com/f/nordic-q-a/35856/questions-about-lesc-mitm-and-passkey/138216#138216 and especially make sure you don't use LE Secure Connections. If you still want to go on (using BLE Legacy Pairing), again use some barcode scanning library to get the passkey and follow instructions how to pragmatically enter the code when pairing, such as this one: Programmatically pairing with a BLE device on Android 4.4+. If the passkey is instead printed and the user should enter it manually, Android OS will automatically show a pop-up where the user can enter the passkey.

Emil
  • 16,784
  • 2
  • 41
  • 52