• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 //
2 // Copyright 2016 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 #ifndef HIDL_GENERATED_android_hardware_bluetooth_V1_1_BluetoothHci_H_
18 #define HIDL_GENERATED_android_hardware_bluetooth_V1_1_BluetoothHci_H_
19 
20 #include <android/hardware/bluetooth/1.0/IBluetoothHci.h>
21 #include <android/hardware/bluetooth/1.1/IBluetoothHci.h>
22 
23 #include <hidl/MQDescriptor.h>
24 
25 #include "async_fd_watcher.h"
26 #include "h4_protocol.h"
27 #include "hci_internals.h"
28 
29 namespace android {
30 namespace hardware {
31 namespace bluetooth {
32 namespace V1_1 {
33 namespace btlinux {
34 
35 using ::android::hardware::Return;
36 using ::android::hardware::hidl_vec;
37 
38 class BluetoothDeathRecipient;
39 
40 class BluetoothHci : public IBluetoothHci {
41  public:
42   BluetoothHci();
43   Return<void> initialize(
44       const ::android::sp<V1_0::IBluetoothHciCallbacks>& cb) override;
45   Return<void> initialize_1_1(
46       const ::android::sp<V1_1::IBluetoothHciCallbacks>& cb) override;
47   Return<void> sendHciCommand(const hidl_vec<uint8_t>& packet) override;
48   Return<void> sendAclData(const hidl_vec<uint8_t>& data) override;
49   Return<void> sendScoData(const hidl_vec<uint8_t>& data) override;
50   Return<void> sendIsoData(const hidl_vec<uint8_t>& data) override;
51   Return<void> close() override;
52 
53  private:
54   Return<void> initialize_impl(
55       const ::android::sp<V1_0::IBluetoothHciCallbacks>& cb,
56       const ::android::sp<V1_1::IBluetoothHciCallbacks>& cb_1_1);
57 
58   async::AsyncFdWatcher fd_watcher_;
59   hci::H4Protocol* hci_handle_;
60   int bt_soc_fd_;
61   char *rfkill_state_;
62 
63   const uint8_t HCI_DATA_TYPE_COMMAND = 1;
64   const uint8_t HCI_DATA_TYPE_ACL = 2;
65   const uint8_t HCI_DATA_TYPE_SCO = 3;
66   const uint8_t HCI_DATA_TYPE_ISO = 5;
67 
68   int waitHciDev(int hci_interface);
69   int findRfKill(void);
70   int rfKill(int block);
71   int openBtHci(void);
72   void closeBtHci(void);
73 
74   void sendDataToController(const uint8_t type, const hidl_vec<uint8_t>& data);
75   ::android::sp<BluetoothDeathRecipient> death_recipient_;
76   std::function<void(sp<BluetoothDeathRecipient>&)> unlink_cb_;
77 };
78 
79 extern "C" IBluetoothHci* HIDL_FETCH_IBluetoothHci(const char* name);
80 
81 }  // namespace btlinux
82 }  // namespace V1_1
83 }  // namespace bluetooth
84 }  // namespace hardware
85 }  // namespace android
86 
87 #endif  // HIDL_GENERATED_android_hardware_bluetooth_V1_1_BluetoothHci_H_
88