Example #1
0
        public async Task <IReadOnlyList <IBluetoothNeighbor> > DiscoverAsync()
        {
            var devices = await bluetoothDiscoveryFacade.DiscoverPeersAsync().ConfigureAwait(false);

            var neighbors = new List <IBluetoothNeighbor>();

            foreach (var device in devices)
            {
                if (device.Name == null || (!device.Name.Contains("Spy") && !device.Name.Contains("G920") && !device.Name.Contains("DESKTOP")))
                {
                    continue;
                }

                var      neighborId = MacUtilities.ConvertMacToGuid(device.Address);
                Neighbor neighbor;
                if (!neighborsById.TryGetValue(neighborId, out neighbor))
                {
                    neighbor = new Neighbor(this, inboundBluetoothSocketTable, device);
                    neighborsById[neighborId] = neighbor;
                }
                neighbors.Add(neighbor);
            }
            return(neighbors);
        }