Windows IoT - Zebra 蓝牙打印机

Mee*_*akt 2 printing bluetooth zebra-printers raspberry-pi2 windows-10-iot-core

我有两台 Zebra 蓝牙打印机,一个 MZ220 和一个 iMZ220。我会做的“唯一”事情是在 Raspberry Pi 2 上使用 Windows IoT 系统打印文本。仅此而已;)

示例: Line1 " Hello World" Line2 "---------------" Line3 "Date:01.01.2016" Line4"Time: 18:00"

ORICO的USB蓝牙适配器BTA-403,我想效果很好。使用资源管理器,我可以连接到打印机。但是,接下来呢?如何连接到打印机?我怎么说打印机打印"Hello World!"

谢谢!

dan*_*nvy 5

这些打印机使用蓝牙,就像串行端口又名 SSP 配置文件。

首先,您必须编辑您的应用清单并添加新的设备功能

<Capabilities>
    <Capability Name="internetClient" />
    <DeviceCapability Name="bluetooth.rfcomm">
        <Device Id="any">
            <Function Type="name:serialPort"/>
        </Device>
    </DeviceCapability>
</Capabilities>
Run Code Online (Sandbox Code Playgroud)

您可以像这样获得配对的打印机

var devices = await DeviceInformation.FindAllAsync(RfcommDeviceService.GetDeviceSelector(RfcommServiceId.SerialPort));
Run Code Online (Sandbox Code Playgroud)

确定正确的打印机后,您可以打开连接

var service = await RfcommDeviceService.FromIdAsync(DeviceInfo.Id);
var socket = new StreamSocket();
await socket.ConnectAsync(service.ConnectionHostName, service.ConnectionServiceName);
Run Code Online (Sandbox Code Playgroud)

你应该能够发送这样的信息

private async void PrintAsync(string line)
{
    var writer = new DataWriter(socket.OutputStream);
    var command = "^XA^LH30,30^F020,10^AD^FD + line + "^FS^XZ";
    writer.WriteString(command);
    await writer.StoreAsync();
}
Run Code Online (Sandbox Code Playgroud)

  • 亲爱的丹维,我爱你……昨天,我收到了你的答复。但是已经是深夜了,我只是在做梦。但是今天我醒来并测试了您的代码,它有效!也没什么好说的。我谢谢你丹维! (2认同)