-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Named pipes ota su #41708
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
Open
r-recchia
wants to merge
22
commits into
project-chip:master
Choose a base branch
from
r-recchia:named-pipes-OTA-SU
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Named pipes ota su #41708
Changes from 16 commits
Commits
Show all changes
22 commits
Select commit
Hold shift + click to select a range
e5571e4
TC_SU_2_8 test with base class
r-recchia 860c30e
Restyle
r-recchia 4e6f818
Restyle
r-recchia ebfef1b
Restyle
r-recchia a62a8b7
Restyle
r-recchia 259d43a
Merge branch 'master' into TC_SU_2_8_fix
r-recchia b0a5611
Minor adjustments
r-recchia d8c5f51
Merge branch 'master' into TC_SU_2_8_fix
r-recchia a88c393
Update version
r-recchia c9a0c44
Merge branch 'master' into TC_SU_2_8_fix
r-recchia a30803d
Cancel download step to make test faster
r-recchia e1486ca
Remove unused variable
r-recchia 74ae5ee
Remove unused import
r-recchia 74bec57
Remove product id
r-recchia 3dd4895
First draft
r-recchia a88d19b
Implement write
r-recchia e94bb95
Adding write to pipe out functionality
r-recchia b543e95
Implement read fifo
r-recchia e530f03
Getting real data from device
r-recchia ad22e29
Adding protocols supported}
r-recchia d8119af
Uncommenting test steps
r-recchia 1297b97
Merge branch 'master' into named-pipes-OTA-SU
r-recchia File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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
89 changes: 89 additions & 0 deletions
89
examples/ota-provider-app/ota-provider-common/OtaProviderAppCommandDelegate.cpp
This file contains hidden or 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,89 @@ | ||
| /* | ||
| *json | ||
| * Copyright (c) 2025 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 "OtaProviderAppCommandDelegate.h" | ||
| #include <platform/PlatformManager.h> | ||
|
|
||
| using namespace chip; | ||
| using namespace chip::app; | ||
| using namespace chip::app::Clusters; | ||
| using namespace chip::DeviceLayer; | ||
|
|
||
| OtaProviderAppCommandHandler * OtaProviderAppCommandHandler::FromJSON(const char * json) | ||
| { | ||
| Json::Reader reader; | ||
| Json::Value value; | ||
|
|
||
| if (!reader.parse(json, value)) | ||
| { | ||
| ChipLogError(NotSpecified, | ||
| "OTA Provider Example: Error parsing JSON with error %s:", reader.getFormattedErrorMessages().c_str()); | ||
| return nullptr; | ||
| } | ||
|
|
||
| if (value.empty() || !value.isObject()) | ||
| { | ||
| ChipLogError(NotSpecified, "OTA Provider Example: Invalid JSON command received"); | ||
| return nullptr; | ||
| } | ||
|
|
||
| if (!value.isMember("Name") || !value["Name"].isString()) | ||
| { | ||
| ChipLogError(NotSpecified, "OTA Provider Example: Invalid JSON command received: command name is missing"); | ||
| return nullptr; | ||
| } | ||
|
|
||
| return chip::Platform::New<OtaProviderAppCommandHandler>(std::move(value)); | ||
| } | ||
|
|
||
| std::string OtaProviderAppCommandHandler::GetQueryImageResponse() | ||
| { | ||
| return "Test"; | ||
| } | ||
|
|
||
| void OtaProviderAppCommandHandler::HandleCommand(intptr_t context) | ||
| { | ||
| auto * self = reinterpret_cast<OtaProviderAppCommandHandler *>(context); | ||
| std::string name = self->mJsonValue["Name"].asString(); | ||
|
|
||
| VerifyOrExit(!self->mJsonValue.empty(), ChipLogError(NotSpecified, "Invalid JSON event command received")); | ||
|
|
||
| if (name == "GetQueryImageResponse") | ||
| { | ||
| std::string queryImage = self->GetQueryImageResponse(); | ||
| } | ||
| else | ||
| { | ||
| ChipLogError(NotSpecified, "Unhandled command: Should never happen"); | ||
| } | ||
|
|
||
| exit: | ||
| chip::Platform::Delete(self); | ||
| } | ||
|
|
||
| void OtaProviderAppCommandDelegate::OnEventCommandReceived(const char * json) | ||
| { | ||
| auto handler = OtaProviderAppCommandHandler::FromJSON(json); | ||
| if (nullptr == handler) | ||
| { | ||
| ChipLogError(NotSpecified, "OTA Provider App: Unable to instantiate a command handler"); | ||
| return; | ||
| } | ||
|
|
||
| chip::DeviceLayer::PlatformMgr().ScheduleWork(OtaProviderAppCommandHandler::HandleCommand, reinterpret_cast<intptr_t>(handler)); | ||
| } | ||
48 changes: 48 additions & 0 deletions
48
examples/ota-provider-app/ota-provider-common/OtaProviderAppCommandDelegate.h
This file contains hidden or 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,48 @@ | ||
| /* | ||
| * | ||
| * Copyright (c) 2025 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 "NamedPipeCommands.h" | ||
|
|
||
| #include <json/json.h> | ||
| #include <platform/DiagnosticDataProvider.h> | ||
|
|
||
| #include <string> | ||
|
|
||
| class OtaProviderAppCommandHandler { | ||
| public: | ||
| static OtaProviderAppCommandHandler * FromJSON(const char * json); | ||
|
|
||
| static void HandleCommand(intptr_t context); | ||
|
|
||
| OtaProviderAppCommandHandler(Json::Value && jsonValue) | ||
| : mJsonValue(std::move(jsonValue)) | ||
| { | ||
| } | ||
|
|
||
| private: | ||
| Json::Value mJsonValue; | ||
|
|
||
| std::string GetQueryImageResponse(); | ||
| }; | ||
|
|
||
| class OtaProviderAppCommandDelegate : public NamedPipeCommandDelegate { | ||
| public: | ||
| void OnEventCommandReceived(const char * json) override; | ||
| }; |
This file contains hidden or 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 hidden or 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 hidden or 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.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.