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