| // Copyright 2024 The Pigweed Authors |
| // |
| // 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 |
| // |
| // https://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 "modules/board/board.h" |
| #include "modules/board/board.rpc.pb.h" |
| #include "modules/worker/worker.h" |
| #include "pw_chrono/system_timer.h" |
| #include "pw_status/status.h" |
| |
| namespace sense { |
| |
| class BoardService final |
| : public ::board::pw_rpc::nanopb::Board::Service<BoardService> { |
| public: |
| BoardService(); |
| |
| void Init(Worker& worker, Board& board); |
| |
| pw::Status Reboot(const board_RebootRequest& request, |
| pw_protobuf_Empty& /*response*/); |
| |
| pw::Status OnboardTemp(const pw_protobuf_Empty& /*request*/, |
| board_OnboardTempResponse& response); |
| |
| void OnboardTempStream(const board_OnboardTempStreamRequest& request, |
| ServerWriter<board_OnboardTempResponse>& writer); |
| |
| private: |
| void TempSampleCallback(); |
| |
| void ScheduleTempSample(); |
| |
| Worker* worker_ = nullptr; |
| Board* board_ = nullptr; |
| pw::chrono::SystemTimer temp_sample_timer_; |
| pw::chrono::SystemClock::duration temp_sample_interval_; |
| ServerWriter<board_OnboardTempResponse> temp_sample_writer_; |
| }; |
| |
| } // namespace sense |