I'm trying to capture BLE broadcast (ADV_NONCONN_IND) packets inside of my
android app. However I'm not able to receive any packets.
I know my peripheral device is sending packets because I have another BLE
capture device that sees all the packets. However my app inside the phone
doesn't see any BLE packets.
My app can see other packets such as ADV_SCAN_ID but not ADV_NONCONN_IND
(broadcast) packets.
public void uploadScanBytes(SensorDataUploader sensorDataUploader, int count) {
BluetoothAdapter btAdapter = getBluetoothAdapter();
if (btAdapter == null) return;
BluetoothLeScanner scanner = btAdapter.getBluetoothLeScanner();
ScanSettings settings = new ScanSettings.Builder()
.setScanMode(ScanSettings.SCAN_MODE_LOW_LATENCY)
.setCallbackType(ScanSettings.CALLBACK_TYPE_ALL_MATCHES)
.build();
scanner.startScan(Collections.<ScanFilter>emptyList(), settings, new
LimitedScanRecordReader(sensorDataUploader, count, scanner));
}
public void onScanResult(int callbackType, ScanResult result) {
if(result.getDevice().getAddress().equals("00:AB:2c:A1:E2:F1")) {
long timestamp = System.currentTimeMillis() -
SystemClock.elapsedRealtime() +
result.getTimestampNanos() / 1000000;
byte[] rawBytes = result.getScanRecord().getBytes();
Log.i(DataTransferService.class.getName(), "Raw bytes: " +
byteArrayToHex(rawBytes));
sensorDataUploader.upload(timestamp, rawBytes);
}}
Please let me know what I'm missing.
Thanks in advance
--
You received this message because you are subscribed to the Google Groups
"Android Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/android-developers.
To view this discussion on the web visit
https://groups.google.com/d/msgid/android-developers/2121cb01-0318-45b0-98e7-797410e2121f%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.