1 /*
2  * Copyright (c) 2023 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 SOFTBUS_ADAPTER_BLE_CONFLICT_H
17 #define SOFTBUS_ADAPTER_BLE_CONFLICT_H
18 
19 #include <stdbool.h>
20 #include <stdint.h>
21 
22 #include "softbus_error_code.h"
23 
24 #ifdef __cplusplus
25 extern "C" {
26 #endif
27 
28 typedef struct {
29     int32_t (*reuseConnection)(const char *address, const char *udid, uint32_t requestId);
30     bool (*postBytes)(int32_t underlayerHandle, uint8_t *data, uint32_t dataLen);
31     void (*disconnect)(int32_t underlayerHandle, bool isForce);
32     void (*occupy)(const char *udid, int32_t timeout);
33     void (*cancelOccupy)(const char *udid);
34     int32_t (*getConnection)(const char *udid);
35 } SoftBusBleConflictListener;
36 
37 typedef struct {
38     void (*conflictNotifyConnectResult)(uint32_t requestId, int32_t underlayerHandle, bool result);
39     void (*conflictNotifyDataReceive)(int32_t underlayerHandle, const uint8_t *data, uint32_t dataLen);
40     void (*conflictNotifyDisconnect)(int32_t underlayerHandle, int32_t status);
41 } LegacyConflictEventListener;
42 
43 void SoftbusBleConflictRegisterListener(SoftBusBleConflictListener *listener);
44 void SoftbusBleConflictNotifyConnectResult(uint32_t requestId, int32_t underlayerHandle, bool status);
45 void SoftbusBleConflictNotifyDateReceive(int32_t underlayerHandle, const uint8_t *data, uint32_t dataLen);
46 void SoftbusBleConflictNotifyDisconnect(const char *addr, const char *udid);
47 
48 int32_t LegacyConflictReuseConnection(const char *address, const char *udid, uint32_t requestId,
49     int32_t *underlayerHandle);
50 bool LegacyConflictPostBytes(uint32_t connectionId, uint8_t *data, uint32_t dataLen);
51 void LegacyConflictDisconnect(int32_t underlayerHandle, bool isForce);
52 void LegacyConflictCancelOccupy(const char *udid);
53 void LegacyConflictOccupy(const char *udid, int32_t timeout);
54 int32_t LegacyConflictGetConnection(const char *udid);
55 
56 int32_t LegacyBleInitConflictModule(LegacyConflictEventListener *listener);
57 
58 #ifdef __cplusplus
59 }
60 #endif /* __cplusplus */
61 #endif /* SOFTBUS_ADAPTER_BLE_CONFLICT_H */