【发布时间】:2019-12-15 11:38:10
【问题描述】:
我已成功将我的 Delphi(FM) 应用程序连接到 ESP32 设备,并且可以通过 BLE 发送命令/接收数据(连接成功/不成功后,我会显示连接状态消息)。但问题是,如果用户关闭/关闭 ESP32 设备,那么移动应用程序仍然显示连接已建立。
我用 TTimer 尝试了 System.Bluetooth.TBluetoothConnectionState 和 System.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