1

I'm using terminal bluetooth client to scan for BLE devices. When I encounter a device by name 'Ac2', I would like to stop searching (stop Popen and continue in my code) and read the particular line in which the device was encountered, for extracting it's MAC address.

I'm using hcitool to scan (following line of code)

child = subprocess.Popen(['sudo', '/usr/local/bin/hcitool', 'lescan'], stdout = subprocess.PIPE)

Now how do I check whether device 'Ac2' has been found or not? And how do I read the line where it was found?

  • Why do you specify an *incomplete* path to `hcitool`? Ideally and most probably `/usr/local/bin` is in your `PATH` already, and if it isn't, you should just add it there. – tripleee Jan 10 '18 at 10:13
  • https://stackoverflow.com/questions/803265/getting-realtime-output-using-subprocess might be a better and more to the point solution instead of the duplicate I proposed above. – tripleee Jan 10 '18 at 10:19
  • Yes, you mention that in the question already. Did you examine whether the duplicates I proposed would help you solve your problem? – tripleee Jan 10 '18 at 11:28

0 Answers0