首页 文章

Windows IoT - Zebra蓝牙打印机

提问于
浏览
1

我有两台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,我觉得很好用 . 使用Explorer我可以连接到打印机 . 但是,下一步是什么?如何连接打印机?怎么说打印机打印 "Hello World!"

谢谢!

1 回答

  • 3

    这些打印机使用蓝牙,如串行端口,即SSP配置文件 .

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

    <Capabilities>
        <Capability Name="internetClient" />
        <DeviceCapability Name="bluetooth.rfcomm">
            <Device Id="any">
                <Function Type="name:serialPort"/>
            </Device>
        </DeviceCapability>
    </Capabilities>
    

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

    var devices = await DeviceInformation.FindAllAsync(RfcommDeviceService.GetDeviceSelector(RfcommServiceId.SerialPort));
    

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

    var service = await RfcommDeviceService.FromIdAsync(DeviceInfo.Id);
    var socket = new StreamSocket();
    await socket.ConnectAsync(service.ConnectionHostName, service.ConnectionServiceName);
    

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

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

相关问题