• 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 (*conlictNotifyConnectResult)(int32_t requestId, uint32_t connectionId,
37         int32_t underlayerHandle, bool status);
38     void (*conlictNotifyDataReceive)(uint32_t connectionId, const uint8_t *data, uint32_t dataLen);
39     void (*conlictNotifyDisconnect)(uint32_t connectionId, int32_t status);
40 } LegacyConflictEventListener;
41 
42 void SoftbusBleConflictRegisterListener(SoftBusBleConflictListener *listener);
43 void SoftbusBleConflictNotifyConnectResult(int32_t requestId, int32_t underlayerHandle, bool status);
44 void SoftbusBleConflictNotifyDateReceive(int32_t underlayerHandle, const uint8_t *data, uint32_t dataLen);
45 void SoftbusBleConflictNotifyDisconnect(const char *addr, const char *udid);
46 
47 int32_t LegacyConflictReuseConnection(const char *address, const char *udid, uint32_t requestId,
48     uint32_t *connectionId);
49 bool LegacyConflictPostBytes(int32_t underlayerHandle, uint8_t *data, uint32_t dataLen);
50 void LegacyConflictDisconnect(int32_t handle, bool isForce);
51 void LegacyConflictCancelOccupy(const char *udid);
52 void LegacyConflictOccupy(const char *udid, int32_t timeout);
53 int32_t LegacyConflictGetConnection(const char *udid);
54 
55 int32_t LegacyBleInitConflictModule(LegacyConflictEventListener *listener);
56 
57 #ifdef __cplusplus
58 }
59 #endif /* __cplusplus */
60 #endif /* SOFTBUS_ADAPTER_BLE_CONFLICT_H */