Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ROADMAP] IoT Gateway #37

Open
Jozott00 opened this issue Mar 4, 2024 · 2 comments
Open

[ROADMAP] IoT Gateway #37

Jozott00 opened this issue Mar 4, 2024 · 2 comments
Labels
enhancement New feature or request roadmap Feature on the roadmap

Comments

@Jozott00
Copy link
Owner

Jozott00 commented Mar 4, 2024

The VS Code extension includes a bundled version of the Wokwi Private IoT Gateway, which allows to connect the virtual WiFi of the simulated ESP32 to your local network and the Internet.

IoT Gateway - Wokwi Docs

@Jozott00 Jozott00 added enhancement New feature or request roadmap Feature on the roadmap labels Mar 4, 2024
@ahilbig
Copy link

ahilbig commented Jan 7, 2025

Hi @Jozott00 ,

very nice, thanks for your work!
Are you or is anybody else working on this feature? I would be very interested - also in contribution, but currently I have no clue how + where to start.. BR.. Andreas

@Jozott00
Copy link
Owner Author

Jozott00 commented Jan 15, 2025

Hello @ahilbig, thank you!
Sorry for the late reply, I've been pretty busy lately. Unfortunately, I currently don't have the time to work on the feature. However, I’m happy to review a PR if you want to work on it.

To get you started here are a couple of hints:

  • simulator/WokwiSimulator.kt is the heart of the simulation logic
  • It communicates with the Wokwi web app and reacts on command received in the messageReceived method.
  • in this method you will see that the commands wifiFrame and wifiConnect are not yet implemented
  • if the plugin receives the wifiConnect from wokwi, you would have to start the wokwi gateway and turn on a callback that sends the data back to wokwi (with the json {command: 'wifiFrame', frame: <data buffer from gateway> }) if the plugin gets any data from the gateway.
  • if the plugin receives wifiFrame from wokwi, the received json will also contain a frame field. You must then send this frame to the wokwi gateway.

This is essentially the whole communication with Wokwi itself.

The tricky part is to start and communicate with the gateway.
The Wokwi Gateway is open source and the vscode plugin bundles it as webassembly. This allows it to directly execute it as well as hooking into the runtime without having to install anything.

Now I think the easiest way of getting started is

  1. implement the wifiConnect and wifiFrame with some WokwiGateway class that handles connection to the actual gateway (initially just mock the actual gateway).
  2. Try to implement the WokwiGateway class in a way such that you can communicate with the WokwiGW binary via TCP. At this point the feature is somewhat implemented.
  3. However, we would like to distribute the gateway with the plugin. The wokwi vscode plugin does this by bundling the gateway as web assembly. It also hooks into the web assembly runtime and therefore does not need to communicate with it via TCP. Unfortunately, I think they are using a closed source version of the gateway for this. However, the gateway is pretty straight forward, so we could also just write our own in our WokwiGateway class. This would probably be the best solution here.

Hope you’re interested in contributing to this project!
If you have any questions, I am happy to help.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request roadmap Feature on the roadmap
Projects
None yet
Development

No branches or pull requests

2 participants