• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 #ifdef __cplusplus
23 extern "C" {
24 #endif
25 
26 typedef struct {
27     int32_t (*reuseConnection)(const char *address, const char *udid, uint32_t requestId);
28     bool (*postBytes)(int32_t underlayerHandle, uint8_t *data, uint32_t dataLen);
29     void (*disconnect)(int32_t underlayerHandle, bool isForce);
30     void (*occupy)(const char *udid, int32_t timeout);
31     void (*cancelOccupy)(const char *udid);
32     int32_t (*getConnection)(const char *udid);
33 } SoftBusBleConflictListener;
34 
35 typedef struct {
36     void (*conflictNotifyConnectResult)(uint32_t requestId, int32_t underlayerHandle, bool result);
37     void (*conflictNotifyDataReceive)(int32_t underlayerHandle, const uint8_t *data, uint32_t dataLen);
38     void (*conflictNotifyDisconnect)(int32_t underlayerHandle, int32_t status);
39 } LegacyConflictEventListener;
40 
41 void SoftbusBleConflictRegisterListener(SoftBusBleConflictListener *listener);
42 void SoftbusBleConflictNotifyConnectResult(uint32_t requestId, int32_t underlayerHandle, bool status);
43 void SoftbusBleConflictNotifyDateReceive(int32_t underlayerHandle, const uint8_t *data, uint32_t dataLen);
44 void SoftbusBleConflictNotifyDisconnect(const char *addr, const char *udid);
45 
46 int32_t LegacyConflictReuseConnection(const char *address, const char *udid, uint32_t requestId,
47     int32_t *underlayerHandle);
48 bool LegacyConflictPostBytes(uint32_t connectionId, uint8_t *data, uint32_t dataLen);
49 void LegacyConflictDisconnect(int32_t underlayerHandle, bool isForce);
50 void LegacyConflictCancelOccupy(const char *udid);
51 void LegacyConflictOccupy(const char *udid, int32_t timeout);
52 int32_t LegacyConflictGetConnection(const char *udid);
53 
54 int32_t LegacyBleInitConflictModule(LegacyConflictEventListener *listener);
55 
56 #ifdef __cplusplus
57 }
58 #endif /* __cplusplus */
59 #endif /* SOFTBUS_ADAPTER_BLE_CONFLICT_H */