ostrya / PresencePublisher

An Android MQTT client that regularly publishes messages to notify about the device's presence
MIT License
79 stars 12 forks source link

Bugs in the detection engine #38

Open AtmanActive opened 3 years ago

AtmanActive commented 3 years ago

Hi,

Thank you for this wonderful software. It is a unique gem of a iBeacon to MQTT glue.

I started using it recently with one Feasybeacon FSC-BP103 (TICC2640R2F) stashed in every room of my house. I find these great because their output power can be fine tuned so I can eliminate crosstalk, i.e. situations where I am sitting in the living room but my phone is still picking up the beacon from the bedroom.

Now, most of the time Presence Publisher works correctly, but every once in a while it gets stuck in a weird loop where it stops working and there is a flood of messages I don't really understand in the logs. Like, for example:

This region () does not match beacon: id1: xxxxxxxxx

What does this even mean? What is a "region"? Nowhere in the app UI is this word mentioned. Also, why is this repeated over and over again in the logs?

It could be that the Presence Publisher is working correctly but my beacons are failing me, which I will try to address in a separate thread.

Thanks.

Screenshot_20210822_095850.jpg

ostrya commented 3 years ago

These log messages come from the underlying altbeacon detection library (https://altbeacon.github.io/android-beacon-library/). I guess the log output is not very helpful without the technical context.

Altbeacon allows apps to define so-called regions which are usually defined by 3 IDs, and will send a notification once the mobile device enters or leaves such a region (which means that at least one beacon with matching IDs is within range or not).

I kind of use a different approach - I match beacons by MAC address. This is also possible, but it means that a) each beacon needs to be mapped to its own "region", because a region can only have one MAC address for filtering b) the mac address does not seem to be important to the library, at least it is not contained in the logs, so it is hard to tell what went wrong.

I can only take guesses: As the MAC address is only visible to an app if the location services are enabled and the app has location permission, maybe you have switched off the location services or Android terminated the main process, and the beacon detection service itself is no longer recognized as having the necessary permissions.

As I don't actually own beacons, I came up with the MAC address mechanism because it is easier to implement. Buf it may work better if I used the library correctly and match by IDs rather than MAC address. I'll have to think about this though.