You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Zebra ZQ620蓝牙打印机在Android Chrome中无法获取服务问题咨询

解决Zebra ZQ620通过Android Chrome Web Bluetooth连接打印问题

核心问题分析

你遇到的「NotFoundError: No Services found in device」问题,主要原因是使用了错误的BLE服务UUID,或打印机的BLE服务未正确启用。从nRF Connect的检测结果来看,设备存在服务但无法访问,大概率是UUID不匹配或打印机未开放对应服务的访问权限。

解决方案步骤

1. 使用Zebra官方标准BLE UUID

Zebra打印机的BLE打印服务有固定的标准UUID,替换你代码中的错误值:

  • 打印服务UUID:0000ffe0-0000-1000-8000-00805f9b34fb
  • 打印特征UUID(用于发送数据):0000ffe1-0000-1000-8000-00805f9b34fb

2. 确认打印机BLE服务已启用

  • 长按打印机电源键或配对键,进入BLE配对模式(具体操作参考ZQ620用户手册)。
  • 使用Zebra官方配置工具(如Zebra Printer Utilities),确认打印机的BLE服务已开启,并设置为允许外部设备访问。

3. 修正后的代码示例

// Zebra官方标准BLE UUID
const PRINT_SERVICE_UUID = '0000ffe0-0000-1000-8000-00805f9b34fb';
const PRINT_CHARACTERISTIC_UUID = '0000ffe1-0000-1000-8000-00805f9b34fb';
var printCharacteristic = null;

// 适配Zebra打印机的打印文本函数(添加ZPL指令格式)
function sendPrintText(text) {
    // ZPL标准指令包裹,确保打印机识别并执行
    const zplContent = `^XA${text}^XZ`;
    const encoder = new TextEncoder("utf-8");
    const encodedData = encoder.encode(zplContent);
    return printCharacteristic.writeValue(encodedData);
}

function connectAndPrint() {
    navigator.bluetooth.requestDevice({
        filters: [{ namePrefix: 'X' }], // 匹配你的打印机名称前缀
        optionalServices: [PRINT_SERVICE_UUID] // 必须声明要访问的服务UUID
    })
    .then(device => {
        console.log('正在连接设备:', device.name);
        return device.gatt.connect();
    })
    .then(server => {
        console.log('获取打印服务');
        return server.getPrimaryService(PRINT_SERVICE_UUID);
    })
    .then(service => {
        console.log('获取打印特征');
        return service.getCharacteristic(PRINT_CHARACTERISTIC_UUID);
    })
    .then(characteristic => {
        printCharacteristic = characteristic;
        // 发送文本框内的打印内容
        return sendPrintText(document.getElementById("_textarea").value);
    })
    .then(() => {
        console.log('打印指令已发送');
    })
    .catch(error => {
        console.error('连接/打印失败:', error);
    });
}

4. 环境与权限检查

  • 必须在HTTPS环境下运行(本地开发可使用localhost,Chrome允许localhost的Web Bluetooth访问)。
  • 连接操作必须由用户主动触发(如点击按钮调用connectAndPrint),Chrome不允许自动触发蓝牙连接。

关于打印机支持性与跨设备使用

  • Zebra ZQ620支持Web Bluetooth连接打印,需确保打印机固件版本为最新(可通过Zebra官方工具升级)。
  • 跨设备使用:除Android Chrome外,iOS 13+的Safari、Windows/macOS的Chrome/Edge也支持Web Bluetooth,只要使用正确的UUID并满足浏览器权限要求即可。

内容的提问来源于stack exchange,提问作者Makoto Uno

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.19 04:25:12