mqtt_udp
mqtt_udp copied to clipboard
Feature request: micropython implementation
Bug or feature
Feature: port code base to "new platform" / "specific python language implementation"
What is wrong / not implemented
Consider micropython implementation
How should it be
mqtt_udp should be ported to MicroPython / Circuitpython (supported by adafruit) / BBC micro:bit MicroPython is strong platform and micro:bit is used in school computer education in the UK. it is running on multiple boards e.g esp8266 / esp32 / stm series, linux port is available
more details about supported boards https://github.com/micropython/micropython/wiki/Boards-Summary
From my side I could provide testing on bare-metal
I was thinking about trying nodemcu with python, and it looks like a good idea. Can you, please, try current python3 code on some micropython device and tell me where is the most obvious problem?
(Just a reference for me on working with micropython)
https://m.habr.com/ru/post/345912/
https://m.habr.com/ru/post/341716/
https://github.com/chrisroedig/nodemcu_python
I've tied to run random_to_udp.py example on my esp8266.
results and actions
- I've got 'no module named 'struct' ' - replaced with import ustruct as struct.
- no module named 'Enum' replaced with simple class Enum: pass. just to proceed further.
I've ended up with module hashlib
, as some official modules exists in separate repo and could be used by need. but in existing module ,md5 is not implemented only sha224/256/384/512 listed.
Thanx. It seems that for the first try we need to strip off digital signature.
Some details on above I've stripped off digital signature and ended in function __make_send_socket(): File "engine.py", line 469, in __make_send_socket AttributeError: 'module' object has no attribute 'SO_BROADCAST' esp8266/esp32 Sockets implementation using modlwip. Is anything could be done at mqtt_udp side related to above?
Just try to remove corresponding code line (option set). It is possible that underlying IP stack does not need it.
I've removed it: Linux port of micropython / python3 reported "OSError: [Errno 13] EACCES" / "PermissionError: [Errno 13] Permission denied." esp8266 acting without an errror by listen.py does not observe any traffic.
Can you, please, publish your current code on github for me to take a look? Possibly, best way is to fork this repo, add lang/upython
dir and put it there?
Here is it: https://github.com/mdef/mqtt_udp/tree/master/lang/micropython/examples to test it, copy required py files to board. compile engine.py (python -m mpy_cross engine.py) into mpy and copy too. run from repl: import random_to_udp.py
Thanx. I'm trying but no success yet. "MemoryError: memory allocation failed, allocating 72 bytes" on engine import :(
And it is not a mem problem, as I see:
gc.mem_free()
gc.mem_free()
19200
>>>
import mqttudp
import mqttudp
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "mqttudp/__init__.py", line 3, in <module>
MemoryError: memory allocation failed, allocating 72 bytes
>>>
gc.mem_free()
gc.mem_free()
18880
The memory is a main isssue in your case.
To succeed you have to follow my instructions:
compile engine.py (python -m mpy_cross engine.py) into engine.mpy
and copy it to the board, at folder mqttudp should be engine.mpy but not engine.py