我目前正在对蓝牙激活(刚刚启用和一定的操作之后,从Windows CE版本6自动禁用蓝牙)禁用蓝牙
我使用SmartDeviceFramework即CAB文件我然后在Windows CE安装如何启用和使用C#
下面是我的方法,我的工作是使用 (InTheHand.Net.Personal.dll文件蓝牙):
private static void setBluetoothConnection()
{
try
{
if (BluetoothRadio.IsSupported == true)
{
MessageBox.Show("Bluetooth Supported", "Information", MessageBoxButtons.OK, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1);
BluetoothRadio radio = BluetoothRadio.PrimaryRadio;
MessageBox.Show(radio.Mode.ToString(), "Before Bluetooth Connection", MessageBoxButtons.OK, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1);
radio.Mode = RadioMode.Discoverable;
// here radio.Mode works only if the Windows Device has Bluetooth enabled otherwise gives error
MessageBox.Show(radio.Mode.ToString(), "RadioMode Discover", MessageBoxButtons.OK, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1);
bluetoothClient = new BluetoothClient();
//Cursor.Current = Cursors.WaitCursor;
BluetoothDeviceInfo[] bluetoothDeviceInfo = bluetoothClient.DiscoverDevices();
MessageBox.Show(bluetoothDeviceInfo.Length.ToString(), "Device Name", MessageBoxButtons.OK, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1);
foreach(BluetoothDeviceInfo device in bluetoothDeviceInfo)
{
Cursor.Current = Cursors.Default;
MessageBox.Show(device.DeviceName, "Device Name", MessageBoxButtons.OK, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1);
bluetoothClient.Connect(new BluetoothEndPoint(device.DeviceAddress, service));
MessageBox.Show("Bluetooth Connected...", "Information", MessageBoxButtons.OK, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1);
break;
}
}
else
{
MessageBox.Show("Bluetooth Not Supported", "Information", MessageBoxButtons.OK, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1);
}
}
catch (Exception ex)
{
log.Error("[Bluetooth] Connection failed", ex);
MessageBox.Show(ex.Message,"Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1);
}
}
所以我面对错误的位置:
BluetoothRadio radio = BluetoothRadio.PrimaryRadio;
radio.Mode = RadioMode.Discoverable; // gives error here
错误:
Error setting BluetoothRadio.Mode
发生上述错误一次当蓝牙设备被禁用,并执行上面的行,并关闭该应用程序
但随着应用程序关闭,并且当我去移动蓝牙管理器,蓝牙启用。
我的问题:
我必须点击一个按钮2倍时, 应用程序错误关闭(但蓝牙设置为ON),并在范围内第2至 搜索设备使按钮(第1 )而不是1次点击。
我的假设
我认为有可能当程序试图 从OFF可发现能够从手机蓝牙的一些安全问题。
那么,有任何过程(System.Digonostics; DLL),通过该我可以自动的WindowsMobile CE在C#设定蓝牙ON和OFF
我试图但没有得到它,所以任何人都可以帮助我,或建议任何dll文件的蓝牙连接。
感谢
物联网,蓝牙和32feet.net?向我致敬; )。 – 2015-02-13 05:38:13
感谢您的回复。我尝试使用32feet.net(InTheHand.Net.Personal.dll),但在启用蓝牙时出现错误。你知道我在哪里可以找到Microsoft.WindowsMobile.SharedSource.Bluetooth DLL吗?这个DLL会工作吗?任何想法 – techGaurdian 2015-02-13 06:07:57