project-chip / connectedhomeip

Matter (formerly Project CHIP) creates more connections between more objects, simplifying development for manufacturers and increasing compatibility for consumers, guided by the Connectivity Standards Alliance.
https://buildwithmatter.com
Apache License 2.0
7.49k stars 2.01k forks source link

[Platform] Python API clean up -- use structs for params #25214

Open erjiaqing opened 1 year ago

erjiaqing commented 1 year ago

Reproduction steps

We have lots of APIs looks like:

PyChipError pychip_OpCreds_AllocateController(OpCredsContext * context, chip::Controller::DeviceCommissioner ** outDevCtrl,
                                              FabricId fabricId, chip::NodeId nodeId, chip::VendorId adminVendorId,
                                              const char * paaTrustStorePath, bool useTestCommissioner,
                                              bool enableServerInteractions, CASEAuthTag * caseAuthTags, uint32_t caseAuthTagLen,
                                              chip::python::pychip_P256Keypair * operationalKey)

Which is hard to maintain, it would be nice to define a struct:

struct AllocateControllerParams {
OpCredsContext * context;
FabricId fabricId;
chip::NodeId nodeId;
chip::VendorId adminVendorId;
const char * paaTrustStorePath;
bool useTestCommissioner;
bool enableServerInteractions;
CASEAuthTag * caseAuthTags;
uint32_t caseAuthTagLen;
chip::python::pychip_P256Keypair * operationalKey;
};

And rewrite it into:

PyChipError pychip_OpCreds_AllocateController(const AllocateControllerParams* params, chip::Controller::DeviceCommissioner ** outDevCtrl);

To make it clearer.

Platform

python

Platform Version(s)

No response

Type

CI tested

(Optional) If manually tested please explain why this is only manually tested

No response

Anything else?

No response

stale[bot] commented 1 year ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs.