May-20-2020, 02:47 PM
Hello,
I'm a beginner , and up until now I did some simple code.
now I want to go up a level :-)
I want to run an application on my PI that scan bluetooth
I found this code
it's working but I want to improve it and to read the RSSI and the name also ? how do I do this ?
also want to understand something
this line
what does this line mean
and finnaly - if I want to code to run the scan for 10 seconds only once every 1 min
what I need to add?
Thanks ,
I'm a beginner , and up until now I did some simple code.
now I want to go up a level :-)
I want to run an application on my PI that scan bluetooth
I found this code
import pexpect
child = pexpect.spawn("bluetoothctl")
child.send("scan on\n")
bdaddrs = []
try:
print("Scan Begin")
while True:
child.expect("Device (([0-9A-Fa-f]{2}:){5}([0-9A-Fa-f]{2})) ",timeout=None)
bdaddr = child.match.group(1)
if bdaddr not in bdaddrs:
bdaddrs.append(bdaddr)
print(bdaddr)
except KeyboardInterrupt:
child.close()
results.close() it's working but I want to improve it and to read the RSSI and the name also ? how do I do this ?
also want to understand something
this line
child.expect.....mean that the code is expecting the following (whats in the bracket , right?)
what does this line mean
child.match.group(1)mean?
and finnaly - if I want to code to run the scan for 10 seconds only once every 1 min
what I need to add?
Thanks ,
