Skip to content

Commit

Permalink
fix build, add missing TXT record values and error messages
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisdecenzo committed Nov 27, 2023
1 parent 50e0c3a commit ee65282
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,12 @@ class DLL_EXPORT IdentificationDeclaration
mAppVendorIds[mNumAppVendorIds++] = vid;
}

const char * GetPairingInst() const { return mPairingInst; }
void SetPairingInst(const char * pairingInst) { Platform::CopyString(mPairingInst, pairingInst); }

uint16_t GetPairingHint() const { return mPairingHint; }
void SetPairingHint(uint16_t pairingHint) { mPairingHint = pairingHint; }

void SetNoPasscode(bool newValue) { mNoPasscode = newValue; };
bool GetNoPasscode() const { return mNoPasscode; };

Expand Down Expand Up @@ -182,7 +188,15 @@ class DLL_EXPORT IdentificationDeclaration
}
for (size_t i = 0; i < mNumAppVendorIds; i++)
{
ChipLogDetail(AppServer, "\app vendor id [%zu]: %u", i, mAppVendorIds[i]);
ChipLogDetail(AppServer, "\tapp vendor id [%zu]: %u", i, mAppVendorIds[i]);
}
if (strlen(mPairingInst) != 0)
{
ChipLogDetail(AppServer, "\tpairing instruction: %s", mPairingInst);
}
if (mPairingHint != 0)
{
ChipLogDetail(AppServer, "\tpairing hint: %d", mPairingHint);
}

if (mNoPasscode)
Expand Down Expand Up @@ -217,6 +231,8 @@ class DLL_EXPORT IdentificationDeclaration
kNameTag,
kRotatingIdTag,
kCdPortTag,
kPairingInstTag,
kPairingHintTag,
kAppVendorIdListTag,
kAppVendorIdTag,
kNoPasscodeTag,
Expand All @@ -241,6 +257,9 @@ class DLL_EXPORT IdentificationDeclaration
size_t mNumAppVendorIds = 0; // number of vendor Ids
uint16_t mAppVendorIds[kMaxAppVendorIds];

char mPairingInst[chip::Dnssd::kMaxPairingInstructionLen + 1] = {};
uint16_t mPairingHint = 0;

bool mNoPasscode = false;
bool mCdUponPasscodeDialog = false;
bool mCommissionerPasscode = false;
Expand Down Expand Up @@ -270,6 +289,10 @@ class DLL_EXPORT CommissionerDeclaration
kBindingConfigurationFailed,
kCommissionerPasscodeNotSupported,
kInvalidIdentificationDeclarationParams,
kAppInstallConsentPending,
kAppInstalling,
kAppInstallFailed,
kAppInstalledRetryNeeded,

kMax = UINT8_MAX
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,9 @@ uint32_t IdentificationDeclaration::WritePayload(uint8_t * payloadBuffer, size_t
VerifyOrExit(CHIP_NO_ERROR == (err = writer.Put(chip::TLV::ContextTag(kVendorIdTag), GetVendorId())), LogErrorOnFailure(err));
VerifyOrExit(CHIP_NO_ERROR == (err = writer.Put(chip::TLV::ContextTag(kProductIdTag), GetProductId())), LogErrorOnFailure(err));
VerifyOrExit(CHIP_NO_ERROR == (err = writer.PutString(chip::TLV::ContextTag(kNameTag), mDeviceName)), LogErrorOnFailure(err));
VerifyOrExit(CHIP_NO_ERROR == (err = writer.PutString(chip::TLV::ContextTag(kPairingInstTag), mPairingInst)),
LogErrorOnFailure(err));
VerifyOrExit(CHIP_NO_ERROR == (err = writer.Put(chip::TLV::ContextTag(kPairingHintTag), mPairingHint)), LogErrorOnFailure(err));
VerifyOrExit(CHIP_NO_ERROR == (err = writer.Put(chip::TLV::ContextTag(kCdPortTag), GetCdPort())), LogErrorOnFailure(err));

VerifyOrExit(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
#include "UserDirectedCommissioning.h"
#include <lib/core/CHIPSafeCasts.h>
#include <system/TLVPacketBufferBackingStore.h>
#include <unistd.h>

namespace chip {
namespace Protocols {
Expand Down Expand Up @@ -248,6 +249,14 @@ CHIP_ERROR IdentificationDeclaration::ReadPayload(uint8_t * udcPayload, size_t p
// deviceName
err = reader.GetString(mDeviceName, sizeof(mDeviceName));
break;
case kPairingInstTag:
// pairingInst
err = reader.GetString(mPairingInst, sizeof(mPairingInst));
break;
case kPairingHintTag:
// pairingHint
err = reader.Get(mPairingHint);
break;
case kRotatingIdTag:
// rotatingId
mRotatingIdLen = reader.GetLength();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -370,6 +370,8 @@ void TestUDCIdentificationDeclaration(nlTestSuite * inSuite, void * inContext)
uint16_t port = 123;
const char * deviceName = "device1";
uint16_t vendorIdTemp = 0;
uint16_t pairingHint = 33;
const char * pairingInst = "Read 6 digit code from screen";

// Rotating ID is given as up to 50 hex bytes
char rotatingIdString[chip::Dnssd::kMaxRotatingIdLen * 2 + 1];
Expand All @@ -382,6 +384,8 @@ void TestUDCIdentificationDeclaration(nlTestSuite * inSuite, void * inContext)
id.SetVendorId(vendorId);
id.SetProductId(productId);
id.SetDeviceName(deviceName);
id.SetPairingInst(pairingInst);
id.SetPairingHint(pairingHint);
id.SetRotatingId(rotatingId, rotatingIdLen);
id.SetCdPort(port);

Expand All @@ -401,6 +405,8 @@ void TestUDCIdentificationDeclaration(nlTestSuite * inSuite, void * inContext)
NL_TEST_ASSERT(inSuite, strcmp(id.GetDeviceName(), deviceName) == 0);
NL_TEST_ASSERT(inSuite, rotatingIdLen == id.GetRotatingIdLength());
NL_TEST_ASSERT(inSuite, memcmp(id.GetRotatingId(), rotatingId, rotatingIdLen) == 0);
NL_TEST_ASSERT(inSuite, pairingHint == id.GetPairingHint());
NL_TEST_ASSERT(inSuite, strcmp(id.GetPairingInst(), pairingInst) == 0);

NL_TEST_ASSERT(inSuite, id.GetNumAppVendorIds() == 3);
NL_TEST_ASSERT(inSuite, id.GetAppVendorId(0, vendorIdTemp) && vendorIdTemp == 1);
Expand All @@ -427,6 +433,8 @@ void TestUDCIdentificationDeclaration(nlTestSuite * inSuite, void * inContext)
NL_TEST_ASSERT(inSuite, strcmp(idOut.GetDeviceName(), deviceName) == 0);
NL_TEST_ASSERT(inSuite, rotatingIdLen == idOut.GetRotatingIdLength());
NL_TEST_ASSERT(inSuite, memcmp(idOut.GetRotatingId(), rotatingId, rotatingIdLen) == 0);
NL_TEST_ASSERT(inSuite, strcmp(idOut.GetPairingInst(), pairingInst) == 0);
NL_TEST_ASSERT(inSuite, pairingHint == idOut.GetPairingHint());

NL_TEST_ASSERT(inSuite, id.GetNumAppVendorIds() == idOut.GetNumAppVendorIds());
NL_TEST_ASSERT(inSuite, idOut.GetAppVendorId(0, vendorIdTemp) && vendorIdTemp == 1);
Expand Down

0 comments on commit ee65282

Please sign in to comment.