A naïve attempt at decoding the pHin BLE GAP Interface

After inspecting the PCB, I decided to start looking at the BLE data. My intention was to simply look at the high-level behavior, such as the protocols implemented in GAP (Advertise) and GATT (Connected mode), as well as to get a general feel of how the data is structured. I ended up spending way too much time trying to decode the data without having sufficient knowledge of what is actually happening on the PCB itself. This is why I call this approach “naïve”.

Overview

The pHin sends BLE Advertisements periodically.

Here is an example capture using the CySmart Desktop application from Cypress, coupled with a CY5677 USB Dongle.

../_images/phin-advertise-summary.png

We can see that:

  • The BLE Advertisement contains the following data:

    • Flags (mandatory)

    • List of 16-bit services

    • Manufacturer Specific Data

  • The device also implements Scan Responses (which is not mandatory). A Scan response is sent by the BLE Peripheral directly after receiving a Scan request from the BLE Central (Scanner), allowing to add some complementary information in case a device wants to advertise more than the 31-byte limit of the Advertisement Packet. In the scan response, we have one optional field:

    • Shortened Local Name

  • The two middle bytes of the MAC Address are used to form the 4 digits in the Shortened Local Name. This is what allows the BLE Scanner to display the user-friendly name pHinA087. Note that using only two byte from the Bluetooth Address makes it non-unique.

Another easy way to decode BLE Advertisements is to use a BLE sniffer based on an nRF52840 development board with a specific firmware, coupled with the Wireshark network analyser.

To be complete, here is a screenshot of Wireshark decoding both the BLE Advertisement and the BLE Scan Response.

BLE Advertise
../_images/phin-advertise-wireshark-screenshot.png
BLE Scan Response
../_images/phin-scan-response-wireshark-screenshot.png

We will look at the contents of each field in more detail, but first, we will discuss how the pHin monitor changes behavior after a 90s init period.