Trying to debug EIR parsing
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@@ -3,3 +3,4 @@
|
||||
local.properties
|
||||
.idea/
|
||||
lint.xml
|
||||
/.apt_generated
|
||||
|
||||
@@ -1,5 +1,9 @@
|
||||
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.util.BluetoothLeScanner;
|
||||
import uk.co.alt236.btlescan.util.BluetoothUtils;
|
||||
@@ -45,7 +49,15 @@ public class MainActivity extends ListActivity {
|
||||
private BluetoothAdapter.LeScanCallback mLeScanCallback = new BluetoothAdapter.LeScanCallback() {
|
||||
@Override
|
||||
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() {
|
||||
// @Override
|
||||
|
||||
@@ -6,7 +6,7 @@ import java.util.Arrays;
|
||||
* Double Encore, Inc.
|
||||
* AdRecord
|
||||
*/
|
||||
public class AdRecord {
|
||||
public final class AdRecord {
|
||||
/**
|
||||
* General FLAGS
|
||||
*
|
||||
@@ -32,7 +32,7 @@ public class AdRecord {
|
||||
|
||||
// Local name
|
||||
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
|
||||
public static final int TYPE_TX_POWER_LEVEL = 0x0A;
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
package uk.co.alt236.btlescan.containers;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.Map;
|
||||
|
||||
public class AdRecordStore {
|
||||
@@ -50,4 +52,8 @@ public class AdRecordStore {
|
||||
public String toString() {
|
||||
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.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
@@ -61,7 +62,7 @@ public class AdRecordUtils {
|
||||
index += length;
|
||||
}
|
||||
|
||||
return records;
|
||||
return Collections.unmodifiableList(records);
|
||||
}
|
||||
|
||||
@SuppressLint("UseSparseArrays")
|
||||
@@ -86,6 +87,6 @@ public class AdRecordUtils {
|
||||
index += length;
|
||||
}
|
||||
|
||||
return records;
|
||||
return Collections.unmodifiableMap(records);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user