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
mean that the code is expecting the following (whats in the bracket , right?)
what does this line mean
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
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 |
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
1 |
child.expect..... |
what does this line mean
1 |
child.match.group( 1 ) |
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 ,