public static ushort GetMinorFromRecord(ScanRecord scanRecord) { byte[] recordByteData = scanRecord.GetBytes(); string minorStr = BitConverter.ToString(recordByteData, 27, 2).Replace("-", ""); ushort minor = Convert.ToUInt16(minorStr, 16); return(minor); }
public static short GetTxPowerFromRecord(ScanRecord scanRecord) { byte[] recordByteData = scanRecord.GetBytes(); string txPowerStr = BitConverter.ToString(recordByteData, 29, 1); short txPower = Convert.ToSByte(txPowerStr, 16); return(txPower); }
public static Guid GetUuidFromRecord(ScanRecord scanRecord) { byte[] recordByteData = scanRecord.GetBytes(); string uuidStr = BitConverter.ToString(recordByteData, 9, 4).Replace("-", "") + "-" + BitConverter.ToString(recordByteData, 13, 2).Replace("-", "") + "-" + BitConverter.ToString(recordByteData, 15, 2).Replace("-", "") + "-" + BitConverter.ToString(recordByteData, 17, 2).Replace("-", "") + "-" + BitConverter.ToString(recordByteData, 19, 6).Replace("-", ""); return(new Guid(uuidStr)); }
public static bool IsIBeacon(ScanRecord scanRecord) { byte[] recordByteData = scanRecord.GetBytes(); if (recordByteData.Length > 30 && recordByteData[5] == 0x4c && recordByteData[6] == 0x00 && recordByteData[7] == 0x02 && recordByteData[8] == 0x15) { return(true); } return(false); }
protected ScanResult ToScanResult(BluetoothDevice native, int rssi, ScanRecord scanRecord) { if (scanRecord?.DeviceName == "FSC_BP103") { } var beacon = Beacon.ParseBeacon(scanRecord?.GetBytes()); var device = Device.GetDeviceInfo(native); //var dev = this.Devices.GetDevice(native); //var result = new ScanResult(dev, rssi, ad); var result = new ScanResult(Guid.Empty, rssi, device, beacon); return(result); }
public AdvertisementData(ScanRecord scanRecord) : this(scanRecord.GetBytes()) { }