i have connected a bluetooth controller to control a rover.
i am able to ping the controller using sudo l2ping 84:30:95:06:C6:6C
on the terminal.
basically i want to execute certain code when ping is not available. i.e., when controller is disconnected.
i tried this:
import bluetooth
while True:
if bluetooth.lookup_name('84:30:95:06:C6:6C'):
print("do nothing")
else:
print("do something")
but this has bit of delay, it takes around 2-3 seconds to give me the output when the controller is disconnected. is there any other way of doing this in python ?