蓝牙设备不响应 LESetScanParameters 和 LESetScanEnable
Bluetooth device does not respond to LESetScanParameters and LESetScanEnable
作为 BLE 日志记录项目的一部分,我将 Arduino 设备(Adafruit Feather 32u4 Adalogger)与 BLE-Central-capable 蓝牙设备(RedBearLab BLEMini,使用 Texas Instruments CC2540 MCU)结合使用 Host-Controller-Interface (HCI) 直通固件。
总体思路是将设备设置为将 LE 广告数据包(作为 LE Advertising Repots)记录到 SD 卡中。设备应该 运行 24/7.
到目前为止,set-up 一直运行良好,直到 LESetScanParameters
,此时 BLEMini 从不响应 Arduino 上状态机发送的命令。对于应在此之后发送的 LESetScanEnable
命令实际上也是如此。蓝牙核心规范明确指出 LESetScanParameters (0x200b)
和 LESetScanEnable (0x200c)
命令都应引起 CommandComplete (0x0e)
事件作为响应,携带所述命令的 return 状态(请参阅蓝牙核心规范v4.2,第 861、977 和 980 页)。
为什么我没有收到回复?我错过了什么?非常感谢您在此问题上提供的任何帮助!
系统目前设计为状态机。
您可以在下面看到调试输出,其中 ->
表示状态转换(可能在冒号 :
后跟一条消息)。发送 (Send: [...]
) 和接收 (Receive: [...]
) 的原始 HCI 数据包总是以 varying-length header 开头(字节以冒号分隔 :
,以英镑 #
),然后是数据包 body。在每个 Await
状态接收到事件后,打印最重要的参数。
注意下面的调试输出状态 Await LESetScanParameters CommandComplete
以超时错误终止,表明数据包 header 不完整。事实上,如果您查看下面的行 (buffer [...]
),您会发现串行缓冲区中没有任何字节。即使我禁用超时(例如等待半小时),我也从未收到过回复。我还尝试发送格式错误的 LESetScanParameters
数据包,并省略命令 GapDeviceInit
、SetEventMask
和 LESetEventMask
,但这并没有改变任何东西。
我对 LESetScanParameters
命令的设置是:
scanType = PassiveScan (0x00)
scanInterval = 0x0010
scanWindow = 0x0010
addressType = PublicIdentityAddress (0x02)
filterPolicy = UndirectedAdsOnly (0x00)
我对 LESetScanEnable
的设置是:
scanEnable = true (0x01)
filterDuplicates = true (0x01)
调试输出(请注意,出于调试目的,状态机当前会在出现问题时转换为 Critical
而不是 Error
):
Uninitialized -> Serial setup
Serial setup -> Clock synchronisation
Clock synchronisation -> SD setup
SD setup -> Initialized
Initialized -> Dispatch GapDeviceInit
Send: 01:00:fe:26#0805000000000000000000000000000000000000000000000000000000000000000000000000
Dispatch GapDeviceInit -> Await GapDeviceInit HciExtCommandStatus
Receive: 04:ff:06#7f060000fe00
HciExtCommandStatus parameters: vendorEvent=0x067f, eventStatus=0x00, opcode=0xfe00
Await GapDeviceInit HciExtCommandStatus -> Await GapDeviceInitDone
Receive: 04:ff:2c#000600610a7b4c99b41b0004030000000000000000000000000000006c95ae6da27e123b450f5430f1bf13c7
GapDeviceInitDone parameters: eventStatus=0x00, ...
Await GapDeviceInitDone -> Dispatch SetEventMask
Send: 01:01:0c:08#0000000000000020
Dispatch SetEventMask -> Await SetEventMask CommandComplete
Receive: 04:0e:04#01010c00
CommandStatus parameters: numCommands=0x01, opcode=0x0c01, cmdStatus=0x00
Await SetEventMask CommandComplete -> Dispatch LESetEventMask
Send: 01:01:20:08#0200000000000000
Dispatch LESetEventMask -> Await LESetEventMask CommandComplete
Receive: 04:0e:04#01012000
CommandStatus parameters: numCommands=0x01, opcode=0x2001, cmdStatus=0x00
Await LESetEventMask CommandComplete -> Dispatch LESetScanParameters
Send: 01:0b:20:07#00100010000200
Dispatch LESetScanParameters -> Await LESetScanParameters CommandComplete
Await LESetScanParameters CommandComplete -> Critical: Timeout error (Last HCI message: Header incomplete)
Buffer contents discarded (numBytes=0x00):
可能是由于 RedBearLabs BLEMini 的硬件故障,我被迫将硬件切换到 Raspberry Pi3。该程序现在作为 systemd
服务运行。
作为 BLE 日志记录项目的一部分,我将 Arduino 设备(Adafruit Feather 32u4 Adalogger)与 BLE-Central-capable 蓝牙设备(RedBearLab BLEMini,使用 Texas Instruments CC2540 MCU)结合使用 Host-Controller-Interface (HCI) 直通固件。
总体思路是将设备设置为将 LE 广告数据包(作为 LE Advertising Repots)记录到 SD 卡中。设备应该 运行 24/7.
到目前为止,set-up 一直运行良好,直到 LESetScanParameters
,此时 BLEMini 从不响应 Arduino 上状态机发送的命令。对于应在此之后发送的 LESetScanEnable
命令实际上也是如此。蓝牙核心规范明确指出 LESetScanParameters (0x200b)
和 LESetScanEnable (0x200c)
命令都应引起 CommandComplete (0x0e)
事件作为响应,携带所述命令的 return 状态(请参阅蓝牙核心规范v4.2,第 861、977 和 980 页)。
为什么我没有收到回复?我错过了什么?非常感谢您在此问题上提供的任何帮助!
系统目前设计为状态机。
您可以在下面看到调试输出,其中 ->
表示状态转换(可能在冒号 :
后跟一条消息)。发送 (Send: [...]
) 和接收 (Receive: [...]
) 的原始 HCI 数据包总是以 varying-length header 开头(字节以冒号分隔 :
,以英镑 #
),然后是数据包 body。在每个 Await
状态接收到事件后,打印最重要的参数。
注意下面的调试输出状态 Await LESetScanParameters CommandComplete
以超时错误终止,表明数据包 header 不完整。事实上,如果您查看下面的行 (buffer [...]
),您会发现串行缓冲区中没有任何字节。即使我禁用超时(例如等待半小时),我也从未收到过回复。我还尝试发送格式错误的 LESetScanParameters
数据包,并省略命令 GapDeviceInit
、SetEventMask
和 LESetEventMask
,但这并没有改变任何东西。
我对 LESetScanParameters
命令的设置是:
scanType = PassiveScan (0x00)
scanInterval = 0x0010
scanWindow = 0x0010
addressType = PublicIdentityAddress (0x02)
filterPolicy = UndirectedAdsOnly (0x00)
我对 LESetScanEnable
的设置是:
scanEnable = true (0x01)
filterDuplicates = true (0x01)
调试输出(请注意,出于调试目的,状态机当前会在出现问题时转换为 Critical
而不是 Error
):
Uninitialized -> Serial setup
Serial setup -> Clock synchronisation
Clock synchronisation -> SD setup
SD setup -> Initialized
Initialized -> Dispatch GapDeviceInit
Send: 01:00:fe:26#0805000000000000000000000000000000000000000000000000000000000000000000000000
Dispatch GapDeviceInit -> Await GapDeviceInit HciExtCommandStatus
Receive: 04:ff:06#7f060000fe00
HciExtCommandStatus parameters: vendorEvent=0x067f, eventStatus=0x00, opcode=0xfe00
Await GapDeviceInit HciExtCommandStatus -> Await GapDeviceInitDone
Receive: 04:ff:2c#000600610a7b4c99b41b0004030000000000000000000000000000006c95ae6da27e123b450f5430f1bf13c7
GapDeviceInitDone parameters: eventStatus=0x00, ...
Await GapDeviceInitDone -> Dispatch SetEventMask
Send: 01:01:0c:08#0000000000000020
Dispatch SetEventMask -> Await SetEventMask CommandComplete
Receive: 04:0e:04#01010c00
CommandStatus parameters: numCommands=0x01, opcode=0x0c01, cmdStatus=0x00
Await SetEventMask CommandComplete -> Dispatch LESetEventMask
Send: 01:01:20:08#0200000000000000
Dispatch LESetEventMask -> Await LESetEventMask CommandComplete
Receive: 04:0e:04#01012000
CommandStatus parameters: numCommands=0x01, opcode=0x2001, cmdStatus=0x00
Await LESetEventMask CommandComplete -> Dispatch LESetScanParameters
Send: 01:0b:20:07#00100010000200
Dispatch LESetScanParameters -> Await LESetScanParameters CommandComplete
Await LESetScanParameters CommandComplete -> Critical: Timeout error (Last HCI message: Header incomplete)
Buffer contents discarded (numBytes=0x00):
可能是由于 RedBearLabs BLEMini 的硬件故障,我被迫将硬件切换到 Raspberry Pi3。该程序现在作为 systemd
服务运行。