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

raylib/ui: Wi-Fi manager #34364

Draft
wants to merge 14 commits into
base: master
Choose a base branch
from
Draft

Conversation

deanlee
Copy link
Contributor

@deanlee deanlee commented Jan 12, 2025

A demonstration of a Wi-Fi manager implemented using raygui and nmcli. This is an initial draft version designed to showcase the core functionality. . The features have been mostly completed, with the exception of advanced network-related operations

File Descriptions:
1. nmcli_backend.cc: Contains the backend logic for Wi-Fi management, interfacing with the system’s nmcli commands to handle network operations.
2. wifi_manager.cc: A reusable widget for managing Wi-Fi networks using raygui. This widget can be easily embedded into other raylib windows (UI, setup, etc.) by calling WifiManager::render(Rectangle), which allows it to be placed within a specified rectangle on the screen for flexible UI integration.
3. main.cc: A demo application that uses the Wi-Fi manager to display available networks and connect/forgot to them. This serves as an example of how to integrate the Wi-Fi manager widget.

This is an early draft intended for demonstration purposes. Future improvements could include error handling, enhanced styling, background threading, and additional features to further enhance both functionality and user experience.

Screenshot:

Screenshot from 2025-01-13 23-18-26

TODO:

  1. Add software keyboard input dialog.
  2. Implement message box for notifications.
  3. Enable mouse drag scrolling.
  4. Display a signal strength icon for networks.
  5. Make check_output non-blocking with select().

@deanlee deanlee force-pushed the raylib_wifi_manager branch 5 times, most recently from 95ed4f8 to ee0f0c8 Compare January 12, 2025 14:56
@adeebshihadeh
Copy link
Contributor

adeebshihadeh commented Jan 12, 2025

Can you make a PR to add raygui and we can merge that first? Done

I love how short this is! The only thing we'll have to be careful about here is not blocking the UI.

@deanlee deanlee force-pushed the raylib_wifi_manager branch from 8d2c826 to a7237fb Compare January 13, 2025 02:31
@deanlee
Copy link
Contributor Author

deanlee commented Jan 13, 2025

@maxime-desroches Do you have any idea why _TextToFloat might not be getting linked properly on macOS ? It’s causing an "Undefined symbols" error related to GuiValueBoxFloat in raygui.h.

@deanlee deanlee force-pushed the raylib_wifi_manager branch 9 times, most recently from 5d58c04 to bfaf503 Compare January 14, 2025 03:42
@deanlee deanlee changed the title raylib/ui: demo Wi-Fi manager implementation using raygui and nmcli raylib/ui: Wi-Fi manager Jan 14, 2025
@deanlee deanlee force-pushed the raylib_wifi_manager branch 4 times, most recently from 136111b to 3846500 Compare January 14, 2025 09:44
@deanlee deanlee force-pushed the raylib_wifi_manager branch from 3846500 to 1c74d8e Compare January 14, 2025 10:31

bool forget(const std::string& ssid) {
std::string command = "nmcli connection delete id '" + ssid + "'";
return system(command.c_str()) == 0;
Copy link
Contributor

Choose a reason for hiding this comment

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

how quick is this? I worry that it'll still block the UI thread for too long

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It depends, may takes 3-5 seconds on 3X. However, since forget is called asynchronously in the wifiManager class, it won’t block the UI.

The main issue occurs when using nmcli device wifi connect. If the password is incorrect, nmcli blocks and waits for NetworkManager to trigger a graphical password prompt from the default front-end (e.g., nm-applet) or another external application managing network connections:

G0xq0

To prevent this takeover, we may need to use dbus or sd_dbus to interact directly with NetworkManager, avoiding external applications being notified to prompt for the password. This would allow us to handle password authentication programmatically, ensuring our app retains full control.

I'll close this PR until the issue is resolved.

Copy link
Contributor

@adeebshihadeh adeebshihadeh Jan 15, 2025

Choose a reason for hiding this comment

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

I think we want to make any CLI commands async... I worry it'll block even for durations like 0.1s. We want to make sure the new UI runs comfortably at 60+ fps

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The UI already calls functions in the WiFi namespace asynchronously, so the CLI commands won’t block the main thread.

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.

2 participants