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

Feature/socket keyboard #18

Merged
merged 18 commits into from
Jun 14, 2022
Merged

Feature/socket keyboard #18

merged 18 commits into from
Jun 14, 2022

Conversation

georgik
Copy link
Owner

@georgik georgik commented Jun 3, 2022

Add support for keyboard via tcp socket

@georgik
Copy link
Owner Author

georgik commented Jun 3, 2022

The implementation requires 3 threads:

  • emulator thread
  • server socket thread for accepting new connection
  • client handler thread to process data from client

How it works:

  • emulator connects to WiFi configured in cfg.toml and opens port 80
  • client can connect from computer by Netcat: nc IP-addr 80
  • client can send keystokes like 10p"Hello"ENTER which is translated to 10 PRINT "Hello"ENTER
  • keystrokes from client handler thread is passed via std::sync::mpsc::{channel, Sender, Receiver}; to emulator thread, this seems to be very reliable even when consumer is very slow like in this case
  • note: Netcat sends data only on Enter key, if you need to send data earlier just press CTRL+D to flush the buffer

This is initial sketch and it's in working state. For merge it would be beneficial to mark the network dependent part as separate feature which can user enabled during the build.

@georgik
Copy link
Owner Author

georgik commented Jun 10, 2022

Few notes from refactoring

@georgik
Copy link
Owner Author

georgik commented Jun 10, 2022

@SergioGasquez @MabezDev @bjoernQ @jessebraham Please review the code.
This change introduces tcpstream_keboard which allows to pass keystrokes via open TCP Socket using Netcat.
There are some challenges discovered during refactoring mentioned above.

wifi.set_configuration(&Configuration::Client(ClientConfiguration {
ssid: app_config.wifi_ssid.into(),
password: app_config.wifi_psk.into(),
auth_method: AuthMethod::None,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does using AuthMethod::None work on WPA2 networks? Maybe we could do some checks like in Ferrous System's repo

@bjoernQ
Copy link

bjoernQ commented Jun 14, 2022

when reference to WiFi goes out of scope, the WiFi is automatically disconnected

I think it's a sane decision in esp-idf-svc to shut down WiFi when it gets dropped

@georgik georgik merged commit 62cb799 into main Jun 14, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants