Zebra ZQ 510移动打印机与Motorola MC32NO兼容(Windows Embedded Compact 7.0)

时间:2016-09-12 21:06:17

标签: bluetooth bluetooth-lowenergy windows-ce zebra-printers

使用以下遗留代码(引用InTheHand.Net.Personal dll)从Motorola MC32N0通过蓝牙连接新购买的Zebra ZQ 510移动打印机时遇到问题:

using InTheHand.Net;
using InTheHand.Net.Bluetooth;
using InTheHand.Net.Sockets;
using InTheHand.Net.Ports;

BluetoothAddress mac = BluetoothAddress.Parse("B0B44879581D");
BluetoothEndPoint btEndPoint = new BluetoothEndPoint(mac, BluetoothService.SerialPort);
BluetoothClient bluetoothClient = new BluetoothClient();
bluetoothClient.Connect(btEndPoint);

我的解决方法是使用BluetoothSecurity.PairRequest()函数来配对打印机,但是使用BTUI应用程序手动分配串行端口(COM5或COM9)。然后使用以下代码(引用Zebra Link OS SDK(ZSDK_API.dll)):

using ZSDK_API.Comm;
// Instantiate connection for ZPL Serial port on COM5. 
ZebraPrinterConnection thePrinterConn = new SerialPrinterConnection("COM5");
// Open the connection - physical connection is established here.
thePrinterConn.Open();

连接到它进行打印。

有两个问题要问: 1.想知道带有智能蓝牙的Zebra ZQ 510移动打印机是否与Motorola MC32NO兼容(在Windows Embedded Compact 7.0上运行)? 2.有没有办法在Windows CE中以编程方式创建虚拟COM端口?

2 个答案:

答案 0 :(得分:0)

最后找出解决方案。下载 Motorola EMDK for .NET v2.9 ,并引用 Symbol.WPAN.dll 。通过使用以下代码,设法连接到 Zebra ZQ510打印机,并按预期打印出标签。别忘了将EMDK中的 BTInterface.dll 复制到程序文件夹中。

        using Symbol.WPAN.Bluetooth;
        Bluetooth m_Bluetooth = new Bluetooth();
        m_Bluetooth.Enable();
        RemoteDevice rd = new RemoteDevice("", currentBTPrinterMacAdd, "");
        rd.LocalComPort = LocalComPortForZebraPrinterZQ510;
        m_Bluetooth.RemoteDevices.Add(rd);

        if (!rd.IsPaired)
            rd.Pair();

        rd.OpenPort();
        rd.Write(Encoding.Default.GetBytes(template));

        rd.ClosePort();
        rd.UnPair();

        m_Bluetooth.Disable();
        m_Bluetooth.Dispose();

答案 1 :(得分:0)

我在没有Zebra链接的QLN320上看到了相同的问题。手中会配对,但是如果您尝试使用本地端口,则会出错。

这里仅在VB 2008中是相同的示例。它工作正常,但有时连接速度有些慢。

Imports Symbol.WPAN
Imports Symbol.WPAN.Bluetooth
Imports System.Text



Dim printline As String = ""
printline = printline & "! 0 200 200 631 1" & vbCrLf 
printline = printline & "PW 576" & vbCrLf
printline = printline & "TONE 0" & vbCrLf
printline = printline & "SPEED 4" & vbCrLf
printline = printline & "ON-FEED IGNORE" & vbCrLf
printline = printline & "NO-PACE" & vbCrLf
printline = printline & "GAP-SENSE" & vbCrLf
printline = printline & "BT 7 0 3" & vbCrLf
printline = printline & "B 128 2 30 458 69 62 02029990324041000014" & vbCrLf 
printline = printline & "PRINT" & vbCrLf

Dim m_Bluetooth As New Bluetooth
m_Bluetooth.Enable()
m_Bluetooth.RemoteDevices.DeleteAll()
Dim rd As New RemoteDevice("Printer35", "", "") 
rd.LocalComPort = 5
m_Bluetooth.RemoteDevices.Add(rd)

Try

    If Not (rd.IsPaired) Then
        rd.Pair("0035")
    End If

    rd.OpenPort()

    Dim ByteArray As Byte() = Encoding.Default.GetBytes(printline & vbCrLf)

    rd.Write(ByteArray)

    rd.ClosePort()

    rd.UnPair()
    m_Bluetooth.RemoteDevices.DeleteAll()

Catch ex As Exception

    MessageBox.Show("Error  - " & ex.Message.ToString)

End Try

m_Bluetooth.Disable()
m_Bluetooth.Dispose()
相关问题