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