サンプルプロジェクトChat2DeviceをDatalogic Scorpio X3でWindows Embedded Handheld 6.5 Professional CE OS 5.2.29366 Build 29366.5.3.12.48を実行して実行しているときに.NET Compact Framework 3.5にIn The Hand 32feet libraryを使用するBluetooth無線を「検出可能」に切り替えるコマンドが失敗します。追加のエラー報告コードを追加しました。ネイティブエラーコードが1359です(内部エラーが発生しました)エラー1359 Bluetoothラジオモードを設定するWindows Embeddedハンドヘルド6.5
モバイルデバイス上のこのサンプルプロジェクトでBluetoothを使用するデバイス間の通信に問題はありません。 RadioModeを任意のモードスロー例外に設定します。
完全なエラーメッセージは、次のとおりでInTheHand.Net.Bluetooth.Msft.WindowsBluetoothRadio.set_Mode BluetoothRadioエラーコード1359を設定
Win32Exceptionエラー(RadioMode値)
コード:
BluetoothRadio.PrimaryRadio.Mode = RadioMode.Discoverable;
サンプル内の次のコードも同様の例外で失敗します。
var myRadio = BluetoothRadio.PrimaryRadio;
if (myRadio == null) {
wtr.WriteLine("No radio hardware or unsupported software stack");
return;
}
var mode = myRadio.Mode;
// Warning: LocalAddress is null if the radio is powered-off.
wtr.WriteLine("* Radio, address: {0:C}", myRadio.LocalAddress);
wtr.WriteLine("Mode: " + mode.ToString());
wtr.WriteLine("Name: " + myRadio.Name);
wtr.WriteLine("HCI Version: " + myRadio.HciVersion
+ ", Revision: " + myRadio.HciRevision);
wtr.WriteLine("LMP Version: " + myRadio.LmpVersion
+ ", Subversion: " + myRadio.LmpSubversion);
wtr.WriteLine("ClassOfDevice: " + myRadio.ClassOfDevice
+ ", device: " + myRadio.ClassOfDevice.Device
+ "/service: " + myRadio.ClassOfDevice.Service);
wtr.WriteLine("S/W Manuf: " + myRadio.SoftwareManufacturer);
wtr.WriteLine("H/W Manuf: " + myRadio.Manufacturer);
ラジオをプログラマチックに検出可能に設定するための修正または代替方法の提案。
ライブラリコードの関連セクション。
private const string btdrtDll = "btdrt.dll";
[DllImport(btdrtDll, SetLastError = true)]
internal static extern int BthReadScanEnableMask(out WinCeScanMask pmask);
[DllImport(btdrtDll, SetLastError = true)]
internal static extern int BthWriteScanEnableMask(WinCeScanMask mask);
[Flags()]
internal enum WinCeScanMask : byte
{
None = 0,
InquiryScan = 1,
PageScan = 2,
}
public void SetMode(bool? connectable, bool? discoverable)
{
// TO-DO set power-on here
//
WinCeScanMask mask;
if (connectable.HasValue && discoverable.HasValue) {
// Will set both bits so do NOT need to know their current value.
mask = 0;
} else {
int resultR = NativeMethods.BthReadScanEnableMask(out mask);
if (resultR != 0) {
throw new System.ComponentModel.Win32Exception(resultR, "Error getting BluetoothRadio mode");
}
}
switch (connectable) {
case true:
mask |= WinCeScanMask.PageScan;
break;
case false:
mask &= ~WinCeScanMask.PageScan;
break;
// null NOP
}
switch (discoverable) {
case true:
mask |= WinCeScanMask.InquiryScan;
break;
case false:
mask &= ~WinCeScanMask.InquiryScan;
break;
// null NOP
}
var result = NativeMethods.BthWriteScanEnableMask(mask);
if (result != 0) {
throw new System.ComponentModel.Win32Exception(result, "Error setting BluetoothRadio mode");
}
}
ありがとうBthSetModeを試してみましたが、それも1359を返します。私はDatalogic SDKをダウンロードしましたが、私は見ることのできるBluetooth APIを持っていますが、無線モードを設定するオプションはありません。私は、Bluetooth Managerの "Find Me"ボタンが使用するものを解決する必要があると思います... –