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

RPC: Refactor to share common code between examples #9444

Merged
merged 1 commit into from
Sep 15, 2021

Conversation

rgoliver
Copy link

@rgoliver rgoliver commented Sep 2, 2021

Problem

As more examples get RPC support it is clear that a lot of code is unnecessarily duplicated.

Change overview

  • Move the common RPC services into a common location and have default virtual implementations which use the ember API.
  • Applications can customize the behavior when necessary by overriding the methods.
  • Also cleanup the lighting proto to better match the spec.

Testing

  • Tested the RPC version of the lighting app on EFR NRF and Linux and ensured Device, Lighting, and Button RPC's worked as expected.
  • Tested the ESP RPC locking app compiled with RPCs (Don't have the correct board to test functionality)
  • Tested the ESP RPC all-clusters app and verified Device, Lighting, and Button RPC's worked as expected.

@todo
Copy link

todo bot commented Sep 2, 2021

auto err = DeviceLayer::SoftwareUpdateMgr().CheckNow();

// TODO: auto err = DeviceLayer::SoftwareUpdateMgr().CheckNow();
return pw::Status::Unimplemented();
}
virtual pw::Status GetDeviceInfo(ServerContext &, const pw_protobuf_Empty & request, chip_rpc_DeviceInfo & response)
{
response.vendor_id = CHIP_DEVICE_CONFIG_DEVICE_VENDOR_ID;
response.product_id = CHIP_DEVICE_CONFIG_DEVICE_PRODUCT_ID;
response.software_version = CHIP_DEVICE_CONFIG_DEVICE_FIRMWARE_REVISION;
snprintf(response.serial_number, sizeof(response.serial_number), CHIP_DEVICE_CONFIG_TEST_SERIAL_NUMBER);
return pw::OkStatus();


This comment was generated by todo based on a TODO comment in 0651c3f in #9444. cc @rgoliver.

@todo
Copy link

todo bot commented Sep 7, 2021

auto err = DeviceLayer::SoftwareUpdateMgr().CheckNow();

// TODO: auto err = DeviceLayer::SoftwareUpdateMgr().CheckNow();
return pw::Status::Unimplemented();
}
virtual pw::Status GetDeviceInfo(ServerContext &, const pw_protobuf_Empty & request, chip_rpc_DeviceInfo & response)
{
response.vendor_id = CHIP_DEVICE_CONFIG_DEVICE_VENDOR_ID;
response.product_id = CHIP_DEVICE_CONFIG_DEVICE_PRODUCT_ID;
response.software_version = CHIP_DEVICE_CONFIG_DEVICE_FIRMWARE_REVISION;
snprintf(response.serial_number, sizeof(response.serial_number), CHIP_DEVICE_CONFIG_TEST_SERIAL_NUMBER);
return pw::OkStatus();


This comment was generated by todo based on a TODO comment in d8067bb in #9444. cc @rgoliver.

@todo
Copy link

todo bot commented Sep 7, 2021

auto err = DeviceLayer::SoftwareUpdateMgr().CheckNow();

// TODO: auto err = DeviceLayer::SoftwareUpdateMgr().CheckNow();
return pw::Status::Unimplemented();
}
virtual pw::Status GetDeviceInfo(ServerContext &, const pw_protobuf_Empty & request, chip_rpc_DeviceInfo & response)
{
response.vendor_id = CHIP_DEVICE_CONFIG_DEVICE_VENDOR_ID;
response.product_id = CHIP_DEVICE_CONFIG_DEVICE_PRODUCT_ID;
response.software_version = CHIP_DEVICE_CONFIG_DEVICE_FIRMWARE_REVISION;
snprintf(response.serial_number, sizeof(response.serial_number), CHIP_DEVICE_CONFIG_TEST_SERIAL_NUMBER);
return pw::OkStatus();


This comment was generated by todo based on a TODO comment in 230a62d in #9444. cc @rgoliver.

@todo
Copy link

todo bot commented Sep 7, 2021

auto err = DeviceLayer::SoftwareUpdateMgr().CheckNow();

// TODO: auto err = DeviceLayer::SoftwareUpdateMgr().CheckNow();
return pw::Status::Unimplemented();
}
virtual pw::Status GetDeviceInfo(ServerContext &, const pw_protobuf_Empty & request, chip_rpc_DeviceInfo & response)
{
response.vendor_id = CHIP_DEVICE_CONFIG_DEVICE_VENDOR_ID;
response.product_id = CHIP_DEVICE_CONFIG_DEVICE_PRODUCT_ID;
response.software_version = CHIP_DEVICE_CONFIG_DEVICE_FIRMWARE_REVISION;
snprintf(response.serial_number, sizeof(response.serial_number), CHIP_DEVICE_CONFIG_TEST_SERIAL_NUMBER);
return pw::OkStatus();


This comment was generated by todo based on a TODO comment in 914e859 in #9444. cc @rgoliver.

examples/common/pigweed/rpc_services/Lighting.h Outdated Show resolved Hide resolved
examples/common/pigweed/rpc_services/Lighting.h Outdated Show resolved Hide resolved
examples/lighting-app/linux/BUILD.gn Outdated Show resolved Hide resolved
@todo
Copy link

todo bot commented Sep 13, 2021

auto err = DeviceLayer::SoftwareUpdateMgr().CheckNow();

// TODO: auto err = DeviceLayer::SoftwareUpdateMgr().CheckNow();
return pw::Status::Unimplemented();
}
virtual pw::Status GetDeviceInfo(ServerContext &, const pw_protobuf_Empty & request, chip_rpc_DeviceInfo & response)
{
response.vendor_id = CHIP_DEVICE_CONFIG_DEVICE_VENDOR_ID;
response.product_id = CHIP_DEVICE_CONFIG_DEVICE_PRODUCT_ID;
response.software_version = CHIP_DEVICE_CONFIG_DEVICE_FIRMWARE_REVISION;
snprintf(response.serial_number, sizeof(response.serial_number), CHIP_DEVICE_CONFIG_TEST_SERIAL_NUMBER);
return pw::OkStatus();


This comment was generated by todo based on a TODO comment in ae62dcc in #9444. cc @rgoliver.

@todo
Copy link

todo bot commented Sep 13, 2021

auto err = DeviceLayer::SoftwareUpdateMgr().CheckNow();

// TODO: auto err = DeviceLayer::SoftwareUpdateMgr().CheckNow();
return pw::Status::Unimplemented();
}
virtual pw::Status GetDeviceInfo(ServerContext &, const pw_protobuf_Empty & request, chip_rpc_DeviceInfo & response)
{
response.vendor_id = CHIP_DEVICE_CONFIG_DEVICE_VENDOR_ID;
response.product_id = CHIP_DEVICE_CONFIG_DEVICE_PRODUCT_ID;
response.software_version = CHIP_DEVICE_CONFIG_DEVICE_FIRMWARE_REVISION;
snprintf(response.serial_number, sizeof(response.serial_number), CHIP_DEVICE_CONFIG_TEST_SERIAL_NUMBER);
return pw::OkStatus();


This comment was generated by todo based on a TODO comment in c14d2f4 in #9444. cc @rgoliver.

Move the common RPC services into a common location and have
default virtual implementations which use the ember API.

Applications can customize the behaviour when neccessary by
overriding the methods.

Also cleanup the lighting proto to better match the spec.
@todo
Copy link

todo bot commented Sep 13, 2021

auto err = DeviceLayer::SoftwareUpdateMgr().CheckNow();

// TODO: auto err = DeviceLayer::SoftwareUpdateMgr().CheckNow();
return pw::Status::Unimplemented();
}
virtual pw::Status GetDeviceInfo(ServerContext &, const pw_protobuf_Empty & request, chip_rpc_DeviceInfo & response)
{
response.vendor_id = CHIP_DEVICE_CONFIG_DEVICE_VENDOR_ID;
response.product_id = CHIP_DEVICE_CONFIG_DEVICE_PRODUCT_ID;
response.software_version = CHIP_DEVICE_CONFIG_DEVICE_FIRMWARE_REVISION;
snprintf(response.serial_number, sizeof(response.serial_number), CHIP_DEVICE_CONFIG_TEST_SERIAL_NUMBER);
return pw::OkStatus();


This comment was generated by todo based on a TODO comment in 8bdddd7 in #9444. cc @rgoliver.

@github-actions
Copy link

Size increase report for "esp32-example-build" from 92d3a28

File Section File VM
chip-lock-app.elf .flash.text -60 -60
chip-temperature-measurement-app.elf .flash.text 36 36
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_info,0,1
.debug_loc,0,-1

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

sections,vmsize,filesize
.debug_abbrev,0,44
.debug_info,0,3
.debug_loc,0,1

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

sections,vmsize,filesize
[Unmapped],0,60
.xt.prop._ZNK4chip4SpanIhE7SubSpanEjj,0,12
.xt.lit._ZNK4chip4SpanIhE7SubSpanEjj,0,8
.debug_info,0,1
.debug_loc,0,-5
.flash.text,-60,-60

Comparing ./master_artifact/chip-shell.elf and ./pull_artifact/chip-shell.elf:

sections,vmsize,filesize
.debug_abbrev,0,44
.debug_info,0,3
.debug_loc,0,1

Comparing ./master_artifact/chip-temperature-measurement-app.elf and ./pull_artifact/chip-temperature-measurement-app.elf:

sections,vmsize,filesize
.debug_abbrev,0,44
.flash.text,36,36
.debug_info,0,3
.debug_loc,0,1
[Unmapped],0,-36

Comparing ./master_artifact/chip-persistent-storage.elf and ./pull_artifact/chip-persistent-storage.elf:

sections,vmsize,filesize

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

sections,vmsize,filesize


@mspang mspang merged commit 8b1cac7 into project-chip:master Sep 15, 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.

5 participants