WebSocket: https://de.wikipedia.org/wiki/WebSocket https://github.com/Links2004/arduinoWebSockets https://github.com/cnlohr/colorchord http://www.whatimade.today/esp8266-on-websockets-mdns-ota-and-leds/ http://www.whatimade.today/realtime-graphs-using-ploty-and-websockets/ https://github.com/uWebSockets/uWebSockets http://code.charitha.org/2016/06/writing-esp8266-based-fire-alarm-plugin.html https://libwebsockets.org/ https://github.com/acooks/jittertrap http://www.cnx-software.com/2012/11/29/soc-power-measurement-with-arm-energy-probes-and-linux-eap-tools/ aepd daemon git.linaro.org/tools/arm-probe.git ----- https://github.com/niccolli/FakeScope https://flotr2.codeplex.com/ http://jsdatav.is/chap01.html http://www.flotcharts.org/ ----- http://smoothiecharts.org/tutorial.html https://github.com/joewalnes/smoothie/ https://joewalnes.com/2010/08/10/introducing-smoothie-charts/ https://github.com/leopd/hookbox/blob/master/examples/python_scope/index.html https://developer.mbed.org/cookbook/Internet-of-Things-Demonstration ----- https://websockets.readthedocs.io/en/stable/ ----- index.html {{ <!DOCTYPE html> <html> <head> <meta charset="utf-8" /> <title>WebSocket Test</title> <script language="javascript" type="text/javascript"> // https://developer.mozilla.org/en-US/docs/Web/API/WebSockets_API/Writing_WebSocket_client_applications var wsUri = "wss://echo.websocket.org/"; // "ws://..." var output; function init() { output = document.getElementById("output"); testWebSocket(); } function testWebSocket() { // Create new WebSocket websocket = new WebSocket(wsUri); // Attach listeners websocket.onopen = function(evt) { onOpen(evt) }; websocket.onclose = function(evt) { onClose(evt) }; websocket.onmessage = function(evt) { onMessage(evt) }; websocket.onerror = function(evt) { onError(evt) }; } function onOpen(evt) { writeToScreen("CONNECTED"); doSend("WebSocket rocks"); } function onClose(evt) { writeToScreen("DISCONNECTED"); } function onMessage(evt) { writeToScreen('<span style="color: blue;">RESPONSE: ' + evt.data + '</span>'); // Close WebSocket websocket.close(); } function onError(evt) { writeToScreen('<span style="color: red;">ERROR:</span> ' + evt.data); } function doSend(message) { writeToScreen("SENT: " + message); // Send data... websocket.send(message); } function writeToScreen(message) { var pre = document.createElement("p"); pre.style.wordWrap = "break-word"; pre.innerHTML = message; output.appendChild(pre); } window.addEventListener("load", init, false); </script> </head> <body> <h2>WebSocket Test</h2> <button id="btn1" onclick="doSend(123)">Click me.</button> <div id="output"></div> </body> </html> }} server.py {{ #!/usr/bin/env python import asyncio import datetime import random import websockets #async def echo(websocket, path): # async for message in websocket: # await websocket.send(message) async def consumer_handler(websocket, path): async for message in websocket: await websocket.send(message) async def producer_handler(websocket, path): while True: # message = await producer() # await websocket.send(message) now = datetime.datetime.utcnow().isoformat() + "Z" await websocket.send(now) await asyncio.sleep(random.random() * 3) async def echo(websocket, path): consumer_task = asyncio.ensure_future( consumer_handler(websocket, path)) producer_task = asyncio.ensure_future( producer_handler(websocket, path)) done, pending = await asyncio.wait( [consumer_task, producer_task], return_when=asyncio.FIRST_COMPLETED, ) for task in pending: task.cancel() start_server = websockets.serve(echo, "localhost", 8765) asyncio.get_event_loop().run_until_complete(start_server) asyncio.get_event_loop().run_forever() }}