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

[linux] Add WiFi support in ConnectivityManager. #1975

Merged
merged 3 commits into from
Aug 7, 2020
Merged

[linux] Add WiFi support in ConnectivityManager. #1975

merged 3 commits into from
Aug 7, 2020

Conversation

yufengwangca
Copy link
Contributor

Problem
The Linux device layer needs a ConnectivityMgr that handles a single, primary WiFi interface.

Summary of Changes

  • Add WiFi support to ConnectivityManager to manage wpa_supplicant using GDBus.

* Add WiFi support to ConnectivityManager to manage wpa_supplicant using GDBus.
* Restyled by whitespace
* Restyled by clang-format
Copy link
Contributor

@yunhanw-google yunhanw-google left a comment

Choose a reason for hiding this comment

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

you should not check-in those generated file, for example, DBusWpa.h. For different codegen version, the generated file are different

@yufengwangca
Copy link
Contributor Author

you should not check-in those generated file, for example, DBusWpa.h. For different codegen version, the generated file are different

This is used to fix the following compile issue from CI. (Did not see this error on local build)

2020-08-05T03:31:18.9931835Z In file included from ../../../../src/include/platform/ConnectivityManager.h:263,
2020-08-05T03:31:18.9932456Z from ../../../../src/include/platform/CHIPDeviceLayer.h:28,
2020-08-05T03:31:18.9932791Z from ../../../../src/lib/../../src/controller/CHIPDeviceController.cpp:35:
2020-08-05T03:31:18.9933109Z ../../../../src/platform/Linux/ConnectivityManagerImpl.h:43:10: fatal error: DBusWpa.h: No such file or directory
2020-08-05T03:31:18.9933399Z 43 | #include <DBusWpa.h>
2020-08-05T03:31:18.9933664Z | ^~~~~~~~~~~
2020-08-05T03:31:18.9933925Z compilation terminated.

The root cause is those header files need to be exist during compile phase not linking phase, that means any file which include header file <platform/CHIPDeviceLayer.h> need to see those DBus header files available before compile.

In theory, we should allow any source files within CHIP stack to include CHIPDeviceLayer.h, how to guarantee those DBus header files are pre-generated before any cpp/hpp file is processed since they are also generated during make phase?

For different codegen version, it should generate the same API prototypes, we need to update those files only when we update the corresponding xml file.

Unless we can make those DBus header files get generated in config phase instead of make phase, otherwise, checking in those auto-generated header files are the safest solution. I would rather use this simple solution to prevent all flaky build sequence errors.

mWpaSupplicant.state = GDBusWpaSupplicant::WPA_NOT_CONNECTED;
}

if (err != NULL)
Copy link
Contributor

Choose a reason for hiding this comment

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

Don't need to check for NULL here as g_error_free() already does.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I prefer always check NULL before calling all g_error_free() even it handles NULL case, this pattern is used throughout gio source code. Suppose there are 0.001 chance of error, then we can prevent 99.99% unnecessary function call.

}
else
{
if (err != NULL)
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggest removing this branch.

Can it really happen that |err| is null here?

If it can't happen,
assert(err);

If it can happen,
ChipLogProgress(DeviceLayer, "wpa_supplicant: failed to create wpa_supplicant1 interface proxy %s: %s",
mWpaSupplicant.interfacePath, err ? err->message : "unknown error");

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ack, in theory, err should never be NULL if iface is NULL, but lets not assume that.

{
mWpaSupplicant.iface = iface;
mWpaSupplicant.state = GDBusWpaSupplicant::WPA_INTERFACE_CONNECTED;
ChipLogProgress(DeviceLayer, "wpa_supplicant: connected to wpa_supplicant interface proxy: %p", iface);
Copy link
Contributor

Choose a reason for hiding this comment

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

Why log the pointer?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ack

}
else
{
if (err != NULL)
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggest removing this branch (see above)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ack

}
}

if (err != NULL)
Copy link
Contributor

Choose a reason for hiding this comment

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

Don't need this branch.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

see comments above

mWpaSupplicant.state = GDBusWpaSupplicant::WPA_GOT_INTERFACE_PATH;
ChipLogProgress(DeviceLayer, "wpa_supplicant: WiFi interface added: %s", mWpaSupplicant.interfacePath);

wpa_fi_w1_wpa_supplicant1_interface_proxy_new_for_bus(G_BUS_TYPE_SYSTEM, G_DBUS_PROXY_FLAGS_NONE, "fi.w1.wpa_supplicant1",
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we move the interface string to a constant?

namespace {
const char kWpaSupplicantInterface[] = "fi.w1.wpa_supplicant1";
}

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ack

}
else
{
if (err != NULL)
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggest removing this branch.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

See comment above

mWpaSupplicant.state = GDBusWpaSupplicant::WPA_NOT_CONNECTED;
}

if (err != NULL)
Copy link
Contributor

Choose a reason for hiding this comment

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

Don't need this branch.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

See comment above

@mspang
Copy link
Contributor

mspang commented Aug 6, 2020

you should not check-in those generated file, for example, DBusWpa.h. For different codegen version, the generated file are different

This is used to fix the following compile issue from CI. (Did not see this error on local build)

2020-08-05T03:31:18.9931835Z In file included from ../../../../src/include/platform/ConnectivityManager.h:263,
2020-08-05T03:31:18.9932456Z from ../../../../src/include/platform/CHIPDeviceLayer.h:28,
2020-08-05T03:31:18.9932791Z from ../../../../src/lib/../../src/controller/CHIPDeviceController.cpp:35:
2020-08-05T03:31:18.9933109Z ../../../../src/platform/Linux/ConnectivityManagerImpl.h:43:10: fatal error: DBusWpa.h: No such file or directory
2020-08-05T03:31:18.9933399Z 43 | #include <DBusWpa.h>
2020-08-05T03:31:18.9933664Z | ^~~~~~~~~~~
2020-08-05T03:31:18.9933925Z compilation terminated.

The root cause is those header files need to be exist during compile phase not linking phase, that means any file which include header file <platform/CHIPDeviceLayer.h> need to see those DBus header files available before compile.

In theory, we should allow any source files within CHIP stack to include CHIPDeviceLayer.h, how to guarantee those DBus header files are pre-generated before any cpp/hpp file is processed since they are also generated during make phase?

For different codegen version, it should generate the same API prototypes, we need to update those files only when we update the corresponding xml file.

Unless we can make those DBus header files get generated in config phase instead of make phase, otherwise, checking in those auto-generated header files are the safest solution. I would rather use this simple solution to prevent all flaky build sequence errors.

We're already generating CHIPVersion.h, maybe take a look at that? It shouldn't be flaky.

@yufengwangca
Copy link
Contributor Author

CHIPVersion.h

Yes, CHIPVersion.h is generated during config phase instead of make phase

@yufengwangca
Copy link
Contributor Author

yufengwangca commented Aug 7, 2020

After piloting, I found I am still not able to use the way to pre-generate CHIPVersion.h to generate GDBus header files. We use the following syntax to generate CHIPVersion.h during config phase.

include_HEADERS =
$(CHIP_CONFIG_INCLUDES)
CHIPVersion.h
$(NULL)

.PHONY: force
CHIPVersion.h: force

That means we force generate CHIPVersion.h for all targets. But we should generate GDBus headers file only if Linux device layer is selected and GIO package are installed & enabled on the host platform. This check is also done during config phase and the result is stored to variable CONFIG_WIFI_PLATFORM_WPA.

From the config log, I found the header file generating process is triggered before variable CONFIG_WIFI_PLATFORM_WPA gets assigned. So the GDBus header files are never get generated with the following syntax.

if CONFIG_WIFI_PLATFORM_WPA
include_HEADERS +=
DBusWpa.h
$(NULL)
endif

If I remove condition check "if CONFIG_WIFI_PLATFORM_WPA", then GDBus header files are pre-generated as expected, but I believe this behavior is not what we want since we mandate all target platforms handle those GDBus stuff.

It looks like checking in those auto-generate header files is still the only viable solution right now.

@mspang
Copy link
Contributor

mspang commented Aug 7, 2020

After piloting, I found I am still not able to use the way to pre-generate CHIPVersion.h to generate GDBus header files. We use the following syntax to generate CHIPVersion.h during config phase.

Ok, thanks for that info. It seems like we are running into either a limitation or a lack of expertise with the automake system.

@github-actions
Copy link

github-actions bot commented Aug 7, 2020

Size increase report for "nrf-example-build"

File Section File VM
Full report output
BLOAT REPORT

Files found only in the build output:
    report.csv

Comparing ./master_artifact/chip-nrf52840-lock-example.out and ./pull_artifact/chip-nrf52840-lock-example.out:

sections,vmsize,filesize


@github-actions
Copy link

github-actions bot commented Aug 7, 2020

Size increase report for "nrfconnect-example-build"

File Section File VM
Full report output
BLOAT REPORT

Files found only in the build output:
    report.csv

Comparing ./master_artifact/chip-nrf52840-lock-example.elf and ./pull_artifact/chip-nrf52840-lock-example.elf:

sections,vmsize,filesize


@github-actions
Copy link

github-actions bot commented Aug 7, 2020

Size increase report for "linux-example-build"

File Section File VM
Full report output
BLOAT REPORT

Files found only in the build output:
    report.csv

Comparing ./master_artifact/chip-standalone-demo.out and ./pull_artifact/chip-standalone-demo.out:

sections,vmsize,filesize
.debug_abbrev,0,16
.debug_info,0,4
[Unmapped],0,4


@github-actions
Copy link

github-actions bot commented Aug 7, 2020

Size increase report for "esp32-example-build"

File Section File VM
Full report output
BLOAT REPORT

Files found only in the build output:
    report.csv

Comparing ./master_artifact/chip-wifi-echo.elf and ./pull_artifact/chip-wifi-echo.elf:

sections,vmsize,filesize


@github-actions
Copy link

github-actions bot commented Aug 7, 2020

Size increase report for "gn_nrf-example-build"

File Section File VM
Full report output
BLOAT REPORT

Files found only in the build output:
    report.csv


@github-actions
Copy link

github-actions bot commented Aug 7, 2020

Size increase report for "gn_linux-example-build"

File Section File VM
Full report output
BLOAT REPORT

Files found only in the build output:
    report.csv


@andy31415 andy31415 merged commit 04aaf89 into project-chip:master Aug 7, 2020
@yufengwangca yufengwangca deleted the pr/linux/wifi branch August 7, 2020 15:09
chirag-silabs pushed a commit to rosahay-silabs/connectedhomeip that referenced this pull request Jul 15, 2024
Merge in WMN_TOOLS/matter from feature/slc_cli_updates to silabs_slc_1.3

Squashed commit of the following:

commit 49afede4bacfe0d0cb37026056e7028e3353d795
Author: Sarthak Shaha <[email protected]>
Date:   Thu Jun 13 23:52:40 2024 +0530

    updated zap to latest
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants