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

Check descriptor clusters during commissioning #14410

Closed
wants to merge 7 commits into from

Conversation

cecille
Copy link
Contributor

@cecille cecille commented Jan 27, 2022

Problem

Adding some additional checks to ensure that the device has the appropriate clusters for commissioning.

Change overview

  • adds descriptor cluster checks for the servers on EP0 and the additional endpoints where a network cluster may be hiding.

Testing

printed values and tested with M5 and linux lighting app. Commissioning completes successfully.

@github-actions
Copy link

github-actions bot commented Jan 27, 2022

PR #14410: Size comparison from 63d0c37 to eb8b946

Increases (1 build for linux)
platform target config section 63d0c37 eb8b946 change % change
linux chip-tool-ipv6only arm64 (read only) 6744396 6749788 5392 0.1
(read/write) 279025 279073 48 0.0
.got 42744 42792 48 0.1
.rodata 387684 388084 400 0.1
.text 5785492 5790340 4848 0.1
Full report (33 builds for cyw30739, efr32, esp32, k32w, linux, mbed, nrfconnect, p6, qpg, telink)
platform target config section 63d0c37 eb8b946 change % change
cyw30739 light cyw930739m2evb_01 (read/write) 580918 580918 0 0.0
.app_xip_area 485716 485716 0 0.0
.bss 77948 77948 0 0.0
.data 596 596 0 0.0
.rodata 0 0 0 0.0
.text 0 0 0 0.0
lock-app CYW30739 (read/write) 538922 538922 0 0.0
.app_xip_area 445264 445264 0 0.0
.bss 76444 76444 0 0.0
.data 560 560 0 0.0
.rodata 0 0 0 0.0
.text 0 0 0 0.0
efr32 lighting-app BRD4161A (read only) 844508 844508 0 0.0
(read/write) 127492 127492 0 0.0
.bss 125592 125592 0 0.0
.data 1900 1900 0 0.0
.text 844500 844500 0 0.0
BRD4161A+rpc (read only) 831880 831880 0 0.0
(read/write) 144152 144152 0 0.0
.bss 142152 142152 0 0.0
.data 2000 2000 0 0.0
.text 831872 831872 0 0.0
window-app BRD4161A (read only) 817124 817124 0 0.0
(read/write) 126148 126148 0 0.0
.bss 124292 124292 0 0.0
.data 1856 1856 0 0.0
.text 817116 817116 0 0.0
esp32 all-clusters-app c3devkit (read only) 934132 934132 0 0.0
(read/write) 1398698 1398698 0 0.0
.dram0.bss 70984 70984 0 0.0
.dram0.data 14236 14236 0 0.0
.flash.rodata 194552 194552 0 0.0
.flash.text 934132 934132 0 0.0
.iram0.text 62056 62056 0 0.0
m5stack (read only) 981551 981551 0 0.0
(read/write) 465528 465528 0 0.0
.dram0.bss 75728 75728 0 0.0
.dram0.data 34024 34024 0 0.0
.flash.rodata 223648 223648 0 0.0
.flash.text 976167 976167 0 0.0
.iram0.text 123399 123399 0 0.0
k32w light k32w061+release (read/write) 665716 665716 0 0.0
.bss 77724 77724 0 0.0
.data 1868 1868 0 0.0
.text 580324 580324 0 0.0
lock k32w061+release (read/write) 666668 666668 0 0.0
.bss 77988 77988 0 0.0
.data 1892 1892 0 0.0
.text 580988 580988 0 0.0
linux chip-tool-ipv6only arm64 (read only) 6744396 6749788 5392 0.1
(read/write) 279025 279073 48 0.0
.bss 55537 55537 0 0.0
.data 1128 1128 0 0.0
.data.rel.ro 175864 175864 0 0.0
.dynamic 560 560 0 0.0
.got 42744 42792 48 0.1
.init 24 24 0 0.0
.init_array 200 200 0 0.0
.rodata 387684 388084 400 0.1
.text 5785492 5790340 4848 0.1
thermostat-no-ble arm64 (read only) 2084468 2084468 0 0.0
(read/write) 152097 152097 0 0.0
.bss 69761 69761 0 0.0
.data 960 960 0 0.0
.data.rel.ro 74256 74256 0 0.0
.dynamic 560 560 0 0.0
.got 4144 4144 0 0.0
.init 24 24 0 0.0
.init_array 336 336 0 0.0
.rodata 131940 131940 0 0.0
.text 1735136 1735136 0 0.0
mbed all-clusters-app CY8CPROTO_062_4343W+release (read only) 6224 6224 0 0.0
(read/write) 2383920 2383920 0 0.0
.bss 189692 189692 0 0.0
.data 5288 5288 0 0.0
.text 1346520 1346520 0 0.0
lighting-app CY8CPROTO_062_4343W+release (read only) 6224 6224 0 0.0
(read/write) 2341488 2341488 0 0.0
.bss 181200 181200 0 0.0
.data 5584 5584 0 0.0
.text 1304088 1304088 0 0.0
lock-app CY8CPROTO_062_4343W+release (read only) 6224 6224 0 0.0
(read/write) 2308240 2308240 0 0.0
.bss 181096 181096 0 0.0
.data 5568 5568 0 0.0
.text 1270840 1270840 0 0.0
pigweed-app CY8CPROTO_062_4343W+release (read only) 6224 6224 0 0.0
(read/write) 1139712 1139712 0 0.0
.bss 11756 11756 0 0.0
.data 4368 4368 0 0.0
.text 103096 103096 0 0.0
shell CY8CPROTO_062_4343W+release (read only) 6224 6224 0 0.0
(read/write) 2294436 2294436 0 0.0
.bss 177828 177828 0 0.0
.data 5384 5384 0 0.0
.text 1257008 1257008 0 0.0
nrfconnect lighting-app nrf52840dk_nrf52840 (read/write) 984183 984183 0 0.0
bss 120956 120956 0 0.0
rodata 116492 116492 0 0.0
text 668944 668944 0 0.0
nrf52840dk_nrf52840+rpc (read/write) 968047 968047 0 0.0
bss 118000 118000 0 0.0
rodata 108028 108028 0 0.0
text 663616 663616 0 0.0
nrf52840dongle_nrf52840 (read/write) 1000303 1000303 0 0.0
bss 122128 122128 0 0.0
rodata 115344 115344 0 0.0
text 674372 674372 0 0.0
nrf5340dk_nrf5340_cpuapp (read/write) 893406 893406 0 0.0
bss 117744 117744 0 0.0
rodata 109792 109792 0 0.0
text 585124 585124 0 0.0
lock-app nrf52840dk_nrf52840 (read/write) 916799 916799 0 0.0
bss 119336 119336 0 0.0
rodata 105132 105132 0 0.0
text 614928 614928 0 0.0
nrf5340dk_nrf5340_cpuapp (read/write) 826834 826834 0 0.0
bss 116152 116152 0 0.0
rodata 98356 98356 0 0.0
text 531880 531880 0 0.0
pigweed-app nrf52840dk_nrf52840 (read/write) 541835 541835 0 0.0
bss 52588 52588 0 0.0
rodata 50104 50104 0 0.0
text 376940 376940 0 0.0
pump-app nrf52840dk_nrf52840 (read/write) 919663 919663 0 0.0
bss 119088 119088 0 0.0
rodata 105644 105644 0 0.0
text 617464 617464 0 0.0
pump-controller-app nrf52840dk_nrf52840 (read/write) 914847 914847 0 0.0
bss 119112 119112 0 0.0
rodata 104748 104748 0 0.0
text 613500 613500 0 0.0
shell nrf52840dk_nrf52840 (read/write) 798203 798203 0 0.0
bss 109776 109776 0 0.0
rodata 78288 78288 0 0.0
text 533640 533640 0 0.0
p6 all-clusters-app default (read/write) 2443448 2443448 0 0.0
.bss 118036 118036 0 0.0
.data 2584 2584 0 0.0
.text 1401712 1401712 0 0.0
light-app default (read/write) 2340096 2340096 0 0.0
.bss 105780 105780 0 0.0
.data 2408 2408 0 0.0
.text 1298360 1298360 0 0.0
lock-app default (read/write) 2305600 2305600 0 0.0
.bss 105524 105524 0 0.0
.data 2360 2360 0 0.0
.text 1263864 1263864 0 0.0
qpg lighting-app qpg6105+debug (read only) 572424 572424 0 0.0
(read/write) 146936 146936 0 0.0
.bss 89936 89936 0 0.0
.data 1060 1060 0 0.0
.text 567104 567104 0 0.0
lock-app qpg6105+debug (read only) 518552 518552 0 0.0
(read/write) 146940 146940 0 0.0
.bss 89408 89408 0 0.0
.data 992 992 0 0.0
.text 513232 513232 0 0.0
persistent-storage-app qpg6105+debug (read only) 107140 107140 0 0.0
(read/write) 146940 146940 0 0.0
.bss 38504 38504 0 0.0
.data 288 288 0 0.0
.text 101820 101820 0 0.0
telink lighting-app tlsr9518adk80d (read/write) 848690 848690 0 0.0
bss 87736 87736 0 0.0
noinit 37160 37160 0 0.0
text 593356 593356 0 0.0

@mlepage-google mlepage-google changed the title Check descriptor clusters during commissining Check descriptor clusters during commissioning Jan 27, 2022
src/controller/CHIPDeviceController.cpp Show resolved Hide resolved
src/controller/CHIPDeviceController.cpp Show resolved Hide resolved
src/controller/CHIPDeviceController.cpp Show resolved Hide resolved
@@ -1602,11 +1680,50 @@ void DeviceCommissioner::PerformCommissioningStep(DeviceProxy * proxy, Commissio

switch (step)
{
case CommissioningStage::kReadVendorId: {
ChipLogProgress(Controller, "Reading vendor ID");
Copy link
Contributor

Choose a reason for hiding this comment

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

This is a lot of round-trips.... Do we actually want to read these attributes one at a time? Why do we want to walk the list of all endpoints starting from the end looking for network commissioning things, instead of starting at the front and stopping when we find the first network commissioning thing which supports a network technology we support?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No, but as far as I can tell, we don't have support for bulk reading attributes right now.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

They're all checked in order to address the request for supporting network commissioning clusters on other endpoints (multiple radios). There is always a NetworkCommissioning cluster on EP0, but you had a request in the network tecnology PR (#13829) to support network commissioning clusters that could be present on endpoints with manufacturer specific device types.

see #14412

Copy link
Contributor

Choose a reason for hiding this comment

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

we don't have support for bulk reading attributes right now

We certainly do. You just have to use a slightly lower-level API to do it, because the results of such a read can't be expressed as a single C++ value.... Doing this can be a followup, though.

They're all checked in order to address the request for supporting network commissioning clusters on other endpoints

This just seems like an odd approach to addressing that request. What I would have expected is we start with the network commissioning on EP0. If we can't commission using that (rare case), we look for another one.

It feels like this is something where people are going to want to do a variety of things and UX flows, and reading all endpoints can be quite costly (latency) for devices with lots of endpoints....

Copy link
Contributor Author

Choose a reason for hiding this comment

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

There's always going to be a network commissioning cluster on EP0, so if we're starting there, we're ending there. If we want to allow devices to specify more than one networking technology, we have to read them all.

Copy link
Contributor

Choose a reason for hiding this comment

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

I'm not following. If what's on EP0 is a WiFi cluster but we don't have any WiFi credentials, but do have Thread ones, then we would want to look for other network commissioning clusters to see if the device supports Thread. But if EP0 has a network technology we're happy to commission with, why would we spend time looking at the other endpoints?

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'd actually argue that dual network commissioning clusters is dubiously supported anyway and unlikely to happen in a real device. The only place where this would be really beneficial would be for a border router, and the network commissioning clusters are insufficient there anyway because we there aren't sufficient commands to support creating a thread network.

The alternate is to assume EP0 for the networking cluster allow devices that require a more complicated setup use a custom commissioning flow. If we want to be able to commission border routers, the network commissioning cluster needs some additional commands, and we could then add a parts list to make the endpoint walk easier.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

How would you know to send in only thread credentials if you didn't know what the device supported in the first place? That assumes that the commissioning parameters are the source of truth, whereas what we really want is for the device to be the source of truth.

I suppose we could cut out some of the back and forth if we only have one set of credentials and it happens to match the feature map for the network cluster on EP0.

I wrote it this way originally because I was going to double-purpose this for a convenience function to allow devs to get device information before calling the commission command. Let me see if I can maybe disentangle this use case and short-circut the full walk during commissioning if we only get one set of network credentials that matches EP0.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

OK, I've updated the PR to just go with the first networking cluster it finds. Working with jerry on a follow up to just query all the network cluster feature maps using wild card - I didn't realize that was implemented now, but it's a bit more of a change.

src/controller/AutoCommissioner.cpp Outdated Show resolved Hide resolved
If we check the feature map right after we check for the existance
of the networking cluster, we can just bail out once we find a
networking cluster that matches

Test: on-network with lighting app on linux
      wifi on all-clusters app on M5
      tested thread using all clusters app - saw reads of endpoints,
      found network cluster on different endpoint.
@github-actions
Copy link

github-actions bot commented Jan 28, 2022

PR #14410: Size comparison from 08d8fd8 to 420142b

Increases (11 builds for cyw30739, efr32, k32w, linux, p6, qpg, telink)
platform target config section 08d8fd8 420142b change % change
cyw30739 light cyw930739m2evb_01 (read/write) 578114 578126 12 0.0
.app_xip_area 484208 484220 12 0.0
lock-app CYW30739 (read/write) 536142 536154 12 0.0
.app_xip_area 443780 443792 12 0.0
efr32 window-app BRD4161A (read only) 815560 815576 16 0.0
.text 815552 815568 16 0.0
k32w light k32w061+release (read/write) 662940 662956 16 0.0
.text 578844 578860 16 0.0
lock k32w061+release (read/write) 663844 663860 16 0.0
.text 579460 579476 16 0.0
linux chip-tool-ipv6only arm64 (read only) 6787220 6792948 5728 0.1
(read/write) 279985 280017 32 0.0
.got 43072 43112 40 0.1
.rodata 388348 388844 496 0.1
.text 5824980 5830084 5104 0.1
p6 all-clusters-app default (read/write) 2441720 2441736 16 0.0
.text 1399984 1400000 16 0.0
light-app default (read/write) 2338536 2338552 16 0.0
.text 1296800 1296816 16 0.0
qpg lighting-app qpg6105+debug (read only) 570868 570884 16 0.0
.text 565548 565564 16 0.0
lock-app qpg6105+debug (read only) 517004 517012 8 0.0
.text 511684 511692 8 0.0
telink lighting-app tlsr9518adk80d (read/write) 845778 845786 8 0.0
text 592512 592524 12 0.0
Full report (16 builds for cyw30739, efr32, k32w, linux, p6, qpg, telink)
platform target config section 08d8fd8 420142b change % change
cyw30739 light cyw930739m2evb_01 (read/write) 578114 578126 12 0.0
.app_xip_area 484208 484220 12 0.0
.bss 76652 76652 0 0.0
.data 596 596 0 0.0
.rodata 0 0 0 0.0
.text 0 0 0 0.0
lock-app CYW30739 (read/write) 536142 536154 12 0.0
.app_xip_area 443780 443792 12 0.0
.bss 75148 75148 0 0.0
.data 560 560 0 0.0
.rodata 0 0 0 0.0
.text 0 0 0 0.0
efr32 lighting-app BRD4161A (read only) 842968 842968 0 0.0
(read/write) 126200 126200 0 0.0
.bss 124296 124296 0 0.0
.data 1900 1900 0 0.0
.text 842960 842960 0 0.0
BRD4161A+rpc (read only) 830320 830320 0 0.0
(read/write) 142856 142856 0 0.0
.bss 140856 140856 0 0.0
.data 2000 2000 0 0.0
.text 830312 830312 0 0.0
window-app BRD4161A (read only) 815560 815576 16 0.0
(read/write) 124852 124852 0 0.0
.bss 122996 122996 0 0.0
.data 1856 1856 0 0.0
.text 815552 815568 16 0.0
k32w light k32w061+release (read/write) 662940 662956 16 0.0
.bss 76428 76428 0 0.0
.data 1868 1868 0 0.0
.text 578844 578860 16 0.0
lock k32w061+release (read/write) 663844 663860 16 0.0
.bss 76692 76692 0 0.0
.data 1892 1892 0 0.0
.text 579460 579476 16 0.0
linux chip-tool-ipv6only arm64 (read only) 6787220 6792948 5728 0.1
(read/write) 279985 280017 32 0.0
.bss 55537 55537 0 0.0
.data 1128 1128 0 0.0
.data.rel.ro 176472 176472 0 0.0
.dynamic 560 560 0 0.0
.got 43072 43112 40 0.1
.init 24 24 0 0.0
.init_array 200 200 0 0.0
.rodata 388348 388844 496 0.1
.text 5824980 5830084 5104 0.1
thermostat-no-ble arm64 (read only) 2080748 2080748 0 0.0
(read/write) 149537 149537 0 0.0
.bss 67169 67169 0 0.0
.data 960 960 0 0.0
.data.rel.ro 74288 74288 0 0.0
.dynamic 560 560 0 0.0
.got 4144 4144 0 0.0
.init 24 24 0 0.0
.init_array 336 336 0 0.0
.rodata 129932 129932 0 0.0
.text 1733472 1733472 0 0.0
p6 all-clusters-app default (read/write) 2441720 2441736 16 0.0
.bss 116740 116740 0 0.0
.data 2584 2584 0 0.0
.text 1399984 1400000 16 0.0
light-app default (read/write) 2338536 2338552 16 0.0
.bss 104484 104484 0 0.0
.data 2408 2408 0 0.0
.text 1296800 1296816 16 0.0
lock-app default (read/write) 2304080 2304080 0 0.0
.bss 104228 104228 0 0.0
.data 2360 2360 0 0.0
.text 1262344 1262344 0 0.0
qpg lighting-app qpg6105+debug (read only) 570868 570884 16 0.0
(read/write) 146936 146936 0 0.0
.bss 88640 88640 0 0.0
.data 1060 1060 0 0.0
.text 565548 565564 16 0.0
lock-app qpg6105+debug (read only) 517004 517012 8 0.0
(read/write) 146940 146940 0 0.0
.bss 88112 88112 0 0.0
.data 992 992 0 0.0
.text 511684 511692 8 0.0
persistent-storage-app qpg6105+debug (read only) 107140 107140 0 0.0
(read/write) 146940 146940 0 0.0
.bss 38504 38504 0 0.0
.data 288 288 0 0.0
.text 101820 101820 0 0.0
telink lighting-app tlsr9518adk80d (read/write) 845778 845786 8 0.0
bss 86440 86440 0 0.0
noinit 37160 37160 0 0.0
text 592512 592524 12 0.0

@cecille
Copy link
Contributor Author

cecille commented Jan 29, 2022

Alternate proposal: #14567

Jerry showed me how to do wildcard reads. I wasn't aware they were supported yet, but it greatly simplifies the logic on the commissioning delegate because we can just query all the network cluster feature maps at once and directly parse which endpoints have which clusters. The logic on the DeviceCommissioner is a bit more complex, but that seems more reasonable to me. In theory I can do that to the general commissioning cluster too (just not in the PR).

If I can get consensus to go with that option, I will drop this PR.

@pullapprove pullapprove bot requested a review from isiu-apple January 29, 2022 04:29
@cecille
Copy link
Contributor Author

cecille commented Feb 3, 2022

#14567 has landed, so this PR is officially obsolete. Closing.

@cecille cecille closed this Feb 3, 2022
@cecille cecille deleted the check_descriptor_cluster branch February 3, 2022 14:57
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.

5 participants