错误1359设置蓝牙无线电模式Windows Embedded Handheld 6.5

时间:2017-07-19 03:29:27

标签: .net bluetooth windows-mobile windows-mobile-6.5 32feet

在.NET Compact Framework 3.5中使用In The Hand 32feet library,在运行Windows Embedded Handheld 6.5 Professional CE OS 5.2.29366 Build 29366.5.3.12.48的Datalogic Sc​​orpio X3上运行示例项目Chat2Device时将蓝牙无线电切换为“可发现”失败。我添加了一些额外的错误报告代码,发现原生错误代码是1359(发生内部错误?)

在移动设备上的此示例项目中使用蓝牙的设备之间进行通信没有问题,只检索PrimaryRadio信息或尝试将RadioMode设置为任何模式抛出异常。

完整的错误消息是:

Win32Exception 在InTheHand.Net.Bluetooth.Msft.WindowsBluetoothRadio.set_Mode(RadioMode值)中设置BluetoothRadio错误代码1359时出错

代码是:

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");
    }
}

1 个答案:

答案 0 :(得分:2)

我不确定" Datalogic Sc​​orpio X3"使用WEH65,但有些设备配备了非MS蓝牙堆栈。

AFAIS," Datalogic Sc​​orpio X3" SDK提供了一个独特的API集来控制蓝牙。

设置BT模块模式的标准功能是BthSetMode。 32feet使用另一个函数BthWriteScanEnableMask。这可能没有在Datalogic X3上实现。