C# Class SensorbergSDK.Internal.Utils.BeaconFactory

Creates beacon instances from received advertisement data. Can also turn beacon instances back to advertisement data.
Afficher le fichier Open project: sensorberg-dev/windows10-sdk

Méthodes publiques

Méthode Description
BeaconCodeToString ( ushort beaconCode ) : string

Converts the given beacon code to string.

BeaconFromBluetoothLeAdvertisementReceivedEventArgs ( BluetoothLEAdvertisementReceivedEventArgs args ) : Beacon

Constructs a Beacon instance and sets the properties based on the given data.

BeaconFromByteArray ( [ data ) : Beacon

Constructs a Beacon instance and sets the properties based on the given data. The expected specification of the data is as follows: Byte(s) Name -------------------------- 0-1 Manufacturer ID (16-bit unsigned integer, big endian) 2-3 Beacon code (two 8-bit unsigned integers, but can be considered as one 16-bit unsigned integer in little endian) 4-19 ID1 (UUID) 20-21 ID2 (16-bit unsigned integer, big endian) 22-23 ID3 (16-bit unsigned integer, big endian) 24 Measured Power (signed 8-bit integer) 25 Additional information byte (optional) For more details on the beacon specifications see https://github.com/AltBeacon/spec The minimum length of the given byte array is 25. If it is longer than 26 bits, everything after the 26th bit is ignored.

BeaconFromDataSection ( BluetoothLEAdvertisementDataSection dataSection ) : Beacon

Constructs a Beacon instance and sets the properties based on the given data.

BeaconFromDataSectionList ( IList dataSections ) : Beacon

Constructs a Beacon instance and sets the properties based on the given data.

BeaconManufacturerData ( ushort manufacturerId, ushort beaconCode ) : BluetoothLEManufacturerData

Creates a BluetoothLEManufacturerData instance based on the given manufacturer ID and beacon code. The returned instance can be used as a filter for a BLE advertisement watcher.

BeaconToSecondDataSection ( Beacon beacon, bool includeAuxByte = false ) : BluetoothLEAdvertisementDataSection

Creates the second part of the beacon advertizing packet. Uses the beacon IDs 1, 2, 3 and measured power to create the data section.

CalculateDistanceFromRssi ( double rawSignalStrengthInDBm, int measuredPower ) : double

Calculates the beacon distance based on the given values. http://developer.radiusnetworks.com/2014/12/04/fundamentals-of-beacon-ranging.html

DataSectionToRawString ( BluetoothLEAdvertisementDataSection dataSection ) : string

Converts the data of the given BluetoothLEAdvertisementDataSection to a string.

FormatUuid ( string uuid ) : string

Formats the given UUID. The method also accepts strings, which do not have the full UUID (are shorter than expected). Too long strings are truncated. An example of a formatted UUID: de305d54-75b4-431b-adb2-eb6b9e546014

ManufacturerIdToString ( ushort manufacturerId ) : string

Converts the given manufacturer ID to string.

UuidToAdvertisementBytePattern ( string uuid, ushort manufacturerId, ushort beaconCode ) : BluetoothLEAdvertisementBytePattern

Constructs a BluetoothLEAdvertisementBytePattern instance from the given UUID. UUID doesn't have to be full 32 hex digits, but length needs to be even.

Private Methods

Méthode Description
ChangeInt16ArrayEndianess ( byte byteArray ) : byte[]

Switches the endianess of the given byte array so that every two bytes are switched.

HexStringToByteArray ( string hexString ) : byte[]

Converts the given hex string to byte array.

Method Details

BeaconCodeToString() public static méthode

Converts the given beacon code to string.
public static BeaconCodeToString ( ushort beaconCode ) : string
beaconCode ushort The beacon code as Uint16.
Résultat string

BeaconFromBluetoothLeAdvertisementReceivedEventArgs() public static méthode

Constructs a Beacon instance and sets the properties based on the given data.
public static BeaconFromBluetoothLeAdvertisementReceivedEventArgs ( BluetoothLEAdvertisementReceivedEventArgs args ) : Beacon
args BluetoothLEAdvertisementReceivedEventArgs
Résultat Beacon

BeaconFromByteArray() public static méthode

Constructs a Beacon instance and sets the properties based on the given data. The expected specification of the data is as follows: Byte(s) Name -------------------------- 0-1 Manufacturer ID (16-bit unsigned integer, big endian) 2-3 Beacon code (two 8-bit unsigned integers, but can be considered as one 16-bit unsigned integer in little endian) 4-19 ID1 (UUID) 20-21 ID2 (16-bit unsigned integer, big endian) 22-23 ID3 (16-bit unsigned integer, big endian) 24 Measured Power (signed 8-bit integer) 25 Additional information byte (optional) For more details on the beacon specifications see https://github.com/AltBeacon/spec The minimum length of the given byte array is 25. If it is longer than 26 bits, everything after the 26th bit is ignored.
public static BeaconFromByteArray ( [ data ) : Beacon
data [ The data to populate the Beacon instance properties with.
Résultat Beacon

BeaconFromDataSection() public static méthode

Constructs a Beacon instance and sets the properties based on the given data.
public static BeaconFromDataSection ( BluetoothLEAdvertisementDataSection dataSection ) : Beacon
dataSection BluetoothLEAdvertisementDataSection A data section containing beacon data.
Résultat Beacon

BeaconFromDataSectionList() public static méthode

Constructs a Beacon instance and sets the properties based on the given data.
public static BeaconFromDataSectionList ( IList dataSections ) : Beacon
dataSections IList A data section containing beacon data.
Résultat Beacon

BeaconManufacturerData() public static méthode

Creates a BluetoothLEManufacturerData instance based on the given manufacturer ID and beacon code. The returned instance can be used as a filter for a BLE advertisement watcher.
public static BeaconManufacturerData ( ushort manufacturerId, ushort beaconCode ) : BluetoothLEManufacturerData
manufacturerId ushort The manufacturer ID.
beaconCode ushort The beacon code.
Résultat BluetoothLEManufacturerData

BeaconToSecondDataSection() public static méthode

Creates the second part of the beacon advertizing packet. Uses the beacon IDs 1, 2, 3 and measured power to create the data section.
public static BeaconToSecondDataSection ( Beacon beacon, bool includeAuxByte = false ) : BluetoothLEAdvertisementDataSection
beacon Beacon A beacon instance.
includeAuxByte bool Defines whether we should add the additional byte or not.
Résultat BluetoothLEAdvertisementDataSection

CalculateDistanceFromRssi() public static méthode

Calculates the beacon distance based on the given values. http://developer.radiusnetworks.com/2014/12/04/fundamentals-of-beacon-ranging.html
public static CalculateDistanceFromRssi ( double rawSignalStrengthInDBm, int measuredPower ) : double
rawSignalStrengthInDBm double The detected signal strength.
measuredPower int The device specific measured power as reported by the beacon.
Résultat double

DataSectionToRawString() public static méthode

Converts the data of the given BluetoothLEAdvertisementDataSection to a string.
public static DataSectionToRawString ( BluetoothLEAdvertisementDataSection dataSection ) : string
dataSection BluetoothLEAdvertisementDataSection The data section instance.
Résultat string

FormatUuid() public static méthode

Formats the given UUID. The method also accepts strings, which do not have the full UUID (are shorter than expected). Too long strings are truncated. An example of a formatted UUID: de305d54-75b4-431b-adb2-eb6b9e546014
public static FormatUuid ( string uuid ) : string
uuid string A UUID to format.
Résultat string

ManufacturerIdToString() public static méthode

Converts the given manufacturer ID to string.
public static ManufacturerIdToString ( ushort manufacturerId ) : string
manufacturerId ushort The manufacturer ID as Uint16.
Résultat string

UuidToAdvertisementBytePattern() public static méthode

Constructs a BluetoothLEAdvertisementBytePattern instance from the given UUID. UUID doesn't have to be full 32 hex digits, but length needs to be even.
public static UuidToAdvertisementBytePattern ( string uuid, ushort manufacturerId, ushort beaconCode ) : BluetoothLEAdvertisementBytePattern
uuid string The UUID.
manufacturerId ushort The manufacturer ID.
beaconCode ushort The beacon code.
Résultat BluetoothLEAdvertisementBytePattern