Skip to content
프로젝트

소개

MicroPython 웹소켓 구현

기타 프로젝트

이 수치를 측정하는 방법

측정된 스타 증가

in 24h
+1
in 7 days
0
in 15 days
0
in 1 month
기록 수집 중

서로 겹치는 기간의 순증가량이며 일별 합계가 아닙니다. 측정값이 없으면 비워 둡니다. 스타는 관심도를 나타내며 품질을 보장하지 않습니다.

README.md

Original

Micropython websockets (esp8266 implementation)

An implementation of websockets for the ESP8266 (client only ATM). This is a work in progress, some of which might move into the modwebsocket C module that's built into micropython, however that's incomplete, and the handshaking isn't standard-compliant.

There's no asyncio on the esp8266 (today) but I'd like to build something that looks for all intents and purposes like a asyncio Protocol using the socket receive handler it does have.

"Screenshot"

$ pip install adafruit-ampy
$ ampy mkdir uwebsockets
$ ampy put uwebsockets/protocol.py uwebsockets/protocol.py
$ ampy put uwebsockets/client.py uwebsockets/client.py
$ ampy run example/client.py
> esp8266 1.5.4(baaeaebb) v1.8.3-80-g1f61fe0-dirty on 2016-08-31 ESP module with ESP8266
< Hello esp8266 1.5.4(baaeaebb) v1.8.3-80-g1f61fe0-dirty on 2016-08-31 ESP module with ESP8266!
$ pip install websockets
$ python example/server.py
Connection from ('192.168.1.11', 1883)
< esp8266 1.5.4(baaeaebb) v1.8.3-80-g1f61fe0-dirty on 2016-08-31 ESP module with ESP8266
> Hello esp8266 1.5.4(baaeaebb) v1.8.3-80-g1f61fe0-dirty on 2016-08-31 ESP module with ESP8266!

Minimal example client against 'ws://echo.websocket.org/'

$ webrepl_client.py 192.168.3.1
Password: 

WebREPL connected
>>> 
>>> 
MicroPython v1.9.4-272-g46091b8a on 2018-07-18; ESP module with ESP8266
Type "help()" for more information.
>>> import echo_websocket_org
The quick brown fox jumps over the lazy dog

>>> 
### closed ###
$ 
$ cat echo_websocket_org.py 
import uwebsockets.client
websocket = uwebsockets.client.connect("ws://echo.websocket.org/")
mesg = "The quick brown fox jumps over the lazy dog"
websocket.send(mesg + "\r\n")
resp = websocket.recv()
print(resp)
assert(mesg + "\r\n" == resp)
$ 

Micropython Socket.io

An implementation of socket.io and engine.io for the ESP8266 (client only ATM). This is a work in progress and has only been tested against Flask-SocketIO.

There's no asyncio on the esp8266 (today) but I'd like to build something that looks for all intents and purposes like the socket.io web API. At the moment this means its own event loop + lots of timeouts.

An interesting example client is this OpsGenie bridge.

Compatibility

You might need to bake this code into your firmware to use it. You also need to bake in the logging module. Finally to run the unix port you need to patch your micropython to support socket.settimeout.

관련 프로젝트 살펴보기

불러오는 중…