C# Class SensorbergSDK.Internal.Utils.BeaconFactory

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

Public Methods

Method 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

Method 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 method

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

BeaconFromBluetoothLeAdvertisementReceivedEventArgs() public static method

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

BeaconFromByteArray() public static method

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.
return Beacon

BeaconFromDataSection() public static method

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.
return Beacon

BeaconFromDataSectionList() public static method

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.
return Beacon

BeaconManufacturerData() public static method

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.
return BluetoothLEManufacturerData

BeaconToSecondDataSection() public static method

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.
return BluetoothLEAdvertisementDataSection

CalculateDistanceFromRssi() public static method

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.
return double

DataSectionToRawString() public static method

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

FormatUuid() public static method

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.
return string

ManufacturerIdToString() public static method

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

UuidToAdvertisementBytePattern() public static method

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.
return BluetoothLEAdvertisementBytePattern