• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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   bool SetPosition(const std::string& node, double x, double y);
48   bool SetLci(const std::string& node, const std::string& lci);
49   bool SetCivicloc(const std::string& node, const std::string& civicloc);
50 
51  private:
WmediumdController()52   WmediumdController() {}
53 
54   bool Connect(const std::string& serverSocketPath);
55   bool SendMessage(const WmediumdMessage& message);
56   std::optional<WmediumdMessageReply> SendMessageWithReply(
57       const WmediumdMessage& message);
58 
59   SharedFD wmediumd_socket_;
60 };
61 
62 }  // namespace cuttlefish
63