BlueZ Mgmt API:“添加扩展广告参数命令”返回未知命令

问题描述 投票:0回答:0

我面临以下问题: 当我从主机发送 Bluez mgmt api“添加扩展广告参数命令”时,它作为状态返回“未知命令”。

我在用 BlueZ 版本 5.64 [bluetoothd -v = 5.64] Linux 内核版本 5.4.x 根据 Bluez 文档,支持的 Bluez 管理 API 版本为 1.14

https://git.kernel.org/pub/scm/bluetooth/bluez.git/tree/doc/mgmt-api.txt#n2618

上述版本之间是否存在任何兼容性问题,或者我是否错过了在此命令之前执行的任何前置条件命令?

提前致谢。

我的代码是这样的。

char buf_write[24] = {0x54,0x00,0x00,0x00,0x12,0x00,0x01,0x02,0x40,0x00,0x00,0x00,0x00,0x00,0x00,0xA0,0x00,0x00,0x00,0xA0,0x00,0x00,0x00,0x0C};

size_t length = write(socketDescriptor, command, commandSize);

here socketDescriptor = socket(PF_BLUETOOTH, SOCK_RAW | SOCK_CLOEXEC | SOCK_NONBLOCK, BTPROTO_HCI);

注意:执行上述代码时,对于未知命令场景,我收到长度 = 0,但是当其他成功场景(例如:获取 PHY 配置(0x0044))时,长度 = commandsize。

btmon 踪迹:

@ MGMT Command: Add Extended Advertising Parameters (0x0054) plen 18
{0x0002} [hci0] 769.600316
        Instance: 1
        Flags: 0x00004002
          Advertise as Discoverable
          Use provided interval parameters
        Duration: 0
        Timeout: 0
        Min advertising interval: 100.000 msec (0x00a0)
        Max advertising interval: 100.000 msec (0x00a0)
        TX power: 12 dbm (0x0c)
@ MGMT Event: Command Status (0x0002) plen 3
{0x0002} [hci0] 769.600333
      Add Extended Advertising Parameters (0x0054)
        Status: Unknown Command (0x01)

当我从 hcitool 执行相同的命令时,它返回成功。

< HCI Command: ogf 0x08, ocf 0x0036, plen 25
  00 13 00 A0 00 00 A0 00 00 07 00 00 00 00 00 00 00 00 00 7F 
  01 00 01 00 01 
< HCI Command: LE Set Extended Advertising Parameters (0x08|0x0036) plen 25                                                                                                        #390 [hci0] 2328.752727
        Handle: 0x00
        Properties: 0x0013
          Connectable
          Scannable
          Use legacy advertising PDUs: ADV_IND
        Min advertising interval: 100.000 msec (0x00a0)
        Max advertising interval: 100.000 msec (0x00a0)
        Channel map: 37, 38, 39 (0x07)
        Own address type: Public (0x00)
        Peer address type: Public (0x00)
        Peer address: 00:00:00:00:00:00 (OUI 00-00-00)
        Filter policy: Allow Scan Request from Any, Allow Connect Request from Any (0x00)
        TX power: Host has no preference (0x7f)
        Primary PHY: LE 1M (0x01)
        Secondary max skip: 0x00
        Secondary PHY: LE 1M (0x01)
        SID: 0x00
        Scan request notifications: Enabled (0x01)
> HCI Event: Command Complete (0x0e) plen 5                                                                                                                                        #391 [hci0] 2328.756594
      LE Set Extended Advertising Parameters (0x08|0x0036) ncmd 1
        Status: Success (0x00)
        TX power (selected): 12 dbm (0x0c)
bluetooth-lowenergy embedded-linux bluez
© www.soinside.com 2019 - 2024. All rights reserved.