Skip to content

Conversation

jepenven-silabs
Copy link
Contributor

Summary

With Zephyr 4.2 some API were deprecated/updated. Update the necessary files so that everything works with the latest and greatest

Also make WPA_SUPPLICANT related functionality modular.

Related issues

None

Testing

We were able to successfully compile a Zephyr based sample app with theses changes without triggering any build failure using zephyr 4.2 upstream

@Copilot Copilot AI review requested due to automatic review settings September 11, 2025 14:13
@jepenven-silabs jepenven-silabs requested review from s07641069 and a team as code owners September 11, 2025 14:13
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR updates the Zephyr platform integration to support Zephyr 4.2, specifically addressing API changes and deprecations in the new version. The changes make WPA_SUPPLICANT functionality modular and adapt the codebase to handle version-specific API differences.

  • Updates event handler signatures to use uint64_t for Zephyr 4.2+ (previously uint32_t)
  • Makes WPA_SUPPLICANT related code conditional via configuration flags
  • Replaces deprecated BT_GATT_CCC_INITIALIZER with BT_GATT_CCC_MANAGED_USER_DATA_INIT for Bluetooth

Reviewed Changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.

File Description
src/platform/Zephyr/wifi/WiFiManager.h Adds version checks and conditional compilation for WPA_SUPPLICANT, updates event handler signatures
src/platform/Zephyr/wifi/WiFiManager.cpp Removes event handler map, adds inline switch statement for event handling, makes disconnect handling conditional
src/platform/Zephyr/BLEManagerImpl.cpp Updates Bluetooth GATT CCC initialization for Zephyr 4.2 compatibility

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request updates the Zephyr API usage to be compatible with version 4.2 and makes the WPA_SUPPLICANT functionality modular. The changes are well-structured and use conditional compilation to support multiple Zephyr versions and configurations.

I've found one critical issue related to a potential memory leak in the DisconnectHandler which should be addressed. Otherwise, the changes look good and align with the goals of the pull request.

Comment on lines 588 to 584
uint16_t reason = 0;
#ifdef CONFIG_WIFI_NM_WPA_SUPPLICANT
Platform::UniquePtr<uint8_t> safePtr(capturedData);
Copy link
Contributor

Choose a reason for hiding this comment

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

critical

There is a potential memory leak here. The safePtr which should take ownership of capturedData is created inside the #ifdef CONFIG_WIFI_NM_WPA_SUPPLICANT block. However, data.release() is called unconditionally later, transferring ownership to the lambda. If CONFIG_WIFI_NM_WPA_SUPPLICANT is not defined, no UniquePtr takes ownership of the raw pointer inside the lambda, leading to a memory leak.

To fix this, Platform::UniquePtr<uint8_t> safePtr(capturedData); should be moved outside and before the #ifdef block to ensure the memory is always managed correctly, regardless of the compilation flag.

        Platform::UniquePtr<uint8_t> safePtr(capturedData);
        uint16_t reason            = 0;
#ifdef CONFIG_WIFI_NM_WPA_SUPPLICANT

@jepenven-silabs jepenven-silabs marked this pull request as draft September 11, 2025 14:58
@jepenven-silabs
Copy link
Contributor Author

Converting to draft to figure out a way to handle disconnection even in the absence of WPA_SUPPLICANT feature of Zephyr.

@jepenven-silabs jepenven-silabs marked this pull request as ready for review September 11, 2025 15:50
Copy link

github-actions bot commented Sep 11, 2025

PR #40948: Size comparison from a82e43e to 2e5063e

Full report (35 builds for bl602, bl702, bl702l, cc13x4_26x4, cc32xx, efr32, esp32, nxp, psoc6, qpg, realtek, stm32, telink)
platform target config section a82e43e 2e5063e change % change
bl602 lighting-app bl602+mfd+littlefs+rpc FLASH 1104520 1104520 0 0.0
RAM 178970 178970 0 0.0
bl702 lighting-app bl702+eth FLASH 659090 659090 0 0.0
RAM 135025 135025 0 0.0
bl702+wifi FLASH 835158 835158 0 0.0
RAM 124509 124509 0 0.0
bl706+mfd+rpc+littlefs FLASH 1068168 1068168 0 0.0
RAM 117333 117333 0 0.0
bl702l contact-sensor-app bl702l+mfd+littlefs FLASH 898408 898408 0 0.0
RAM 105676 105676 0 0.0
lighting-app bl702l+mfd+littlefs FLASH 981320 981320 0 0.0
RAM 109828 109828 0 0.0
cc13x4_26x4 lighting-app LP_EM_CC1354P10_6 FLASH 768172 768172 0 0.0
RAM 103392 103392 0 0.0
lock-ftd LP_EM_CC1354P10_6 FLASH 779800 779800 0 0.0
RAM 108560 108560 0 0.0
pump-app LP_EM_CC1354P10_6 FLASH 725396 725396 0 0.0
RAM 96932 96932 0 0.0
pump-controller-app LP_EM_CC1354P10_6 FLASH 709888 709888 0 0.0
RAM 97140 97140 0 0.0
cc32xx air-purifier CC3235SF_LAUNCHXL FLASH 553162 553162 0 0.0
RAM 205168 205168 0 0.0
lock CC3235SF_LAUNCHXL FLASH 585854 585854 0 0.0
RAM 205400 205400 0 0.0
efr32 lock-app BRD4187C FLASH 959752 959752 0 0.0
RAM 126408 126408 0 0.0
BRD4338a FLASH 755176 755168 -8 -0.0
RAM 255732 255732 0 0.0
window-app BRD4187C FLASH 1053988 1053988 0 0.0
RAM 122604 122604 0 0.0
esp32 all-clusters-app c3devkit DRAM 102552 102552 0 0.0
FLASH 1775084 1775084 0 0.0
IRAM 83862 83862 0 0.0
nxp contact mcxw71+release FLASH 633264 633264 0 0.0
RAM 64204 64204 0 0.0
lock mcxw71+release FLASH 742392 742392 0 0.0
RAM 65240 65240 0 0.0
psoc6 all-clusters cy8ckit_062s2_43012 FLASH 1664660 1664660 0 0.0
RAM 211288 211288 0 0.0
all-clusters-minimal cy8ckit_062s2_43012 FLASH 1584644 1584644 0 0.0
RAM 208560 208560 0 0.0
light cy8ckit_062s2_43012 FLASH 1455108 1455108 0 0.0
RAM 197248 197248 0 0.0
lock cy8ckit_062s2_43012 FLASH 1487436 1487436 0 0.0
RAM 224968 224968 0 0.0
qpg lighting-app qpg6200+debug FLASH 831400 831400 0 0.0
RAM 127788 127788 0 0.0
lock-app qpg6200+debug FLASH 768452 768452 0 0.0
RAM 118748 118748 0 0.0
realtek light-switch-app rtl8777g FLASH 703608 703608 0 0.0
RAM 106660 106660 0 0.0
lighting-app rtl8777g FLASH 755368 755368 0 0.0
RAM 127040 127040 0 0.0
stm32 light STM32WB5MM-DK FLASH 467876 467876 0 0.0
RAM 141400 141400 0 0.0
telink bridge-app tl7218x FLASH 709726 709726 0 0.0
RAM 93468 93468 0 0.0
light-app-ota-compress-lzma-shell-factory-data tl3218x FLASH 798740 798740 0 0.0
RAM 44028 44028 0 0.0
light-app-ota-shell-factory-data tl7218x FLASH 789954 789954 0 0.0
RAM 100772 100772 0 0.0
light-switch-app-ota-compress-lzma-factory-data tl7218x_retention FLASH 716136 716136 0 0.0
RAM 54256 54256 0 0.0
light-switch-app-ota-compress-lzma-shell-factory-data tlsr9528a FLASH 749490 749490 0 0.0
RAM 77404 77404 0 0.0
light-switch-app-ota-factory-data tl3218x_retention FLASH 726282 726282 0 0.0
RAM 37004 37004 0 0.0
lighting-app-ota-factory-data tlsr9118bdk40d FLASH 606350 606350 0 0.0
RAM 112580 112580 0 0.0
lighting-app-ota-rpc-factory-data-4mb tlsr9518adk80d FLASH 822674 822678 4 0.0
RAM 99168 99168 0 0.0

Copy link

codecov bot commented Sep 11, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 50.92%. Comparing base (c30c1d4) to head (2e5063e).
⚠️ Report is 4 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master   #40948      +/-   ##
==========================================
+ Coverage   50.77%   50.92%   +0.15%     
==========================================
  Files        1361     1361              
  Lines       99850    99861      +11     
  Branches    12933    12917      -16     
==========================================
+ Hits        50695    50851     +156     
+ Misses      49155    49010     -145     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

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.

2 participants