<s> import atexit <EOL> import time <EOL> import Adafruit_BluefruitLE <EOL> from Adafruit_BluefruitLE . services import UART <EOL> ble = Adafruit_BluefruitLE . get_provider ( ) <EOL> def main ( ) : <EOL> ble . clear_cached_data ( ) <EOL> adapter = ble . get_default_adapter ( ) <EOL> adapter . power_on ( ) <EOL> print ( '<STR_LIT>' . format ( adapter . name ) ) <EOL> adapter . start_scan ( ) <EOL> atexit . register ( adapter . stop_scan ) <EOL> print ( '<STR_LIT>' ) <EOL> print ( '<STR_LIT>' ) <EOL> known_uarts = set ( ) <EOL> while True : <EOL> found = set ( UART . find_devices ( ) ) <EOL> new = found - known_uarts <EOL> for device in new : <EOL> print ( '<STR_LIT>' . format ( device . name , device . id ) ) <EOL> known_uarts . update ( new ) <EOL> time . sleep ( <NUM_LIT:1.0> ) <EOL> ble . initialize ( ) <EOL> ble . run_mainloop_with ( main ) </s>
