Home > Mobile >  How to tell apart Scan-Response from all other Advertisement-Types in Android.Bluetooth.LE (C#)
How to tell apart Scan-Response from all other Advertisement-Types in Android.Bluetooth.LE (C#)

Time:06-20

I'm fairly new to BLE so bare with me. I'm aware of:

Bluetooth Low Energy: when scanning for advertisements, how are scan responses identified?

But I don't know how to dig into classes like

Android.Bluetooth.LE.ScanResult

In order to figure out whether I'm dealing with SCAN_RSP or something else

(or is ScanResult always about Scan-Responses and nothing else? If this is the case how can one intercept all other kinds of advertisement-types in Android?).

PS: To put my question into perspective, in the Windows world the class

  Windows.Devices.Bluetooth.Advertisement.BluetoothLEAdvertisementReceivedEventArgs

Makes it very clear what type of message is being handled via the property:

  args.AdvertisementType

This enum-property can have the following types:

   BluetoothLEAdvertisementType.ScanResponse   <--- crystal clear!
   BluetoothLEAdvertisementType.ConnectableDirected
   BluetoothLEAdvertisementType.ScannableUndirected
   BluetoothLEAdvertisementType.ConnectableUndirected
   BluetoothLEAdvertisementType.NonConnectableUndirected

CodePudding user response:

From the application's point of view, it does not matter whether the transported information was part of the 'Advertising' or the 'ScanResponse' packet. Both packets share the same format and can therefore be combined.

Android also does this and therefore combines both packets in the ScanResult class. This information can also be found in ScanResult.getScanRecord.

  • Related