• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2021-2022 Huawei Device Co., Ltd.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
16 #ifndef OHOS_HDI_BLUETOOTH_HCI_H4_PROTOCOL_H
17 #define OHOS_HDI_BLUETOOTH_HCI_H4_PROTOCOL_H
18 
19 #include "hci_protocol.h"
20 
21 namespace OHOS {
22 namespace HDI {
23 namespace Bluetooth {
24 namespace Hci {
25 class H4Protocol : public HciProtocol {
26 public:
27     H4Protocol(int fd, HciDataCallback onAclReceive, HciDataCallback onScoReceive, HciDataCallback onEventReceive);
28 
29     ssize_t SendPacket(HciPacketType packetType, const std::vector<uint8_t> &packetData) override;
30     void ReadData(int fd);
31 
32 private:
33     void PacketCallback();
34 
35 private:
36     int hciFd_ = 0;
37     HciDataCallback onAclReceive_;
38     HciDataCallback onScoReceive_;
39     HciDataCallback onEventReceive_;
40 
41     uint8_t packetType_ = 0;
42     std::vector<uint8_t> hciPacket_;
43     uint32_t readLength_ = 0;
44 };
45 }  // namespace Hci
46 }  // namespace Bluetooth
47 }  // namespace HDI
48 }  // namespace OHOS
49 
50 #endif /* OHOS_HDI_BLUETOOTH_HCI_H4_PROTOCOL_H */