Skip to content

Instantly share code, notes, and snippets.

@anoken
Last active November 30, 2021 02:04
Show Gist options
  • Save anoken/1b94cb2334f65f761f23b854df72f032 to your computer and use it in GitHub Desktop.
Save anoken/1b94cb2334f65f761f23b854df72f032 to your computer and use it in GitHub Desktop.
UI Flow http post dump
Test Code
------
import wifiCfg
import urequests
import gc
import micropython
micropython.mem_info()
print('Initial free: {} allocated: {}'.format(gc.mem_free(), gc.mem_alloc()))
wifiCfg.autoConnect()
print('Initial free: {} allocated: {}'.format(gc.mem_free(), gc.mem_alloc()))
req = urequests.request(method='POST', url='https://notify-api.line.me/api/notify',json=(str('message=hogehoge')), headers={'Authorization':'Bearer my_line_notify_token','Content-Type':'application/x-www-form-urlencoded'})
print(req.text)
print(req.status_code)
print('Initial free: {} allocated: {}'.format(gc.mem_free(), gc.mem_alloc()))
micropython.mem_info()
================
Line Notify Try with UI FLow
Arduino is follow
https://github.com/anoken/purin_wo_mamoru_gijutsu/blob/master/3-1_LINE_Notify_sendmessage/3-1_LINE_Notify_sendmessage.ino
V1.4.5.1 -> OSError: [Errno 12] ENOMEM
======================================
>>> import wifiCfg
>>> import urequests
>>> import gc
>>> import micropython
>>> micropython.mem_info()
stack: 736 out of 15360
GC: total: 86016, used: 24384, free: 61632
No. of 1-blocks: 594, 2-blocks: 88, max blk sz: 109, max free sz: 3848
>>> print('Initial free: {} allocated: {}'.format(gc.mem_free(), gc.mem_alloc()))
Initial free: 61392 allocated: 24624
>>> wifiCfg.autoConnect()
True
>>> print('Initial free: {} allocated: {}'.format(gc.mem_free(), gc.mem_alloc()))
Initial free: 60928 allocated: 25088
>>> req = urequests.request(method='POST', url='https://notify-api.line.me/api/notify',json=(str('message=hogehoge')), headers={'Authorization':'Bearer XXXXXXXXXXXXXXXXXXXXXXXXXXXXX','Content-Type':'application/x-www-form-urlencoded'})
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "flowlib/lib/urequests.py", line 105, in request
File "flowlib/lib/urequests.py", line 60, in request
OSError: [Errno 12] ENOMEM
>>> print(req.text)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
NameError: name 'req' isn't defined
>>> print(req.status_code)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
NameError: name 'req' isn't defined
>>> print('Initial free: {} allocated: {}'.format(gc.mem_free(), gc.mem_alloc()))
Initial free: 57136 allocated: 28880
>>> micropython.mem_info()
stack: 736 out of 15360
GC: total: 86016, used: 29104, free: 56912
No. of 1-blocks: 669, 2-blocks: 102, max blk sz: 109, max free sz: 3527
V1.5.2 -> OK
======================================
>>> import wifiCfg
I (15313) system_api: Base MAC address is not set, read default base MAC address from BLK0 of EFUSE
I (15313) system_api: Base MAC address is not set, read default base MAC address from BLK0 of EFUSE
>>> import urequests
I (15351) modsocket: Initializing
>>> import gc
>>> import micropython
>>> micropython.mem_info()
stack: 720 out of 15360
GC: total: 96000, used: 18160, free: 77840
No. of 1-blocks: 419, 2-blocks: 56, max blk sz: 30, max free sz: 4854
>>> print('Initial free: {} allocated: {}'.format(gc.mem_free(), gc.mem_alloc()))
Initial free: 77568 allocated: 18432
>>> wifiCfg.autoConnect(lcdShow = False)
I (15591) phy: phy_version: 4180, cb3948e, Sep 12 2019, 16:39:13, 0, 0
I (17387) network: CONNECTED
I (18762) network: GOT_IP
0
>>> print('Initial free: {} allocated: {}'.format(gc.mem_free(), gc.mem_alloc()))
Initial free: 78208 allocated: 17792
>>> req = urequests.request(method='POST', url='https://notify-api.line.me/api/notify',json=(str('message=hogehoge')), headers={'Authorization':'Bearer my_line_notify_token','Content-Type':'application/x-www-form-urlencoded'})
>>> print(req.text)
{"status":200,"message":"ok"}
>>> print(req.status_code)
200
>>> print('Initial free: {} allocated: {}'.format(gc.mem_free(), gc.mem_alloc()))
Initial free: 74496 allocated: 21504
>>> micropython.mem_info()
stack: 720 out of 15360
GC: total: 96000, used: 21728, free: 74272
No. of 1-blocks: 440, 2-blocks: 65, max blk sz: 109, max free sz: 4631
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment