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

Initial support for adding codegen for interaction model #4298

Merged
merged 48 commits into from
Jan 29, 2021

Conversation

erjiaqing
Copy link
Contributor

@erjiaqing erjiaqing commented Jan 8, 2021

Problem

Interaction model is merged but not enabled.

Summary of Changes

This PR implemented ZAP templates and some necessary API in device and controller to support interaction model.

Testing

  1. Build chip-device-controller and linux lighting app with new interaction model enabled.
    Useful snippet for device controller:
    ./gn_build.sh chip_devctrl_use_interaction_model=true chip_app_use_interation_model=true && (yes | sudo pip3 uninstall chip) && sudo pip3 install ./out/debug/linux_arm64_clang/controller/python/chip-0.0-cp38-cp38-linux_aarch64.whl

Build linux lighting app:
gn gen out --args="chip_app_use_interation_model=true" && ninja -C out

1.5 Config IPv6 address on device running controller and device running lighting app

  1. Run chip-device-controller and linux lighting app

  2. In chip-device-controller, run:

connect -ip fd12::2 12345678
zcl OnOff Toggle 12344321 1 0

Fixes #4253

@andy31415
Copy link
Contributor

Size diff reports 4K extra code and 1K extra BSS. Are these size diffs expected?

src/app/im-encoder.cpp Outdated Show resolved Hide resolved
src/app/im-encoder.cpp Outdated Show resolved Hide resolved
TLV::TLVType dummyType = TLV::kTLVType_NotSpecified;

uint8_t argSeqNumber = 0;
(void) argSeqNumber;
Copy link
Contributor

Choose a reason for hiding this comment

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

this (void) does not seem needed as argSeqNumber is used. Same below.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is a generated code, some commands does not have arguments and compiler will complain.

Copy link
Contributor

Choose a reason for hiding this comment

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

Can code generation detect this?

Ideally I would like even generated code to be readable and look close to human-generated. an (if no arguments, add void statement) seems to be easy enough to place in a template.

Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe zcl_command_arguments_count ?

src/controller/python/chip/ChipCluster.py Outdated Show resolved Hide resolved
src/controller/python/chip/ChipCluster.py Outdated Show resolved Hide resolved
src/controller/python/chip/ChipExceptions.py Outdated Show resolved Hide resolved
src/controller/python/chip/ChipExceptions.py Outdated Show resolved Hide resolved
src/controller/python/chip/ChipExceptions.py Outdated Show resolved Hide resolved
build/config/BUILDCONFIG.gn Outdated Show resolved Hide resolved
src/app/im-encoder.cpp Outdated Show resolved Hide resolved
src/controller/python/chip-device-ctrl.py Show resolved Hide resolved
src/controller/python/chip/ChipCluster.py Outdated Show resolved Hide resolved
Copy link
Contributor

@rwalker-apple rwalker-apple left a comment

Choose a reason for hiding this comment

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

please request my re-review once @mspang's comments are addressed

@erjiaqing erjiaqing requested review from mspang and andy31415 January 12, 2021 04:01
@@ -202,6 +205,9 @@ CHIP_ERROR nl_Chip_Stack_Shutdown();
const char * nl_Chip_Stack_ErrorToString(CHIP_ERROR err);
Copy link
Contributor

Choose a reason for hiding this comment

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

nit for future PRs: will we remove/replace the "nl_" prefix at some point?

@woody-apple
Copy link
Contributor

@mspang, are your comments all resolved?

return CHIP_ERROR_NO_MEMORY;
}

strncpy(value, val->second.c_str(), val->second.size() + 1);
Copy link
Contributor

Choose a reason for hiding this comment

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

memcpy?

{
mStorage[key] = value;
ChipLogDetail(Controller, "SetKeyValue: K=%s", key);
ChipLogDetail(Controller, "SetKeyValue: V=%s", value);
Copy link
Contributor

Choose a reason for hiding this comment

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

Why separate logs for key and value?

@BroderickCarlin BroderickCarlin merged commit a77a662 into project-chip:master Jan 29, 2021
austinh0 pushed a commit to austinh0/connectedhomeip that referenced this pull request Feb 3, 2021
austinh0 pushed a commit to austinh0/connectedhomeip that referenced this pull request Feb 3, 2021
austinh0 pushed a commit to austinh0/connectedhomeip that referenced this pull request Feb 4, 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.

Integrate Invoke Command APIs into ZAP codegen
10 participants