【问题标题】:How to check a BLE device still connected with Delphi 10.3如何检查仍然与 Delphi 10.3 连接的 BLE 设备
【发布时间】:2019-12-15 11:38:10
【问题描述】:

我已成功将我的 Delphi(FM) 应用程序连接到 ESP32 设备,并且可以通过 BLE 发送命令/接收数据(连接成功/不成功后,我会显示连接状态消息)。但问题是,如果用户关闭/关闭 ESP32 设备,那么移动应用程序仍然显示连接已建立。

我用 TTimer 尝试了 System.Bluetooth.TBluetoothConnectionStateSystem.Bluetooth.TBluetoothLEManager.ConnectionState,但没有成功。

if not (BLEDevice1.ConnectionState = TBluetoothConnectionState.Connected) then
  begin
  Showmessge('Connection not established!');
  // this type of control doesn't change anything.
  end;

【问题讨论】:

  • BLEDevice1.OnDisconnect 事件?
  • @DaveNottage 感谢您的评论,我之前尝试过但它不起作用,因为问题是我没有等到 OnDisconnect 事件触发(这需要太长时间)。等待一段时间后,消息已显示。唯一的问题是这个控制大约在 10-15 秒内完成。但似乎正确的答案是你的建议。所以请您将其添加为答案..

标签: delphi bluetooth bluetooth-lowenergy firemonkey


【解决方案1】:

使用蓝牙设备(TBluetoothLEDevice)的OnDisconnect事件

【讨论】:

    猜你喜欢
    • 2012-10-14
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-10-18
    • 1970-01-01
    • 1970-01-01
    • 2019-09-29
    • 1970-01-01
    相关资源
    最近更新 更多