use of org.altbeacon.beacon.Beacon in project android-beacon-library by AltBeacon.
the class RangingDataTest method testSerializationBenchmark.
@Test
public // On MacBookPro 2.5 GHz Core I7, 10000 serialization/deserialiation cycles of RangingData took 22ms
void testSerializationBenchmark() throws Exception {
Context context = ShadowApplication.getInstance().getApplicationContext();
ArrayList<Identifier> identifiers = new ArrayList<Identifier>();
identifiers.add(Identifier.parse("2f234454-cf6d-4a0f-adf2-f4911ba9ffa6"));
identifiers.add(Identifier.parse("1"));
identifiers.add(Identifier.parse("2"));
Region region = new Region("testRegion", identifiers);
ArrayList<Beacon> beacons = new ArrayList<Beacon>();
Beacon beacon = new Beacon.Builder().setIdentifiers(identifiers).setRssi(-1).setTxPower(-50).setBluetoothAddress("01:02:03:04:05:06").build();
for (int i = 0; i < 10; i++) {
beacons.add(beacon);
}
RangingData data = new RangingData(beacons, region);
long time1 = System.currentTimeMillis();
for (int i = 0; i < 10000; i++) {
Parcel parcel = Parcel.obtain();
data.writeToParcel(parcel, 0);
parcel.setDataPosition(0);
RangingData data2 = new RangingData(parcel);
}
long time2 = System.currentTimeMillis();
System.out.println("*** Ranging Data Serialization benchmark: " + (time2 - time1));
}
use of org.altbeacon.beacon.Beacon in project android-beacon-library by AltBeacon.
the class EddystoneTelemetryAccessorTest method testAllowsAccessToBase64EncodedTelemetryBytes.
@Test
public void testAllowsAccessToBase64EncodedTelemetryBytes() throws MalformedURLException {
ArrayList<Long> telemetryFields = new ArrayList<Long>();
// version
telemetryFields.add(0x01l);
// battery level
telemetryFields.add(0x0212l);
// temperature
telemetryFields.add(0x0313l);
// pdu count
telemetryFields.add(0x04142434l);
// uptime
telemetryFields.add(0x05152535l);
Beacon beaconWithTelemetry = new Beacon.Builder().setId1("0x0102030405060708090a").setId2("0x01020304050607").setTxPower(-59).setExtraDataFields(telemetryFields).build();
byte[] telemetryBytes = new EddystoneTelemetryAccessor().getTelemetryBytes(beaconWithTelemetry);
String encodedTelemetryBytes = new EddystoneTelemetryAccessor().getBase64EncodedTelemetry(beaconWithTelemetry);
assertNotNull(telemetryBytes);
}
Aggregations