forked from project-chip/connectedhomeip
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #4 from hnnajh/rotating-id-test
Update Rotating id test from local master
- Loading branch information
Showing
18 changed files
with
698 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
37 changes: 37 additions & 0 deletions
37
examples/chip-tool/commands/payload/AdditionalDataParseCommand.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
/* | ||
* Copyright (c) 2020 Project CHIP Authors | ||
* All rights reserved. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
* | ||
*/ | ||
|
||
#include "AdditionalDataParseCommand.h" | ||
|
||
#include <setup_payload/AdditionalDataPayloadParser.h> | ||
#include <setup_payload/AdditionalDataPayload.h> | ||
|
||
using namespace ::chip; | ||
|
||
CHIP_ERROR AdditionalDataParseCommand::Run(PersistentStorage & storage, NodeId localId, NodeId remoteId) | ||
{ | ||
std::string payload(mPayload); | ||
AdditionalDataPayload resultPayload; | ||
CHIP_ERROR err = CHIP_NO_ERROR; | ||
SuccessOrExit(err); | ||
ChipLogProgress(chipTool, "AdditionalDataParseCommand, payload=%s", payload.c_str()); | ||
|
||
err = AdditionalDataPayloadParser(payload).populatePayload(resultPayload); | ||
exit: | ||
return err; | ||
} |
31 changes: 31 additions & 0 deletions
31
examples/chip-tool/commands/payload/AdditionalDataParseCommand.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
/* | ||
* Copyright (c) 2020 Project CHIP Authors | ||
* All rights reserved. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
* | ||
*/ | ||
|
||
#pragma once | ||
|
||
#include "../common/Command.h" | ||
|
||
class AdditionalDataParseCommand : public Command | ||
{ | ||
public: | ||
AdditionalDataParseCommand() : Command("parse-additional-data") { AddArgument("payload", &mPayload); } | ||
CHIP_ERROR Run(PersistentStorage & storage, NodeId localId, NodeId remoteId) override; | ||
|
||
private: | ||
char * mPayload; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
104 changes: 104 additions & 0 deletions
104
examples/chip-tool/commands/payload/QRCodeParseCommand.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,104 @@ | ||
/* | ||
* Copyright (c) 2020 Project CHIP Authors | ||
* All rights reserved. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
* | ||
*/ | ||
|
||
#include "QRCodeParseCommand.h" | ||
#include <setup_payload/ManualSetupPayloadParser.h> | ||
#include <setup_payload/QRCodeSetupPayloadParser.h> | ||
#include <setup_payload/SetupPayload.h> | ||
|
||
using namespace ::chip; | ||
|
||
CHIP_ERROR QRCodeParseCommand::Run(PersistentStorage & storage, NodeId localId, NodeId remoteId) | ||
{ | ||
std::string codeString(mCode); | ||
SetupPayload payload; | ||
|
||
CHIP_ERROR err = CHIP_NO_ERROR; | ||
err = Parse(codeString, payload); | ||
SuccessOrExit(err); | ||
|
||
err = Print(payload); | ||
SuccessOrExit(err); | ||
exit: | ||
return err; | ||
} | ||
|
||
CHIP_ERROR QRCodeParseCommand::Print(chip::SetupPayload payload) | ||
{ | ||
std::string serialNumber; | ||
std::vector<OptionalQRCodeInfo> optionalVendorData; | ||
CHIP_ERROR err = CHIP_NO_ERROR; | ||
|
||
ChipLogProgress(SetupPayload, "RequiresCustomFlow: %u", payload.requiresCustomFlow); | ||
ChipLogProgress(SetupPayload, "VendorID: %u", payload.vendorID); | ||
ChipLogProgress(SetupPayload, "Version: %u", payload.version); | ||
ChipLogProgress(SetupPayload, "ProductID: %u", payload.productID); | ||
ChipLogProgress(SetupPayload, "Discriminator: %u", payload.discriminator); | ||
ChipLogProgress(SetupPayload, "SetUpPINCode: %u", payload.setUpPINCode); | ||
ChipLogProgress(SetupPayload, "RendezvousInformation: %u", payload.rendezvousInformation); | ||
|
||
if (payload.getSerialNumber(serialNumber) == CHIP_NO_ERROR) | ||
{ | ||
ChipLogProgress(SetupPayload, "SerialNumber: %s", serialNumber.c_str()); | ||
} | ||
|
||
optionalVendorData = payload.getAllOptionalVendorData(); | ||
for (const OptionalQRCodeInfo & info : optionalVendorData) | ||
{ | ||
if (info.type == optionalQRCodeInfoTypeString) | ||
{ | ||
ChipLogProgress(SetupPayload, "OptionalQRCodeInfo: tag=%u,string value=%s", info.tag, info.data.c_str()); | ||
} | ||
else if (info.type == optionalQRCodeInfoTypeInt32) | ||
{ | ||
ChipLogProgress(SetupPayload, "OptionalQRCodeInfo: tag=%u,int value=%u", info.tag, info.int32); | ||
} | ||
else | ||
{ | ||
err = CHIP_ERROR_INVALID_ARGUMENT; | ||
} | ||
} | ||
|
||
SuccessOrExit(err); | ||
|
||
exit: | ||
return err; | ||
} | ||
|
||
CHIP_ERROR QRCodeParseCommand::Parse(std::string codeString, chip::SetupPayload & payload) | ||
{ | ||
|
||
CHIP_ERROR err = CHIP_NO_ERROR; | ||
if (IsQRCode(codeString)) | ||
{ | ||
ChipLogDetail(SetupPayload, "Parsing base41Representation: %s", codeString.c_str()); | ||
err = QRCodeSetupPayloadParser(codeString).populatePayload(payload); | ||
} | ||
else | ||
{ | ||
ChipLogDetail(SetupPayload, "Parsing decimalRepresentation: %s", codeString.c_str()); | ||
err = ManualSetupPayloadParser(codeString).populatePayload(payload); | ||
} | ||
|
||
return err; | ||
} | ||
|
||
bool QRCodeParseCommand::IsQRCode(std::string codeString) | ||
{ | ||
return codeString.rfind(QRCODE_PREFIX) == 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
/* | ||
* Copyright (c) 2020 Project CHIP Authors | ||
* All rights reserved. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
* | ||
*/ | ||
|
||
#pragma once | ||
|
||
#include "../common/Command.h" | ||
#include <setup_payload/SetupPayload.h> | ||
|
||
class QRCodeParseCommand : public Command | ||
{ | ||
public: | ||
QRCodeParseCommand() : Command("parse-qr-code") { AddArgument("code", &mCode); } | ||
CHIP_ERROR Run(PersistentStorage & storage, NodeId localId, NodeId remoteId) override; | ||
|
||
private: | ||
char * mCode; | ||
CHIP_ERROR Parse(std::string codeString, chip::SetupPayload & payload); | ||
CHIP_ERROR Print(chip::SetupPayload payload); | ||
bool IsQRCode(std::string codeString); | ||
const std::string QRCODE_PREFIX = "CH:"; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.