Search in sources :

Example 1 with AltBeaconParser

use of org.altbeacon.beacon.AltBeaconParser in project android-beacon-library by AltBeacon.

the class ScanFilterUtilsTest method testGetAltBeaconScanFilter.

@Test
public void testGetAltBeaconScanFilter() throws Exception {
    org.robolectric.shadows.ShadowLog.stream = System.err;
    BeaconParser parser = new AltBeaconParser();
    // no manifest available in robolectric
    BeaconManager.setManifestCheckingDisabled(true);
    List<ScanFilterUtils.ScanFilterData> scanFilterDatas = new ScanFilterUtils().createScanFilterDataForBeaconParser(parser, null);
    assertEquals("scanFilters should be of correct size", 1, scanFilterDatas.size());
    ScanFilterUtils.ScanFilterData sfd = scanFilterDatas.get(0);
    assertEquals("manufacturer should be right", 0x0118, sfd.manufacturer);
    assertEquals("mask length should be right", 2, sfd.mask.length);
    assertArrayEquals("mask should be right", new byte[] { (byte) 0xff, (byte) 0xff }, sfd.mask);
    assertArrayEquals("filter should be right", new byte[] { (byte) 0xbe, (byte) 0xac }, sfd.filter);
}
Also used : BeaconParser(org.altbeacon.beacon.BeaconParser) AltBeaconParser(org.altbeacon.beacon.AltBeaconParser) AltBeaconParser(org.altbeacon.beacon.AltBeaconParser) ScanFilterUtils(org.altbeacon.beacon.service.scanner.ScanFilterUtils) Test(org.junit.Test)

Example 2 with AltBeaconParser

use of org.altbeacon.beacon.AltBeaconParser 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);
}
Also used : StaticBeaconSimulator(org.altbeacon.beacon.simulator.StaticBeaconSimulator) AltBeaconParser(org.altbeacon.beacon.AltBeaconParser) Beacon(org.altbeacon.beacon.Beacon) AltBeacon(org.altbeacon.beacon.AltBeacon) ArrayList(java.util.ArrayList) Test(org.junit.Test)

Aggregations

AltBeaconParser (org.altbeacon.beacon.AltBeaconParser)2 Test (org.junit.Test)2 ArrayList (java.util.ArrayList)1 AltBeacon (org.altbeacon.beacon.AltBeacon)1 Beacon (org.altbeacon.beacon.Beacon)1 BeaconParser (org.altbeacon.beacon.BeaconParser)1 ScanFilterUtils (org.altbeacon.beacon.service.scanner.ScanFilterUtils)1 StaticBeaconSimulator (org.altbeacon.beacon.simulator.StaticBeaconSimulator)1