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() { return port_; }
35 
36   // Set the listening TCP port for rootcanal HCI socket
SetPort(uint16_t port)37   void SetPort(uint16_t port) { port_ = port; }
38 
39   // Get the server address for rootcanal HCI socket
GetServerAddress()40   std::string GetServerAddress() { return server_address_; }
41 
42   // Set the server address for rootcanal HCI socket
SetServerAddress(const std::string & address)43   void SetServerAddress(const std::string& address) { server_address_ = address; }
44 
45 private:
46   HciHalHostRootcanalConfig() = default;
47   uint16_t port_ = 6402;                      // Default server TCP port
48   std::string server_address_ = "127.0.0.1";  // Default server address
49 };
50 
51 }  // namespace hal
52 }  // namespace bluetooth
53