Comments (3)
@gerardmundo-birket, the original design of the data field is to support two beacon formats, AltBeacon and Eddystone-UID each of which have a one byte data field. As you have seen, the data field is implemented internally as a signed Java long, which would in theory allow an 8 byte signed integer data field. But also as you have seen, the byteArrayToFormattedString function has its own limitations that impact this -- it is designed for formatting beacon identifiers 16 bytes are treated as UUIDs and formatted with dashes, > 4 bytes are formatted as hex, and <= 4 bytes are formatted as decimal.
Bottom line: the data fields were specifically built and tested to handle one byte, but designed to handle more bytes. But because of the above limitations, they really only work properly with four bytes or less. This is admittedly not documented.
Possible solutions in increasing order of complexity:
- Document a four byte limitation on data fields
- Add code to enforce the above limitation by throwing an exception in BeaconParser
- Add code to expand support for data field lengths up to the 8 byte length of a Java long. This is a small fix that would require no API changes
- Add code to expand support for longer data field lengths. This would require API changes to provide larger storage for the data fields internally and new accessors that operate on something other than a Java long.
It certainly makes sense to implement 1 and 2. If your use case requires a longer data field, I am open to you creating a pull request for 3 or 4 above. If your use case needs 4, however, we should discuss the details of the internal and API changes first to keep the impact as small as possible.
from android-beacon-library.
@davidgyoung , thank you for your prompt response.
For my use case, I am still experimenting with different options, but I am interested in code efficiency and after seeing the overhead of the parsing of data fields and the formatting, I think my best option is if I work with the raw packet data directly (I'm brave like that!).
I think option 1+2+3 will be the best experience for most users of the library, though. I'll update this thread in a few days with whatever I settle with, but I'm happy to keep the discussion going in the mean time.
from android-beacon-library.
David,
After testing for a while, I'll be using the raw bytes directly.
I think 1+2+3 will be the most reasonable solution, should you want to address this problem.
Thank you again for your promptness, and your time and dedication! It's a great library you've got here.
PS: are there other limits on other types of fields, for example the matching field?
from android-beacon-library.
Related Issues (20)
- Range beacons when app is terminating HOT 7
- Beacons ranging not working on android 13 HOT 1
- App stops scanning right after screen is locked and starts giving the results right after unlocked HOT 1
- Android beacon library - multiple regions monitoring - unable remove regions HOT 2
- startForeground Exception when app is not in foreground HOT 3
- StartupBroadcastReceiver throws NullPointerException HOT 2
- No beacons after locked screen HOT 20
- Cannot parse iBeacons HOT 3
- BeaconService.startForegroundIfConfigured HOT 12
- TargetSdk 34 (android 14) Beacon foreground service no longer working due to new Google restriction HOT 1
- Do we have sample app to implement the library including the operation running in Background HOT 4
- Only a maximum of 2 beacons can be received at a time HOT 1
- java.io.FileNotFoundException android-distance.json HOT 3
- android-distance.json database not found
- Custom Distance calculator is being overwritten HOT 6
- Samsung devices not detecting beacons by intent after first screen off
- Can we use this with tauri mobile? HOT 3
- Main thread can be blocked sometimes
- Android 14 didDetermineStateForRegion no beacon is detected or scanned HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from android-beacon-library.