1 /*
2  * Copyright 2024 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 <memory>
21 #include <vector>
22 
23 // syslog.h conflicts with os/*.h
24 #undef LOG_DEBUG
25 #undef LOG_INFO
26 #undef LOG_WARNING
27 #include "os/handler.h"
28 
29 namespace bluetooth::hal {
30 
31 class HciBackendCallbacks {
32  public:
33   virtual ~HciBackendCallbacks() = default;
34   virtual void initializationComplete(void) = 0;
35   virtual void hciEventReceived(const std::vector<uint8_t>&) = 0;
36   virtual void aclDataReceived(const std::vector<uint8_t>&) = 0;
37   virtual void scoDataReceived(const std::vector<uint8_t>&) = 0;
38   virtual void isoDataReceived(const std::vector<uint8_t>&) = 0;
39 };
40 
41 class HciBackend {
42  public:
43   static std::shared_ptr<HciBackend> CreateAidl();
44   static std::shared_ptr<HciBackend> CreateHidl(::bluetooth::os::Handler*);
45 
46   virtual ~HciBackend() = default;
47   virtual void initialize(std::shared_ptr<HciBackendCallbacks>) = 0;
48   virtual void sendHciCommand(const std::vector<uint8_t>&) = 0;
49   virtual void sendAclData(const std::vector<uint8_t>&) = 0;
50   virtual void sendScoData(const std::vector<uint8_t>&) = 0;
51   virtual void sendIsoData(const std::vector<uint8_t>&) = 0;
52 };
53 
54 }  // namespace bluetooth::hal
55