Struct BaseBluetoothAdvertisement
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
deviceNamestringThe device name from the advertisement.
servicesGuidsIEnumerable<Guid>The collection of service GUIDs advertised.
isConnectableboolWhether the device is connectable.
signalStrengthInDBmintThe raw signal strength (RSSI) in dBm.
transmitPowerLevelInDBmintThe transmit power level in dBm.
bluetoothAddressstringThe Bluetooth address of the device.
manufacturerDataReadOnlyMemory<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
DateReceived
A timestamp for the point in time in which each Advertisement was received.
public DateTimeOffset DateReceived { get; }
Property Value
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
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
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
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
ManufacturerId
Gets the ID of the manufacturer.
public int ManufacturerId { get; }
Property Value
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
SignalStrengthInDBm
Raw Signal Strength In DBm. Android : ScanResult.Rssi iOS : Rssi.Int32Value Windows : BluetoothLeAdvertisementReceivedEventArgs.RawSignalStrengthInDBm
public int SignalStrengthInDBm { get; }
Property Value
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; }