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

Python: Add TestOnlyCommissionableDataProvider to pychip_server_native_init() #22498

Merged
merged 4 commits into from
Oct 3, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
4 changes: 2 additions & 2 deletions scripts/build_python_device.sh
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ gn --root="$CHIP_ROOT" gen "$OUTPUT_ROOT" --args="chip_detail_logging=$chip_deta
if [ "$enable_pybindings" == true ]; then
ninja -v -C "$OUTPUT_ROOT" pycontroller
else
ninja -v -C "$OUTPUT_ROOT" chip-library
ninja -v -C "$OUTPUT_ROOT" chip-core
fi

# Create a virtual environment that has access to the built python tools
Expand All @@ -115,7 +115,7 @@ virtualenv --clear "$ENVIRONMENT_ROOT"
if [ "$enable_pybindings" == true ]; then
WHEEL=("$OUTPUT_ROOT"/pybindings/pycontroller/pychip-*.whl)
else
WHEEL=("$OUTPUT_ROOT"/controller/python/chip_library*.whl)
WHEEL=("$OUTPUT_ROOT"/controller/python/chip_core*.whl)
fi

source "$ENVIRONMENT_ROOT"/bin/activate
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,
)