1 /*
2  * Copyright 2019 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 
17 #pragma once
18 
19 #include <cstdint>
20 #include <string>
21 
22 namespace bluetooth {
23 namespace hal {
24 
25 // Singleton object to store runtime configuration for rootcanal
26 class HciHalHostRootcanalConfig {
27  public:
Get()28   static HciHalHostRootcanalConfig* Get() {
29     static HciHalHostRootcanalConfig instance;
30     return &instance;
31   }
32 
33   // Get the listening TCP port for rootcanal HCI socket
GetPort()34   uint16_t GetPort() {
35     return port_;
36   }
37 
38   // Set the listening TCP port for rootcanal HCI socket
SetPort(uint16_t port)39   void SetPort(uint16_t port) {
40     port_ = port;
41   }
42 
43   // Get the server address for rootcanal HCI socket
GetServerAddress()44   std::string GetServerAddress() {
45     return server_address_;
46   }
47 
48   // Set the server address for rootcanal HCI socket
SetServerAddress(const std::string & address)49   void SetServerAddress(const std::string& address) {
50     server_address_ = address;
51   }
52 
53  private:
54   HciHalHostRootcanalConfig() = default;
55   uint16_t port_ = 6402;                      // Default server TCP port
56   std::string server_address_ = "127.0.0.1";  // Default server address
57 };
58 
59 }  // namespace hal
60 }  // namespace bluetooth
61