• 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 /**
17  * @file softbus_broadcast_adapter_interface.h
18  * @brief Different broadcast protocol stacks adapt layer interfaces
19  *
20  * @since 4.1
21  * @version 1.0
22  */
23 
24 #ifndef SOFTBUS_BROADCAST_ADAPTER_INTERFACE_H
25 #define SOFTBUS_BROADCAST_ADAPTER_INTERFACE_H
26 
27 #include "softbus_broadcast_adapter_type.h"
28 #include "softbus_broadcast_type.h"
29 
30 #ifdef __cplusplus
31 extern "C"{
32 #endif
33 
34 #define MEDIUM_MAX_NUM 2
35 
36 /**
37  * @brief Defines the broadcast callback function.
38  *
39  * @since 4.1
40  * @version 1.0
41  */
42 typedef struct {
43     void (*OnStartBroadcastingCallback)(int32_t advId, int32_t status);
44     void (*OnStopBroadcastingCallback)(int32_t advId, int32_t status);
45     void (*OnUpdateBroadcastingCallback)(int32_t advId, int32_t status);
46     void (*OnSetBroadcastingCallback)(int32_t advId, int32_t status);
47     void (*OnSetBroadcastingParamCallback)(int32_t advId, int32_t status);
48     void (*OnEnableBroadcastingCallback)(int32_t advId, int32_t status);
49     void (*OnDisableBroadcastingCallback)(int32_t advId, int32_t status);
50 } SoftbusBroadcastCallback;
51 
52 /**
53  * @brief Defines the broadcast scan callback function.
54  *
55  * @since 4.1
56  * @version 1.0
57  */
58 typedef struct {
59     void (*OnStartScanCallback)(int32_t scannerId, int32_t status);
60     void (*OnStopScanCallback)(int32_t scannerId, int32_t status);
61     void (*OnReportScanDataCallback)(int32_t scannerId, const SoftBusBcScanResult *reportData);
62     void (*OnScanStateChanged)(int32_t resultCode, bool isStartScan);
63     void (*OnLpDeviceInfoCallback)(const SoftbusBroadcastUuid *uuid, int32_t type, uint8_t *data, uint32_t dataSize);
64 } SoftbusScanCallback;
65 
66 /**
67  * @brief Defines Different broadcast protocol stacks adapt layer interfaces
68  *
69  * @since 4.1
70  * @version 1.0
71  */
72 typedef struct {
73     int32_t (*Init)(void);
74     int32_t (*DeInit)(void);
75     int32_t (*RegisterBroadcaster)(int32_t *advId, const SoftbusBroadcastCallback *cb);
76     int32_t (*UnRegisterBroadcaster)(int32_t advId);
77     int32_t (*RegisterScanListener)(int32_t *scannerId, const SoftbusScanCallback *cb);
78     int32_t (*UnRegisterScanListener)(int32_t scannerId);
79     int32_t (*StartBroadcasting)(int32_t advId, const SoftbusBroadcastParam *param, const SoftbusBroadcastData *data);
80     int32_t (*SetScanParams)(int32_t scannerId, const SoftBusBcScanParams *param, const SoftBusBcScanFilter *scanFilter,
81         int32_t filterSize, SoftbusSetFilterCmd cmdId);
82     int32_t (*StopBroadcasting)(int32_t advId);
83     int32_t (*SetBroadcastingData)(int32_t advId, const SoftbusBroadcastData *data);
84     int32_t (*SetBroadcastingParam)(int32_t advId, const SoftbusBroadcastParam *param);
85     int32_t (*EnableBroadcasting)(int32_t advId);
86     int32_t (*DisableBroadcasting)(int32_t advId);
87     int32_t (*UpdateBroadcasting)(int32_t advId, const SoftbusBroadcastParam *param, const SoftbusBroadcastData *data);
88     int32_t (*StartScan)(int32_t scannerId, const SoftBusBcScanParams *param, const SoftBusBcScanFilter *scanFilter,
89         int32_t filterSize);
90     int32_t (*StopScan)(int32_t scannerId);
91     bool (*IsLpDeviceAvailable)(void);
92     bool (*SetAdvFilterParam)(LpServerType type, const SoftBusLpBroadcastParam *bcParam,
93         const SoftBusLpScanParam *scanParam);
94     int32_t (*GetBroadcastHandle)(int32_t advId, int32_t *bcHandle);
95     int32_t (*EnableSyncDataToLpDevice)(void);
96     int32_t (*DisableSyncDataToLpDevice)(void);
97     int32_t (*SetScanReportChannelToLpDevice)(int32_t scannerId, bool enable);
98     int32_t (*SetLpDeviceParam)(int32_t duration, int32_t maxExtAdvEvents, int32_t window,
99         int32_t interval, int32_t bcHandle);
100 } SoftbusBroadcastMediumInterface;
101 
102 /**
103  * @brief Defines interface functions for registering different media
104  *
105  * @since 4.1
106  * @version 1.0
107  */
108 int32_t RegisterBroadcastMediumFunction(SoftbusMediumType type, const SoftbusBroadcastMediumInterface *interface);
109 
110 /**
111  * @brief Defines interface functions for unregistering different media
112  *
113  * @since 4.1
114  * @version 1.0
115  */
116 int32_t UnRegisterBroadcastMediumFunction(SoftbusMediumType type);
117 
118 #ifdef __cplusplus
119 }
120 #endif
121 
122 #endif /* SOFTBUS_BROADCAST_ADAPTER_INTERFACE_H */
123