Skip to content

Commit

Permalink
[nrf noup] Fix Enhanced Commissioning Window
Browse files Browse the repository at this point in the history
The admin ECM command would ignore the input passcode.
Also, the JNI layer would incorrectly use the method which
generates the passcode randomly despite of having a text box
for inputing the passcode.
  • Loading branch information
Damian-Nordic committed Dec 2, 2021
1 parent af75642 commit 1547488
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 9 deletions.
6 changes: 4 additions & 2 deletions examples/chip-tool/commands/pairing/PairingCommand.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -176,8 +176,10 @@ void PairingCommand::OnOpenCommissioningWindowResponse(void * context, NodeId re

CHIP_ERROR PairingCommand::OpenCommissioningWindow()
{
return mController.OpenCommissioningWindowWithCallback(mNodeId, mTimeout, mIteration, mDiscriminator,
mCommissioningWindowOption, &mOnOpenCommissioningWindowCallback);
SetupPayload payload;
payload.discriminator = mDiscriminator;
return mController.OpenCommissioningWindowWithCallback(mNodeId, mTimeout, mIteration, payload, mCommissioningWindowOption,
&mOnOpenCommissioningWindowCallback);
}

void PairingCommand::OnStatusUpdate(DevicePairingDelegate::Status status)
Expand Down
5 changes: 1 addition & 4 deletions src/controller/CHIPDeviceController.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -467,7 +467,7 @@ CHIP_ERROR DeviceController::ComputePASEVerifier(uint32_t iterations, uint32_t s
}

CHIP_ERROR DeviceController::OpenCommissioningWindowWithCallback(NodeId deviceId, uint16_t timeout, uint16_t iteration,
uint16_t discriminator, uint8_t option,
SetupPayload & payload, uint8_t option,
Callback::Callback<OnOpenCommissioningWindow> * callback)
{
ChipLogProgress(Controller, "OpenCommissioningWindow for device ID %" PRIu64, deviceId);
Expand All @@ -478,12 +478,9 @@ CHIP_ERROR DeviceController::OpenCommissioningWindowWithCallback(NodeId deviceId

std::string QRCode;
std::string manualPairingCode;
SetupPayload payload;
CommissioningWindowOption commissioningWindowOption;
ByteSpan salt(reinterpret_cast<const uint8_t *>(kSpake2pKeyExchangeSalt), strlen(kSpake2pKeyExchangeSalt));

payload.discriminator = discriminator;

switch (option)
{
case 0:
Expand Down
5 changes: 3 additions & 2 deletions src/controller/CHIPDeviceController.h
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,8 @@ class DLL_EXPORT DeviceController : public Messaging::ExchangeMgrDelegate,
CHIP_ERROR OpenCommissioningWindow(NodeId deviceId, uint16_t timeout, uint16_t iteration, uint16_t discriminator,
uint8_t option, SetupPayload & payload)
{
return OpenCommissioningWindowWithCallback(deviceId, timeout, iteration, discriminator, option, nullptr);
payload.discriminator = discriminator;
return OpenCommissioningWindowWithCallback(deviceId, timeout, iteration, payload, option, nullptr);
}

/**
Expand All @@ -318,7 +319,7 @@ class DLL_EXPORT DeviceController : public Messaging::ExchangeMgrDelegate,
*
* @return CHIP_ERROR CHIP_NO_ERROR on success, or corresponding error
*/
CHIP_ERROR OpenCommissioningWindowWithCallback(NodeId deviceId, uint16_t timeout, uint16_t iteration, uint16_t discriminator,
CHIP_ERROR OpenCommissioningWindowWithCallback(NodeId deviceId, uint16_t timeout, uint16_t iteration, SetupPayload & payload,
uint8_t option, Callback::Callback<OnOpenCommissioningWindow> * callback);

#if CHIP_DEVICE_CONFIG_ENABLE_DNSSD
Expand Down
2 changes: 1 addition & 1 deletion src/controller/java/CHIPDeviceController-JNI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -424,7 +424,7 @@ JNI_METHOD(jboolean, openPairingWindowWithPIN)
}

AndroidDeviceControllerWrapper * wrapper = AndroidDeviceControllerWrapper::FromJNIHandle(handle);
err = wrapper->Controller()->OpenCommissioningWindow(chipDevice->GetDeviceId(), duration, 1000, discriminator, 1, setupPayload);
err = wrapper->Controller()->OpenCommissioningWindow(chipDevice->GetDeviceId(), duration, 1000, discriminator, 2, setupPayload);

if (err != CHIP_NO_ERROR)
{
Expand Down

0 comments on commit 1547488

Please sign in to comment.