1 /* 2 * Copyright 2018 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 <vector> 21 22 #include "model/controller/dual_mode_controller.h" 23 #include "model/devices/h4_packetizer.h" 24 25 namespace { 26 const std::string kHciSocketDevicePropertiesFile = "/etc/bluetooth/hci_socket_device_controller_properties.json"; 27 } // namespace 28 29 namespace test_vendor_lib { 30 31 class HciSocketDevice : public DualModeController { 32 public: 33 HciSocketDevice(int socket_fd); 34 ~HciSocketDevice() = default; 35 Create(int socket_fd)36 static std::shared_ptr<HciSocketDevice> Create(int socket_fd) { 37 return std::make_shared<HciSocketDevice>(socket_fd); 38 } 39 GetTypeString()40 virtual std::string GetTypeString() const override { 41 return "hci_socket_device"; 42 } 43 44 virtual void TimerTick() override; 45 46 void SendHci(hci::PacketType packet_type, const std::shared_ptr<std::vector<uint8_t>> packet); 47 48 private: 49 int socket_file_descriptor_{-1}; 50 hci::H4Packetizer h4_{socket_file_descriptor_, [](const std::vector<uint8_t>&) {}, [](const std::vector<uint8_t>&) {}, 51 [](const std::vector<uint8_t>&) {}, [](const std::vector<uint8_t>&) {}}; 52 }; 53 54 } // namespace test_vendor_lib 55