我有一个58毫米“MINI热敏打印机”,型号:ZJ-5805DD与我的POS应用POS打印机使用。
我已经成功地编程通过蓝牙连接我的应用程序的打印机,可以使用打印文本罚款
KitchenPrinter.writeValue(myStringData, for: A2orC2, type: .withoutResponse)
*注:A2或C2 [见-下文]特性产生相同的文本打印出来。
更改字体打印尺寸已经成为我一个死胡同。我知道这是可能的,因为打印机曼努埃尔让我下载打印测试“POS-打印机V1.0”从App Store可以改变字体大小
在服务/特征的发现,我们发现4个服务A,B,C,d(为简化讨论)
A:
CBService:0x1c0a6a5c0,值isPrimary = YES,UUID = 49535343-FE7D-4AE5-8FA9-9FAFD205E455
CBCharacteristic: 0x1c02adf80, UUID = 49535343-1E4D-4BD9-BA61-23C647249616, properties = 0x10, value = (null), notifying = NO
包含NOTIFY
CBCharacteristic: 0x1c02bba80, UUID = 49535343-8841-43F4-A8D4-ECBE34729BB3, properties = 0xC, value = (null), notifying = NO
包含WRITE WRITEWITHOUTRESPONSE
B:
CBService:0x1c0a6ce80,值isPrimary = YES,UUID = E7810A71-73AE-499D-8C15-FAA9AEF0C3F2
CBCharacteristic: 0x1c02adfe0, UUID = BEF8D6C9-9C21-4C9E-B632-BD58C1009F9F, properties = 0x3E, value = (null), notifying = NO
都包含写WRITEWITHOUTRESPONSE通知读取INDICATE
C:
CBService:0x1c0a69100,值isPrimary = YES,UUID = 18F0
CBCharacteristic: 0x1c02b8000, UUID = 2AF0, properties = 0x30, value = (null), notifying = NO
包含NOTIFY INDICATE
CBCharacteristic: 0x1c02a5700, UUID = 2AF1, properties = 0xC, value = (null), notifying = NO
包含WRITE WRITEWITHOUTRESPONSE
d:
CBService:0x1c0a68300,值isPrimary = YES,UUID =设备信息
CBCharacteristic: 0x1c02a5dc0, UUID = Serial Number String, properties = 0x2, value = (null), notifying = NO
包含READ
CBCharacteristic: 0x1c02a77a0, UUID = Software Revision String, properties = 0x2, value = (null), notifying = NO
包含READ
CBCharacteristic: 0x1c02a76e0, UUID = Hardware Revision String, properties = 0x2, value = (null), notifying = NO
包含READ
CBCharacteristic: 0x1c02a6060, UUID = Manufacturer Name String, properties = 0x2, value = (null), notifying = NO
包含READ
我一直在网上淘了天为迅速解决。可以请别人帮忙吗?
解决的问题:寻找ESC/POS commands和this StackOverflow post后,我能够改变使用以下函数,它接受hexcodes的阵列称为M58-LL或ZJ-5805打印机上的打印尺寸,将它们转换成UnicodeScalar
,然后Character
和它们附加到这是发送到打印机相同的文本打印输出String
。
let hexs = [0x1b,0x21,0x20] //doubleWide
var hexString = String()
for all in hexs {
if let scalar = UnicodeScalar(all) {
hexString.append(Character(scalar))
}
}
let theData = hexString.data(using: .utf8)!
myPrinter.writeValue(theData, for: printCharacteristic, type: .withoutResponse)
//printCharacteristic corresponds with Service/Characteristic B
[0x1b,0x21,0x00] //default
[0x1b,0x21,0x01] //small font
[0x1b,0x21,0x08] //bold
[0x1b,0x21,0x10] //doubleHeight
[0x1b,0x21,0x20] //doubleWidth
[0x1b,0x21,0x20] //doubleHeightAndWidth