Search in sources :

Example 6 with ScanFilterUtils

use of org.altbeacon.beacon.service.scanner.ScanFilterUtils in project android-beacon-library by AltBeacon.

the class ScanFilterUtilsTest method testGenericScanFilter.

@Test
public void testGenericScanFilter() throws Exception {
    org.robolectric.shadows.ShadowLog.stream = System.err;
    BeaconParser parser = new BeaconParser();
    parser.setBeaconLayout("m:2-3=1111,i:4-6,p:24-24");
    // 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", 0x004c, 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) 0x11, (byte) 0x11 }, sfd.filter);
    assertNull("serviceUuid should be null", sfd.serviceUuid);
}
Also used : BeaconParser(org.altbeacon.beacon.BeaconParser) AltBeaconParser(org.altbeacon.beacon.AltBeaconParser) ScanFilterUtils(org.altbeacon.beacon.service.scanner.ScanFilterUtils) Test(org.junit.Test)

Aggregations

BeaconParser (org.altbeacon.beacon.BeaconParser)6 ScanFilterUtils (org.altbeacon.beacon.service.scanner.ScanFilterUtils)6 AltBeaconParser (org.altbeacon.beacon.AltBeaconParser)5 Test (org.junit.Test)5 BluetoothAdapter (android.bluetooth.BluetoothAdapter)1 BluetoothManager (android.bluetooth.BluetoothManager)1 BluetoothLeScanner (android.bluetooth.le.BluetoothLeScanner)1 ScanFilter (android.bluetooth.le.ScanFilter)1 ScanSettings (android.bluetooth.le.ScanSettings)1 RequiresApi (androidx.annotation.RequiresApi)1 ArrayList (java.util.ArrayList)1 Identifier (org.altbeacon.beacon.Identifier)1