kopia lustrzana https://github.com/micropython/micropython-lib
aioble/examples/temp_client.py: Check connection before reading temp.
Only read from the temp characteristic if the connection is still active. Improves the example by avoiding a TypeError exception if/when the sensor disconnects.pull/496/head
rodzic
da46c4b9f7
commit
f0b683218e
|
@ -55,7 +55,7 @@ async def main():
|
|||
print("Timeout discovering services/characteristics")
|
||||
return
|
||||
|
||||
while True:
|
||||
while connection.is_connected():
|
||||
temp_deg_c = _decode_temperature(await temp_characteristic.read())
|
||||
print("Temperature: {:.2f}".format(temp_deg_c))
|
||||
await asyncio.sleep_ms(1000)
|
||||
|
|
Ładowanie…
Reference in New Issue