danni / uwebsockets

Micropython websockets implementation
MIT License
192 stars 44 forks source link

ESP32 support #7

Open yanoom opened 5 years ago

yanoom commented 5 years ago

Hi, I'm looking for a socket.io client for ESP32.

How complicated would it be to adapt this project to ESP32? (estimations regarding what's there to do...)

=) thanks

danni commented 5 years ago

I don't actually know what the difference is between ESP32 and ESP8266. I haven't done much work in micropython lately. In general this entire codebase could probably do with updating to be consistent with the most recent versions of micropython, in terms of using asyncio, etc.

carterw commented 5 years ago

There isn't any difference between the Python API for networking on the ESP32 and the ESP8266 far as I can tell.

socket.io, on the other hand, is a layer of protocol that sits on top of websockets and it requires code on both the client and the server side. In principle someone who knows what they are doing could get a Python socket.io client running over this websocket implementation on an ESP32.

yanoom commented 5 years ago

Thanks for your answers!

@carterw - I will try to use this socket.on on websockets for ESP8266 on my ESP32...

Do you have recommendation for the easiest way to start a testing-server, to test my client? So far I'm going with this: Python socket.io wsgi server

=)

danni commented 5 years ago

Thanks Carter. I did write a socket.io implementations years ago. Tested against Python and the node reference implementation.

Again the code is nearly 2 years old and I haven’t been keeping it up to date, so I don’t know how well it works against latest uPython. Send PRs :)

carterw commented 5 years ago

I use node.js for everything on the server side (JavaScript on the server). I did successfully experiment with this socket.io package, it includes a JavaScript client that you can pull in to a browser app. It works. They communicate and you can send messages back and forth between browser app and server that trigger events on both sides.

If it were me, and seeing as how I have a working example on both ends, I would look at the JavaScript client code and try to port it to MicroPython as a first attempt. If you are seeing a good socket.io Python client that works with a server implementation and you can make it run, that might be a better place to start.

carterw commented 5 years ago

Thanks Carter. I did write a socket.io implementations years ago. Tested against Python and the node reference implementation.

Sounds very useful. The ESP32 devices don't have a lot of memory and I have found that it is hard to cram network infrastructure in there and still have enough room to run significant application code. I have some event-driven client code that runs on a modified version of your repository here and had to be careful to make it all fit.

step21 commented 5 years ago

Thanks Carter. I did write a socket.io implementations years ago. Tested against Python and the node reference implementation.

Sounds very useful. The ESP32 devices don't have a lot of memory and I have found that it is hard to cram network infrastructure in there and still have enough room to run significant application code. I have some event-driven client code that runs on a modified version of your repository here and had to be careful to make it all fit.

You could try to get one of those modules with extra PSRAM. On the other hand if you are doing everything with javascript, I heard there was now embedded js for esp too.

carterw commented 5 years ago

There are modules available with more memory for sure, but I am resisting moving to them because they are larger and more expensive. What I do now is make pared-down custom firmware for specific application use cases rather than attempt to have a large general-purpose image.