blob: 28b302021c8b66ed1fde6eb8716f8fce81c167e1 [file] [log] [blame]
// Copyright 2022 The Fuchsia Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "child-driver.h"
#include <fidl/fuchsia.examples.gizmo/cpp/wire.h>
#include <lib/driver2/service_client.h>
namespace child_driver {
zx::result<> ChildDriver::Start() {
auto connect_result =
driver::Connect<fuchsia_examples_gizmo::Service::Testing>(*context().incoming());
if (connect_result.is_error()) {
FDF_SLOG(WARNING, "Failed to connect to gizmo service.",
KV("status", connect_result.status_string()));
return connect_result.take_error();
}
auto client = fidl::WireSyncClient(std::move(connect_result.value()));
auto get_result = client->Get();
if (!get_result.ok()) {
FDF_SLOG(WARNING, "Failed to send Get to TestingProtocol.",
KV("status", get_result.error().status_string()));
return zx::error(get_result.error().status());
}
FDF_LOG(INFO, "Succeeded!");
return zx::ok();
}
} // namespace child_driver
FUCHSIA_DRIVER_RECORD_CPP_V2(driver::Record<child_driver::ChildDriver>);