Windows IoT - Zebra Bluetooth Printer

后端 未结 1 1879
面向向阳花
面向向阳花 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

    
        
        
            
                
            
        
    
    

    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)
自定义标题
段落格式
字体
字号
代码语言
提交回复
热议问题