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 BLUETOOTH_HDI_H
17 #define BLUETOOTH_HDI_H
18 
19 #include <stdlib.h>
20 #include <stdbool.h>
21 #include <stdint.h>
22 
23 #ifdef __cplusplus
24 extern "C" {
25 #endif
26 
27 // Hci hal backend status
28 typedef enum {
29     SUCCESS,
30     TRANSPORT_ERROR,
31     INITIALIZATION_ERROR,
32     UNKNOWN,
33 } BtInitStatus;
34 
35 typedef enum {
36     PACKET_TYPE_UNKNOWN = 0,
37     PACKET_TYPE_CMD = 1,
38     PACKET_TYPE_ACL = 2,
39     PACKET_TYPE_SCO = 3,
40     PACKET_TYPE_EVENT = 4
41 } BtPacketType;
42 
43 // Hci packet received from backend
44 typedef struct BtPacket {
45     uint8_t *data;
46     uint32_t size;
47 } BtPacket;
48 
49 // BluetoothHciCallbacks register to hal by upperlayer protocol
50 typedef struct BtHciCallbacks {
51     void (*OnInited)(BtInitStatus status);
52     void (*OnReceivedHciPacket)(BtPacketType type, const BtPacket *packet);
53 } BtHciCallbacks;
54 
55 int HdiInit(BtHciCallbacks *callbacks);
56 int HdiSendHciPacket(BtPacketType type, const BtPacket *packet);
57 void HdiClose(void);
58 
59 typedef int (*HdiInitFunc)(BtHciCallbacks *callbacks);
60 typedef int (*HdiSendHciPacketFunc)(BtPacketType type, const BtPacket *packet);
61 typedef void (*HdiCloseFunc)(void);
62 
63 #ifdef __cplusplus
64 }
65 #endif
66 
67 #endif