【问题标题】:Error 1359 Setting Bluetooth Radio Mode Windows Embedded Handheld 6.5错误 1359 设置蓝牙无线电模式 Windows Embedded Handheld 6.5
【发布时间】:2017-12-24 03:06:55
【问题描述】:

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

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

完整的错误信息是:

Win32异常 在 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");
    }
}

【问题讨论】:

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


    【解决方案1】:

    我不确定带有 WEH65 的“Datalogic Sc​​orpio X3”,但有些设备带有非 MS 蓝牙堆栈。

    AFAIS,“Datalogic Sc​​orpio X3”SDK 提供了用于控制蓝牙的独特 API 集。

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

    【讨论】:

    • 谢谢我尝试了 BthSetMode,但它也返回 1359。我下载了 Datalogic SDK,它确实有蓝牙 API bur,我可以看到它不提供设置无线电模式的选项。我想我需要弄清楚蓝牙管理器“查找我”按钮的用途......
    猜你喜欢
    • 2014-11-21
    • 1970-01-01
    • 1970-01-01
    • 2016-05-02
    • 2016-10-21
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多