Skip to content

Commit

Permalink
Fixed application launcher cluster
Browse files Browse the repository at this point in the history
  • Loading branch information
lazarkov committed Dec 9, 2021
1 parent 98056b5 commit 1671f17
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,11 @@ bool emberAfApplicationLauncherClusterLaunchAppCallback(app::CommandHandler * co
return true;
}

void sendResponse(app::CommandHandler * command, app::CommandPathParams cmdParams, ApplicationLauncherResponse response)
void sendResponse(app::CommandHandler * command, app::ConcreteCommandPath path, ApplicationLauncherResponse response)
{
CHIP_ERROR err = CHIP_NO_ERROR;
TLV::TLVWriter * writer = nullptr;
SuccessOrExit(err = command->PrepareCommand(cmdParams));
SuccessOrExit(err = command->PrepareCommand(path));
VerifyOrExit((writer = command->GetCommandDataIBTLVWriter()) != nullptr, err = CHIP_ERROR_INCORRECT_STATE);
SuccessOrExit(err = writer->Put(TLV::ContextTag(0), response.status));
SuccessOrExit(err = writer->PutString(TLV::ContextTag(1), reinterpret_cast<const char *>(response.data)));
Expand Down Expand Up @@ -77,13 +77,12 @@ bool emberAfApplicationLauncherClusterLaunchAppCallback(app::CommandHandler * co
auto & requestApplicationCatalogVendorId = commandData.application.catalogVendorId;
auto & requestApplicationId = commandData.application.applicationId;

app::CommandPathParams cmdParams = { emberAfCurrentEndpoint(), /* group id */ 0, ApplicationLauncher::Id,
Commands::LaunchAppResponse::Id, (app::CommandPathFlags::kEndpointIdValid) };
app::ConcreteCommandPath path = { emberAfCurrentEndpoint(), ApplicationLauncher::Id, Commands::LaunchAppResponse::Id };

::ApplicationLauncherApp application = getApplicationFromCommand(requestApplicationCatalogVendorId, requestApplicationId);
std::string reqestDataString(requestData.data(), requestData.size());
ApplicationLauncherResponse response = applicationLauncherClusterLaunchApp(application, reqestDataString);
sendResponse(command, cmdParams, response);
sendResponse(command, path, response);
return true;
}

Expand All @@ -96,12 +95,11 @@ bool emberAfApplicationLauncherClusterStopAppCallback(app::CommandHandler * comm
auto & requestApplicationCatalogVendorId = commandData.application.catalogVendorId;
auto & requestApplicationId = commandData.application.applicationId;

app::CommandPathParams cmdParams = { emberAfCurrentEndpoint(), /* group id */ 0, ApplicationLauncher::Id,
Commands::StopAppResponse::Id, (app::CommandPathFlags::kEndpointIdValid) };
app::ConcreteCommandPath path = { emberAfCurrentEndpoint(), ApplicationLauncher::Id, Commands::StopAppResponse::Id };

::ApplicationLauncherApp application = getApplicationFromCommand(requestApplicationCatalogVendorId, requestApplicationId);
ApplicationLauncherResponse response = applicationLauncherClusterLaunchApp(application, "data");
sendResponse(command, cmdParams, response);
sendResponse(command, path, response);
return true;
}
/**
Expand All @@ -113,12 +111,12 @@ bool emberAfApplicationLauncherClusterHideAppCallback(app::CommandHandler * comm
auto & requestApplicationCatalogVendorId = commandData.application.catalogVendorId;
auto & requestApplicationId = commandData.application.applicationId;

app::CommandPathParams cmdParams = { emberAfCurrentEndpoint(), /* group id */ 0, ApplicationLauncher::Id,
Commands::HideAppResponse::Id, (app::CommandPathFlags::kEndpointIdValid) };

app::ConcreteCommandPath path = { emberAfCurrentEndpoint(), ApplicationLauncher::Id, Commands::HideAppResponse::Id };

::ApplicationLauncherApp application = getApplicationFromCommand(requestApplicationCatalogVendorId, requestApplicationId);
ApplicationLauncherResponse response = applicationLauncherClusterLaunchApp(application, "data");
sendResponse(command, cmdParams, response);
sendResponse(command, path, response);
return true;
}

Expand Down
8 changes: 4 additions & 4 deletions src/app/tests/suites/TV_ContentLauncherCluster.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,9 @@ tests:
response:
values:
- name: "data"
value: "exampleData"
value: "exampleData"
- name: "contentLaunchStatus"
value: 0
value: 0

- label: "Launch URL Command"
command: "LaunchURL"
Expand Down Expand Up @@ -123,6 +123,6 @@ tests:
response:
values:
- name: "data"
value: "exampleData"
value: "exampleData"
- name: "contentLaunchStatus"
value: 0
value: 0

0 comments on commit 1671f17

Please sign in to comment.