ESP32 + uPython + uaiohttpclient
Updated 2022-12-01: Let go this rough uaiohttpclient since it’s kind too simple (just GET, no POST, and lacking almost anything needed) to be integrated to something really useful. So currently I’m using someone’s own stuff (async mod on urequests) that works – from the REPO HERE.
This is a basic test around the async http client of micropython, which is NOT built-in with the official uPy image on download page of offcial site. Anyway it can be easily installed thru the upip – make sure you have sufficient free RAM before the installation though, otherwise it could fail.
1 2 3 4 5 6 7 8 9 10 11 12 13 |
WebREPL connected >>> import gc >>> import upip >>> upip.install("micropython-uaiohttpclient") Installing to: /lib/ Warning: micropython.org SSL certificate is not validated Installing micropython-uaiohttpclient 0.5.1 from https://micropython.org/pi/uaiohttpclient/uaiohttpclient-0.5.1.tar.gz >>>utils.free() '61.11%' >>>gc.collect() >>>utils.free() '93.75%' |
I somehow guess that the reason it’s not included in standard build might be… the asyncio is not quite common among the uPy developers? So people can use the built-in urequests instead.
Well I’m not an async – await Python guy on Mac/Linux either (since we’ve an powerful O/S anyway), but here I consider it might be the only method, AFAIK, to make my ESP32 nodeMCU work with kinda multi-tasking with uPy, non-preemptive, though. If not, then I’m about to be left with no choice and head back to the C stuff (with a traditional RTOS), right?
文章的脚注信息由WordPress的wp-posturl插件自动生成
完整阅读本篇»