| seeedfarming: fix the python scripts ports - brcon2025-hackathons - Bitreichcon… | |
| git clone git://bitreich.org/brcon2025-hackathons git://enlrupgkhuxnvlhsf6lc3fz… | |
| Log | |
| Files | |
| Refs | |
| Tags | |
| --- | |
| commit 8a8676661a7b1c437b1c080f7d196aac413756b4 | |
| parent cf8fffb39e892e8458e279bd69f81f484b05452d | |
| Author: Josuah Demangeon <[email protected]> | |
| Date: Fri, 1 Aug 2025 21:21:56 +0200 | |
| seeedfarming: fix the python scripts ports | |
| Diffstat: | |
| M seeedfarming/example.py | 25 +++++++++++++++++-------- | |
| M seeedfarming/windowshell.py | 11 ++++++++--- | |
| 2 files changed, 25 insertions(+), 11 deletions(-) | |
| --- | |
| diff --git a/seeedfarming/example.py b/seeedfarming/example.py | |
| @@ -10,11 +10,13 @@ import socket | |
| wlan = network.WLAN() | |
| wlan.active(True) | |
| -print(wlan.scan()) | |
| +wlan.scan() | |
| wlan.connect('seeeder', 'seeedrooots') | |
| while not wlan.isconnected(): | |
| - print('.', end='') | |
| + print('.', end='') | |
| + | |
| +print(' connected') | |
| myip = wlan.ipconfig('addr4')[0] | |
| print(myip) | |
| @@ -22,12 +24,19 @@ print(myip) | |
| # To access internet services: | |
| # https://docs.micropython.org/en/latest/library/socket.html | |
| -s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) | |
| -s.bind((myip, 70)) | |
| -s.listen(9) | |
| +bindport = 70 | |
| +maxconn = 100 | |
| +myport = 7000 + int(myip.split('.')[3]) | |
| +myserver = 'bitreich.org' | |
| -conn, addr = s.accept() | |
| +s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) | |
| +s.bind((myip, bindport)) | |
| +s.listen(maxconn) | |
| -print('Connected with ' + addr[0] + ':' + str(addr[1])) | |
| +print("available at gopher://%s:%u/0/" % (myserver, myport)) | |
| -conn.write('hello world!\n') | |
| +while True: | |
| + conn, addr = s.accept() | |
| + conn.write("hello world!\r\n") | |
| + conn.write(".\r\n") | |
| + conn.close() | |
| diff --git a/seeedfarming/windowshell.py b/seeedfarming/windowshell.py | |
| @@ -20,12 +20,16 @@ print(' connected') | |
| myip = wlan.ipconfig('addr4')[0] | |
| print(myip) | |
| -myport = 70 | |
| +bindport = 70 | |
| +maxconn = 100 | |
| +myport = 7000 + int(myip.split('.')[3]) | |
| myserver = 'bitreich.org' | |
| s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) | |
| -s.bind((myip, myport)) | |
| -s.listen(9) | |
| +s.bind((myip, bindport)) | |
| +s.listen(maxconn) | |
| + | |
| +print("available at gopher://%s:%u/1/" % (myserver, myport)) | |
| def gopher_info(conn, line): | |
| line = line.replace("\t", " ") | |
| @@ -58,3 +62,4 @@ while True: | |
| for number in range(0, 9): | |
| gopher_link(conn, selector, str(number)) | |
| conn.write(".\r\n".encode()) | |
| + conn.close() |