物联网的Windows - 斑马蓝牙打印机 [英] Windows IoT - Zebra Bluetooth Printer
问题描述
我有两个斑马蓝牙打印机,MZ220和iMZ220。 唯一的事我会做,就是在树莓派2.没有打印与Windows系统的物联网更多的文本;)
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 的Hello World
2号线---------------
3号线日期:2016年1月1日
4号线时间:18:00
的USB蓝牙适配器BTA-403从ORICO,我想效果很好。随着浏览器我可以连接到打印机。但是,何去何从?我如何连接到打印机?我如何打印到打印机说的Hello World!
The USB Bluetooth Adapter BTA-403 from ORICO, I guess works well. With the Explorer I can connect to the Printer. But, what next? How do I connect to the Printer? How do I say to the Printer print "Hello World!"
谢谢!
推荐答案
这些打印机使用蓝牙像一个串口又名SSP的个人资料。
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();
}
这篇关于物联网的Windows - 斑马蓝牙打印机的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!