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
21namespace OHOS {
22namespace HDI {
23namespace Bluetooth {
24namespace Hci {
25class H4Protocol : public HciProtocol {
26public:
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    ~H4Protocol() override;
32
33private:
34    void PacketCallback();
35
36private:
37    int hciFd_ = 0;
38    HciDataCallback onAclReceive_;
39    HciDataCallback onScoReceive_;
40    HciDataCallback onEventReceive_;
41
42    uint8_t packetType_ = 0;
43    std::vector<uint8_t> hciPacket_;
44    uint32_t readLength_ = 0;
45};
46}  // namespace Hci
47}  // namespace Bluetooth
48}  // namespace HDI
49}  // namespace OHOS
50
51#endif /* OHOS_HDI_BLUETOOTH_HCI_H4_PROTOCOL_H */