0

Is there any method to check that connection lost with connected device in python bluez library ?

Navneet Garg
  • 1,364
  • 12
  • 29

1 Answers1

0

Either you can directly check the "Connected" property for the device as per below command. Probably you need to use the according python GDBUS method call programmatically.

dbus-send --system --print-reply --type=method_call --dest=org.bluez /org/bluez/hci0/dev_44_D8_84_02_A3_17 org.freedesktop.DBus.Properties.Get string:"org.bluez.Device1" string:"Connected"

One other best option is to watch for the "PropertiesChanged" signal with below configurations,

Interface: org.freedesktop.DBus.Properties
Object Path: /org/bluez/hci0/dev_44_D8_84_02_A3_17
Signal : PropertiesChanged
Method: g_dbus_connection_signal_subscribe <<== with function pointer in callback mode

which enables the notification when the device is disconnected and you may have the async handling in callback function.

Parthiban
  • 2,130
  • 2
  • 14
  • 27