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

Adding request-commissioning CHIPTool command #7729

Merged
merged 1 commit into from
Jun 24, 2021

Conversation

sharadb-amazon
Copy link
Contributor

@sharadb-amazon sharadb-amazon commented Jun 17, 2021

Problem

Support for Initializing setup via "commissioner-discovery-from-an-on-network-device" is pending implementation of commands for Steps 7-12.

Note: Steps 3-5 were previously implemented as a discover-commissioner command in the CHIPTool (see PR)

What is being fixed?

  • Implementation of Commissionable Node advertisement in the new request-commissioning CHIPTool command.

Change overview

  • This PR adds the basic skeleton for the request-commissioning command on the CLI CHIPTool and initiates advertisement of the tool as a Commissionable Node.
  • More actions like sending a UDC request, entering commissioning mode, etc. will be implemented as part of the same command later on, in separate PRs.

Testing

Tested by running the new request-commissioning command on the CHIPTool and verifying using minimal-mdns-client that a commissionable node is advertised. See outputs below from each command:

$> ./chip-tool pairing request-commissioning
[1623962271.779161][33013] CHIP:IN: TransportMgr initialized
[1623962271.779210][33013] CHIP:DIS: Init admin pairing table with server storage
[1623962271.779507][33013] CHIP:IN: Loading certs from KVS
[1623962271.779555][33013] CHIP:IN: local node id is 0x000000000001B669
[1623962271.780311][33013] CHIP:ZCL: Using ZAP configuration...
[1623962271.780371][33013] CHIP:ZCL: deactivate report event
[1623962271.780435][33013] CHIP:CTL: Getting operational keys
[1623962271.780447][33013] CHIP:CTL: Generating credentials
[1623962271.780577][33013] CHIP:CTL: Loaded credentials successfully
[1623962271.781020][33013] CHIP:DIS: CHIP minimal mDNS started advertising.
[1623962271.781126][33013] CHIP:DIS: Replying to DNS-SD service listing request
[1623962271.781183][33013] CHIP:DIS: Replying to DNS-SD service listing request
[1623962271.781216][33013] CHIP:DIS: Replying to DNS-SD service listing request
[1623962271.781248][33013] CHIP:DIS: Replying to DNS-SD service listing request
[1623962271.781281][33013] CHIP:DIS: Replying to DNS-SD service listing request
[1623962271.781295][33013] CHIP:DL: wpa_supplicant: _IsWiFiStationProvisioned: interface not connected
[1623962271.784222][33013] CHIP:DIS: Using wifi MAC for hostname
[1623962271.784364][33013] CHIP:DL: rotatingDeviceId: 0000490C1FF0DB5910AD14994F162DB850F3
[1623962271.784378][33013] CHIP:DIS: Advertise commission parameter vendorID=9050 productID=65279 discriminator=2976/160
[1623962271.784405][33013] CHIP:DIS: CHIP minimal mDNS configured as 'Commissionable node device'.
[1623962271.784417][33013] CHIP:TOO: Waiting for 30 sec
[1623962271.781380][33018] CHIP:DL: CHIP task running
[1623962288.933834][33018] CHIP:DIS: Directly sending mDns reply to peer on port 5388
[1623962288.935128][33018] CHIP:DIS: Directly sending mDns reply to peer on port 5388
[1623962288.936404][33018] CHIP:DIS: Directly sending mDns reply to peer on port 5388
[1623962288.937910][33018] CHIP:DIS: Directly sending mDns reply to peer on port 5388
[1623962288.939446][33018] CHIP:DIS: Directly sending mDns reply to peer on port 5388
[1623962288.942679][33018] CHIP:DIS: Directly sending mDns reply to peer on port 5388
[1623962301.785356][33013] CHIP:TOO: No response from device
[1623962301.786065][33013] CHIP:CTL: Shutting down the commissioner
[1623962301.786123][33013] CHIP:CTL: Shutting down the controller
[1623962301.786139][33013] CHIP:DL: Inet Layer shutdown
[1623962301.786232][33013] CHIP:DL: BLE layer shutdown
[1623962301.786248][33013] CHIP:DL: System Layer shutdown

$> ./minimal-mdns-client -q _chipc._udp.local
Running...
Usable interface: eth0 (2)
Usable interface: services1 (5)
Usable interface: docker0 (7)
[1623962288.932292][33112] CHIP:DIS: Attempt to mDNS broadcast to an unreachable destination.
RESPONSE from: fe80::50:ff:fe00:1 on port 5353, via interface 2
RESPONSE: REPLY 4660 (1, 1, 0, 4):
RESPONSE:     QUERY ANY/IN UNICAST: _chipc._udp.local.
RESPONSE:     ANSWER PTR/IN ttl 120: _chipc._udp.local.
RESPONSE:       PTR:  1F2958EC944A5CFF._chipc._udp.local.
RESPONSE:     ADDITIONAL SRV/IN ttl 120: 1F2958EC944A5CFF._chipc._udp.local.
RESPONSE:       SRV on port 11097, priority 0, weight 0:  025000000001.local.
RESPONSE:     ADDITIONAL AAAA/IN ttl 120: 025000000001.local.
RESPONSE:       IP:  fe80::50:ff:fe00:1
RESPONSE:     ADDITIONAL A/IN ttl 120: 025000000001.local.
RESPONSE:       IP:  192.168.65.3
RESPONSE:     ADDITIONAL TXT/IN ttl 4500: 1F2958EC944A5CFF._chipc._udp.local.
RESPONSE:     TXT:  'VP' = '9050+65279'
RESPONSE:     TXT:  'D' = '2976'
RESPONSE:     TXT:  'CM' = '1'
RESPONSE:     TXT:  'RI' = '0000490C1FF0DB5910AD14994F162DB850F3'
RESPONSE:     TXT:  'PH' = '33'
RESPONSE:     TXT:  'PI' = ''
RESPONSE from: fe80::50:ff:fe00:1 on port 5353, via interface 2
RESPONSE: REPLY 4660 (1, 1, 0, 4):
RESPONSE:     QUERY ANY/IN UNICAST: _chipc._udp.local.
RESPONSE:     ANSWER PTR/IN ttl 120: _chipc._udp.local.
RESPONSE:       PTR:  1F2958EC944A5CFF._chipc._udp.local.
RESPONSE:     ADDITIONAL SRV/IN ttl 120: 1F2958EC944A5CFF._chipc._udp.local.
RESPONSE:       SRV on port 11097, priority 0, weight 0:  025000000001.local.
RESPONSE:     ADDITIONAL AAAA/IN ttl 120: 025000000001.local.
RESPONSE:       IP:  fe80::50:ff:fe00:1
RESPONSE:     ADDITIONAL A/IN ttl 120: 025000000001.local.
RESPONSE:       IP:  192.168.65.3
RESPONSE:     ADDITIONAL TXT/IN ttl 4500: 1F2958EC944A5CFF._chipc._udp.local.
RESPONSE:     TXT:  'VP' = '9050+65279'
RESPONSE:     TXT:  'D' = '2976'
RESPONSE:     TXT:  'CM' = '1'
RESPONSE:     TXT:  'RI' = '0000490C1FF0DB5910AD14994F162DB850F3'
RESPONSE:     TXT:  'PH' = '33'
RESPONSE:     TXT:  'PI' = ''
RESPONSE from: fe80::50:ff:fe00:1 on port 5353, via interface 2
RESPONSE: REPLY 4660 (1, 1, 0, 4):
RESPONSE:     QUERY ANY/IN UNICAST: _chipc._udp.local.
RESPONSE:     ANSWER PTR/IN ttl 120: _chipc._udp.local.
RESPONSE:       PTR:  1F2958EC944A5CFF._chipc._udp.local.
RESPONSE:     ADDITIONAL SRV/IN ttl 120: 1F2958EC944A5CFF._chipc._udp.local.
RESPONSE:       SRV on port 11097, priority 0, weight 0:  025000000001.local.
RESPONSE:     ADDITIONAL AAAA/IN ttl 120: 025000000001.local.
RESPONSE:       IP:  fe80::50:ff:fe00:1
RESPONSE:     ADDITIONAL A/IN ttl 120: 025000000001.local.
RESPONSE:       IP:  192.168.65.3
RESPONSE:     ADDITIONAL TXT/IN ttl 4500: 1F2958EC944A5CFF._chipc._udp.local.
RESPONSE:     TXT:  'VP' = '9050+65279'
RESPONSE:     TXT:  'D' = '2976'
RESPONSE:     TXT:  'CM' = '1'
RESPONSE:     TXT:  'RI' = '0000490C1FF0DB5910AD14994F162DB850F3'
RESPONSE:     TXT:  'PH' = '33'
RESPONSE:     TXT:  'PI' = ''
RESPONSE from: fe80::f0c6:79ff:fe6e:4308 on port 5353, via interface 5
RESPONSE: REPLY 4660 (1, 1, 0, 4):
RESPONSE:     QUERY ANY/IN UNICAST: _chipc._udp.local.
RESPONSE:     ANSWER PTR/IN ttl 120: _chipc._udp.local.
RESPONSE:       PTR:  1F2958EC944A5CFF._chipc._udp.local.
RESPONSE:     ADDITIONAL SRV/IN ttl 120: 1F2958EC944A5CFF._chipc._udp.local.
RESPONSE:       SRV on port 11097, priority 0, weight 0:  025000000001.local.
RESPONSE:     ADDITIONAL AAAA/IN ttl 120: 025000000001.local.
RESPONSE:       IP:  fe80::f0c6:79ff:fe6e:4308
RESPONSE:     ADDITIONAL A/IN ttl 120: 025000000001.local.
RESPONSE:       IP:  192.168.65.4
RESPONSE:     ADDITIONAL TXT/IN ttl 4500: 1F2958EC944A5CFF._chipc._udp.local.
RESPONSE:     TXT:  'VP' = '9050+65279'
RESPONSE:     TXT:  'D' = '2976'
RESPONSE:     TXT:  'CM' = '1'
RESPONSE:     TXT:  'RI' = '0000490C1FF0DB5910AD14994F162DB850F3'
RESPONSE:     TXT:  'PH' = '33'
RESPONSE:     TXT:  'PI' = ''
RESPONSE from: fe80::f0c6:79ff:fe6e:4308 on port 5353, via interface 5
RESPONSE: REPLY 4660 (1, 1, 0, 4):
RESPONSE:     QUERY ANY/IN UNICAST: _chipc._udp.local.
RESPONSE:     ANSWER PTR/IN ttl 120: _chipc._udp.local.
RESPONSE:       PTR:  1F2958EC944A5CFF._chipc._udp.local.
RESPONSE:     ADDITIONAL SRV/IN ttl 120: 1F2958EC944A5CFF._chipc._udp.local.
RESPONSE:       SRV on port 11097, priority 0, weight 0:  025000000001.local.
RESPONSE:     ADDITIONAL AAAA/IN ttl 120: 025000000001.local.
RESPONSE:       IP:  fe80::f0c6:79ff:fe6e:4308
RESPONSE:     ADDITIONAL A/IN ttl 120: 025000000001.local.
RESPONSE:       IP:  192.168.65.4
RESPONSE:     ADDITIONAL TXT/IN ttl 4500: 1F2958EC944A5CFF._chipc._udp.local.
RESPONSE:     TXT:  'VP' = '9050+65279'
RESPONSE:     TXT:  'D' = '2976'
RESPONSE:     TXT:  'CM' = '1'
RESPONSE:     TXT:  'RI' = '0000490C1FF0DB5910AD14994F162DB850F3'
RESPONSE:     TXT:  'PH' = '33'
RESPONSE:     TXT:  'PI' = ''
RESPONSE from: fe80::f0c6:79ff:fe6e:4308 on port 5353, via interface 5
RESPONSE: REPLY 4660 (1, 1, 0, 4):
RESPONSE:     QUERY ANY/IN UNICAST: _chipc._udp.local.
RESPONSE:     ANSWER PTR/IN ttl 120: _chipc._udp.local.
RESPONSE:       PTR:  1F2958EC944A5CFF._chipc._udp.local.
RESPONSE:     ADDITIONAL SRV/IN ttl 120: 1F2958EC944A5CFF._chipc._udp.local.
RESPONSE:       SRV on port 11097, priority 0, weight 0:  025000000001.local.
RESPONSE:     ADDITIONAL AAAA/IN ttl 120: 025000000001.local.
RESPONSE:       IP:  fe80::f0c6:79ff:fe6e:4308
RESPONSE:     ADDITIONAL A/IN ttl 120: 025000000001.local.
RESPONSE:       IP:  192.168.65.4
RESPONSE:     ADDITIONAL TXT/IN ttl 4500: 1F2958EC944A5CFF._chipc._udp.local.
RESPONSE:     TXT:  'VP' = '9050+65279'
RESPONSE:     TXT:  'D' = '2976'
RESPONSE:     TXT:  'CM' = '1'
RESPONSE:     TXT:  'RI' = '0000490C1FF0DB5910AD14994F162DB850F3'
RESPONSE:     TXT:  'PH' = '33'
RESPONSE:     TXT:  'PI' = ''
[1623962289.434855][33112] CHIP:DL: Inet Layer shutdown
[1623962289.435056][33112] CHIP:DL: BLE layer shutdown
[1623962289.435087][33112] CHIP:DL: System Layer shutdown
Done...

@todo
Copy link

todo bot commented Jun 17, 2021

ReturnErrorOnFailure(mCommissionableNodeController.SendUserDirectedCommissioningRequest(args...));

// TODO: ReturnErrorOnFailure(mCommissionableNodeController.SendUserDirectedCommissioningRequest(args...));
ChipLogProgress(chipTool, "Waiting for %d sec", kWaitDurationInSeconds);
}
WaitForResponse(kWaitDurationInSeconds);
return CHIP_NO_ERROR;
}


This comment was generated by todo based on a TODO comment in 621d6e8 in #7729. cc @sharadb-amazon.

@todo
Copy link

todo bot commented Jun 17, 2021

integrate with Server:SendUserDirectedCommissioningRequest()

// TODO: integrate with Server:SendUserDirectedCommissioningRequest()
ChipLogError(Controller, "Unsupported operation CommissionableNodeController::SendUserDirectedCommissioningRequest");
return CHIP_ERROR_NOT_IMPLEMENTED;
}
} // namespace Controller
} // namespace chip


This comment was generated by todo based on a TODO comment in 621d6e8 in #7729. cc @sharadb-amazon.

Copy link
Contributor

@chrisdecenzo chrisdecenzo left a comment

Choose a reason for hiding this comment

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

seems straight forward


constexpr uint16_t kWaitDurationInSeconds = 30;

CHIP_ERROR RequestCommissioningCommand::Run(NodeId localId, NodeId remoteId)
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 surprised that localId and remoteId are the right arguments for this. The UDC command sends the instance name (which is not the nodeId) to the IP and port specified in the SRV record of the selected commissioner. Is there code to derive those values from the remoteId in the "SendUserDirectedCommissioningRequest" command?

Copy link
Contributor

@bzbarsky-apple bzbarsky-apple Jun 18, 2021

Choose a reason for hiding this comment

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

I'm surprised that localId and remoteId are the right arguments for this.

Those are the arguments that currently all commands get; the virtual Run method has those arguments. Some commands completely ignore them (and indeed don't get useful ones); the QR code parsing commands are a good example. In addition to these args commands can have whatever members are initialized via the command line. The args are just a way to avoid having to keep passing in node ids on the command line for various IM bits once you've set them up with one of the "pairing" commands....

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 did not really have a use for the passed down localId or remoteId, but didn't have a choice to stop them from being passed.
As for deriving the instance name, looking at https://github.com/project-chip/connectedhomeip/pull/6790/files I believe the GetCommissionableInstanceName() function could be used?

@msandstedt msandstedt self-requested a review June 22, 2021 18:49
ChipLogProgress(chipTool, "Waiting for %d sec", kWaitDurationInSeconds);
}

WaitForResponse(kWaitDurationInSeconds);
Copy link
Contributor

Choose a reason for hiding this comment

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

Where will the response come from, exactly? This looks like it'll just sit here for 30 seconds and then time out...

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The response would be expected from a Device Commissioner on the network that receives the User Directed commissioning request as described in step # 9 in https://github.com/CHIP-Specifications/connectedhomeip-spec/blob/master/src/rendezvous/InitiatingSetup.adoc#242-high-level-flow - the call to sendUDC method would be included in a follow-up PR (trying to keep diffs for review manageable).

#endif
}

CHIP_ERROR CommissionableNodeController::SendUserDirectedCommissioningRequest(chip::Inet::IPAddress commissioner, uint16_t port)
Copy link
Contributor

Choose a reason for hiding this comment

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

Where would the input to this function come from?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It would come from the user in the form of a command line argument to this command as per step # 5 in https://github.com/CHIP-Specifications/connectedhomeip-spec/blob/master/src/rendezvous/InitiatingSetup.adoc#242-high-level-flow (in a follow-up PR).

@msandstedt
Copy link
Contributor

This generally looks good to me. I believe, however, it will need a slight refactor to conform to #7829.

@github-actions
Copy link

Size increase report for "esp32-example-build" from 039dfbd

File Section File VM
chip-all-clusters-app.elf .flash.text 4 4
Full report output
BLOAT REPORT

Files found only in the build output:
    report.csv

Comparing ./master_artifact/chip-pigweed-app.elf and ./pull_artifact/chip-pigweed-app.elf:

sections,vmsize,filesize

Comparing ./master_artifact/chip-all-clusters-app.elf and ./pull_artifact/chip-all-clusters-app.elf:

sections,vmsize,filesize
.debug_loc,0,84
.debug_info,0,54
.debug_line,0,34
.debug_ranges,0,32
.flash.text,4,4
.debug_str,0,2
.debug_abbrev,0,-30


@@ -18,6 +18,9 @@ static_library("controller") {
output_name = "libChipController"

sources = [
"${chip_root}/src/app/server/Mdns.cpp",
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 do this.

A source file should belong to one library at a time which determines its options (defines, include dirs, etc). If you want to share code, create a new library and make it a dependency.

mspang added a commit that referenced this pull request Jul 5, 2021
nikita-s-wrk pushed a commit to nikita-s-wrk/connectedhomeip that referenced this pull request Sep 23, 2021
nikita-s-wrk pushed a commit to nikita-s-wrk/connectedhomeip that referenced this pull request Sep 23, 2021
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