tag:blogger.com,1999:blog-8214401912480503366.post3700983975729796960..comments2023-08-10T13:35:15.093+02:00Comments on My life with Android :-): Parsing BLE advertisement packetsGabor Pallerhttp://www.blogger.com/profile/14307475522972458932noreply@blogger.comBlogger4125tag:blogger.com,1999:blog-8214401912480503366.post-57905151991305444142017-01-05T15:57:31.316+01:002017-01-05T15:57:31.316+01:00Tony, I wrote an e-mail to you about the issue. Co...Tony, I wrote an e-mail to you about the issue. Could you try the Android application linked to <a href="http://mylifewithandroid.blogspot.hu/2016/10/android-phone-as-weather-station-with.html" rel="nofollow">this post?</a> This application is very similar to yours (uses BluetoothLeScanner) but is reliably able to capture unidirectional advertisement packet indications that my sensors generate. Look for the onScanResult method in BLESensorGWService.java, there's a log message there.Gabor Pallerhttps://www.blogger.com/profile/02390936870056951146noreply@blogger.comtag:blogger.com,1999:blog-8214401912480503366.post-54087605093046242482017-01-05T09:09:54.777+01:002017-01-05T09:09:54.777+01:00Gabor -
I'm trying to capture BLE broadcast (...Gabor - <br />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.<br /><br />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.<br /><br />My app can see other packets such as ADV_SCAN_ID but not ADV_NONCONN_IND (broadcast) packets.<br /><br />public void uploadScanBytes(SensorDataUploader sensorDataUploader, int count) {<br /> BluetoothAdapter btAdapter = getBluetoothAdapter();<br /> if (btAdapter == null) return;<br /><br /> BluetoothLeScanner scanner = btAdapter.getBluetoothLeScanner();<br /> ScanSettings settings = new ScanSettings.Builder()<br /> .setScanMode(ScanSettings.SCAN_MODE_LOW_LATENCY)<br /> .setCallbackType(ScanSettings.CALLBACK_TYPE_ALL_MATCHES)<br /> .build();<br /> scanner.startScan(Collections.emptyList(), settings, new LimitedScanRecordReader(sensorDataUploader, count, scanner));<br /> }<br /><br /><br />public void onScanResult(int callbackType, ScanResult result) {<br /><br /> if(result.getDevice().getAddress().equals("00:AB:2c:A1:E2:F1")) {<br /> long timestamp = System.currentTimeMillis() - SystemClock.elapsedRealtime() +<br /> result.getTimestampNanos() / 1000000;<br /> byte[] rawBytes = result.getScanRecord().getBytes();<br /> Log.i(DataTransferService.class.getName(), "Raw bytes: " + byteArrayToHex(rawBytes));<br /> sensorDataUploader.upload(timestamp, rawBytes);<br /> }<br />}<br /><br />Please let me know what I'm doing wrong.<br />Thanks.Anonymoushttps://www.blogger.com/profile/15262994329150022327noreply@blogger.comtag:blogger.com,1999:blog-8214401912480503366.post-73275529619255542582016-02-01T15:58:12.199+01:002016-02-01T15:58:12.199+01:00Thanks, Damon. You may want to check out the updat...Thanks, Damon. You may want to check out the updated code, it supports more BLE advertisement elements (although still not all the 4.2 elements).Gabor Pallerhttps://www.blogger.com/profile/02390936870056951146noreply@blogger.comtag:blogger.com,1999:blog-8214401912480503366.post-3958856735322662932015-04-07T23:39:49.352+02:002015-04-07T23:39:49.352+02:00I've build a different demo with a temperature...I've build a different demo with a temperature sensor that also sends it over advertisements. But I ran into the same issues as you did when i tried to add more data.<br />Did you try and look at <a href="www.argenox.com/bluetooth-low-energy-ble.../a-ble-advertising-primer/" rel="nofollow"> this ble guide</a>? it explained to me exactly what I needed to know.<br /><br />The page isn't enough. You still need to look a t the Bluetooth spec.Anonymousnoreply@blogger.com