Mar-18-2020, 08:53 AM
In C all my functions run in the main loop
void main(void) { Init(); while (1) { DoSomeStuff(); } }Now I see a Python example
def demo(): ble = bluetooth.BLE() central = BLETemperatureCentral(ble) not_found = False def on_scan(addr_type, addr, name): if addr_type is not None: print("Found sensor:", addr_type, addr, name) central.connect() else: nonlocal not_found not_found = True print("No sensor found.") central.scan(callback=on_scan) # Wait for connection... while not central.is_connected(): time.sleep_ms(100) if not_found: return print("Connected") # Explicitly issue reads, using "print" as the callback. while central.is_connected(): central.read(callback=print) time.sleep_ms(2000) # Alternative to the above, just show the most recently notified value. # while central.is_connected(): # print(central.value()) # time.sleep_ms(2000) print("Disconnected") if __name__ == "__main__": demo()demo() doesn't run constantly, does it?