PC上面的蓝牙的通信(C#)

时间:2022-03-08 17:43:08

1 List<LanYa> lanYaList = new List<LanYa>(); //搜索到的蓝牙的集合 2 BluetoothClient client = new BluetoothClient(); 3 BluetoothRadio radio = BluetoothRadio.PrimaryRadio; //获取蓝牙适配器 4 radio.Mode = RadioMode.Connectable; 5 BluetoothDeviceInfo[] devices = client.DiscoverDevices();//搜索蓝牙 10秒钟 6 foreach (var item in devices) { 7 lanYaList.Add(new LanYa { blueName = item.DeviceName, blueAddress = item.DeviceAddress, blueClassOfDevice = item.ClassOfDevice, IsBlueAuth = item.Authenticated, IsBlueRemembered = item.Remembered, blueLastSeen = item.LastSeen, blueLastUsed = item.LastUsed });//把搜索到的蓝牙添加到集合中 8 }