我目前正在對藍牙激活(剛剛啓用和一定的操作之後,從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