我正在尝试将代码示例用于我的案例,从 配对蓝牙设备到具有 32feet .NET 蓝牙库的计算机
在这里,xmashallax 提到了本地mac地址。为了获得本地地址,我正在尝试这个-
public static BluetoothAddress GetBTMacAddress()
{
var nics = NetworkInterface.GetAllNetworkInterfaces();
foreach (NetworkInterface nic in nics)
{
// Only consider Bluetooth network interfaces
if (nic.NetworkInterfaceType != NetworkInterfaceType.FastEthernetFx &&
nic.NetworkInterfaceType != NetworkInterfaceType.Wireless80211 && nic.Description.Contains("Bluetooth"))
{
return new BluetoothEndPoint(nic.GetPhysicalAddress().GetAddressBytes(), BluetoothService.SerialPort);
}
}
return null;
}
我在这里遇到错误“ The requested address is not valid in its context
”
ErrorCode: AddressNotAvailable
您能否建议获取当前本地PC的mac地址的正确方法?