1 /* 2 * Copyright (c) 2025 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_STRUCT_H 25 #define SOFTBUS_BROADCAST_ADAPTER_INTERFACE_STRUCT_H 26 27 #include "softbus_broadcast_adapter_type_struct.h" 28 #include "softbus_broadcast_type_struct.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)(BroadcastProtocol protocol, int32_t advId, int32_t status); 44 void (*OnStopBroadcastingCallback)(BroadcastProtocol protocol, int32_t advId, int32_t status); 45 void (*OnUpdateBroadcastingCallback)(BroadcastProtocol protocol, int32_t advId, int32_t status); 46 void (*OnSetBroadcastingCallback)(BroadcastProtocol protocol, int32_t advId, int32_t status); 47 void (*OnSetBroadcastingParamCallback)(BroadcastProtocol protocol, int32_t advId, int32_t status); 48 void (*OnEnableBroadcastingCallback)(BroadcastProtocol protocol, int32_t advId, int32_t status); 49 void (*OnDisableBroadcastingCallback)(BroadcastProtocol protocol, 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)(BroadcastProtocol protocol, int32_t scannerId, int32_t status); 60 void (*OnStopScanCallback)(BroadcastProtocol protocol, int32_t scannerId, int32_t status); 61 void (*OnReportScanDataCallback)(BroadcastProtocol protocol, int32_t scannerId, 62 const SoftBusBcScanResult *reportData); 63 void (*OnScanStateChanged)(BroadcastProtocol protocol, int32_t resultCode, bool isStartScan); 64 void (*OnLpDeviceInfoCallback)(BroadcastProtocol protocol, const SoftbusBroadcastUuid *uuid, 65 int32_t type, uint8_t *data, uint32_t dataSize); 66 } SoftbusScanCallback; 67 68 /** 69 * @brief Defines Different broadcast protocol stacks adapt layer interfaces 70 * 71 * @since 4.1 72 * @version 1.0 73 */ 74 typedef struct { 75 int32_t (*Init)(void); 76 int32_t (*DeInit)(void); 77 int32_t (*RegisterBroadcaster)(int32_t *advId, const SoftbusBroadcastCallback *cb); 78 int32_t (*UnRegisterBroadcaster)(int32_t advId); 79 int32_t (*RegisterScanListener)(int32_t *scannerId, const SoftbusScanCallback *cb); 80 int32_t (*UnRegisterScanListener)(int32_t scannerId); 81 int32_t (*StartBroadcasting)(int32_t advId, const SoftbusBroadcastParam *param, SoftbusBroadcastData *data); 82 int32_t (*SetScanParams)(int32_t scannerId, const SoftBusBcScanParams *param, const SoftBusBcScanFilter *scanFilter, 83 int32_t filterSize, SoftbusSetFilterCmd cmdId); 84 int32_t (*StopBroadcasting)(int32_t advId); 85 int32_t (*EnableAdvertising)(uint8_t advHandle); 86 int32_t (*DisableAdvertising)(uint8_t advHandle); 87 int32_t (*SetBroadcastingData)(int32_t advId, const SoftbusBroadcastData *data); 88 int32_t (*SetBroadcastingParam)(int32_t advId, const SoftbusBroadcastParam *param); 89 int32_t (*EnableBroadcasting)(int32_t advId); 90 int32_t (*DisableBroadcasting)(int32_t advId); 91 int32_t (*UpdateBroadcasting)(int32_t advId, const SoftbusBroadcastParam *param, SoftbusBroadcastData *data); 92 int32_t (*StartScan)(int32_t scannerId, const SoftBusBcScanParams *param, const SoftBusBcScanFilter *scanFilter, 93 int32_t filterSize); 94 int32_t (*StopScan)(int32_t scannerId); 95 bool (*IsLpDeviceAvailable)(void); 96 bool (*SetAdvFilterParam)(LpServerType type, const SoftBusLpBroadcastParam *bcParam, 97 const SoftBusLpScanParam *scanParam); 98 int32_t (*GetBroadcastHandle)(int32_t advId, int32_t *bcHandle); 99 int32_t (*EnableSyncDataToLpDevice)(void); 100 int32_t (*DisableSyncDataToLpDevice)(void); 101 int32_t (*SetScanReportChannelToLpDevice)(int32_t scannerId, bool enable); 102 int32_t (*SetLpDeviceParam)(int32_t duration, int32_t maxExtAdvEvents, int32_t window, 103 int32_t interval, int32_t bcHandle); 104 } SoftbusBroadcastMediumInterface; 105 106 #ifdef __cplusplus 107 } 108 #endif 109 110 #endif /* SOFTBUS_BROADCAST_ADAPTER_INTERFACE_STRUCT_H */ 111