Table of Contents

Struct BaseBluetoothAdvertisement

Namespace
Bluetooth.Core.Scanning
Assembly
Bluetooth.Core.Scanning.dll

Interface representing a Bluetooth advertisement, providing properties for accessing advertisement data received from a Bluetooth device.

public readonly record struct BaseBluetoothAdvertisement : IBluetoothAdvertisement, IEquatable<BaseBluetoothAdvertisement>
Implements
Inherited Members

Remarks

This is a readonly struct for memory efficiency. Advertisements are immutable snapshots that are created frequently (thousands per second), so using a value type reduces heap allocations and GC pressure significantly.

Constructors

BaseBluetoothAdvertisement(string?, IEnumerable<Guid>?, bool, int, int, string?, ReadOnlyMemory<byte>)

Initializes a new instance of the BaseBluetoothAdvertisement struct.

public BaseBluetoothAdvertisement(string? deviceName, IEnumerable<Guid>? servicesGuids, bool isConnectable, int signalStrengthInDBm, int transmitPowerLevelInDBm, string? bluetoothAddress, ReadOnlyMemory<byte> manufacturerData)

Parameters

deviceName string

The device name from the advertisement.

servicesGuids IEnumerable<Guid>

The collection of service GUIDs advertised.

isConnectable bool

Whether the device is connectable.

signalStrengthInDBm int

The raw signal strength (RSSI) in dBm.

transmitPowerLevelInDBm int

The transmit power level in dBm.

bluetoothAddress string

The Bluetooth address of the device.

manufacturerData ReadOnlyMemory<byte>

The manufacturer-specific data.

Properties

BluetoothAddress

Gets the Bluetooth address of the device sending the Bluetooth LE advertisement. Android : ScanResult.Device?.Address iOS : Peripheral.Identifier.AsString() Windows : BluetoothLeAdvertisementReceivedEventArgs.BluetoothAddress

public string BluetoothAddress { get; }

Property Value

string

DateReceived

A timestamp for the point in time in which each Advertisement was received.

public DateTimeOffset DateReceived { get; }

Property Value

DateTimeOffset

DeviceName

Name of the device sending that advertisement. Android : ScanResult.ScanRecord?.DeviceName iOS : AdvertisementData.LocalName Windows : BluetoothLeAdvertisementReceivedEventArgs.Advertisement?.GetDeviceName()

public string DeviceName { get; }

Property Value

string

IsConnectable

Indicates whether the received advertisement is connectable. Android : ScanResult.ScanRecord?.IsConnectable [not available prior to API 8.0 (API level 26)] iOS : AdvertisementData.IsConnectable Windows : BluetoothLeAdvertisementReceivedEventArgs.AdvertisementType is BluetoothLEAdvertisementType.ConnectableDirected or BluetoothLEAdvertisementType.ConnectableUndirected

public bool IsConnectable { get; }

Property Value

bool

Manufacturer

Gets the Primary Manufacturer based on the "Manufacturer Data" sectors in BLE "Advertising-Messages" and BLE "Scan-Response-Messages".

Corresponds to the bytes [0] and [1] of the "Manufacturer Data" sector.

public Manufacturer Manufacturer { get; }

Property Value

Manufacturer

ManufacturerData

Gets the BLE advertisement-payload-data that was received.

Note that this byte array is normalized to enforce same byte-layout across all platforms (iOS, Android, Windows).

This property has been introduced for the sake of backwards compatibility back in 2020 when the BLE library was being consolidated.

The byte-layout has been inspired by the one that iOS offers natively in its APIs:

[2 bytes of manufacturer-id in reserve order] [one byte of device-id] [... chunks of manufacturer-data here]

Note: Don't resort to byte-sniffing this byte-array unless maybe for debugging purposes. when it comes to this particular property these libs' maintainers can't and won't provide any guarantees in terms of compatibility.

public ReadOnlyMemory<byte> ManufacturerData { get; }

Property Value

ReadOnlyMemory<byte>

ManufacturerId

Gets the ID of the manufacturer.

public int ManufacturerId { get; }

Property Value

int

ServicesGuids

Gets the Bluetooth address of the device sending the Bluetooth LE advertisement. Android : ScanResult.ScanRecord?.ServiceUuids iOS : AdvertisementData.ServiceUuids Windows : BluetoothLeAdvertisementReceivedEventArgs.Advertisement?.GetServiceUuids()

public IEnumerable<Guid> ServicesGuids { get; }

Property Value

IEnumerable<Guid>

SignalStrengthInDBm

Raw Signal Strength In DBm. Android : ScanResult.Rssi iOS : Rssi.Int32Value Windows : BluetoothLeAdvertisementReceivedEventArgs.RawSignalStrengthInDBm

public int SignalStrengthInDBm { get; }

Property Value

int

TransmitPowerLevelInDBm

Represents the received transmit power of the advertisement. Android : ScanResult.ScanRecord?.TxPowerLevel iOS : AdvertisementData.TxPowerLevel?.Int32Value Windows : BluetoothLeAdvertisementReceivedEventArgs.Advertisement?.GetTxPower()

public int TransmitPowerLevelInDBm { get; }

Property Value

int