1 /*
2  * Copyright (C) 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 /**
17  * @file hci_if.h
18  *
19  * @brief Interface of bluetooth hci vendor cmd
20  *
21  */
22 
23 #ifndef HIC_VENDOR_IF_H
24 #define HIC_VENDOR_IF_H
25 
26 #include "btstack.h"
27 
28 #ifdef __cplusplus
29 extern "C" {
30 #endif  // __cplusplus
31 
32 #define HCI_COMMAND_OGF_VENDOR_SPECIFIC 0x3F
33 
34 typedef struct {
35     void (*hciCommandCompleteEvent)(uint16_t opCode, const void *param, uint8_t paramLength, void *context);
36     void (*hciVendorClosed)(void *context);
37 } HCIVendorEventCallback;
38 
39 /**
40  * @brief       Register hci vendor event callback
41  * @param       callback            hci vendor event callback
42  * @param[in]   context             hci vendor event parameter
43  * @return      @c BT_SUCCESS      : The function is executed successfully.
44  *              @c otherwise        : The function is not executed successfully.
45  */
46 BTSTACK_API int HCIVIF_RegisterVendorEventCallback(
47     const HCIVendorEventCallback *callback, void *context);
48 
49 /**
50  * @brief       Deregister vendor event callback
51  * @param       callback            hci vendor event callback
52  * @return      @c BT_SUCCESS      : The function is executed successfully.
53  *              @c otherwise        : The function is not executed successfully.
54  */
55 BTSTACK_API int HCIVIF_DeregisterVendorEventCallback(const HCIVendorEventCallback *callback);
56 
57 /**
58  * @brief       Send hci vendor cmd
59  *
60  * @param       opCode              The cmd opcode.
61  * @param       param               The cmd parameter.
62  * @param       paramLength         The cmd parameter length.
63  * @return      @c BT_SUCCESS      : The function is executed successfully.
64  *              @c otherwise        : The function is not executed successfully.
65  */
66 int BTSTACK_API HCIVIF_SendCmd(uint16_t opCode, const void *param, size_t paramLength);
67 
68 /**
69  * @brief       Receive a vendor commannd complete event
70  *
71  * @param       opCode              The event opcode.
72  * @param       param               The event parameter.
73  * @param       paramLength         The event parameter length.
74  */
75 void HciEventOnVendorCommandComplete(uint16_t opCode, const void *param, uint8_t paramLength);
76 
77 /**
78  * @brief       Initialize function for hci vendor cmd/event.
79  */
80 void HciVendorInit(void);
81 
82 /**
83  * @brief       Close function for hci vendor cmd/event.
84  */
85 void HciVendorClose(void);
86 
87 #ifdef __cplusplus
88 }
89 #endif  // __cplusplus
90 
91 #endif  // HIC_VENDOR_IF_H
92