蓝牙设备不响应LESetScanParameters和LESetScanEnable

作为BLE记录项目的一部分,我将Arduino设备(Adafruit Feather 32u4 Adalogger)与具有BLE中央功能的蓝牙设备(RedBearLab BLEMini,使用Texas Instruments CC2540 MCU)和主机控制器接口(HCI)结合使用直通固件。

通常的想法是将设备设置为将LE广告数据包(作为LE广告资源)记录到SD卡。设备应运行24/7。

到目前为止,设置工作良好,直到LESetScanParametersBLEMini从未响应Arduino上状态机发送的命令为止实际上,对于LESetScanEnable紧随其后发送命令也是如此蓝牙核心规范特别指出,LESetScanParameters (0x200b)LESetScanEnable (0x200c)命令都应引起CommandComplete (0x0e)事件,并带有所述命令的返回状态(请参阅蓝牙核心规范v4.2,第861、977和980页)。

为什么我没有得到回应?我想念什么?非常感谢您在此问题上的任何帮助!

该系统当前被设计为状态机。

您可以在下面看到调试输出,其中->表示状态转换(可能在冒号之后显示一条消息:)。发送(Send: [...])和接收(Receive: [...]的原始HCI数据包始终以变长报头(以冒号分隔的字节:,以磅结尾的字节#)开头,后跟数据包主体。在每种Await状态下接收到事件后,将打印最重要的参数。

请注意,在下面的调试输出中,状态Await LESetScanParameters CommandComplete以超时错误终止,指出数据包头不完整。实际上,如果您查看(buffer [...]下方的行,则会发现串行缓冲区中没有字节。即使我禁用超时(例如等待半小时),我也永远不会收到响应。我也试着发送畸形LESetScanParameters数据包,并留下了命令GapDeviceInitSetEventMask并且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服务使用。

本文收集自互联网,转载请注明来源。

如有侵权,请联系[email protected] 删除。

编辑于
0

我来说两句

0条评论
登录后参与评论

相关文章