Trying to debug EIR parsing

This commit is contained in:
Alexandros Schillings
2014-03-09 23:17:43 +00:00
parent a738bcc38e
commit ea0d9a6d72
5 changed files with 25 additions and 5 deletions
+1
View File
@@ -3,3 +3,4 @@
local.properties local.properties
.idea/ .idea/
lint.xml lint.xml
/.apt_generated
+13 -1
View File
@@ -1,5 +1,9 @@
package uk.co.alt236.btlescan; package uk.co.alt236.btlescan;
import java.util.Collection;
import uk.co.alt236.btlescan.containers.AdRecord;
import uk.co.alt236.btlescan.containers.AdRecordUtils;
import uk.co.alt236.btlescan.containers.BluetoothLeDevice; import uk.co.alt236.btlescan.containers.BluetoothLeDevice;
import uk.co.alt236.btlescan.util.BluetoothLeScanner; import uk.co.alt236.btlescan.util.BluetoothLeScanner;
import uk.co.alt236.btlescan.util.BluetoothUtils; import uk.co.alt236.btlescan.util.BluetoothUtils;
@@ -45,7 +49,15 @@ public class MainActivity extends ListActivity {
private BluetoothAdapter.LeScanCallback mLeScanCallback = new BluetoothAdapter.LeScanCallback() { private BluetoothAdapter.LeScanCallback mLeScanCallback = new BluetoothAdapter.LeScanCallback() {
@Override @Override
public void onLeScan(final BluetoothDevice device, int rssi, byte[] scanRecord) { public void onLeScan(final BluetoothDevice device, int rssi, byte[] scanRecord) {
Log.d("TAG", "~ New BT Device: " + new BluetoothLeDevice(device, rssi, scanRecord));
final BluetoothLeDevice deviceLe = new BluetoothLeDevice(device, rssi, scanRecord);
Log.d("TAG", "~ New BT Device: " + deviceLe);
final Collection<AdRecord> adRecords = deviceLe.getAdRecordStore().getRecordsAsCollection();
for(final AdRecord record : adRecords){
Log.d("TAG", "~ Has Record: " + record.getType() + ": '" + record.getHumanReadableType() +"', data: '"+ AdRecordUtils.getRecordDataAsString(record) + "'");
}
// runOnUiThread(new Runnable() { // runOnUiThread(new Runnable() {
// @Override // @Override
@@ -6,7 +6,7 @@ import java.util.Arrays;
* Double Encore, Inc. * Double Encore, Inc.
* AdRecord * AdRecord
*/ */
public class AdRecord { public final class AdRecord {
/** /**
* General FLAGS * General FLAGS
* *
@@ -32,7 +32,7 @@ public class AdRecord {
// Local name // Local name
public static final int TYPE_LOCAL_NAME_SHORT = 0x08; public static final int TYPE_LOCAL_NAME_SHORT = 0x08;
public static final int TYPE_LOCAL_NAME_COMPLETE = 0x09; public static final int TYPE_LOCAL_NAME_COMPLETE = 0x09;
// TX Power Level // TX Power Level
public static final int TYPE_TX_POWER_LEVEL = 0x0A; public static final int TYPE_TX_POWER_LEVEL = 0x0A;
@@ -1,5 +1,7 @@
package uk.co.alt236.btlescan.containers; package uk.co.alt236.btlescan.containers;
import java.util.Collection;
import java.util.Collections;
import java.util.Map; import java.util.Map;
public class AdRecordStore { public class AdRecordStore {
@@ -50,4 +52,8 @@ public class AdRecordStore {
public String toString() { public String toString() {
return "AdRecordStore [mServiceDataUUId=" + mServiceDataUUId + ", mLocalNameComplete=" + mLocalNameComplete + ", mLocalNameShort=" + mLocalNameShort + "]"; return "AdRecordStore [mServiceDataUUId=" + mServiceDataUUId + ", mLocalNameComplete=" + mLocalNameComplete + ", mLocalNameShort=" + mLocalNameShort + "]";
} }
public Collection<AdRecord> getRecordsAsCollection() {
return Collections.unmodifiableCollection(mAdRecords.values());
}
} }
@@ -2,6 +2,7 @@ package uk.co.alt236.btlescan.containers;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
@@ -61,7 +62,7 @@ public class AdRecordUtils {
index += length; index += length;
} }
return records; return Collections.unmodifiableList(records);
} }
@SuppressLint("UseSparseArrays") @SuppressLint("UseSparseArrays")
@@ -86,6 +87,6 @@ public class AdRecordUtils {
index += length; index += length;
} }
return records; return Collections.unmodifiableMap(records);
} }
} }