Windows IoT - Zebra Bluetooth Printer

后端 未结 1 1877
面向向阳花
面向向阳花 2021-01-15 03:10

I have two Zebra Bluetooth Printers, a MZ220 and iMZ220. The \"only\" thing I would do, is to print text with a Windows IoT System on a Raspberry Pi 2. Nothing more ;)

相关标签:
1条回答
  • 2021-01-15 03:28

    These printers are using Bluetooth like a serial port aka SSP profile.

    First, you'll have to edit your app manifest and add a new device capability

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

    You can get the paired printers like this

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

    Once you identified the right printer, you can open the connection

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

    You should be able to send then information like this

    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();
    }
    
    0 讨论(0)
提交回复
热议问题