Estimote / Android-Fleet-Management-SDK

Estimote Fleet Management SDK for Android
https://developer.estimote.com
MIT License
836 stars 451 forks source link

Duplicate reports in onTelemetriesFound() #187

Closed arslanmustafa closed 7 years ago

arslanmustafa commented 7 years ago

I discovered that onTelemetriesFound() method is possibly reporting the same value over and over again even though no new telemetry packet is received.

Here is what I tried:

Estimote Location beacon is set to advertise Estimote Telemetry packet with 2570 ms. period. BeaconManager is configured with 250 ms. foreground scanning period with no wait (setForegroundScanPeriod(250, 0)).

When onTelemetriesFound() method returns at every 250 ms, it repeats the last received telemetry packet since it is impossible for the beacon to transmit a new packet that frequently. If my suspicion is correct and these are indeed duplicates, is there a way for the API to filter these or do I have to implement some filtering scheme myself?

Here is the output of my logcat:

02-08 09:26:51.831 14844-14844/telemetry D/Line 47: MainActivity onTelemetriesFound(): beaconID: [XXXXX] rssi: -54 accelerometer: (-0.02,0.00,1.02) 02-08 09:26:52.084 14844-14844/telemetry D/Line 47: MainActivity onTelemetriesFound(): beaconID: [XXXXX] rssi: -54 accelerometer: (-0.02,0.00,1.02) 02-08 09:26:52.330 14844-14844/telemetry D/Line 47: MainActivity onTelemetriesFound(): beaconID: [XXXXX] rssi: -54 accelerometer: (-0.02,0.00,1.02) 02-08 09:26:52.580 14844-14844/telemetry D/Line 47: MainActivity onTelemetriesFound(): beaconID: [XXXXX] rssi: -54 accelerometer: (-0.02,0.00,1.02) 02-08 09:26:52.830 14844-14844/telemetry D/Line 47: MainActivity onTelemetriesFound(): beaconID: [XXXXX] rssi: -54 accelerometer: (-0.02,0.00,1.02) 02-08 09:26:53.085 14844-14844/telemetry D/Line 47: MainActivity onTelemetriesFound(): beaconID: [XXXXX] rssi: -54 accelerometer: (-0.02,0.00,1.02) 02-08 09:26:53.331 14844-14844/telemetry D/Line 47: MainActivity onTelemetriesFound(): beaconID: [XXXXX] rssi: -54 accelerometer: (-0.02,0.00,1.02)

pawelDylag commented 7 years ago

Helo @arslanmustafa!

Take a look at our freshly released version 1.0.0 - your problem should be fixed :)

Let me know if this works for you now :)

arslanmustafa commented 7 years ago

Hi @pawelDylag,

I regret to say that the problem persists. I made sure I updated my SDK version to 1.0.0 in my gradle file. My little experiment is as follows:

I have flip to sleep enabled on my beacon, so when I flip it on its back it stops broadcasting telemetry packets (verified using a secondary receiver laptop using node.js). In my Android phone (running Android 5.1), I simply log the received telemetry packets to the console from within the onTelemetriesFound() method.

public void onTelemetriesFound(List list) {
for (EstimoteTelemetry tlm : list) { Log.d("Line 71", "MainActivity onTelemetriesFound(): " + tlm.deviceId.toString() + "," + tlm.rssi + "," + tlm.ambientLight + "," + tlm.magnetometer); } }

I turn my beacon "on" and wait till I get one packet printed on my log. After that, I immediately turn the beacon upside down, but my log keeps printing that same first packet for as long as 20 seconds (while the node.js receiver stops getting packets). Please see log below:

03-31 15:42:57.802 32196-32196/telemetry D/Line 76: MainActivity onServiceReady(): 03-31 15:42:57.825 32196-32212/telemetry D/BluetoothLeScanner: onClientRegistered() - status=0 clientIf=5 03-31 15:43:30.935 32196-32196/telemetry D/Line 71: MainActivity onTelemetriesFound(): [XXXXX],-58,0.0,(0.00,0.00,0.00) 03-31 15:43:31.904 32196-32196/telemetry D/Line 71: MainActivity onTelemetriesFound(): [XXXXX],-58,0.0,(0.00,0.00,0.00) 03-31 15:43:32.909 32196-32196/telemetry D/Line 71: MainActivity onTelemetriesFound(): [XXXXX],-58,0.0,(0.00,0.00,0.00) 03-31 15:43:33.910 32196-32196/telemetry D/Line 71: MainActivity onTelemetriesFound(): [XXXXX],-58,0.0,(0.00,0.00,0.00) 03-31 15:43:34.909 32196-32196/telemetry D/Line 71: MainActivity onTelemetriesFound(): [XXXXX],-58,0.0,(0.00,0.00,0.00) 03-31 15:43:35.916 32196-32196/telemetry D/Line 71: MainActivity onTelemetriesFound(): [XXXXX],-58,0.0,(0.00,0.00,0.00) 03-31 15:43:36.917 32196-32196/telemetry D/Line 71: MainActivity onTelemetriesFound(): [XXXXX],-58,0.0,(0.00,0.00,0.00) 03-31 15:43:37.917 32196-32196/telemetry D/Line 71: MainActivity onTelemetriesFound(): [XXXXX],-58,0.0,(0.00,0.00,0.00) 03-31 15:43:38.925 32196-32196/telemetry D/Line 71: MainActivity onTelemetriesFound(): [XXXXX],-58,0.0,(0.00,0.00,0.00) 03-31 15:43:39.924 32196-32196/telemetry D/Line 71: MainActivity onTelemetriesFound(): [XXXXX],-58,0.0,(0.00,0.00,0.00) 03-31 15:43:40.927 32196-32196/telemetry D/Line 71: MainActivity onTelemetriesFound(): [XXXXX],-58,0.0,(0.00,0.00,0.00) 03-31 15:43:41.929 32196-32196/telemetry D/Line 71: MainActivity onTelemetriesFound(): [XXXXX],-58,0.0,(0.00,0.00,0.00) 03-31 15:43:42.922 32196-32196/telemetry D/Line 71: MainActivity onTelemetriesFound(): [XXXXX],-58,0.0,(0.00,0.00,0.00) 03-31 15:43:43.920 32196-32196/telemetry D/Line 71: MainActivity onTelemetriesFound(): [XXXXX],-58,0.0,(0.00,0.00,0.00) 03-31 15:43:44.929 32196-32196/telemetry D/Line 71: MainActivity onTelemetriesFound(): [XXXXX],-58,0.0,(0.00,0.00,0.00) 03-31 15:43:45.931 32196-32196/telemetry D/Line 71: MainActivity onTelemetriesFound(): [XXXXX],-58,0.0,(0.00,0.00,0.00) 03-31 15:43:46.923 32196-32196/telemetry D/Line 71: MainActivity onTelemetriesFound(): [XXXXX],-58,0.0,(0.00,0.00,0.00) 03-31 15:43:47.923 32196-32196/telemetry D/Line 71: MainActivity onTelemetriesFound(): [XXXXX],-58,0.0,(0.00,0.00,0.00) 03-31 15:43:48.930 32196-32196/telemetry D/Line 71: MainActivity onTelemetriesFound(): [XXXXX],-58,0.0,(0.00,0.00,0.00) 03-31 15:43:49.933 32196-32196/telemetry D/Line 71: MainActivity onTelemetriesFound(): [XXXXX],-58,0.0,(0.00,0.00,0.00)

pawelDylag commented 7 years ago

Hello @arslanmustafa

Thanks for the confirmation! This behaviour is connected to our internal caching mechanism. We will add some fixups to avoid caching packets when using discovery methods. I'll inform you when the fixes are introduced - probably next release :)

Have a wonderful day!

pawelDylag commented 7 years ago

Hey,

This problem should be fixed in sdk version 1.0.1. Please notice that the data will not be reported duplicated now, but it won't be reported on every scan cycle either. TLM packes are splitted into smaller packets which we need to merge internally. Read more here under Single packet paragraph )

Let me know if it works for you right now - I will close this issue then.

Cheers!