-->

How to get battery level of Kontakt ibeacons

2020-03-08 05:47发布

问题:

The ibeacon beaconlayout for kontakt is
m:2-3=0215,i:4-19,i:20-21,i:22-23,p:24-24,d:25-25

I am using altbeacon library for android for detecting it but i am unable get the battery level of the beacon an answer here says that they are transmitting the power level but i am unable to fetch it. Further the comment on this page (from line no 100 to 103) describes the byte structure hope this helps.

How can i get the battery level from the beacon.

回答1:

If your beaconlayout expression is correct for that beacon, then you can read the battery value for the d25-25 data field with:

long batteryLevel=beacon.getDataFields().get(0);

See documentation for reading data fields here:

http://altbeacon.github.io/android-beacon-library/javadoc/org/altbeacon/beacon/Beacon.html#getDataFields()

However, the first link in your question mentions the field is in the "scan response" of the beacon. If that statement is true and not a misstatement, that means the battery level is not in the advertisement at all, so you will not be able to get it without separately polling for this info.