Ejemplo n.º 1
0
        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);
        }
Ejemplo n.º 2
0
        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);
        }
Ejemplo n.º 3
0
        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));
        }
Ejemplo n.º 4
0
        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);
        }
Ejemplo n.º 6
0
 public AdvertisementData(ScanRecord scanRecord) : this(scanRecord.GetBytes())
 {
 }