Giter Site home page Giter Site logo

Comments (11)

davidgyoung avatar davidgyoung commented on September 8, 2024

I suspect that the broadcast packet you are trying to decode does not have a 25th byte, and therefore you are reading a byte outside the valid range that has an inconsistent value. What beacon manufacturer is this? Are you sure it broadcasts a 25th byte?

Apologies, but due to intellectual property restrictions we cannot publish details of proprietary beacon formats in this forum. I have therefore edited the issue above to redact details about decoding the proprietary beacon you mention.

from android-beacon-library.

quitequick avatar quitequick commented on September 8, 2024

The manufacturer confirms the 25th byte is the battery level - the values are in the ballpark [0-100] % and I have a new battery in the beacon (98 and 100). The battery level I read agrees with the manufacturers own beacon config app's value (barring this discrepancy).

I have since noticed that if start my app at the same time on both devices, the values agree between themselves and the manufacturers config app. So I wonder whether the data field value is being updated every time the beacon is ranged?

I am getting the beacon from...
public void didRangeBeaconsInRegion(Collection beacons, Region region)
and I call beacon.getDataFields().get(0).byteValue() every time it is called.

A long shot I know, but it sounded consistent with my observations.

(If you needed to redact the manufacturer from the beacon layout, I guess I shouldn't mention who it is either. If you would like to know, we could communicate via email.)

from android-beacon-library.

quitequick avatar quitequick commented on September 8, 2024

Just a ping on this...

Is the value returned by
beacon.getDataFields().get(0).byteValue()
updated every time the beacon is ranged?

from android-beacon-library.

davidgyoung avatar davidgyoung commented on September 8, 2024

I am not sure I even understand the problem. The comment when the issue opened says that two devices return different values (100 and 98). A subsequent comment says that if both of these devices start ranging simultaneously, they get the same value -- this is inconsistent with the first comment. It seems like it might be reasonable for a battery level measurement to vary between 98 and 100 anyway. I don't think this indicates a problem.

After reviewing the code and adding a test, I have verified that the data fields do get updated from the scan data each time. Can you please describe what you are seeing that leads you to believe the value is not being updated on every ranging callback? What value are you seeing returned by this field that leads you to believe it is not correct? It might be useful if you turn on debugging with beaconManager.setDebug(true) and then provide a LogCat excerpt for 10 seconds or so, which will show the parsed values.

from android-beacon-library.

davidgyoung avatar davidgyoung commented on September 8, 2024

@quitequick, also, can you please let me know the name of the manufacturer and model of the beacon where you see this behavior? There is no problem mentioning this info -- we just cannot publish the details of how to decode a proprietary beacon format in this forum.

from android-beacon-library.

quitequick avatar quitequick commented on September 8, 2024

In the first comment I hadn't discovered that starting the app on two devices at different times was significant. When I wrote the second comment, I had discovered it was.

While the app is running it reads and reports the battery level every time the beacon is ranged. So, I start the app on one device and it reports, say, 98% and I leave it running, continually reading and reporting the battery level when the beacon is ranged (1 Hz). It never changes from 98%. I wait five minutes and start the same app on a second device. The second device finds the same beacon but reads and reports a battery level of 100%. So, the same app running on two different devices at the same time - one reports a battery level of 98% and the other 100%. Both are ranging the same beacon at 1Hz and reading and reporting the battery level.

When I check the battery level using the manufacturers own beacon management app, I get a battery level which generally agrees with my second run app.

This lead me to think that perhaps the data fields were not being read every time the beacon was ranged.

Logcat below...

12-22 16:26:08.862 31007-31007/app_package_name D/BeaconManager﹕ we have a connection to the service now
12-22 16:26:08.862 31007-31007/app_package_name D/AppStarter﹕ Activating background region monitoring
12-22 16:26:08.862 31007-31007/app_package_name D/AppStarter﹕ Background region monitoring activated for region id1: XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX id2: null id3: null
12-22 16:26:08.862 31007-31007/app_package_name D/BeaconManager﹕ callback packageName: app_package_name
12-22 16:26:08.863 31007-31007/app_package_name V/ApplicationName onBeaconServiceConnect
12-22 16:26:08.863 31007-31007/app_package_name D/BeaconManager﹕ callback packageName: app_package_name
12-22 16:26:08.927 31007-31007/app_package_name I/BeaconService﹕ start monitoring received
12-22 16:26:08.927 31007-31007/app_package_name D/BeaconService﹕ startMonitoring called
12-22 16:26:08.928 31007-31007/app_package_name D/BeaconService﹕ Currently monitoring 1 regions.
12-22 16:26:08.931 31007-31007/app_package_name D/BluetoothAdapter﹕ startLeScan(): null
12-22 16:26:08.935 31007-31019/app_package_name D/BluetoothAdapter﹕ onClientRegistered() - status=0 clientIf=5
12-22 16:26:08.937 31007-31007/app_package_name D/BeaconService﹕ Waiting to stop scan for another 1100 milliseconds
12-22 16:26:08.937 31007-31007/app_package_name D/BeaconService﹕ Scan started
12-22 16:26:08.937 31007-31007/app_package_name I/BeaconService﹕ start ranging received
12-22 16:26:08.938 31007-31007/app_package_name D/BeaconService﹕ Currently ranging 1 regions.
12-22 16:26:09.784 31007-31018/app_package_name D/BeaconService﹕ got record
12-22 16:26:09.785 31007-31117/app_package_name D/BeaconParser﹕ This is not a matching Beacon advertisement. (Was expecting be ac. The bytes I see are: 0201061bff4c00YYYYXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX00010001c86200000000000000000000000000000000000000000000000000000000000000
12-22 16:26:09.786 31007-31117/app_package_name D/BeaconParser﹕ This is a recognized beacon advertisement -- YYYY seen
12-22 16:26:09.787 31007-31117/app_package_name D/BeaconParser﹕ Byte array is size 2
12-22 16:26:09.787 31007-31117/app_package_name D/BeaconParser﹕ index is 0
12-22 16:26:09.788 31007-31117/app_package_name D/BeaconParser﹕ calculatedValue for position 0 with positionValue 1 and byteValue 1 is 1
12-22 16:26:09.788 31007-31117/app_package_name D/BeaconParser﹕ index is 1
12-22 16:26:09.788 31007-31117/app_package_name D/BeaconParser﹕ calculatedValue for position 1 with positionValue 256 and byteValue 0 is 0
12-22 16:26:09.788 31007-31117/app_package_name D/BeaconParser﹕ Byte array is size 2
12-22 16:26:09.788 31007-31117/app_package_name D/BeaconParser﹕ index is 0
12-22 16:26:09.789 31007-31117/app_package_name D/BeaconParser﹕ calculatedValue for position 0 with positionValue 1 and byteValue 1 is 1
12-22 16:26:09.789 31007-31117/app_package_name D/BeaconParser﹕ index is 1
12-22 16:26:09.789 31007-31117/app_package_name D/BeaconParser﹕ calculatedValue for position 1 with positionValue 256 and byteValue 0 is 0
12-22 16:26:09.789 31007-31117/app_package_name D/BeaconParser﹕ Byte array is size 1
12-22 16:26:09.789 31007-31117/app_package_name D/BeaconParser﹕ index is 0
12-22 16:26:09.790 31007-31117/app_package_name D/BeaconParser﹕ calculatedValue for position 0 with positionValue 1 and byteValue 98 is 98
12-22 16:26:09.790 31007-31117/app_package_name D/BeaconParser﹕ parsing found data field 0
12-22 16:26:09.790 31007-31117/app_package_name D/BeaconParser﹕ Byte array is size 1
12-22 16:26:09.790 31007-31117/app_package_name D/BeaconParser﹕ index is 0
12-22 16:26:09.790 31007-31117/app_package_name D/BeaconParser﹕ calculatedValue for position 0 with positionValue 1 and byteValue 200 is 200
12-22 16:26:09.790 31007-31117/app_package_name D/BeaconParser﹕ Byte array is size 2
12-22 16:26:09.791 31007-31117/app_package_name D/BeaconParser﹕ index is 0
12-22 16:26:09.791 31007-31117/app_package_name D/BeaconParser﹕ calculatedValue for position 0 with positionValue 1 and byteValue 21 is 21
12-22 16:26:09.791 31007-31117/app_package_name D/BeaconParser﹕ index is 1
12-22 16:26:09.791 31007-31117/app_package_name D/BeaconParser﹕ calculatedValue for position 1 with positionValue 256 and byteValue 2 is 512
12-22 16:26:09.791 31007-31117/app_package_name D/BeaconParser﹕ Byte array is size 2
12-22 16:26:09.792 31007-31117/app_package_name D/BeaconParser﹕ index is 0
12-22 16:26:09.792 31007-31117/app_package_name D/BeaconParser﹕ calculatedValue for position 0 with positionValue 1 and byteValue 76 is 76
12-22 16:26:09.793 31007-31117/app_package_name D/BeaconParser﹕ index is 1
12-22 16:26:09.793 31007-31117/app_package_name D/BeaconParser﹕ calculatedValue for position 1 with positionValue 256 and byteValue 0 is 0
12-22 16:26:09.794 31007-31117/app_package_name D/BeaconService﹕ beacon detected :id1: XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX id2: 1 id3: 1
12-22 16:26:09.795 31007-31117/app_package_name D/Callback﹕ attempting callback via intent: ComponentInfo{app_package_name/org.altbeacon.beacon.BeaconIntentProcessor}
12-22 16:26:09.797 31007-31117/app_package_name D/BeaconService﹕ looking for ranging region matches for this beacon
12-22 16:26:09.797 31007-31117/app_package_name D/BeaconService﹕ matches ranging region: id1: XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX id2: null id3: null
12-22 16:26:09.798 31007-31117/app_package_name D/RangeState﹕ adding id1: XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX id2: 1 id3: 1 to new rangedBeacon
12-22 16:26:09.799 31007-31118/app_package_name D/BeaconIntentProcessor﹕ got an intent to process
12-22 16:26:09.801 31007-31118/app_package_name D/BeaconIntentProcessor﹕ got monitoring data
12-22 16:26:09.801 31007-31118/app_package_name D/BeaconIntentProcessor﹕ Calling monitoring notifier:app_package_name.ApplicationName@41f8be10
12-22 16:26:09.801 31007-31118/app_package_name V/ApplicationName APP didDetermineStateForRegion
12-22 16:26:09.801 31007-31118/app_package_name V/ApplicationName APP didEnterRegion and rssi is -999
12-22 16:26:09.938 31007-31007/app_package_name D/BeaconService﹕ Waiting to stop scan for another 100 milliseconds
12-22 16:26:10.038 31007-31007/app_package_name D/BeaconService﹕ Done with scan cycle
12-22 16:26:10.038 31007-31007/app_package_name D/BeaconService﹕ Calling ranging callback
12-22 16:26:10.039 31007-31007/app_package_name D/RangedBeacon﹕ Running average mRssi based on 1 measurements: -58.0
12-22 16:26:10.039 31007-31007/app_package_name D/RangedBeacon﹕ calculated new runningAverageRssi:-58.0
12-22 16:26:10.039 31007-31007/app_package_name D/Callback﹕ attempting callback via intent: ComponentInfo{app_package_name/org.altbeacon.beacon.BeaconIntentProcessor}
12-22 16:26:10.039 31007-31007/app_package_name D/RangingData﹕ writing RangingData
12-22 16:26:10.040 31007-31007/app_package_name D/Beacon﹕ serializing identifiers of size 3
12-22 16:26:10.040 31007-31007/app_package_name D/CurveFittedDistanceCalculator﹕ calculating distance based on mRssi of -58.0 and txPower of -56
12-22 16:26:10.040 31007-31007/app_package_name D/CurveFittedDistanceCalculator﹕ avg mRssi: -58.0 distance: 1.0870644230595385
12-22 16:26:10.041 31007-31007/app_package_name D/RangingData﹕ done writing RangingData
12-22 16:26:10.043 31007-31007/app_package_name D/BluetoothAdapter﹕ stopLeScan()
12-22 16:26:10.049 31007-31007/app_package_name D/BeaconService﹕ Restarting scan. Unique beacons seen last cycle: 1 Total beacon advertisement packets seen: 1
12-22 16:26:10.049 31007-31007/app_package_name D/BluetoothAdapter﹕ startLeScan(): null
12-22 16:26:10.051 31007-31018/app_package_name D/BluetoothAdapter﹕ onClientRegistered() - status=0 clientIf=5
12-22 16:26:10.053 31007-31007/app_package_name D/BeaconService﹕ Waiting to stop scan for another 1100 milliseconds
12-22 16:26:10.053 31007-31007/app_package_name D/BeaconService﹕ Scan started
12-22 16:26:10.055 31007-31122/app_package_name D/BeaconIntentProcessor﹕ got an intent to process
12-22 16:26:10.055 31007-31122/app_package_name D/RangingData﹕ parsing RangingData
12-22 16:26:10.058 31007-31122/app_package_name D/RangingData﹕ parsing RangingData
12-22 16:26:10.060 31007-31122/app_package_name D/BeaconIntentProcessor﹕ got ranging data
12-22 16:26:10.060 31007-31122/app_package_name V/ApplicationName beacon IN range
12-22 16:26:11.054 31007-31007/app_package_name D/BeaconService﹕ Waiting to stop scan for another 99 milliseconds
12-22 16:26:11.153 31007-31007/app_package_name D/BeaconService﹕ Done with scan cycle
12-22 16:26:11.154 31007-31007/app_package_name D/BeaconService﹕ Calling ranging callback
12-22 16:26:11.154 31007-31007/app_package_name D/Callback﹕ attempting callback via intent: ComponentInfo{app_package_name/org.altbeacon.beacon.BeaconIntentProcessor}
12-22 16:26:11.154 31007-31007/app_package_name D/RangingData﹕ writing RangingData
12-22 16:26:11.154 31007-31007/app_package_name D/RangingData﹕ done writing RangingData
12-22 16:26:11.157 31007-31007/app_package_name D/BluetoothAdapter﹕ stopLeScan()
12-22 16:26:11.160 31007-31007/app_package_name D/BeaconService﹕ Restarting scan. Unique beacons seen last cycle: 0 Total beacon advertisement packets seen: 0
12-22 16:26:11.160 31007-31007/app_package_name D/BluetoothAdapter﹕ startLeScan(): null
12-22 16:26:11.162 31007-31019/app_package_name D/BluetoothAdapter﹕ onClientRegistered() - status=0 clientIf=5
12-22 16:26:11.164 31007-31007/app_package_name D/BeaconService﹕ Waiting to stop scan for another 1100 milliseconds
12-22 16:26:11.164 31007-31007/app_package_name D/BeaconService﹕ Scan started
12-22 16:26:11.165 31007-31123/app_package_name D/BeaconIntentProcessor﹕ got an intent to process
12-22 16:26:11.165 31007-31123/app_package_name D/RangingData﹕ parsing RangingData
12-22 16:26:11.166 31007-31123/app_package_name D/RangingData﹕ parsing RangingData
12-22 16:26:11.166 31007-31123/app_package_name D/BeaconIntentProcessor﹕ got ranging data
12-22 16:26:11.795 31007-31018/app_package_name D/BeaconService﹕ got record
12-22 16:26:11.805 31007-31126/app_package_name D/BeaconParser﹕ This is not a matching Beacon advertisement. (Was expecting be ac. The bytes I see are: 0201061bff4c00YYYYXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX00010001c86200000000000000000000000000000000000000000000000000000000000000
12-22 16:26:11.806 31007-31126/app_package_name D/BeaconParser﹕ This is a recognized beacon advertisement -- YYYY seen
12-22 16:26:11.806 31007-31126/app_package_name D/BeaconParser﹕ Byte array is size 2
12-22 16:26:11.806 31007-31126/app_package_name D/BeaconParser﹕ index is 0
12-22 16:26:11.806 31007-31126/app_package_name D/BeaconParser﹕ calculatedValue for position 0 with positionValue 1 and byteValue 1 is 1
12-22 16:26:11.807 31007-31126/app_package_name D/BeaconParser﹕ index is 1
12-22 16:26:11.811 31007-31126/app_package_name D/BeaconParser﹕ calculatedValue for position 1 with positionValue 256 and byteValue 0 is 0
12-22 16:26:11.811 31007-31126/app_package_name D/BeaconParser﹕ Byte array is size 2
12-22 16:26:11.812 31007-31126/app_package_name D/BeaconParser﹕ index is 0
12-22 16:26:11.817 31007-31126/app_package_name D/BeaconParser﹕ calculatedValue for position 0 with positionValue 1 and byteValue 1 is 1
12-22 16:26:11.818 31007-31126/app_package_name D/BeaconParser﹕ index is 1
12-22 16:26:11.821 31007-31126/app_package_name D/BeaconParser﹕ calculatedValue for position 1 with positionValue 256 and byteValue 0 is 0
12-22 16:26:11.822 31007-31126/app_package_name D/BeaconParser﹕ Byte array is size 1
12-22 16:26:11.822 31007-31126/app_package_name D/BeaconParser﹕ index is 0
12-22 16:26:11.822 31007-31126/app_package_name D/BeaconParser﹕ calculatedValue for position 0 with positionValue 1 and byteValue 98 is 98
12-22 16:26:11.830 31007-31126/app_package_name D/BeaconParser﹕ parsing found data field 0
12-22 16:26:11.830 31007-31126/app_package_name D/BeaconParser﹕ Byte array is size 1
12-22 16:26:11.832 31007-31126/app_package_name D/BeaconParser﹕ index is 0
12-22 16:26:11.835 31007-31126/app_package_name D/BeaconParser﹕ calculatedValue for position 0 with positionValue 1 and byteValue 200 is 200
12-22 16:26:11.838 31007-31126/app_package_name D/BeaconParser﹕ Byte array is size 2
12-22 16:26:11.841 31007-31126/app_package_name D/BeaconParser﹕ index is 0
12-22 16:26:11.848 31007-31126/app_package_name D/BeaconParser﹕ calculatedValue for position 0 with positionValue 1 and byteValue 21 is 21
12-22 16:26:11.851 31007-31126/app_package_name D/BeaconParser﹕ index is 1
12-22 16:26:11.858 31007-31126/app_package_name D/BeaconParser﹕ calculatedValue for position 1 with positionValue 256 and byteValue 2 is 512
12-22 16:26:11.860 31007-31126/app_package_name D/BeaconParser﹕ Byte array is size 2
12-22 16:26:11.863 31007-31126/app_package_name D/BeaconParser﹕ index is 0
12-22 16:26:11.868 31007-31126/app_package_name D/BeaconParser﹕ calculatedValue for position 0 with positionValue 1 and byteValue 76 is 76
12-22 16:26:11.872 31007-31126/app_package_name D/BeaconParser﹕ index is 1
12-22 16:26:11.872 31007-31126/app_package_name D/BeaconParser﹕ calculatedValue for position 1 with positionValue 256 and byteValue 0 is 0
12-22 16:26:11.906 31007-31126/app_package_name D/BeaconService﹕ beacon detected :id1: XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX id2: 1 id3: 1
12-22 16:26:11.906 31007-31126/app_package_name D/BeaconService﹕ looking for ranging region matches for this beacon
12-22 16:26:11.906 31007-31126/app_package_name D/BeaconService﹕ matches ranging region: id1: XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX id2: null id3: null
12-22 16:26:11.907 31007-31126/app_package_name D/RangeState﹕ adding id1: XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX id2: 1 id3: 1 to existing range for: org.altbeacon.beacon.service.RangedBeacon@42738078
12-22 16:26:12.068 31007-31007/app_package_name D/dalvikvm﹕ GC_FOR_ALLOC freed 700K, 6% free 16231K/17224K, paused 26ms, total 26ms
12-22 16:26:12.134 31007-31007/app_package_name D/dalvikvm﹕ GC_FOR_ALLOC freed 1285K, 11% free 16751K/18616K, paused 24ms, total 24ms
12-22 16:26:12.389 31007-31007/app_package_name D/dalvikvm﹕ GC_FOR_ALLOC freed 1391K, 8% free 17937K/19368K, paused 33ms, total 33ms
12-22 16:26:12.832 31007-31007/app_package_name D/dalvikvm﹕ GC_FOR_ALLOC freed 1866K, 10% free 19049K/20956K, paused 41ms, total 41ms
12-22 16:26:12.833 31007-31019/app_package_name D/BeaconService﹕ got record
12-22 16:26:12.836 31007-31149/app_package_name D/BeaconParser﹕ This is not a matching Beacon advertisement. (Was expecting be ac. The bytes I see are: 0201061bff4c00YYYYXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX00010001c86200000000000000000000000000000000000000000000000000000000000000
12-22 16:26:12.837 31007-31149/app_package_name D/BeaconParser﹕ This is a recognized beacon advertisement -- YYYY seen
12-22 16:26:12.837 31007-31149/app_package_name D/BeaconParser﹕ Byte array is size 2
12-22 16:26:12.837 31007-31149/app_package_name D/BeaconParser﹕ index is 0
12-22 16:26:12.837 31007-31149/app_package_name D/BeaconParser﹕ calculatedValue for position 0 with positionValue 1 and byteValue 1 is 1
12-22 16:26:12.838 31007-31149/app_package_name D/BeaconParser﹕ index is 1
12-22 16:26:12.838 31007-31149/app_package_name D/BeaconParser﹕ calculatedValue for position 1 with positionValue 256 and byteValue 0 is 0
12-22 16:26:12.838 31007-31149/app_package_name D/BeaconParser﹕ Byte array is size 2
12-22 16:26:12.838 31007-31149/app_package_name D/BeaconParser﹕ index is 0
12-22 16:26:12.838 31007-31149/app_package_name D/BeaconParser﹕ calculatedValue for position 0 with positionValue 1 and byteValue 1 is 1
12-22 16:26:12.838 31007-31149/app_package_name D/BeaconParser﹕ index is 1
12-22 16:26:12.838 31007-31149/app_package_name D/BeaconParser﹕ calculatedValue for position 1 with positionValue 256 and byteValue 0 is 0
12-22 16:26:12.839 31007-31149/app_package_name D/BeaconParser﹕ Byte array is size 1
12-22 16:26:12.839 31007-31149/app_package_name D/BeaconParser﹕ index is 0
12-22 16:26:12.839 31007-31149/app_package_name D/BeaconParser﹕ calculatedValue for position 0 with positionValue 1 and byteValue 98 is 98
12-22 16:26:12.839 31007-31149/app_package_name D/BeaconParser﹕ parsing found data field 0
12-22 16:26:12.839 31007-31149/app_package_name D/BeaconParser﹕ Byte array is size 1
12-22 16:26:12.839 31007-31149/app_package_name D/BeaconParser﹕ index is 0
12-22 16:26:12.840 31007-31149/app_package_name D/BeaconParser﹕ calculatedValue for position 0 with positionValue 1 and byteValue 200 is 200
12-22 16:26:12.840 31007-31149/app_package_name D/BeaconParser﹕ Byte array is size 2
12-22 16:26:12.840 31007-31149/app_package_name D/BeaconParser﹕ index is 0
12-22 16:26:12.840 31007-31149/app_package_name D/BeaconParser﹕ calculatedValue for position 0 with positionValue 1 and byteValue 21 is 21
12-22 16:26:12.840 31007-31149/app_package_name D/BeaconParser﹕ index is 1
12-22 16:26:12.840 31007-31149/app_package_name D/BeaconParser﹕ calculatedValue for position 1 with positionValue 256 and byteValue 2 is 512
12-22 16:26:12.840 31007-31149/app_package_name D/BeaconParser﹕ Byte array is size 2
12-22 16:26:12.840 31007-31149/app_package_name D/BeaconParser﹕ index is 0
12-22 16:26:12.841 31007-31149/app_package_name D/BeaconParser﹕ calculatedValue for position 0 with positionValue 1 and byteValue 76 is 76
12-22 16:26:12.841 31007-31149/app_package_name D/BeaconParser﹕ index is 1
12-22 16:26:12.841 31007-31149/app_package_name D/BeaconParser﹕ calculatedValue for position 1 with positionValue 256 and byteValue 0 is 0
12-22 16:26:12.843 31007-31149/app_package_name D/BeaconService﹕ beacon detected multiple times in scan cycle :id1: XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX id2: 1 id3: 1
12-22 16:26:12.843 31007-31149/app_package_name D/BeaconService﹕ beacon detected :id1: XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX id2: 1 id3: 1
12-22 16:26:12.844 31007-31149/app_package_name D/BeaconService﹕ looking for ranging region matches for this beacon
12-22 16:26:12.844 31007-31149/app_package_name D/BeaconService﹕ matches ranging region: id1: XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX id2: null id3: null
12-22 16:26:12.845 31007-31149/app_package_name D/RangeState﹕ adding id1: XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX id2: 1 id3: 1 to existing range for: org.altbeacon.beacon.service.RangedBeacon@42738078

from android-beacon-library.

davidgyoung avatar davidgyoung commented on September 8, 2024

OK, in the log excerpt you provided, you can see three examples of where the beacon is detected, along with the raw bytes (which I see you have edited to remove your UUID -- no problem there). In these three examples, you can see the raw bytes detected by the bluetooth radio on Android:

0201061bff4c00YYYYXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX00010001c86200000000000000000000000000000000000000000000000000000000000000

Note that in all three cases the first data field byte is 0x62 hex (98 decimal). If you leave this running, do you ever see this change?

The best way to help troubleshoot this (since I cannot reproduce) is to add a log line in the didRangeBeaconsInRegion callback that prints out the battery level. You can then capture a longer log excerpt like above and look for a case where the first data field does not match the battery level in a log line like above.

from android-beacon-library.

quitequick avatar quitequick commented on September 8, 2024

The troubleshooting you suggest is what I did to determine that they were different...

        public void didRangeBeaconsInRegion(Collection<Beacon> beacons, Region region)
        {
            Beacon beacon = null;
            for (Iterator iterator = beacons.iterator(); iterator.hasNext(); )
                {
                // code to choose and set variable 'beacon'
                // but in my tests I only have one beacon running in the region anyway
                }

           ....

            byte beaconBatteryLevel = beacon.getDataFields().get(0).byteValue();
            Log.v(TAG, "beaconBatteryLevel = "+beaconBatteryLevel);
           etc.

If I leave it running I don't see it change. And if I start the app on another device, sometimes I will see a different value. I see this discrepancy when I am handling the battery thus warming it up which no doubt increases the reported battery level. It doesn't happen all the time because, presumably, the actual battery level didn't change between app invocations.

As I say, with the above code with two devices running the same app ranging the same device, I sometimes get different battery levels reported when the app is started at different times (thus leaving time for the battery level to possibly change).

from android-beacon-library.

davidgyoung avatar davidgyoung commented on September 8, 2024

This is fixed in fb5c11e

@quitequick was correct that the data fields did not get updated on each ranging callback. While a new Beacon object with the proper data values did get created on each detection, it was inadvertently thrown away in favor of the copy of the object form the previous detection, and the RSSI was updated on that object. This was a holdover from the 1.0 version of the library where data fields did not exist, and this technique was valid. This is no longer a valid approach since not just RSSI can change with each detection -- data field values also can change. The fix is to replace the old Beacon instance with a new beacon instance in the RangedBeacon class for each detection.

from android-beacon-library.

quitequick avatar quitequick commented on September 8, 2024

@davidgyoung - Thanks for fixing this!

from android-beacon-library.

davidgyoung avatar davidgyoung commented on September 8, 2024

Just a little Christmas gift from Radius Networks :)

from android-beacon-library.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.