<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Johnas Nellen on Medium]]></title>
        <description><![CDATA[Stories by Johnas Nellen on Medium]]></description>
        <link>https://medium.com/@johnas.nellen?source=rss-4ef1eb8f5511------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*yI3-4SegbVZqdBvr</url>
            <title>Stories by Johnas Nellen on Medium</title>
            <link>https://medium.com/@johnas.nellen?source=rss-4ef1eb8f5511------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sun, 22 Nov 2026 03:35:00 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@johnas.nellen/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Bluetooth LE packet capture on Android]]></title>
            <link>https://medium.com/propeller-health-tech-blog/bluetooth-le-packet-capture-on-android-a2109439b2a1?source=rss-4ef1eb8f5511------2</link>
            <guid isPermaLink="false">https://medium.com/p/a2109439b2a1</guid>
            <category><![CDATA[android]]></category>
            <category><![CDATA[bluetooth-low-energy]]></category>
            <category><![CDATA[bluetooth]]></category>
            <category><![CDATA[debugging]]></category>
            <dc:creator><![CDATA[Johnas Nellen]]></dc:creator>
            <pubDate>Tue, 30 Jun 2020 14:42:28 GMT</pubDate>
            <atom:updated>2020-06-30T15:11:49.640Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Wc3MgXJ00mrdGO_-8vJXTw.jpeg" /><figcaption>Photo by <a href="https://unsplash.com/@euwars?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Farzad Nazifi</a> on <a href="https://unsplash.com/?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Unsplash</a></figcaption></figure><p>At Propeller Health we develop products that help people with asthma or COPD manage their condition. One component of our platform is a sensor that attaches to a person’s inhaled medication and sends medication usage data to a connected device over Bluetooth Low Energy (BLE).</p><p>BLE communication in Android can be finicky for many reasons, including inconsistencies in hardware such as Bluetooth adapters (radios), software such as the firmware the Bluetooth adapter is programmed with, and vendor implementations of the Android OS.</p><p>What if you were asked to troubleshoot one of these finicky devices? Wouldn’t it be useful if you could see what is being transmitted between them? Well, thankfully there is packet capture, and Android provides a way to do this for BLE communication. Performing a BLE packet capture is a good way to inspect the data being transferred between central (e.g. an Android phone) and peripheral devices (e.g. a Propeller sensor). This can be useful to verify that the data transmitted between the devices is what is expected.</p><h3>How Bluetooth packet capture works on Android</h3><h4>What you’ll need</h4><ol><li>An Android device running Android 4.4 (KitKat) or greater to use as the central device</li><li>A BLE device to use as the peripheral device</li><li>A Windows, Linux or Mac workstation with the Android SDK tools installed</li></ol><h4>Enable Developer Options</h4><p>As previously mentioned, Developer options need to be enabled in order to intercept and store packets as they are being sent and received. In order to enable Developer options perform the following:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*MINWs9mViFc-YD2JE55mhw.png" /></figure><ol><li>On stock Android open Settings &gt; About phone &gt; Build number</li><li>Tap Build number seven times. After the first few taps, you should see the steps counting down until you unlock the developer options. Once activated you’ll see a message that reads <em>You are now a developer!</em></li><li>Go back to Settings &gt; System &gt; Advanced where you’ll now find a Developer options entry or use the search feature to search for “Developer options”</li></ol><p>Note, it’s not recommended to leave Developer options enabled longer than necessary as device security is reduced. We are capturing and storing data meant to be transferred between the central and peripheral devices after all and that exposes some risk.</p><h4>Enable Bluetooth HCI snoop log</h4><p>Now that we have Developer options enabled, we can enable the Bluetooth HCI snoop log. When the Bluetooth HCI snoop log is enabled, the Android framework will capture Bluetooth packets sent and received between central and peripheral devices and store them as part of a bug report. To enable the Bluetooth HCI snoop log:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*HNRLTVutSmJPDLLqfbwudg.png" /></figure><ol><li>On stock Android open Settings &gt; System &gt; Advanced &gt; Developer options</li><li>Tap Enable Bluetooth HCI snoop log</li><li>Tap the Enable option on the dialog that displays</li></ol><p>After the Bluetooth HCI snoop log has been enabled you will need to restart the Bluetooth adapter which you can do by turning Bluetooth off and back on. All Bluetooth packets sent and received by the Bluetooth adapter will now be saved to the Bluetooth HCI snoop log.</p><h4>Initiate BLE communication</h4><p>Now that we have our central device configured to capture Bluetooth traffic being transmitted we can initiate communication between the central and peripheral devices. One way to initiate communication for Propeller sensors is by performing a manual sync by pressing the auxiliary button on a sensor. When the auxiliary button is pressed Propeller sensors will send advertising packets at a much higher rate for a short period of time. When the central scanner receives the advertising packets the data will be logged to the Bluetooth HCI snoop log.</p><h4>Extract the Bluetooth HCI snoop log</h4><p>In order to extract the Bluetooth HCI snoop log from the Android device you need to connect the Android device to your workstation and use the adb command to generate a bug report:</p><blockquote>adb bugreport bugreport</blockquote><p>This will extract the bug report to a zip file named bugreport.zip on your workstation. Unzip the bug report:</p><blockquote>unzip bugreport.zip</blockquote><p>Locate the file named btsnoop_hci.log in the extracted files, this is the file which contains the packet capture.</p><h4>Disable Bluetooth HCI snoop log</h4><p>After you’ve captured the traffic you’re interested in the Bluetooth HCI snoop log can be disabled. You can disable the Bluetooth HCI snoop log the same way it was enabled:</p><ol><li>On stock Android open Settings &gt; System &gt; Advanced &gt; Developer options</li><li>Tap Enable Bluetooth HCI snoop log</li><li>Tap the Disable option on the dialog that displays</li></ol><p>Again, you must also toggle Bluetooth services in order to restart the Bluetooth adapter. Additionally, now may also be a good time to disable Developer options if you are done troubleshooting.</p><h4>Analyze the Bluetooth HCI snoop log</h4><p>Now that you have a packet capture you can load it into your favorite network protocol analyzer. A popular and well known network protocol analyzer is <a href="https://www.wireshark.org/">Wireshark</a>. Understanding how to configure Wireshark display filters is outside the scope of this blog post, however if you know the mac address of the peripheral device you’ll find the following display filter useful:</p><blockquote>bthci_evt.bd_addr == xx:xx:xx:xx:xx:xx || bthci_cmd.bd_addr == xx:xx:xx:xx:xx:xx || bluetooth.addr == xx:xx:xx:xx:xx:xx</blockquote><h3>Conclusion</h3><p>Troubleshooting BLE communication on an Android device can feel like working with a black box. You now have another tool in your arsenal to build a deeper understanding of the packets sent and received by peripheral devices. The next time you’re left wondering why your BLE device isn’t communicating properly, fire up the Bluetooth HCI snoop log, capture some packets and take a look at what your central and peripheral devices are saying to each other, you may be surprised at what you find!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a2109439b2a1" width="1" height="1" alt=""><hr><p><a href="https://medium.com/propeller-health-tech-blog/bluetooth-le-packet-capture-on-android-a2109439b2a1">Bluetooth LE packet capture on Android</a> was originally published in <a href="https://medium.com/propeller-health-tech-blog">Propeller Health Tech Blog</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>