首页 > 解决方案 > 如何使用 jicai q2 POS 热敏打印机 (商米 V1) 使用基于 asp.net 的 web 应用程序?

问题描述

我有一个基于 Web 的应用程序,我可以在 Android 浏览器应用程序中运行它,现在我的客户希望它在集菜 Q2 POS 设备上使用它,应用程序运行良好,但我无法从集菜 Q2 POS 热敏打印机打印它(猜猜它类似于宣米V1)。我希望它通过 asp.net 和 Javascript 打印以连接到设备,任何人都可以帮助我吗?我是这个发展的新手

标签: javascriptc#asp.net

解决方案


我能够在将 Esc/Pos 命令传递给 BluetoothSocket.OutputStream 的 jicai 热敏打印机中进行打印:

using Android.Bluetooth;

// First you get the BluetoothAdapter:
BluetoothAdapter adapter = BluetoothAdapter.DefaultAdapter;
// then, you get the device:
BluetoothDevice device = adapter.BondedDevices.FirstOrDefault(d => d.Address.Equals("00:11:22:33:44:55"));
// now you create the socket
BluetoothSocket socket = device.CreateRfcommSocketToServiceRecord(Java.Util.UUID.FromString("00001101-0000-1000-8000-00805F9B34FB"));
// and now, you're able to get OOS:
Stream outputStream = socket.OutputStream;

// then, you can send esc/pos commands:
var command = new byte[] { 0x0A }; // example line feed command
outputStream.Write(command, 0, command.Length);

此外,您可以选择使用他们提供的库,就像在这个例子中一样。

我希望它有所帮助。


推荐阅读