blob: 68100728f60c110dd4ff6ba96f0f14c85fb188ea [file]
// Copyright 2023 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 <lib/async-loop/cpp/loop.h>
#include <lib/component/incoming/cpp/protocol.h>
#include <lib/syslog/cpp/log_settings.h>
#include <lib/syslog/cpp/macros.h>
#include "fan-controller.h"
// fan-controller is a component that bridges between the drivers implementing fuchsia_hardware_fan
// and the component implementing fuchsia_thermal::ClientStateWatcher.
// The value of `state` returned by fuchsia_thermal::ClientStateWatcher::Watch() must match fan
// levels defined and used by fuchsia_hardware_fan::Device::Set/GetFanLevel().
int main(int argc, const char* argv[], char* envp[]) {
fuchsia_logging::SetTags({"fan-controller"});
auto result = component::Connect<fuchsia_thermal::ClientStateConnector>();
if (result.is_error()) {
FX_LOGS(ERROR) << "Could not connect to fuchsia_thermal::ClientStateConnector "
<< result.status_string();
return result.error_value();
}
async::Loop loop{&kAsyncLoopConfigNeverAttachToThread};
fan_controller::FanController controller(loop.dispatcher(), std::move(*result));
loop.Run();
return ZX_OK;
}