Java Code Examples for org.altbeacon.beacon.logging.LogManager#setLogger()
The following examples show how to use
org.altbeacon.beacon.logging.LogManager#setLogger() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: BeaconParserTest.java From android-beacon-library with Apache License 2.0 | 6 votes |
@Test public void testParsesBeaconMissingDataField() { LogManager.setLogger(Loggers.verboseLogger()); org.robolectric.shadows.ShadowLog.stream = System.err; byte[] bytes = hexStringToByteArray("02011a1aff1801beac2f234454cf6d4a0fadf2f4911ba9ffa600010002c5000000"); BeaconParser parser = new BeaconParser(); parser.setBeaconLayout("m:2-3=beac,i:4-19,i:20-21,i:22-23,p:24-24,d:25-25"); Beacon beacon = parser.fromScanData(bytes, -55, null, 123456L); assertEquals("mRssi should be as passed in", -55, beacon.getRssi()); assertEquals("uuid should be parsed", "2f234454-cf6d-4a0f-adf2-f4911ba9ffa6", beacon.getIdentifier(0).toString()); assertEquals("id2 should be parsed", "1", beacon.getIdentifier(1).toString()); assertEquals("id3 should be parsed", "2", beacon.getIdentifier(2).toString()); assertEquals("txPower should be parsed", -59, beacon.getTxPower()); assertEquals("manufacturer should be parsed", 0x118 ,beacon.getManufacturer()); assertEquals("missing data field zero should be zero", new Long(0l), beacon.getDataFields().get(0)); }
Example 2
Source File: GattBeaconTest.java From android-beacon-library with Apache License 2.0 | 6 votes |
@Test public void testDetectsGattBeacon() { org.robolectric.shadows.ShadowLog.stream = System.err; LogManager.setLogger(Loggers.verboseLogger()); LogManager.setVerboseLoggingEnabled(true); System.err.println("verbose logging:"+LogManager.isVerboseLoggingEnabled()); byte[] bytes = hexStringToByteArray("020106030334121516341200e72f234454f4911ba9ffa6000000000001000000000000000000000000000000000000000000000000000000000000000000"); BeaconParser parser = new BeaconParser().setBeaconLayout("s:0-1=1234,m:2-2=00,p:3-3:-41,i:4-13,i:14-19"); assertNotNull("Service uuid parsed should not be null", parser.getServiceUuid()); Beacon gattBeacon = parser.fromScanData(bytes, -55, null, 123456L); assertNotNull("GattBeacon should be not null if parsed successfully", gattBeacon); assertEquals("id1 should be parsed", "0x2f234454f4911ba9ffa6", gattBeacon.getId1().toString()); assertEquals("id2 should be parsed", "0x000000000001", gattBeacon.getId2().toString()); assertEquals("serviceUuid should be parsed", 0x1234, gattBeacon.getServiceUuid()); assertEquals("txPower should be parsed", -66, gattBeacon.getTxPower()); }
Example 3
Source File: GattBeaconTest.java From android-beacon-library with Apache License 2.0 | 6 votes |
@Test public void testDetectsGattBeacon2WithShortIdentifier() { org.robolectric.shadows.ShadowLog.stream = System.err; LogManager.setLogger(Loggers.verboseLogger()); LogManager.setVerboseLoggingEnabled(true); LogManager.d("GattBeaconTest", "Parsing short packet"); byte[] bytes = hexStringToByteArray("020106030334121516341210ec007261646975736e6574776f726b7307000000000000000000000000000000000000000000000000000000000000000000"); BeaconParser parser = new BeaconParser().setBeaconLayout("s:0-1=1234,m:2-2=10,p:3-3:-41,i:4-20v"); Beacon gattBeacon = parser.fromScanData(bytes, -55, null, 123456L); assertNotNull("GattBeacon should be not null if parsed successfully", gattBeacon); assertEquals("GattBeacon identifier length should be adjusted smaller if packet is short", 16, gattBeacon.getId1().toByteArray().length); assertEquals("GattBeacon identifier should have proper first byte", (byte)0x00, gattBeacon.getId1().toByteArray()[0]); assertEquals("GattBeacon identifier should have proper second to last byte", (byte) 0x73, gattBeacon.getId1().toByteArray()[14]); assertEquals("GattBeacon identifier should have proper last byte", (byte)0x07, gattBeacon.getId1().toByteArray()[15]); }
Example 4
Source File: Application.java From PresencePublisher with MIT License | 6 votes |
private void initBeaconReceiver() { if (supportsBeacons()) { LogManager.setLogger(new HyperlogLogger()); Beacon.setHardwareEqualityEnforced(true); Beacon.setDistanceCalculator(new ModelSpecificDistanceCalculator(this, org.altbeacon.beacon.BeaconManager.getDistanceModelUpdateUrl())); org.altbeacon.beacon.BeaconManager beaconManager = org.altbeacon.beacon.BeaconManager.getInstanceForApplication(this); List<BeaconParser> beaconParsers = beaconManager.getBeaconParsers(); beaconParsers.add(new BeaconParser("iBeacon") .setBeaconLayout("m:2-3=0215,i:4-19,i:20-21,i:22-23,p:24-24")); beaconParsers.add(new BeaconParser("Eddystone UID") .setBeaconLayout(BeaconParser.EDDYSTONE_UID_LAYOUT)); SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(this); if (!sharedPreferences.getStringSet(BEACON_LIST, Collections.emptySet()).isEmpty()) { BeaconManager.getInstance().initialize(this); } if (Build.VERSION.SDK_INT >= 18) { backgroundPowerSaver = new BackgroundPowerSaver(this); } } }
Example 5
Source File: GattBeaconTest.java From android-beacon-library with Apache License 2.0 | 6 votes |
@Test public void testDetectsUriBeacon() { org.robolectric.shadows.ShadowLog.stream = System.err; LogManager.setLogger(Loggers.verboseLogger()); LogManager.setVerboseLoggingEnabled(true); //"https://goo.gl/hqBXE1" byte[] bytes = {2, 1, 4, 3, 3, (byte) 216, (byte) 254, 19, 22, (byte) 216, (byte) 254, 0, (byte) 242, 3, 103, 111, 111, 46, 103, 108, 47, 104, 113, 66, 88, 69, 49, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; BeaconParser parser = new BeaconParser().setBeaconLayout("s:0-1=fed8,m:2-2=00,p:3-3:-41,i:4-21v"); LogManager.d("xxx", "------"); Beacon uriBeacon = parser.fromScanData(bytes, -55, null, 123456L); assertNotNull("UriBeacon should be not null if parsed successfully", uriBeacon); assertEquals("UriBeacon identifier length should be correct", 14, uriBeacon.getId1().toByteArray().length); String urlString = UrlBeaconUrlCompressor.uncompress(uriBeacon.getId1().toByteArray()); assertEquals("URL should be decompressed successfully", "https://goo.gl/hqBXE1", urlString); }
Example 6
Source File: GattBeaconTest.java From android-beacon-library with Apache License 2.0 | 5 votes |
@Test public void testDetectsEddystoneUID() { org.robolectric.shadows.ShadowLog.stream = System.err; LogManager.setLogger(Loggers.verboseLogger()); LogManager.setVerboseLoggingEnabled(true); byte[] bytes = hexStringToByteArray("0201060303aafe1516aafe00e700010203040506070809010203040506000000000000000000000000000000000000000000000000000000000000000000"); BeaconParser parser = new BeaconParser().setBeaconLayout(BeaconParser.EDDYSTONE_UID_LAYOUT); Beacon eddystoneUidBeacon = parser.fromScanData(bytes, -55, null, 123456L); assertNotNull("Eddystone-UID should be not null if parsed successfully", eddystoneUidBeacon); }
Example 7
Source File: CBeaconTest.java From android-beacon-library with Apache License 2.0 | 5 votes |
@Test public void doesNotDetectManufacturerAdvert() { LogManager.setLogger(Loggers.verboseLogger()); org.robolectric.shadows.ShadowLog.stream = System.err; byte[] bytes = hexStringToByteArray("02011a1bff1801beac2f234454cf6d4a0fadf2f4911ba9ffa600010002c50900"); BeaconParser parser = new BeaconParser(); parser.setBeaconLayout("s:0-1=fd6f,p:0-0:63,i:2-17"); Beacon beacon = parser.fromScanData(bytes, -55, null, 0l); assertNull("CBeacon should not be parsed", beacon); }
Example 8
Source File: BeaconParserTest.java From android-beacon-library with Apache License 2.0 | 5 votes |
@Test public void testRecognizeBeaconWithFormatSpecifyingManufacturer() { LogManager.setLogger(Loggers.verboseLogger()); org.robolectric.shadows.ShadowLog.stream = System.err; byte[] bytes = hexStringToByteArray("02011a1bff1801beac2f234454cf6d4a0fadf2f4911ba9ffa600010002c509000000"); BeaconParser parser = new BeaconParser(); parser.setBeaconLayout("m:0-3=1801beac,i:4-19,i:20-21,i:22-23,p:24-24,d:25-25"); Beacon beacon = parser.fromScanData(bytes, -55, null, 123456L); assertEquals("mRssi should be as passed in", -55, beacon.getRssi()); assertEquals("uuid should be parsed", "2f234454-cf6d-4a0f-adf2-f4911ba9ffa6", beacon.getIdentifier(0).toString()); assertEquals("id2 should be parsed", "1", beacon.getIdentifier(1).toString()); assertEquals("id3 should be parsed", "2", beacon.getIdentifier(2).toString()); assertEquals("txPower should be parsed", -59, beacon.getTxPower()); assertEquals("manufacturer should be parsed", 0x118 ,beacon.getManufacturer()); }
Example 9
Source File: BeaconParserTest.java From android-beacon-library with Apache License 2.0 | 5 votes |
@Test public void testAllowsAccessToParserIdentifier() { LogManager.setLogger(Loggers.verboseLogger()); org.robolectric.shadows.ShadowLog.stream = System.err; byte[] bytes = hexStringToByteArray("02011a1aff180112342f234454cf6d4a0fadf2f4911ba9ffa600010002c5"); BeaconParser parser = new BeaconParser("my_beacon_type"); parser.setBeaconLayout("m:2-3=1234,i:4-19,i:20-21,i:22-23,p:24-24,d:25-25"); Beacon beacon = parser.fromScanData(bytes, -55, null, 123456L); assertEquals("parser identifier should be accessible", "my_beacon_type", beacon.getParserIdentifier()); }
Example 10
Source File: BeaconParserTest.java From android-beacon-library with Apache License 2.0 | 5 votes |
@Test public void testRecognizeBeacon() { LogManager.setLogger(Loggers.verboseLogger()); org.robolectric.shadows.ShadowLog.stream = System.err; byte[] bytes = hexStringToByteArray("02011a1aff180112342f234454cf6d4a0fadf2f4911ba9ffa600010002c5"); BeaconParser parser = new BeaconParser(); parser.setBeaconLayout("m:2-3=1234,i:4-19,i:20-21,i:22-23,p:24-24,d:25-25"); Beacon beacon = parser.fromScanData(bytes, -55, null, 123456L); assertEquals("mRssi should be as passed in", -55, beacon.getRssi()); assertEquals("uuid should be parsed", "2f234454-cf6d-4a0f-adf2-f4911ba9ffa6", beacon.getIdentifier(0).toString()); assertEquals("id2 should be parsed", "1", beacon.getIdentifier(1).toString()); assertEquals("id3 should be parsed", "2", beacon.getIdentifier(2).toString()); assertEquals("txPower should be parsed", -59, beacon.getTxPower()); assertEquals("manufacturer should be parsed", 0x118 ,beacon.getManufacturer()); }
Example 11
Source File: GattBeaconTest.java From android-beacon-library with Apache License 2.0 | 5 votes |
@Test public void doesNotCrashOnMalformedEddystoneBeacon() { org.robolectric.shadows.ShadowLog.stream = System.err; LogManager.setLogger(Loggers.verboseLogger()); LogManager.setVerboseLoggingEnabled(true); LogManager.d("GattBeaconTest", "Parsing malformed packet"); byte[] bytes = hexStringToByteArray("0201060303aafe0416aafe100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"); BeaconParser parser = new BeaconParser().setBeaconLayout("s:0-1=feaa,m:2-2=10,p:3-3:-41,i:4-20v"); LogManager.d("xxx", "------"); Beacon gattBeacon = parser.fromScanData(bytes, -55, null, 123456L); assertNull("GattBeacon should be null when not parsed successfully", gattBeacon); }
Example 12
Source File: GattBeaconTest.java From android-beacon-library with Apache License 2.0 | 5 votes |
@Test public void testDetectsGattBeaconWithCnn() { org.robolectric.shadows.ShadowLog.stream = System.err; LogManager.setLogger(Loggers.verboseLogger()); LogManager.setVerboseLoggingEnabled(true); LogManager.d("GattBeaconTest", "Parsing short packet"); byte[] bytes = hexStringToByteArray("020106030334120a16341210ed00636e6e070000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"); BeaconParser parser = new BeaconParser().setBeaconLayout("s:0-1=1234,m:2-2=10,p:3-3:-41,i:4-20v"); LogManager.d("xxx", "------"); Beacon gattBeacon = parser.fromScanData(bytes, -55, null, 123456L); assertNotNull("GattBeacon should be not null if parsed successfully", gattBeacon); assertEquals("GattBeacon identifier length should be adjusted smaller if packet is short", 5, gattBeacon.getId1().toByteArray().length); }
Example 13
Source File: GattBeaconTest.java From android-beacon-library with Apache License 2.0 | 5 votes |
@Test public void testDetectsGattBeacon2MaxLength() { org.robolectric.shadows.ShadowLog.stream = System.err; LogManager.setLogger(Loggers.verboseLogger()); LogManager.setVerboseLoggingEnabled(true); byte[] bytes = hexStringToByteArray("020106030334121616341210ec007261646975736e6574776f726b7373070000000000000000000000000000000000000000000000000000000000000000"); BeaconParser parser = new BeaconParser().setBeaconLayout("s:0-1=1234,m:2-2=10,p:3-3:-41,i:4-20v"); Beacon gattBeacon = parser.fromScanData(bytes, -55, null, 123456L); assertNotNull("GattBeacon should be not null if parsed successfully", gattBeacon); assertEquals("GattBeacon identifier length should be proper length", 17, gattBeacon.getId1().toByteArray().length); }
Example 14
Source File: BeaconServiceTest.java From android-beacon-library with Apache License 2.0 | 5 votes |
@Before public void before() { org.robolectric.shadows.ShadowLog.stream = System.err; LogManager.setLogger(Loggers.verboseLogger()); LogManager.setVerboseLoggingEnabled(true); BeaconManager.setsManifestCheckingDisabled(true); }
Example 15
Source File: RangingDataTest.java From android-beacon-library with Apache License 2.0 | 5 votes |
@Before public void before() { org.robolectric.shadows.ShadowLog.stream = System.err; LogManager.setLogger(Loggers.verboseLogger()); LogManager.setVerboseLoggingEnabled(true); BeaconManager.setsManifestCheckingDisabled(true); }
Example 16
Source File: ScanStateTest.java From android-beacon-library with Apache License 2.0 | 5 votes |
@Before public void before() { org.robolectric.shadows.ShadowLog.stream = System.err; LogManager.setLogger(Loggers.verboseLogger()); LogManager.setVerboseLoggingEnabled(true); BeaconManager.setsManifestCheckingDisabled(true); }
Example 17
Source File: MonitoringStatusTest.java From android-beacon-library with Apache License 2.0 | 5 votes |
@Before public void before() { org.robolectric.shadows.ShadowLog.stream = System.err; LogManager.setLogger(Loggers.verboseLogger()); LogManager.setVerboseLoggingEnabled(true); BeaconManager.setManifestCheckingDisabled(true); Context context = RuntimeEnvironment.application; new MonitoringStatus(context).clear(); }
Example 18
Source File: BeaconManager.java From android-beacon-library with Apache License 2.0 | 3 votes |
/** * Set to true if you want to show library debugging. * * @param debug True turn on all logs for this library to be printed out to logcat. False turns * off detailed logging.. * * This is a convenience method that calls setLogger to a verbose logger and enables verbose * logging. For more fine grained control, use: * {@link org.altbeacon.beacon.logging.LogManager#setLogger(org.altbeacon.beacon.logging.Logger)} * instead. */ public static void setDebug(boolean debug) { if (debug) { LogManager.setLogger(Loggers.verboseLogger()); LogManager.setVerboseLoggingEnabled(true); } else { LogManager.setLogger(Loggers.empty()); LogManager.setVerboseLoggingEnabled(false); } }