Skip to content

Commit

Permalink
Python: Add TestOnlyCommissionableDataProvider to pychip_server_nativ…
Browse files Browse the repository at this point in the history
…e_init() (#22498)

* build_python_device.sh: use chip-core instead of chip-library

* Python: Add TestOnlyCommissionableDataProvider to pychip_server_native_init()

* Python: use Example DAC Provider in pychip_server_native_init()

* Python: use MatterPostAttributeChangeCallback (instead of emberAfPostAttributeChangeCallback)
  • Loading branch information
sandeepmistry authored and pull[bot] committed Sep 21, 2023
1 parent e9cd2e4 commit 1792820
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 9 deletions.
1 change: 0 additions & 1 deletion examples/lighting-app/python/lighting.py
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,6 @@ def attributeChangeCallback(
endpoint: int,
clusterId: int,
attributeId: int,
manufacturerCode: int,
xx_type: int,
size: int,
value: bytes,
Expand Down
19 changes: 13 additions & 6 deletions src/controller/python/chip/server/ServerInit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

#include <platform/CHIPDeviceLayer.h>
#include <platform/PlatformManager.h>
#include <platform/TestOnlyCommissionableDataProvider.h>

#include <app/server/OnboardingCodesUtil.h>
#include <app/server/Server.h>
Expand All @@ -29,6 +30,8 @@
#include <setup_payload/QRCodeSetupPayloadGenerator.h>
#include <setup_payload/SetupPayload.h>

#include <credentials/examples/DeviceAttestationCredsExample.h>

// #include <support/CHIPMem.h>
// #include <support/ErrorStr.h>

Expand Down Expand Up @@ -98,8 +101,8 @@ static bool EnsureWiFiIsStarted()
}
#endif

using PostAttributeChangeCallback = void (*)(EndpointId endpoint, ClusterId clusterId, AttributeId attributeId,
uint16_t manufacturerCode, uint8_t type, uint16_t size, uint8_t * value);
using PostAttributeChangeCallback = void (*)(EndpointId endpoint, ClusterId clusterId, AttributeId attributeId, uint8_t type,
uint16_t size, uint8_t * value);

class PythonServerDelegate // : public ServerDelegate
{
Expand Down Expand Up @@ -138,6 +141,9 @@ void pychip_server_native_init()
ChipLogError(DeviceLayer, "Failed to initialize CHIP stack: platform init failed: %s", chip::ErrorStr(err));
}

static chip::DeviceLayer::TestOnlyCommissionableDataProvider TestOnlyCommissionableDataProvider;
chip::DeviceLayer::SetCommissionableDataProvider(&TestOnlyCommissionableDataProvider);

ConfigurationMgr().LogDeviceConfig();

PrintOnboardingCodes(chip::RendezvousInformationFlag(chip::RendezvousInformationFlag::kBLE));
Expand Down Expand Up @@ -177,7 +183,7 @@ void pychip_server_native_init()
chip::Server::GetInstance().Init(initParams);

// Initialize device attestation config
// SetDeviceAttestationCredentialsProvider(Examples::GetExampleDACProvider());
SetDeviceAttestationCredentialsProvider(chip::Credentials::Examples::GetExampleDACProvider());

result = pthread_create(&sPlatformMainThread, nullptr, PlatformMainLoop, nullptr);
tmpErrno = errno;
Expand All @@ -191,14 +197,15 @@ void pychip_server_native_init()
}
}

void emberAfPostAttributeChangeCallback(chip::EndpointId endpoint, chip::ClusterId clusterId, chip::AttributeId attributeId,
uint16_t manufacturerCode, uint8_t type, uint16_t size, uint8_t * value)
void MatterPostAttributeChangeCallback(const chip::app::ConcreteAttributePath & attributePath, uint8_t type, uint16_t size,
uint8_t * value)
{
// ChipLogProgress(NotSpecified, "emberAfPostAttributeChangeCallback()");
if (gPythonServerDelegate.mPostAttributeChangeCallback != nullptr)
{
// ChipLogProgress(NotSpecified, "callback %p", gPythonServerDelegate.mPostAttributeChangeCallback);
gPythonServerDelegate.mPostAttributeChangeCallback(endpoint, clusterId, attributeId, manufacturerCode, type, size, value);
gPythonServerDelegate.mPostAttributeChangeCallback(attributePath.mEndpointId, attributePath.mClusterId,
attributePath.mAttributeId, type, size, value);
}
else
{
Expand Down
2 changes: 0 additions & 2 deletions src/controller/python/chip/server/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,5 @@
c_uint16,
c_uint8,
c_uint16,
c_uint8,
c_uint16,
c_char_p,
)

0 comments on commit 1792820

Please sign in to comment.