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 } SoftbusBroadcastCallback; 48 49 /** 50 * @brief Defines the broadcast scan callback function. 51 * 52 * @since 4.1 53 * @version 1.0 54 */ 55 typedef struct { 56 void (*OnStartScanCallback)(int32_t scannerId, int32_t status); 57 void (*OnStopScanCallback)(int32_t scannerId, int32_t status); 58 void (*OnReportScanDataCallback)(int32_t scannerId, const SoftBusBcScanResult *reportData); 59 void (*OnScanStateChanged)(int32_t resultCode, bool isStartScan); 60 void (*OnLpDeviceInfoCallback)(const SoftbusBroadcastUuid *uuid, int32_t type, uint8_t *data, uint32_t dataSize); 61 } SoftbusScanCallback; 62 63 /** 64 * @brief Defines Different broadcast protocol stacks adapt layer interfaces 65 * 66 * @since 4.1 67 * @version 1.0 68 */ 69 typedef struct { 70 int32_t (*Init)(void); 71 int32_t (*DeInit)(void); 72 int32_t (*RegisterBroadcaster)(int32_t *advId, const SoftbusBroadcastCallback *cb); 73 int32_t (*UnRegisterBroadcaster)(int32_t advId); 74 int32_t (*RegisterScanListener)(int32_t *scannerId, const SoftbusScanCallback *cb); 75 int32_t (*UnRegisterScanListener)(int32_t scannerId); 76 int32_t (*StartBroadcasting)(int32_t advId, const SoftbusBroadcastParam *param, const SoftbusBroadcastData *data); 77 int32_t (*StopBroadcasting)(int32_t advId); 78 int32_t (*SetBroadcastingData)(int32_t advId, const SoftbusBroadcastData *data); 79 int32_t (*UpdateBroadcasting)(int32_t advId, const SoftbusBroadcastParam *param, const SoftbusBroadcastData *data); 80 int32_t (*StartScan)(int32_t scannerId, const SoftBusBcScanParams *param, const SoftBusBcScanFilter *scanFilter, 81 int32_t filterSize); 82 int32_t (*StopScan)(int32_t scannerId); 83 bool (*IsLpDeviceAvailable)(void); 84 bool (*SetAdvFilterParam)(LpServerType type, const SoftBusLpBroadcastParam *bcParam, 85 const SoftBusLpScanParam *scanParam); 86 int32_t (*GetBroadcastHandle)(int32_t advId, int32_t *bcHandle); 87 int32_t (*EnableSyncDataToLpDevice)(void); 88 int32_t (*DisableSyncDataToLpDevice)(void); 89 int32_t (*SetScanReportChannelToLpDevice)(int32_t scannerId, bool enable); 90 int32_t (*SetLpDeviceParam)(int32_t duration, int32_t maxExtAdvEvents, int32_t window, 91 int32_t interval, int32_t bcHandle); 92 } SoftbusBroadcastMediumInterface; 93 94 /** 95 * @brief Defines interface functions for registering different media 96 * 97 * @since 4.1 98 * @version 1.0 99 */ 100 int32_t RegisterBroadcastMediumFunction(SoftbusMediumType type, const SoftbusBroadcastMediumInterface *interface); 101 102 /** 103 * @brief Defines interface functions for unregistering different media 104 * 105 * @since 4.1 106 * @version 1.0 107 */ 108 int32_t UnRegisterBroadcastMediumFunction(SoftbusMediumType type); 109 110 #ifdef __cplusplus 111 } 112 #endif 113 114 #endif /* SOFTBUS_BROADCAST_ADAPTER_INTERFACE_H */ 115