如何检查仍然与 Delphi 10.3 连接的 BLE 设备
How to check a BLE device still connected with Delphi 10.3
我已成功将我的 Delphi(FM) 应用程序连接到 ESP32 设备,我可以通过 BLE 发送 commands/receive 数据(连接 [= 后我显示连接状态消息18=]).但问题是,如果用户 close/power 关闭 ESP32 设备,则移动应用程序仍会显示已建立连接。
我用 TTimer 都试过 System.Bluetooth.TBluetoothConnectionState and 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;
使用蓝牙设备(TBluetoothLEDevice)的OnDisconnect事件
我已成功将我的 Delphi(FM) 应用程序连接到 ESP32 设备,我可以通过 BLE 发送 commands/receive 数据(连接 [= 后我显示连接状态消息18=]).但问题是,如果用户 close/power 关闭 ESP32 设备,则移动应用程序仍会显示已建立连接。
我用 TTimer 都试过 System.Bluetooth.TBluetoothConnectionState and 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;
使用蓝牙设备(TBluetoothLEDevice)的OnDisconnect事件