-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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
[NXP] Add --wifipaf commission in chip-tool and apps of Linux platform #33977
base: master
Are you sure you want to change the base?
Conversation
crlonxp
commented
Jun 18, 2024
•
edited
Loading
edited
Co-authored-by: Boris Zbarsky <bzbarsky@apple.com>
Co-authored-by: Boris Zbarsky <bzbarsky@apple.com>
Co-authored-by: Karsten Sperling <113487422+ksperling-apple@users.noreply.github.com>
* Change the name of option to [pair_mode]-[network] * Remove redundant compile flags * Move to start the Wi-Fi Manager in initialization stage * Unconditional the defintion * Add the cancel-publish / cancel-subscribe dbus interface * Fix bugs: - Redundant callback function registration - Remove the incorrect StackLock Signed-off-by: Lo,Chin-Ran <chin-ran.lo@nxp.com>
- Unconditional functions in SetUpCodePairer - Change the description of the comment Signed-off-by: Lo,Chin-Ran <chin-ran.lo@nxp.com>
* Unconditional the SetupCode verification Signed-off-by: Lo,Chin-Ran <chin-ran.lo@nxp.com>
Signed-off-by: Lo,Chin-Ran <chin-ran.lo@nxp.com>
example: - Linux DUT: sudo ./chip-all-clusters-app --wifi --wifipaf - Controller: sudo ./chip-tool pairing code-wifi 1 ap_ssid ap_pwd MT:-24J0SGJ10KA0648G00 Signed-off-by: Lo,Chin-Ran <chin-ran.lo@nxp.com>
Co-authored-by: Boris Zbarsky <bzbarsky@apple.com>
Co-authored-by: Boris Zbarsky <bzbarsky@apple.com>
Co-authored-by: Boris Zbarsky <bzbarsky@apple.com>
* Add to end of the queue in OnDiscoveredDeviceOverWifiPAF() * Factor out the long expression into local Signed-off-by: Lo,Chin-Ran <chin-ran.lo@nxp.com>
Signed-off-by: Lo,Chin-Ran <chin-ran.lo@nxp.com>
…allback function Signed-off-by: Lo,Chin-Ran <chin-ran.lo@nxp.com>
PR #33977: Size comparison from 05e4c10 to c4e090e Increases above 0.2%:
Full report (54 builds for bl602, bl702, bl702l, cc13x4_26x4, cc32xx, cyw30739, efr32, esp32, linux, mbed, nrfconnect, nxp, psoc6, qpg, stm32, tizen)
|
Signed-off-by: Lo,Chin-Ran <chin-ran.lo@nxp.com>
PR #33977: Size comparison from 05e4c10 to ea75eeb Increases above 0.2%:
Full report (85 builds for bl602, bl702, bl702l, cc13x4_26x4, cc32xx, cyw30739, efr32, esp32, linux, mbed, nrfconnect, nxp, psoc6, qpg, stm32, telink, tizen)
|
…a_supplicant Signed-off-by: Lo,Chin-Ran <chin-ran.lo@nxp.com>
@@ -90,6 +93,10 @@ using namespace chip::Encoding; | |||
#if CHIP_DEVICE_CONFIG_ENABLE_COMMISSIONER_DISCOVERY | |||
using namespace chip::Protocols::UserDirectedCommissioning; | |||
#endif // CHIP_DEVICE_CONFIG_ENABLE_COMMISSIONER_DISCOVERY | |||
#if CHIP_DEVICE_CONFIG_ENABLE_WIFIPAF | |||
static std::shared_ptr<DeviceCommissioner> DevCommPtr; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't understand how this is supposed to work. Per C++ spec:
If the object pointed to by ptr is already owned, the function generally results in undefined behavior.
and that's the scenario here, no? There are non-shared-ptr bits that will happily delete that object out from under you.
Maybe the intent was that you then reset the static shared_ptr when you get deleted? That would at least kind of work in that a properly created weak_ptr from that shared_ptr (which is also not happening here) would get notified when the shared_ptr gets reset, I think. But:
- That's not happening here.
- You can't use a static because multiple DeviceCommissioner instances might be trying to commission things at once, no?
} | ||
DevCommPtr.reset(this, custom_del); | ||
mRendezvousParametersForDeviceDiscoveredOverWiFiPAF = params; | ||
DeviceLayer::ConnectivityMgr().WiFiPAFConnect(params.GetSetupDiscriminator().value(), (void *) (&(DevCommPtr)), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK, so this passes a pointer to the shared_ptr
as the void*, right?
#if CHIP_DEVICE_CONFIG_ENABLE_WIFIPAF | ||
void DeviceCommissioner::OnWiFiPAFSubscribeComplete(void * appState) | ||
{ | ||
std::weak_ptr<DeviceCommissioner> * caller = (std::weak_ptr<DeviceCommissioner> *) (appState); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But this is casting the pointer we passed (to shared_ptr) to a weak_ptr?
I don't understand how this works.
@@ -243,6 +253,39 @@ CHIP_ERROR SetUpCodePairer::StopConnectOverSoftAP() | |||
return CHIP_NO_ERROR; | |||
} | |||
|
|||
#if CHIP_DEVICE_CONFIG_ENABLE_WIFIPAF | |||
static std::shared_ptr<SetUpCodePairer> SetUpCodeParserPtr; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Again, I don't think this works. SetUpCodePairer lifetime is not managed via the shared ptr....
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just to repeat for the Nth time: this needs tests. Not manual things that got run. Just fix the file in the tests
directory under here to test these bits.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you are saying to add the tests in setup_payload/tests/TestQRCode.cpp, right?
I add more tests in the last commit. Please review. Thank you
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, that is much better, thank you, except for the missing checks.
* Add more tests in QRCode test Signed-off-by: Lo,Chin-Ran <chin-ran.lo@nxp.com>
bool mWiFiPAF = false; | ||
const char * mWiFiPafExtCmds = nullptr; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why the inconsistent capitalization?
|
||
inPayload.rendezvousInformation.SetValue(RendezvousInformationFlags( | ||
RendezvousInformationFlag::kWiFiPAF, RendezvousInformationFlag::kSoftAP, RendezvousInformationFlag::kOnNetwork)); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't there be a EXPECT_TRUE(CheckWriteRead(inPayload))
here? Otherwise, the next line will just reset things and this is not tested...
|
||
inPayload.rendezvousInformation.SetValue(RendezvousInformationFlags( | ||
RendezvousInformationFlag::kWiFiPAF, RendezvousInformationFlag::kBLE, RendezvousInformationFlag::kOnNetwork)); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Again, should have EXPECT_TRUE(CheckWriteRead(inPayload))
.