1

I have a BLE Beacon and instead of broadcasting constantly it just broadcasts a message when you push a button. It's a commissioning message. I'm looking all over the place but can't find a library that listens to Beacon messages.

I've taken a look and tried these solutions:

https://altbeacon.github.io/android-beacon-library/index.html

https://developers.google.com/nearby/messages/android/get-started

Is there a library that allows this?

5
  • I have written a blog regarding scanning Eddystone and also have a link to the source code of the sample you can check that out. it's not the library as you asked for but you can get started. talentica.com/blogs/… Commented Apr 30, 2021 at 16:03
  • Hey dinkar, thank you for commenting I appreciate it. I've used the android native scanner before but I just assumed it wouldn't work in my case given it's a single message that I'm trying to catch instead of a device. Commented Apr 30, 2021 at 16:09
  • In the end all the devices send one or another type of protocol message only (eddystone-uid,iBeacon etc). its not like your message should be continuous to get heard by your scanner, if you are broadcasting once also if your scanner active already, it will pick that up. Commented Apr 30, 2021 at 16:14
  • 1
    Hey Dinkar, I'm finally being able to scan for these messages. It turned out to be such a simple thing. I was getting the concepts mixed up. Thanks for clarifying those! Have a great w/e Commented May 1, 2021 at 11:52
  • Awesome. Have a great weekend you too 👍 Commented May 1, 2021 at 12:53

1 Answer 1

1

In order to detect a beacon message sent at the push of a button, you need the mobile app to be listening constantly ("scanning" is the BLE term) because it doesn't know when you are going to press the button.

You can use the open source Android Beacon Library mentioned in your question to do this. You would want to use its "beacon ranging" API which scans for beacons and tells your app what beacons it sees (if any) with a callback every second. If somebody hits the button the beacon, your app will get a callback to didRangeBeaconsInRegion with a single beacon in the list. (If nobody hits the button, the app would get a callback with zero beacons in the list.)

A couple of important points:

  1. You need to know the format of the beacon your hardware is transmitting (iBeacon, AltBeacon, Eddystone-UID, Eddystone-URL, etc.) so you can set up the scanning library to look for that kind of beacon.

  2. You need to know what kind of identifier the hardware beacon sends out. Formats like iBeacon and Altbeacon transmit long hexadecimal UUID identifiers like "2F234454-CF6D-4A0F-ADF2-F4911BA9FFA6". You will need to know what it sends so you can tell if the beacon is yours. Otherwise your program will react even if somebody else's beacon is transmitting.

Full disclosure: I am the lead developer on the Android Beacon Library Open Source Project

Sign up to request clarification or add additional context in comments.

2 Comments

Hey David. Thank you so much for taking the time to write all that. I've implemented your solution but sadly I still see 0 beacons even when I press the button. At the moment I don't know which type of beacon I have in hand so I didn't set up the scanning library to scan for this type of beacon. You think it's because of that? Shouldn't I be able to scan any beacon at all regardless its type?
Try using my BeaconScope app in the Google Play store to find the beacon format. It will scan for any iBeacon, AltBeacon or Eddystone transmission among others. You can make the Android Beacon Library do the same, but it does not do so by default because it has costs in terms of phone battery usage.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.