P2P remote REPL across internet (WebRTC) #15329
Replies: 4 comments 2 replies
-
I'd never heard of WebRTC however a quick search suggests it's aimed at "real-time audio, video streaming and video conferencing applications". Regardless, in terms of communicating directly with a device, at work I regularly use a design pattern where we use stm32 configured with two CDC serial ports. The first is normal repl, the second is treated like a fake socket. On device I use a simple wrapper function to pass this serial port stream to microdot so we can make http requests directly over this serial port. On the PC side, custom apps either use a similarly wrapped python http library to make requests over the serial port rather than opening new sockets, or we can run a simple script that proxies the serial port to a local socket to then use a web browser or any other app. There's some slight complexities in terms of needing a lock on the PC side so that only one request can run at a time but it works surprisingly well! Because it's a single stream however, there's no way to keep a second persistent connection open like a websocket. ... Alternatively, LWIP does have support for PPP so it should be possible to get this running now on devices, even without a native network interface (#12872) which then might make it easier to get PPP running over the USB/serial to get a "real" network connection. That would mean using a modem driver of the host to configure the connection however. Either way, if you can get a real network connection then protocols like WebRTC or websockets should just work. |
Beta Was this translation helpful? Give feedback.
-
WebRTC allows direct connection between ViperIDE and the bridge app, over the internet. Currently it requires a bridge app that converts Serial to WebRTC |
Beta Was this translation helpful? Give feedback.
-
After some testing, i figured out that WebRTC is rather cumbersome, and I'll probably need to run a TURN server to make it working reliably. Given that getting WebRTC running on the board directly requires significant additional efforts, I'll focus on a different approach:
Basically this is the same as I'll probably do some prototyping for this in the following weeks. Will keep you posted 😎 |
Beta Was this translation helpful? Give feedback.
-
The initial version of a remote Secure WebSocket Relay connection is now available for public testing: |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
While working on Web based MicroPython IDE, I came across this idea of using WebRTC to create a remote connection to the device.
It was rather easy to create a proof of concept. It works like this:
Demo: https://viper-ide.org/bridge.html
Also, this raises an interesting question:
What if MicroPython could run the WebRTC client directly?
This is different from WebREPL because enables connection from anywhere. Alternatively I can run a WebSocket relay server, and modify WebREPL to act as a Client instead of Server.
If anyone has experience with this and would like to participate - you're welcome!
Beta Was this translation helpful? Give feedback.
All reactions