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 = RuntimeEnvironment.application;
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).setRunningAverageRssi(-2).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++) {
Bundle bundle = data.toBundle();
RangingData data2 = RangingData.fromBundle(bundle);
}
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);
}
use of org.altbeacon.beacon.Beacon in project android-beacon-library by AltBeacon.
the class BeaconSimulatorTest method testSetBeacons.
@Test
public void testSetBeacons() {
StaticBeaconSimulator staticBeaconSimulator = new StaticBeaconSimulator();
byte[] beaconBytes = hexStringToByteArray("02011a1bff1801beac2f234454cf6d4a0fadf2f4911ba9ffa600010002c509");
Beacon beacon = new AltBeaconParser().fromScanData(beaconBytes, -55, null, 123456L);
ArrayList<Beacon> beacons = new ArrayList<Beacon>();
beacons.add(beacon);
staticBeaconSimulator.setBeacons(beacons);
assertEquals("getBeacons should match values entered with setBeacons", staticBeaconSimulator.getBeacons(), beacons);
}
use of org.altbeacon.beacon.Beacon in project android-beacon-library by AltBeacon.
the class RunningAverageRssiFilterTest method legacySetSampleExpirationMillisecondsWorksText.
@Test
public void legacySetSampleExpirationMillisecondsWorksText() {
RangedBeacon.setSampleExpirationMilliseconds(20000);
RunningAverageRssiFilter.setSampleExpirationMilliseconds(20000);
Beacon beacon = new Beacon.Builder().setId1("1").build();
RangedBeacon.setSampleExpirationMilliseconds(33l);
RangedBeacon rb = new RangedBeacon(beacon);
assertEquals("RunningAverageRssiFilter sampleExprirationMilliseconds should not be altered by constructing RangedBeacon", 33l, RunningAverageRssiFilter.getSampleExpirationMilliseconds());
}
Aggregations