1 // 2 // Copyright (C) 2021 The Android Open Source Project 3 // 4 // Licensed under the Apache License, Version 2.0 (the "License"); 5 // you may not use this file except in compliance with the License. 6 // You may obtain a copy of the License at 7 // 8 // http://www.apache.org/licenses/LICENSE-2.0 9 // 10 // Unless required by applicable law or agreed to in writing, software 11 // distributed under the License is distributed on an "AS IS" BASIS, 12 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 // See the License for the specific language governing permissions and 14 // limitations under the License. 15 16 #pragma once 17 18 #include <cstdint> 19 #include <memory> 20 #include <string> 21 22 #include "common/libs/fs/shared_fd.h" 23 #include "host/libs/wmediumd_controller/wmediumd_api_protocol.h" 24 25 namespace cuttlefish { 26 27 class WmediumdController { 28 public: 29 static std::unique_ptr<WmediumdController> New( 30 const std::string& serverSocketPath); 31 ~WmediumdController()32 virtual ~WmediumdController() {} 33 34 WmediumdController(const WmediumdController& rhs) = delete; 35 WmediumdController& operator=(const WmediumdController& rhs) = delete; 36 37 WmediumdController(WmediumdController&& rhs) = delete; 38 WmediumdController& operator=(WmediumdController&& rhs) = delete; 39 40 bool SetControl(const uint32_t flags); 41 bool SetSnr(const std::string& node1, const std::string& node2, uint8_t snr); 42 bool ReloadCurrentConfig(void); 43 bool ReloadConfig(const std::string& configPath); 44 bool StartPcap(const std::string& pcapPath); 45 bool StopPcap(void); 46 std::optional<WmediumdMessageStationsList> GetStations(void); 47 48 private: WmediumdController()49 WmediumdController() {} 50 51 bool Connect(const std::string& serverSocketPath); 52 bool SendMessage(const WmediumdMessage& message); 53 std::optional<WmediumdMessageReply> SendMessageWithReply( 54 const WmediumdMessage& message); 55 56 SharedFD wmediumd_socket_; 57 }; 58 59 } // namespace cuttlefish 60