Skip to content

Commit 2880bf1

Browse files
committed
Release for uasyncio V3. pb_link doc is out of date.
1 parent bde0d74 commit 2880bf1

13 files changed

+81
-14
lines changed

README.md

+16-8
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,7 @@ its associated RAM saving.
213213
This repository is a python package, consequently on the client the directory
214214
structure must be retained. The following installs all demos on the target.
215215

216-
Clone the repository after moving to a directory of your choice:
216+
On your PC move to a directory of your choice and clone the repository there:
217217
```
218218
git clone https://github.com/peterhinch/micropython-iot
219219
```
@@ -381,7 +381,7 @@ class App:
381381
async def start(self):
382382
await self.cl # Wait until client has connected to server
383383
asyncio.create_task(self.reader())
384-
asyncio.create_task(self.writer())
384+
await self.writer() # Wait forever
385385

386386
def state(self, state): # Callback for change in connection status
387387
print("Connection state:", state)
@@ -405,9 +405,14 @@ class App:
405405
def close(self):
406406
self.cl.close()
407407

408-
app = App(True)
408+
app = None
409+
async def main():
410+
global app # For closure by finally clause
411+
app = App(True)
412+
await app.start() # Wait forever
413+
409414
try:
410-
loop.run_forever()
415+
asyncio.run(main())
411416
finally:
412417
app.close() # Ensure proper shutdown e.g. on ctrl-C
413418
asyncio.new_event_loop()
@@ -489,7 +494,7 @@ awaiting incoming data.
489494

490495
When an application instantiates a `Client` it attemps to connect to WiFi and
491496
then to the server. Initial connection is handled by the following `Client`
492-
asynchronous bound methods:
497+
asynchronous bound methods (which may be modified by subclassing):
493498

494499
1. `bad_wifi` No args.
495500
2. `bad_server` No args. Awaited if server refuses an initial connection.
@@ -579,12 +584,15 @@ class App:
579584
await self.conn.write(json.dumps(self.data)) # May pause in event of outage
580585
await asyncio.sleep(5)
581586

582-
def run():
587+
async def main():
583588
clients = {1, 2, 3, 4}
584589
apps = [App(n) for n in clients] # Accept 4 clients with ID's 1-4
590+
await server.run(clients, True, local.PORT, local.TIMEOUT) # Verbose
591+
592+
def run():
585593
try:
586-
asyncio.run(server.run(clients, False, local.PORT, local.TIMEOUT))
587-
except KeyboardInterrupt: # Skip this if you want a traceback
594+
asyncio.run(main())
595+
except KeyboardInterrupt: # Delete this if you want a traceback
588596
print('Interrupted')
589597
finally:
590598
server.Connection.close_all()

esp_link/.rshell-ignore

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
README.md
2+
LICENSE
3+
docs
4+
private
5+
__pycache__
6+

iot/.rshell-ignore

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
README.md
2+
LICENSE
3+
docs
4+
private
5+
__pycache__
6+

iot/client.mpy

13 Bytes
Binary file not shown.

iot/examples/.rshell-ignore

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
README.md
2+
LICENSE
3+
docs
4+
private
5+
__pycache__
6+

iot/examples/c_app.py

+7-2
Original file line numberDiff line numberDiff line change
@@ -71,9 +71,14 @@ async def writer(self):
7171
def shutdown(self):
7272
self.cl.close() # Shuts down WDT (but not on Pyboard D).
7373

74-
app = App(verbose=True)
74+
app = None
75+
async def main():
76+
global app # For finally clause
77+
app = App(verbose=True)
78+
await app.start()
79+
7580
try:
76-
asyncio.run(app.start())
81+
asyncio.run(main())
7782
finally:
7883
app.shutdown()
7984
asyncio.new_event_loop()

iot/primitives/.rshell-ignore

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
README.md
2+
LICENSE
3+
docs
4+
private
5+
__pycache__
6+

iot/qos/.rshell-ignore

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
README.md
2+
LICENSE
3+
docs
4+
private
5+
__pycache__
6+

iot/qos/c_qos.py

+7-2
Original file line numberDiff line numberDiff line change
@@ -85,9 +85,14 @@ def close(self):
8585
self.cl.close()
8686

8787

88-
app = App(True)
88+
app = None
89+
async def main():
90+
global app # For finally clause
91+
app = App(verbose=True)
92+
await app.start()
93+
8994
try:
90-
asyncio.run(app.start())
95+
asyncio.run(main())
9196
finally:
9297
app.close()
9398
asyncio.new_event_loop()

iot/qos/c_qos_fast.py

+7-2
Original file line numberDiff line numberDiff line change
@@ -86,9 +86,14 @@ def close(self):
8686
self.cl.close()
8787

8888

89-
app = App(True)
89+
app = None
90+
async def main():
91+
global app # For finally clause
92+
app = App(verbose=True)
93+
await app.start()
94+
9095
try:
91-
asyncio.run(app.start())
96+
asyncio.run(main())
9297
finally:
9398
app.close()
9499
asyncio.new_event_loop()

iot/remote/.rshell-ignore

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
README.md
2+
LICENSE
3+
docs
4+
private
5+
__pycache__
6+

pb_link/.rshell-ignore

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
README.md
2+
LICENSE
3+
docs
4+
private
5+
__pycache__
6+

pb_link/README.md

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# WARNING: This doc is out of date and under review
2+
13
# 0. IOT design for clients lacking a LAN interface
24

35
This uses an ESP8266 to provide a resilient "socket-like" link between a non

0 commit comments

Comments
 (0)