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] Linux wifi-lan medium implementation #2983

Open
wants to merge 148 commits into
base: main
Choose a base branch
from

Conversation

kidfromjupiter
Copy link

@kidfromjupiter kidfromjupiter commented Oct 26, 2024

Summary

This PR adds desktop linux implementations for the wifi_lan medium using avahi. The real heroes behind this PR are @vibhavp and @proatgram who have already submitted a PR before. I do not claim credit for most of this code, but I will do my best to fix any bugs and maintain the linux implementation. I decided to make a seperate PR with wifi-lan medium only due to their PR being inactive for the past year. Another reason was that their initial PR was very large with a lot of components added, which might have made it hard to review. All I did was remove wifi_hotspot, wifi_direct, bluetooth_classic and ble. My plan is to create seperate PRs with all those mediums included.

As far as I can tell, all utility classes were referenced directly from the windows implementation. Some files were directly copied and some altered to fit the linux environment. So the bulk of this PR is either the same code in the windows implementation, or slightly altered versions of it

The following is extracted from the original PR

This PR adds an implementation geared towards Desktop Linux systems in internal/platform/implementation/linux. The motivation behind the code is to rely on widely available interfaces to implement mediums, and to use D-Bus as the primary transport for talking to system services. The code is broadly untested (and undocumented!), and is currently missing an implementation for the Bluetooth Low Energy medium, as I still haven't gotten around to understanding BlueZ's LE interfaces, parts of which are currently marked as experimental.
The implementation tries to rely on as few external libraries as possible, and as such, pulls in sdbus-c++, libsystemd, and libcurl via pkg-config rules added to WORKSPACE

Networking

  • The only supported backend right now is NetworkManager as its status as the de-facto network configuration service on Linux desktops.
  • Scanning for WiFi APs, creating hotspots, connecting to WiFi networks, and fetching networking and connectivity information is done through the NetworkManager D-Bus APIs.
    api::WifiLan uses the Avahi's D-Bus interfaces for performing service discovery and advertising.

api::DeviceInfo

  • Download and AppData paths are handled using the environment variables specified by the XDG Base Directory Spec.
  • Screen lock information and support for preventing device sleep is provided via org.freedesktop.login1 (implemented by systemd-logind).
  • Device type and name are looked up from org.freedesktop.hostname1 (implemented by systemd-hostnamed).

Miscellaneous

  • api::LogMessage: All LogMessages are sent to a glog LogSink that implements the org.freedesktop.LogControl1 D-Bus interface, to allow the log target and severity threshold to be externally controlled via the default bus connection (at the name com.google.nearby).
  • HTTP requests are executed using libcurl.

How did you test this change?

Wifi lan medium was tested using the walkietalkie example app that was in @vibhavp's walkietalkie branch. This app broke when the repo was updated to match upstream. It was already broken due to the original creator's own ble updates. I have since cherry picked working versions and it is available on my own walkietalkie branch

Sidenote

I'm learning cpp and bazel as I go so forgive me if I seem a little dense at times

proatgram and others added 30 commits May 18, 2023 13:33
The build directories should not be commited and definitly not pushed to
remote. This will prevent that from accidentally happening, and will
declutter `git status`
This is the start of the implementing for the Linux platform.

I aim to make this as similar to the Windows platform as possible,
although due to the fundamental difference in the two OS's, there will
be things that need to be different.
As such, I will be using the Windows platform files as a base, and
reimplementing the functions with Linux equivalents.

I am sure this will have bugs, which by my best attempt will be fixed
when found.
There was no free after we were finished with the interface pointer
There are a couple of places where apps can store data in Linux, one is
in the HOME directory, which is being phased out, the second, is in
HOME/.config, and the other is HOME/.local/share. This uses
HOME/.local/share, and since there isn't a common appdata path on Linux
that function will just return the local appdata path.
This adds a Linux equivalent to file path operations done in the Windows
headers and source files. Some differences that will occur are the
invalid path names and contents, as there are no invalid path names, and
only one invalid path content (excluding non-printable characters) on
Linux.
The `http_loader` class takes a `WebRequest` with information to send a
web request, and sends it. This uses `libcurl`, which is present from
installation on most major Linux distrobutions (e.g. Fedora, Ubuntu,
PopOS...).

If libcurl is not present on the target system, it will need to be
installed.
A file was named wrong. It was changed.
The Windows implementation of the Timer class (in timer.h) used Timer
Queues. This brings in implementation for a mostly Windows complient
TimerQueue class to work with the Timer class.
This are unimplemented currently, but will be in the future.
I missed some implementation when I was looking over them. These are
them.
vibhavp and others added 28 commits September 1, 2023 21:38
@proatgram
Copy link
Contributor

Amazing work. I am happy to see that this project is still being worked on in the Linux/UNIX space. I'm excited to test out the progress that has been achieved.

@kidfromjupiter kidfromjupiter changed the title Feature wifilan medium linux [Feature] Linux wifi-lan medium implementation Oct 26, 2024
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