altbeacon

dataFields holding only one long value in AltBeacon


I am trying to send two long values (latitude and longitude) in the beacon's data fields, as a list of long, but only the first long value gets through.

I tried to put both values, latitude and longitude, in the dataFields: .setDataFields(listOf(latitude.toLong(), longitude.toLong())) and the result is [53], which is just the latitude.

I tried to put the latitude in the dataFields and the longitude in the extraDataFields: .setDataFields(listOf(latitude.toLong())) .setExtraDataFields(listOf(longitude.toLong())) and the latitude is correctly set, while the extraDataFields remains empty.

Is there a constraint regarding the dataFields, such as being able to only hold one value, despite being a list of long?


Solution

  • Different beacon formats support different numbers of data fields and sizes.

    You may also define custom formats with any number of data fields that fit into the packet.

    If you use the setDataFields method to put more data bytes into the beacon than the format allows, the extra data will be ignored and not be included in the advertisement.

    A common alternative approach for encoding latitude and longitude is to encode these in the major and minor identifier fields (ID2 and ID3) for iBeacon and AltBeacon.