前言
通过bluetoothctl(blueZ)发送原始字节到蓝牙SPP无线打印机
一、发送命令
1.1 方式1
bluetoothctl gatt.list-attributes //获取attribute列表
bluetoothctl gatt.select-attribute /org/bluez/hci0/dev_57_4C_54_18_76_05/service000f/char0013
bluetoothctl gatt.write "0x41 0x41 0x0D 0x0A" //打印“AA”并换行
1.2方式二
bluetoothctl
[BlueTooth Printer ]# menu gatt
[BlueTooth Printer ]# select-attribute /org/bluez/hci0/dev_57_4C_54_18_76_05/service000f/char0013
[BlueTooth Printer ]# write "0x41 0x41 0x0D 0x0A" //打印“AA”并换行
二、发送中文
中文采用GB18030编码。
举例:打印“你好”
bluetoothctl
[BlueTooth Printer ]# menu gatt
[BlueTooth Printer ]# select-attribute /org/bluez/hci0/dev_57_4C_54_18_76_05/service000f/char0013
[BlueTooth Printer ]# write "0xC4 0xE3 0xBA 0xC3 0x0D 0x0A" //打印“你好”并换行