Skip to content

Proximity Ranging server and example app implementation#43768

Open
s-mcclain wants to merge 9 commits intoproject-chip:masterfrom
s-mcclain:proximity-ranging-server-impl
Open

Proximity Ranging server and example app implementation#43768
s-mcclain wants to merge 9 commits intoproject-chip:masterfrom
s-mcclain:proximity-ranging-server-impl

Conversation

@s-mcclain
Copy link
Copy Markdown
Contributor

Summary

Adds the code-driven Proximity Ranging cluster server implementation and a Linux example application (proximity-ranger-app).

The cluster follows the combined DefaultServerCluster pattern with an application-owned Instance for registration.
Commands (StartRangingRequest, StopRangingRequest) are handled synchronously by the driver. Async events (measurement data, unsolicited session stops) flow back through a narrow ProximityRangingDriver::Callback interface,
keeping the driver decoupled from the cluster class.

The example app demonstrates the controller/adapter architecture: DefaultProximityRangingDriver ->
RangingTechnologyController -> per-technology RangingTechnologyAdapter implementations (platform adapters not yet
included).

This PR
is stacked on #43525 (cluster XML definition and ZAP generation).

Related issues

N/A

Testing

  • Verified Linux build compiles successfully (proximity-ranger-app target)
  • Unit tests not yet implemented (tracked as future work in README)

Readability checklist

The checklist below will help the reviewer finish PR review in time and keep the
code readable:

See: [Pull Request Guidelines](https://project-chip.github.io/connectedhomeip-doc/contributing/pull_request_
guidelines.html)

Copy link
Copy Markdown
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 implements the Proximity Ranging cluster server, including core logic, a driver interface, and a Linux example application. The review identified several critical issues in session management where synchronous callbacks could lead to leaked or "zombie" sessions. Key recommendations include registering sessions before invoking external drivers, implementing collision detection for session ID generation, and ensuring event emission is guarded by successful session removal to prevent re-entrancy issues.

Comment thread src/app/clusters/proximity-ranging-server/ProximityRangingCluster.cpp Outdated
Comment thread src/app/clusters/proximity-ranging-server/ProximityRangingCluster.h Outdated
Comment thread src/app/clusters/proximity-ranging-server/ProximityRangingCluster.cpp Outdated
@s-mcclain s-mcclain marked this pull request as draft March 31, 2026 22:40
@s-mcclain s-mcclain marked this pull request as ready for review March 31, 2026 23:59
@s-mcclain
Copy link
Copy Markdown
Contributor Author

/gemini review

Copy link
Copy Markdown
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 introduces the Proximity Ranging cluster (0x0433), including the server implementation, driver interfaces, and integration into the Linux example application. The implementation follows the code-driven cluster pattern and supports features like Wi-Fi USD, Bluetooth Channel Sounding, and BLE Beacon RSSI. Feedback is provided regarding the use of a more appropriate error code when registering duplicate technology adapters.

@github-actions
Copy link
Copy Markdown

github-actions Bot commented Apr 1, 2026

PR #43768: Size comparison from a27c039 to 27df0d4

Full report (10 builds for cc13x4_26x4, cc32xx, nrfconnect, realtek, stm32)
platform target config section a27c039 27df0d4 change % change
cc13x4_26x4 lighting-app LP_EM_CC1354P10_6 FLASH 775864 775880 16 0.0
RAM 103396 103396 0 0.0
lock-ftd LP_EM_CC1354P10_6 FLASH 788068 788084 16 0.0
RAM 108588 108588 0 0.0
pump-app LP_EM_CC1354P10_6 FLASH 734392 734408 16 0.0
RAM 97396 97396 0 0.0
pump-controller-app LP_EM_CC1354P10_6 FLASH 717812 717828 16 0.0
RAM 97556 97556 0 0.0
cc32xx air-purifier CC3235SF_LAUNCHXL FLASH 559874 559874 0 0.0
RAM 204568 204568 0 0.0
lock CC3235SF_LAUNCHXL FLASH 592742 592742 0 0.0
RAM 204816 204816 0 0.0
nrfconnect all-clusters-app nrf52840dk_nrf52840 FLASH 860440 860440 0 0.0
RAM 162094 162094 0 0.0
realtek light-switch-app rtl8777g FLASH 676960 676976 16 0.0
RAM 101516 101516 0 0.0
lighting-app rtl8777g FLASH 724504 724520 16 0.0
RAM 101956 101956 0 0.0
stm32 light STM32WB5MM-DK FLASH 475428 475444 16 0.0
RAM 141388 141388 0 0.0

@s-mcclain s-mcclain force-pushed the proximity-ranging-server-impl branch from 27df0d4 to 18f3bd1 Compare April 13, 2026 21:10
@github-actions
Copy link
Copy Markdown

github-actions Bot commented Apr 13, 2026

PR #43768: Size comparison from 5d5eb0c to 18f3bd1

Full report (6 builds for cc32xx, nrfconnect, realtek, stm32)
platform target config section 5d5eb0c 18f3bd1 change % change
cc32xx air-purifier CC3235SF_LAUNCHXL FLASH 560842 560842 0 0.0
RAM 204608 204608 0 0.0
lock CC3235SF_LAUNCHXL FLASH 592730 592730 0 0.0
RAM 204816 204816 0 0.0
nrfconnect all-clusters-app nrf52840dk_nrf52840 FLASH 863452 863452 0 0.0
RAM 162170 162170 0 0.0
realtek light-switch-app rtl8777g FLASH 680880 680880 0 0.0
RAM 101600 101600 0 0.0
lighting-app rtl8777g FLASH 724816 724816 0 0.0
RAM 101956 101956 0 0.0
stm32 light STM32WB5MM-DK FLASH 475468 475468 0 0.0
RAM 141396 141396 0 0.0

@github-actions
Copy link
Copy Markdown

github-actions Bot commented Apr 16, 2026

PR #43768: Size comparison from e09871c to 5fcfde1

Full report (9 builds for cc13x4_26x4, cc32xx, realtek, stm32)
platform target config section e09871c 5fcfde1 change % change
cc13x4_26x4 lighting-app LP_EM_CC1354P10_6 FLASH 775960 775960 0 0.0
RAM 103420 103420 0 0.0
lock-ftd LP_EM_CC1354P10_6 FLASH 788204 788204 0 0.0
RAM 108604 108604 0 0.0
pump-app LP_EM_CC1354P10_6 FLASH 735596 735596 0 0.0
RAM 97444 97444 0 0.0
pump-controller-app LP_EM_CC1354P10_6 FLASH 717980 717980 0 0.0
RAM 97572 97572 0 0.0
cc32xx air-purifier CC3235SF_LAUNCHXL FLASH 560954 560954 0 0.0
RAM 204616 204616 0 0.0
lock CC3235SF_LAUNCHXL FLASH 592858 592858 0 0.0
RAM 204824 204824 0 0.0
realtek light-switch-app rtl8777g FLASH 681104 681104 0 0.0
RAM 101632 101632 0 0.0
lighting-app rtl8777g FLASH 724904 724904 0 0.0
RAM 101964 101964 0 0.0
stm32 light STM32WB5MM-DK FLASH 475548 475548 0 0.0
RAM 141412 141412 0 0.0

@s-mcclain s-mcclain force-pushed the proximity-ranging-server-impl branch from 5fcfde1 to cf073ba Compare April 21, 2026 20:44
@s-mcclain s-mcclain requested a review from a team as a code owner April 21, 2026 20:44
@s-mcclain s-mcclain force-pushed the proximity-ranging-server-impl branch from f79017a to 4045bf0 Compare April 21, 2026 21:26
@github-actions
Copy link
Copy Markdown

github-actions Bot commented Apr 21, 2026

PR #43768: Size comparison from 61afff7 to 4045bf0

Full report (16 builds for cc13x4_26x4, cc32xx, nrfconnect, psoc6, qpg, realtek, stm32)
platform target config section 61afff7 4045bf0 change % change
cc13x4_26x4 lighting-app LP_EM_CC1354P10_6 FLASH 776016 776016 0 0.0
RAM 103492 103492 0 0.0
lock-ftd LP_EM_CC1354P10_6 FLASH 788556 788556 0 0.0
RAM 108684 108684 0 0.0
pump-app LP_EM_CC1354P10_6 FLASH 735692 735692 0 0.0
RAM 97516 97516 0 0.0
pump-controller-app LP_EM_CC1354P10_6 FLASH 717748 717748 0 0.0
RAM 97644 97644 0 0.0
cc32xx air-purifier CC3235SF_LAUNCHXL FLASH 562706 562706 0 0.0
RAM 205072 205072 0 0.0
lock CC3235SF_LAUNCHXL FLASH 594578 594578 0 0.0
RAM 205272 205272 0 0.0
nrfconnect all-clusters-app nrf52840dk_nrf52840 FLASH 866472 866472 0 0.0
RAM 162404 162404 0 0.0
psoc6 all-clusters cy8ckit_062s2_43012 FLASH 1717764 1717764 0 0.0
RAM 214628 214628 0 0.0
all-clusters-minimal cy8ckit_062s2_43012 FLASH 1615180 1615180 0 0.0
RAM 211500 211500 0 0.0
light cy8ckit_062s2_43012 FLASH 1469396 1469396 0 0.0
RAM 197548 197548 0 0.0
lock cy8ckit_062s2_43012 FLASH 1502372 1502372 0 0.0
RAM 225276 225276 0 0.0
qpg lighting-app qpg6200+debug FLASH 843052 843052 0 0.0
RAM 127956 127956 0 0.0
lock-app qpg6200+debug FLASH 781628 781628 0 0.0
RAM 118904 118904 0 0.0
realtek light-switch-app rtl8777g FLASH 682832 682832 0 0.0
RAM 101824 101824 0 0.0
lighting-app rtl8777g FLASH 726736 726736 0 0.0
RAM 102164 102164 0 0.0
stm32 light STM32WB5MM-DK FLASH 477332 477332 0 0.0
RAM 141604 141604 0 0.0

@s-mcclain
Copy link
Copy Markdown
Contributor Author

Successful in running tests with linux and ESP32 sample application using chip-tool and running the commands:

proximityranging read ranging-capabilities 5 1
proximityranging start-ranging-request 3 0 '{"startTime": 0, "endTime": 5000,"rangingInstanceInterval": 1000}' 5 1

@github-actions
Copy link
Copy Markdown

github-actions Bot commented Apr 22, 2026

PR #43768: Size comparison from 462fcc2 to c14c126

Full report (16 builds for cc13x4_26x4, cc32xx, nrfconnect, psoc6, qpg, realtek, stm32)
platform target config section 462fcc2 c14c126 change % change
cc13x4_26x4 lighting-app LP_EM_CC1354P10_6 FLASH 776024 776024 0 0.0
RAM 103492 103492 0 0.0
lock-ftd LP_EM_CC1354P10_6 FLASH 788564 788564 0 0.0
RAM 108684 108684 0 0.0
pump-app LP_EM_CC1354P10_6 FLASH 735708 735708 0 0.0
RAM 97516 97516 0 0.0
pump-controller-app LP_EM_CC1354P10_6 FLASH 717756 717756 0 0.0
RAM 97644 97644 0 0.0
cc32xx air-purifier CC3235SF_LAUNCHXL FLASH 562722 562722 0 0.0
RAM 205072 205072 0 0.0
lock CC3235SF_LAUNCHXL FLASH 594586 594586 0 0.0
RAM 205272 205272 0 0.0
nrfconnect all-clusters-app nrf52840dk_nrf52840 FLASH 866540 866540 0 0.0
RAM 162404 162404 0 0.0
psoc6 all-clusters cy8ckit_062s2_43012 FLASH 1717796 1717796 0 0.0
RAM 214628 214628 0 0.0
all-clusters-minimal cy8ckit_062s2_43012 FLASH 1615228 1615228 0 0.0
RAM 211500 211500 0 0.0
light cy8ckit_062s2_43012 FLASH 1469428 1469428 0 0.0
RAM 197548 197548 0 0.0
lock cy8ckit_062s2_43012 FLASH 1502404 1502404 0 0.0
RAM 225276 225276 0 0.0
qpg lighting-app qpg6200+debug FLASH 843068 843068 0 0.0
RAM 127956 127956 0 0.0
lock-app qpg6200+debug FLASH 781644 781644 0 0.0
RAM 118904 118904 0 0.0
realtek light-switch-app rtl8777g FLASH 682856 682856 0 0.0
RAM 101824 101824 0 0.0
lighting-app rtl8777g FLASH 726760 726760 0 0.0
RAM 102164 102164 0 0.0
stm32 light STM32WB5MM-DK FLASH 477348 477348 0 0.0
RAM 141604 141604 0 0.0

@s-mcclain s-mcclain force-pushed the proximity-ranging-server-impl branch from c14c126 to b552616 Compare April 22, 2026 15:49
@s-mcclain s-mcclain force-pushed the proximity-ranging-server-impl branch from b552616 to cced2de Compare April 28, 2026 14:58
@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 28, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 54.52%. Comparing base (fc27df9) to head (ddc6ae1).
⚠️ Report is 7 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master   #43768      +/-   ##
==========================================
- Coverage   54.52%   54.52%   -0.01%     
==========================================
  Files        1592     1592              
  Lines      108733   108732       -1     
  Branches    13388    13388              
==========================================
- Hits        59291    59290       -1     
  Misses      49442    49442              

☔ 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.

@github-actions
Copy link
Copy Markdown

github-actions Bot commented Apr 28, 2026

PR #43768: Size comparison from fc27df9 to cced2de

Full report (33 builds for bl602, bl616, bl702, bl702l, cc13x4_26x4, cc32xx, efr32, nrfconnect, nxp, psoc6, qpg, realtek, stm32, telink)
platform target config section fc27df9 cced2de change % change
bl602 lighting-app bl602+mfd+littlefs+rpc FLASH 1090734 1090734 0 0.0
RAM 144930 144930 0 0.0
bl616 lighting-app bl616+thread FLASH 1102236 1102236 0 0.0
RAM 104344 104344 0 0.0
bl616+wifi+shell FLASH 1589180 1589180 0 0.0
RAM 98240 98240 0 0.0
bl702 lighting-app bl702+eth FLASH 1053904 1053904 0 0.0
RAM 108549 108549 0 0.0
bl702l contact-sensor-app bl702l+mfd+littlefs FLASH 892608 892608 0 0.0
RAM 105940 105940 0 0.0
cc13x4_26x4 lighting-app LP_EM_CC1354P10_6 FLASH 776024 776024 0 0.0
RAM 103492 103492 0 0.0
lock-ftd LP_EM_CC1354P10_6 FLASH 788580 788580 0 0.0
RAM 108684 108684 0 0.0
pump-app LP_EM_CC1354P10_6 FLASH 735708 735708 0 0.0
RAM 97516 97516 0 0.0
pump-controller-app LP_EM_CC1354P10_6 FLASH 717756 717756 0 0.0
RAM 97644 97644 0 0.0
cc32xx air-purifier CC3235SF_LAUNCHXL FLASH 562722 562722 0 0.0
RAM 205072 205072 0 0.0
lock CC3235SF_LAUNCHXL FLASH 594586 594586 0 0.0
RAM 205272 205272 0 0.0
efr32 lock-app BRD4187C FLASH 993412 993412 0 0.0
RAM 131352 131352 0 0.0
BRD4338a FLASH 797645 797637 -8 -0.0
RAM 243452 243452 0 0.0
window-app BRD4187C FLASH 1099220 1099220 0 0.0
RAM 130392 130392 0 0.0
nrfconnect all-clusters-app nrf52840dk_nrf52840 FLASH 866652 866652 0 0.0
RAM 162404 162404 0 0.0
nxp contact mcxw71+release FLASH 742664 742664 0 0.0
RAM 67160 67160 0 0.0
psoc6 all-clusters cy8ckit_062s2_43012 FLASH 1717716 1717716 0 0.0
RAM 214628 214628 0 0.0
all-clusters-minimal cy8ckit_062s2_43012 FLASH 1615116 1615116 0 0.0
RAM 211500 211500 0 0.0
light cy8ckit_062s2_43012 FLASH 1469428 1469428 0 0.0
RAM 197548 197548 0 0.0
lock cy8ckit_062s2_43012 FLASH 1502404 1502404 0 0.0
RAM 225276 225276 0 0.0
qpg lighting-app qpg6200+debug FLASH 843068 843068 0 0.0
RAM 127956 127956 0 0.0
lock-app qpg6200+debug FLASH 781644 781644 0 0.0
RAM 118904 118904 0 0.0
realtek light-switch-app rtl8777g FLASH 684680 684680 0 0.0
RAM 101832 101832 0 0.0
lighting-app rtl8777g FLASH 728728 728728 0 0.0
RAM 102164 102164 0 0.0
stm32 light STM32WB5MM-DK FLASH 477348 477348 0 0.0
RAM 141604 141604 0 0.0
telink bridge-app tl7218x FLASH 730678 730678 0 0.0
RAM 95932 95932 0 0.0
light-app-ota-compress-lzma-shell-factory-data tl3218x FLASH 850378 850378 0 0.0
RAM 44400 44400 0 0.0
tl7218x FLASH 841784 841784 0 0.0
RAM 99796 99796 0 0.0
light-switch-app-ota-compress-lzma-factory-data tl7218x_retention FLASH 730300 730300 0 0.0
RAM 56064 56064 0 0.0
light-switch-app-ota-compress-lzma-shell-factory-data tlsr9528a FLASH 793526 793526 0 0.0
RAM 75248 75248 0 0.0
light-switch-app-ota-factory-data tl3218x_retention FLASH 730198 730198 0 0.0
RAM 33544 33544 0 0.0
lighting-app-ota-factory-data tlsr9118bdk40d FLASH 613126 613126 0 0.0
RAM 118632 118632 0 0.0
lighting-app-ota-rpc-factory-data-4mb tlsr9518adk80d FLASH 839898 839902 4 0.0
RAM 97504 97504 0 0.0

@github-actions
Copy link
Copy Markdown

github-actions Bot commented Apr 28, 2026

PR #43768: Size comparison from 7e589aa to 899feef

Full report (30 builds for bl602, bl616, bl702, bl702l, cc13x4_26x4, cc32xx, nrfconnect, nxp, psoc6, qpg, realtek, stm32, telink)
platform target config section 7e589aa 899feef change % change
bl602 lighting-app bl602+mfd+littlefs+rpc FLASH 1090734 1090734 0 0.0
RAM 144930 144930 0 0.0
bl616 lighting-app bl616+thread FLASH 1102236 1102236 0 0.0
RAM 104344 104344 0 0.0
bl616+wifi+shell FLASH 1589180 1589180 0 0.0
RAM 98240 98240 0 0.0
bl702 lighting-app bl702+eth FLASH 1053904 1053904 0 0.0
RAM 108549 108549 0 0.0
bl702l contact-sensor-app bl702l+mfd+littlefs FLASH 892608 892608 0 0.0
RAM 105940 105940 0 0.0
cc13x4_26x4 lighting-app LP_EM_CC1354P10_6 FLASH 776024 776024 0 0.0
RAM 103492 103492 0 0.0
lock-ftd LP_EM_CC1354P10_6 FLASH 788580 788580 0 0.0
RAM 108684 108684 0 0.0
pump-app LP_EM_CC1354P10_6 FLASH 735708 735708 0 0.0
RAM 97516 97516 0 0.0
pump-controller-app LP_EM_CC1354P10_6 FLASH 717756 717756 0 0.0
RAM 97644 97644 0 0.0
cc32xx air-purifier CC3235SF_LAUNCHXL FLASH 562722 562722 0 0.0
RAM 205072 205072 0 0.0
lock CC3235SF_LAUNCHXL FLASH 594586 594586 0 0.0
RAM 205272 205272 0 0.0
nrfconnect all-clusters-app nrf52840dk_nrf52840 FLASH 866652 866652 0 0.0
RAM 162404 162404 0 0.0
nxp contact mcxw71+release FLASH 742664 742664 0 0.0
RAM 67160 67160 0 0.0
psoc6 all-clusters cy8ckit_062s2_43012 FLASH 1717716 1717716 0 0.0
RAM 214628 214628 0 0.0
all-clusters-minimal cy8ckit_062s2_43012 FLASH 1615116 1615116 0 0.0
RAM 211500 211500 0 0.0
light cy8ckit_062s2_43012 FLASH 1469428 1469428 0 0.0
RAM 197548 197548 0 0.0
lock cy8ckit_062s2_43012 FLASH 1502404 1502404 0 0.0
RAM 225276 225276 0 0.0
qpg lighting-app qpg6200+debug FLASH 843068 843068 0 0.0
RAM 127956 127956 0 0.0
lock-app qpg6200+debug FLASH 781644 781644 0 0.0
RAM 118904 118904 0 0.0
realtek light-switch-app rtl8777g FLASH 684680 684680 0 0.0
RAM 101832 101832 0 0.0
lighting-app rtl8777g FLASH 728728 728728 0 0.0
RAM 102164 102164 0 0.0
stm32 light STM32WB5MM-DK FLASH 477348 477348 0 0.0
RAM 141604 141604 0 0.0
telink bridge-app tl7218x FLASH 730678 730678 0 0.0
RAM 95932 95932 0 0.0
light-app-ota-compress-lzma-shell-factory-data tl3218x FLASH 850378 850378 0 0.0
RAM 44400 44400 0 0.0
tl7218x FLASH 841784 841784 0 0.0
RAM 99796 99796 0 0.0
light-switch-app-ota-compress-lzma-factory-data tl7218x_retention FLASH 730300 730300 0 0.0
RAM 56064 56064 0 0.0
light-switch-app-ota-compress-lzma-shell-factory-data tlsr9528a FLASH 793526 793526 0 0.0
RAM 75248 75248 0 0.0
light-switch-app-ota-factory-data tl3218x_retention FLASH 730198 730198 0 0.0
RAM 33544 33544 0 0.0
lighting-app-ota-factory-data tlsr9118bdk40d FLASH 613126 613126 0 0.0
RAM 118632 118632 0 0.0
lighting-app-ota-rpc-factory-data-4mb tlsr9518adk80d FLASH 839898 839902 4 0.0
RAM 97504 97504 0 0.0

@s-mcclain s-mcclain force-pushed the proximity-ranging-server-impl branch from 899feef to ddc6ae1 Compare April 28, 2026 20:51
@github-actions
Copy link
Copy Markdown

github-actions Bot commented Apr 28, 2026

PR #43768: Size comparison from dcfc4ce to ddc6ae1

Full report (34 builds for bl602, bl616, bl702, bl702l, cc13x4_26x4, cc32xx, efr32, esp32, nrfconnect, nxp, psoc6, qpg, realtek, stm32, telink)
platform target config section dcfc4ce ddc6ae1 change % change
bl602 lighting-app bl602+mfd+littlefs+rpc FLASH 1090980 1090980 0 0.0
RAM 144930 144930 0 0.0
bl616 lighting-app bl616+thread FLASH 1102476 1102476 0 0.0
RAM 104344 104344 0 0.0
bl616+wifi+shell FLASH 1589428 1589428 0 0.0
RAM 98240 98240 0 0.0
bl702 lighting-app bl702+eth FLASH 1054150 1054150 0 0.0
RAM 108549 108549 0 0.0
bl702l contact-sensor-app bl702l+mfd+littlefs FLASH 892854 892854 0 0.0
RAM 105940 105940 0 0.0
cc13x4_26x4 lighting-app LP_EM_CC1354P10_6 FLASH 776264 776264 0 0.0
RAM 103492 103492 0 0.0
lock-ftd LP_EM_CC1354P10_6 FLASH 788764 788764 0 0.0
RAM 108684 108684 0 0.0
pump-app LP_EM_CC1354P10_6 FLASH 735884 735884 0 0.0
RAM 97516 97516 0 0.0
pump-controller-app LP_EM_CC1354P10_6 FLASH 717940 717940 0 0.0
RAM 97644 97644 0 0.0
cc32xx air-purifier CC3235SF_LAUNCHXL FLASH 562882 562882 0 0.0
RAM 205072 205072 0 0.0
lock CC3235SF_LAUNCHXL FLASH 594754 594754 0 0.0
RAM 205272 205272 0 0.0
efr32 lock-app BRD4187C FLASH 993596 993596 0 0.0
RAM 131352 131352 0 0.0
BRD4338a FLASH 797709 797701 -8 -0.0
RAM 243452 243452 0 0.0
window-app BRD4187C FLASH 1099316 1099308 -8 -0.0
RAM 130392 130392 0 0.0
esp32 all-clusters-app c3devkit DRAM 99164 99164 0 0.0
FLASH 1607574 1607574 0 0.0
IRAM 94776 94776 0 0.0
nrfconnect all-clusters-app nrf52840dk_nrf52840 FLASH 866644 866644 0 0.0
RAM 162404 162404 0 0.0
nxp contact mcxw71+release FLASH 742776 742776 0 0.0
RAM 67160 67160 0 0.0
psoc6 all-clusters cy8ckit_062s2_43012 FLASH 1717780 1717780 0 0.0
RAM 214628 214628 0 0.0
all-clusters-minimal cy8ckit_062s2_43012 FLASH 1615180 1615180 0 0.0
RAM 211500 211500 0 0.0
light cy8ckit_062s2_43012 FLASH 1469492 1469492 0 0.0
RAM 197548 197548 0 0.0
lock cy8ckit_062s2_43012 FLASH 1502452 1502452 0 0.0
RAM 225276 225276 0 0.0
qpg lighting-app qpg6200+debug FLASH 843308 843308 0 0.0
RAM 127956 127956 0 0.0
lock-app qpg6200+debug FLASH 781884 781884 0 0.0
RAM 118904 118904 0 0.0
realtek light-switch-app rtl8777g FLASH 684880 684880 0 0.0
RAM 101832 101832 0 0.0
lighting-app rtl8777g FLASH 728928 728928 0 0.0
RAM 102164 102164 0 0.0
stm32 light STM32WB5MM-DK FLASH 477568 477568 0 0.0
RAM 141604 141604 0 0.0
telink bridge-app tl7218x FLASH 730866 730866 0 0.0
RAM 95932 95932 0 0.0
light-app-ota-compress-lzma-shell-factory-data tl3218x FLASH 850614 850614 0 0.0
RAM 44400 44400 0 0.0
tl7218x FLASH 842020 842020 0 0.0
RAM 99796 99796 0 0.0
light-switch-app-ota-compress-lzma-factory-data tl7218x_retention FLASH 730536 730536 0 0.0
RAM 56064 56064 0 0.0
light-switch-app-ota-compress-lzma-shell-factory-data tlsr9528a FLASH 793762 793762 0 0.0
RAM 75248 75248 0 0.0
light-switch-app-ota-factory-data tl3218x_retention FLASH 730434 730434 0 0.0
RAM 33544 33544 0 0.0
lighting-app-ota-factory-data tlsr9118bdk40d FLASH 613362 613362 0 0.0
RAM 118632 118632 0 0.0
lighting-app-ota-rpc-factory-data-4mb tlsr9518adk80d FLASH 840134 840138 4 0.0
RAM 97504 97504 0 0.0

- Operational State
- Oven Cavity Operational State
- Oven Mode
- Proximity Ranging
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

If I recall correctly, it is actually not needed to add the cluster in this list if it was already added in the CodeDrivenClusters one since CHI and SCI are mutually exclusive.


#define CHIP_DEVICE_CONFIG_ENABLE_COMMISSIONABLE_DEVICE_TYPE 1

#define CHIP_DEVICE_CONFIG_DEVICE_TYPE 0x0152 // Proximity Ranger
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

We used to hardcode these this way, but generally wondering if we should use generated constants instead of manual ones. This ID shows up as chip::app::Device::kProximityRangerDeviceTypeId in

https://github.com/project-chip/connectedhomeip/blob/master/zzz_generated/app-common/devices/Ids.h#L230

class AppDeviceCallbacks : public CommonDeviceCallbacks
{
public:
virtual void PostAttributeChangeCallback(chip::EndpointId endpointId, chip::ClusterId clusterId, chip::AttributeId attributeId,
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Is this callbacks class required for this example? All we seem to do is logging...

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Is there a readme on why we have this example app?

Looking at it I wonder:

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I'll go ahead and update this to be included within the all-devices-app instead.
One question is: If we do not have an example directory specific for the proximity ranger (e.g. proximity-ranger-common), what would be the recommendation for where to keep the "common" application files for this cluster / device type?

*
* @code
* static MyProximityRangingDriver sDriver;
* static ProximityRanging::Instance sInstance(endpointId, sDriver, features);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

If we do this, this means the cluster is fully code driven and zap configuration is not taken into account at all.

Does this mean that we do not have much codegen integration at all (i.e. I cannot select something from zap and have it work)?

Other choices that other instances have:

  • they use zap to initialize/shutdown
  • they provide a FindClusterByEndpointId and then main would do something like either:
    • SetDriver(endpointid, driver) before app init (so we can save a pointer and use it in a constructor
    • FindClusterByEndpointId(id)->SetDriver() after app init (so that cluster is created)

Neither are amazing because SetDriver requires separate pointer and FindClusterByEndpoint makes the driver mutable ... however at least it makes a cluster appear as soon as the zap UI selects something in the ZAP UI.

If we explicitly chose not to support zap UI (essentially, no features are forwarded, no other options) we should probably state in the docs here.

switch (request.path.mAttributeId)
{
case Attributes::RangingCapabilities::Id:
return mDriver.GetRangingCapabilities(encoder);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Ranging capabilities (and it seems like ALL attributes) are non-fixed. This means whenever they change the driver has to "NotifyAttributeChanged". Was this considered? I see we did pass "self" to the init of the driver, however we do not expose a notification mechanism.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Fair point, currently only the SessionIdList change notifications get published. We'll add notification mechanisms for all the attributes.

if (config.featureFlags.Has(Feature::kBluetoothChannelSounding))
{
attrs.ForceSet<Attributes::BLTDevIK::Id>();
attrs.ForceSet<Attributes::BLTCSSecurityLevel::Id>();
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This one is marked O in the spec, so seems like fully optional. Maybe a spec issue? It should be [BLTCS] maybe? but even then it would be "optional for this feature" and the config here enforces it for the feature. So we cannot fully implement all spec variations.

This can be fine (if we chose our impl to support a specific subset) but should be called out very explicitly.

DefaultServerCluster({ config.endpointId, ProximityRanging::Id }), mDriver(config.driver),
mFeatureFlags(config.featureFlags), mOptionalAttributes([&config]() -> OptionalAttributes {
AttributeSet attrs;
if (config.featureFlags.Has(Feature::kWiFiUsdProximityDetection))
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

nit: please add {} everywhere for ifs.

return mDriver.GetRangingCapabilities(encoder);

case Attributes::WiFiDevIK::Id: {
VerifyOrReturnError(mFeatureFlags.Has(Feature::kWiFiUsdProximityDetection), CHIP_IM_GLOBAL_STATUS(UnsupportedAttribute));
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This is not needed - please remove from all instances:

  • API requirement is to guarantee that Read/Write/Invoke is done for existent paths only. This means that if you implement Attributes() correctly you do not need to verify (clutters the code less, uses less flash)

MutableByteSpan span(buf);
CHIP_ERROR err = mDriver.GetWiFiDevIK(span);
VerifyOrReturnError(err != CHIP_ERROR_UNSUPPORTED_CHIP_FEATURE, CHIP_IM_GLOBAL_STATUS(UnsupportedAttribute));
VerifyOrReturnError(err == CHIP_NO_ERROR, Protocols::InteractionModel::Status::Failure);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

return the error directly: there are slightly better conversions (it allows drivers to return things like global IM errors that get converted) and I am unsure if we should allow Attributes() to say attribute exist and then return unsupported attribute.

I would ReturnErrorOnFailure(mDriver.GetWiFiDevIK(span)). Allowing UNSUPPORTED_CHIP_FEATURE seems like an antipattern. Driver should tell you what it supports (feature map) and if it supports something, it should be implemented.

Thinking on this, we should not pass in the feature map to the cluster then: the cluster should get the feature map from the driver then.

}

case Attributes::FeatureMap::Id:
return encoder.Encode(mFeatureFlags.Raw());
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggested change
return encoder.Encode(mFeatureFlags.Raw());
return encoder.Encode(mFeatureFlags);

I think raw is not needed

return encoder.Encode(ProximityRanging::kRevision);

default:
return CHIP_IM_GLOBAL_STATUS(UnsupportedAttribute);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

maybe Status::UnsupportedAttribute is clearer and the same for commands, so we do not wrap in a chip-error.

the ActionRestult has casts from chiperror and statuses.

CommandHandler * handler)
{
Commands::StartRangingRequest::DecodableType commandData;
VerifyOrReturnValue(commandData.Decode(reader) == CHIP_NO_ERROR, CHIP_IM_GLOBAL_STATUS(InvalidCommand));
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

return the error directly

Suggested change
VerifyOrReturnValue(commandData.Decode(reader) == CHIP_NO_ERROR, CHIP_IM_GLOBAL_STATUS(InvalidCommand));
ReturnErrorOnFailure(commandData.Decode(reader));

The idea would be that if you check, you will lose the actual error information when you convert.

VerifyOrReturnValue(commandData.Decode(reader) == CHIP_NO_ERROR, CHIP_IM_GLOBAL_STATUS(InvalidCommand));

Commands::StartRangingResponse::Type response;
ResultCodeEnum resultCode;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

why don't you use response.resultCode directly all the time? why have a separate resultCode variable?

{
MarkSessionIdListModified();

if (mContext != nullptr)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

to make it consistent, should we VerifyOrReturn(mContext != nullptr); like the above measurement data handler? that would also decrease indent a bit.

Comment on lines +283 to +295
bool collision = false;
for (size_t i = 0; i < activeSessions.size(); i++)
{
if (activeSessions.data()[i] == candidate)
{
collision = true;
break;
}
}
if (!collision)
{
return candidate;
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Is this where we could use std::none_of?

I imagine code like:

if (std::none_of(activeSessions.begin(), activeSessions.end(), [candidate](uint8_t value) { 
        return value == candidate; 
    }))
{
    return candidate;
}

}

std::optional<DataModel::ActionReturnStatus>
ProximityRangingCluster::HandleStopRangingRequest(const DataModel::InvokeRequest & request, TLV::TLVReader & reader,
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

you do not seem to need the handler as an argument (no response) and then you do not need the std::optional as a response either.

Copy link
Copy Markdown
Contributor

@andy31415 andy31415 left a comment

Choose a reason for hiding this comment

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

Request changes:

  • please split cluster implementation from "add example app". I would very much prefer to not create yet another example app as they are harder to maintain (either we overload CI or never test it, both being bad) and we already have a lot of unmaintained apps in https://project-chip.github.io/connectedhomeip-doc/issue_triage.html#example-maintenance . If we do add another app, we need maintainers.

  • we need unit tests for any code driven cluster. This PR does not add any unit test, not even a skeleton. I think the cluster is testable today because the driver can be mocked, so we should have tests.

@github-project-automation github-project-automation Bot moved this from Todo to In Progress in [Platform] Darwin Apr 29, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

Status: In Progress

Development

Successfully merging this pull request may close these issues.

4 participants