1 /* 2 * Copyright (C) 2021 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 HCI_EVT_H 17 #define HCI_EVT_H 18 19 #include "packet.h" 20 #include "platform/include/list.h" 21 #include "platform/include/mutex.h" 22 23 #ifdef __cplusplus 24 extern "C" { 25 #endif 26 27 #define HCI_FOREACH_EVT_CALLBACKS_START(x) \ 28 MutexLock(HciGetEventCallbackListLock()); \ 29 ListNode *node_ = ListGetFirstNode(HciGetEventCallbackList()); \ 30 while (node_ != NULL) { \ 31 x = ListGetNodeData(node_); \ 32 if ((x) != NULL) { 33 34 #define HCI_FOREACH_EVT_CALLBACKS_END \ 35 } \ 36 node_ = ListGetNextNode(node_); \ 37 } \ 38 MutexUnlock(HciGetEventCallbackListLock()); 39 40 void HciInitEvent(); 41 42 void HciOnEvent(Packet *packet); 43 44 void HciCloseEvent(); 45 46 List *HciGetEventCallbackList(); 47 Mutex *HciGetEventCallbackListLock(); 48 49 #ifdef __cplusplus 50 } 51 #endif 52 53 #endif // HCI_EVT_H 54