You need to enable JavaScript to run this app.
最新活动
大模型
产品
解决方案
定价
生态与合作
支持与服务
开发者
了解我们

DS2278条码扫描器(SPP主设备)无法连接PC(SPP从设备)的故障排查求助

DS2278条码扫描器(SPP主设备)无法连接PC(SPP从设备)的故障排查求助

各位大佬好,目前我在折腾DS2278条码扫描器的蓝牙SPP连接,遇到了瓶颈,想请大家帮忙分析下。

情况是这样的:我把扫描器配置成SPP主设备,需要扫描包含LNKB + <无冒号的从设备MAC地址>的条码来发起连接到我的PC(作为SPP从设备)。但每次扫描这个条码,扫描器都会报错——LED和蜂鸣器提示「扫描的符号检测到传输错误,数据被忽略,设备配置可能不正确」,对应手册里的说明是:

A transmission error was detected in a scanned symbol. The data is ignored. This occurs if a unit is not properly configured. Check option setting.

我已经做的基础配置很简单:先恢复出厂默认,然后设置成SPP主设备模式。

不过有个反向验证是成功的:把扫描器设成SPP从设备,PC当主设备时,按照差不多的配置操作,能正常连接上,而且我也确认了PC端的SPP Profile注册是没问题的——用root权限打开qdbusviewer(qt6-tools提供的),找到我的总线my.bus,展开org.bluez.Profile1接口,调用Release方法,我的Python脚本会打印SerialPortProfile: Released,说明Profile的注册和代码处理是正常的。

现在我有点摸不着头脑了,下面附上相关的配置文件和输出信息,麻烦大家帮忙看看问题出在哪里?

已做的排查步骤

  • 完成扫描器基础配置:恢复出厂默认→设置为SPP主设备
  • 成功验证反向连接(扫描器作为SPP从设备,PC作为主设备)
  • 通过qdbusviewer确认D-Bus上的Profile注册有效,调用Release方法能触发脚本的Released日志
  • bluetoothctl show确认PC的蓝牙控制器支持SPP服务

相关信息

1. bluetoothctl show 输出

Controller 14:18:C3:2D:E7:E9 (public)
        Manufacturer: 0x0002 (2)
        Version: 0x0b (11)
        Name: pc
        Alias: pc
        Class: 0x006c010c (7078156)
        Powered: yes
        PowerState: on
        Discoverable: yes
        DiscoverableTimeout: 0x000000b4 (180)
        Pairable: yes
        UUID: A/V Remote Control                (0000110e-0000-1000-8000-00805f9b34fb)
        UUID: Handsfree Audio Gateway           (0000111f-0000-1000-8000-00805f9b34fb)
        UUID: PnP Information                   (00001200-0000-1000-8000-00805f9b34fb)
        UUID: Audio Sink                        (0000110b-0000-1000-8000-00805f9b34fb)
        UUID: Audio Source                      (0000110a-0000-1000-8000-00805f9b34fb)
        UUID: A/V Remote Control Target         (0000110c-0000-1000-8000-00805f9b34fb)
        UUID: Generic Access Profile            (00001800-0000-1000-8000-00805f9b34fb)
        UUID: Generic Attribute Profile         (00001801-0000-1000-8000-00805f9b34fb)
        UUID: Serial Port                       (00001101-0000-1000-8000-00805f9b34fb)
        UUID: Device Information                (0000180a-0000-1000-8000-00805f9b34fb)
        UUID: Vendor specific                   (03b80e5a-ede8-4b33-a751-6ce34ec4c700)
        UUID: Handsfree                         (0000111e-0000-1000-8000-00805f9b34fb)
        Modalias: usb:v1D6Bp0246d0552
        Discovering: no
        Roles: central
        Roles: peripheral
        Advertising Features:
                ActiveInstances: 0x00 (0)
                SupportedInstances: 0x0c (12)
                SupportedIncludes: tx-power
                SupportedIncludes: appearance
                SupportedIncludes: local-name
                SupportedSecondaryChannels: 1M
                SupportedSecondaryChannels: 2M
                SupportedCapabilities.MinTxPower: 0xffffffde (-34)
                SupportedCapabilities.MaxTxPower: 0x0007 (7)
                SupportedCapabilities.MaxAdvLen: 0xfb (251)
                SupportedCapabilities.MaxScnRspLen: 0xfb (251)
                SupportedFeatures: CanSetTxPower
                SupportedFeatures: HardwareOffload

2. /usr/share/dbus-1/system.conf 修改内容

<!DOCTYPE busconfig PUBLIC "-//freedesktop//DTD D-Bus Bus Configuration 1.0//EN"
 "http://www.freedesktop.org/standards/dbus/1.0/busconfig.dtd">
<busconfig>
  <!-- <SNIP> -->
  <policy context="default">
    <!-- <SNIP> -->
    <!-- Holes must be punched in service configuration files for name ownership and sending method calls -->
    <deny own="*"/>
    <deny send_type="method_call"/>
    <allow own="my.bus"/>
    <allow send_type="method_call" name="my.bus"/>
    <allow send_destination="my.bus"/>
    <!-- <SNIP> -->
  </policy>
  <!-- <SNIP> -->
</busconfig>

3. sdp_record.xml 内容(AI生成,因找不到官方参考的属性ID规则)

<?xml version="1.0" encoding="UTF-8" ?>
<record>
  <attribute id="0x0001">
    <sequence>
      <uuid value="0x1101"/>
      <!-- Serial Port Service Class UUID -->
      <uuid value="00001101-0000-1000-8000-00805f9b34fb"/>
      <!-- Explicit 128-bit UUID -->
    </sequence>
  </attribute>
  <attribute id="0x0004">
    <sequence>
      <sequence>
        <uuid value="0x0100"/>
        <!-- L2CAP Protocol -->
      </sequence>
      <sequence>
        <uuid value="0x0003"/>
        <!-- RFCOMM Protocol -->
        <uint8 value="3"/>
        <!-- RFCOMM Channel -->
      </sequence>
    </sequence>
  </attribute>
  <attribute id="0x0005">
    <sequence>
      <uuid value="0x1002"/>
      <!-- Public Browse Group -->
    </sequence>
  </attribute>
</record>

目前我怀疑可能是扫描器的主设备模式下有隐藏配置未开启,或者PC端的SPP从设备配置有遗漏?麻烦各位大佬给点排查方向,谢谢了!

火山引擎 最新活动