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_type.h 18 * @brief Declare functions and constants for the soft bus broadcast adaptation 19 * 20 * @since 4.1 21 * @version 1.0 22 */ 23 24 #ifndef SOFTBUS_BROADCAST_ADAPTER_TYPE_H 25 #define SOFTBUS_BROADCAST_ADAPTER_TYPE_H 26 27 #include <stdbool.h> 28 #include <stdint.h> 29 30 #ifdef __cplusplus 31 extern "C"{ 32 #endif 33 34 /** 35 * @brief Defines mac address length 36 * 37 * @since 4.1 38 * @version 1.0 39 */ 40 #define SOFTBUS_ADDR_MAC_LEN 6 41 42 #define SOFTBUS_IRK_LEN 16 43 #define SOFTBUS_UDID_HASH_LEN 32 44 45 /** 46 * @brief Defines the length of local name, the maximum length of complete local name is 30 bytes. 47 * 48 * @since 4.1 49 * @version 1.0 50 */ 51 #define SOFTBUS_LOCAL_NAME_LEN_MAX 30 52 53 /** 54 * @brief Defines different broadcast media protocol stacks 55 * 56 * @since 4.1 57 * @version 1.0 58 */ 59 typedef enum { 60 BROADCAST_MEDIUM_TYPE_BLE, 61 BROADCAST_MEDIUM_TYPE_SLE, 62 BROADCAST_MEDIUM_TYPE_BUTT, 63 } SoftbusMediumType; 64 65 /** 66 * @brief Defines the broadcast service type. 67 * 68 * @since 4.1 69 * @version 1.0 70 */ 71 typedef enum { 72 BROADCAST_DATA_TYPE_SERVICE, // The broadcast data type is service data. 73 BROADCAST_DATA_TYPE_MANUFACTURER, // The broadcast data type is manufacturer data. 74 BROADCAST_DATA_TYPE_BUTT, 75 } SoftbusBcDataType; 76 77 /** 78 * @brief Defines the broadcast data information 79 * 80 * @since 4.1 81 * @version 1.0 82 */ 83 typedef struct { 84 SoftbusBcDataType type; // broadcast data type {@link SoftbusBcDataType}. 85 uint16_t id; // broadcast data id, uuid or company id. 86 uint16_t payloadLen; 87 uint8_t *payload; // if pointer defines rsp payload, pointer may be null 88 } SoftbusBroadcastPayload; 89 90 /** 91 * @brief Defines the broadcast packet. 92 * 93 * @since 4.1 94 * @version 1.0 95 */ 96 typedef struct { 97 SoftbusBroadcastPayload bcData; 98 SoftbusBroadcastPayload rspData; 99 // By default, the flag behavior is supported. If the flag behavior is not supported, the value must be set to false 100 bool isSupportFlag; 101 uint8_t flag; 102 } SoftbusBroadcastData; 103 104 /** 105 * @brief Defines mac address information 106 * 107 * @since 4.1 108 * @version 1.0 109 */ 110 typedef struct { 111 uint8_t addr[SOFTBUS_ADDR_MAC_LEN]; 112 } SoftbusMacAddr; 113 114 typedef struct { 115 uint8_t uuidLen; 116 uint8_t *uuid; 117 } SoftbusBroadcastUuid; 118 119 /** 120 * @brief Defines the device information returned by <b>SoftbusBroadcastCallback</b>. 121 * 122 * @since 4.1 123 * @version 1.0 124 */ 125 typedef struct { 126 uint8_t eventType; 127 uint8_t dataStatus; 128 uint8_t primaryPhy; 129 uint8_t secondaryPhy; 130 uint8_t advSid; 131 int8_t txPower; 132 int8_t rssi; 133 uint8_t addrType; 134 SoftbusMacAddr addr; 135 int8_t *deviceName; 136 uint8_t localName[SOFTBUS_LOCAL_NAME_LEN_MAX]; 137 SoftbusBroadcastData data; 138 } SoftBusBcScanResult; 139 140 /** 141 * @brief Defines the broadcast parameters 142 * 143 * @since 4.1 144 * @version 1.0 145 */ 146 typedef struct { 147 int32_t minInterval; 148 int32_t maxInterval; 149 uint8_t advType; 150 uint8_t advFilterPolicy; 151 uint8_t ownAddrType; 152 uint8_t peerAddrType; 153 SoftbusMacAddr peerAddr; 154 int32_t channelMap; 155 int32_t duration; 156 int8_t txPower; 157 bool isSupportRpa; 158 uint8_t ownIrk[SOFTBUS_IRK_LEN]; 159 uint8_t ownUdidHash[SOFTBUS_UDID_HASH_LEN]; 160 SoftbusMacAddr localAddr; 161 } SoftbusBroadcastParam; 162 163 /** 164 * @brief Defines broadcast scan filters 165 * 166 * @since 4.1 167 * @version 1.0 168 */ 169 typedef struct { 170 int8_t *address; 171 int8_t *deviceName; 172 uint16_t serviceUuid; 173 uint32_t serviceDataLength; 174 uint8_t *serviceData; 175 uint8_t *serviceDataMask; 176 uint16_t manufactureId; 177 uint32_t manufactureDataLength; 178 uint8_t *manufactureData; 179 uint8_t *manufactureDataMask; 180 bool advIndReport; 181 } SoftBusBcScanFilter; 182 183 /** 184 * @brief Defines broadcast scan parameters 185 * 186 * @since 4.1 187 * @version 1.0 188 */ 189 typedef struct { 190 uint16_t scanInterval; 191 uint16_t scanWindow; 192 uint8_t scanType; 193 uint8_t scanPhy; 194 uint8_t scanFilterPolicy; 195 } SoftBusBcScanParams; 196 197 typedef struct { 198 int32_t advHandle; 199 SoftbusBroadcastData advData; 200 SoftbusBroadcastParam advParam; 201 } SoftBusLpBroadcastParam; 202 203 typedef struct { 204 SoftBusBcScanParams scanParam; 205 SoftBusBcScanFilter *filter; 206 uint8_t filterSize; 207 } SoftBusLpScanParam; 208 209 #ifdef __cplusplus 210 } 211 #endif 212 213 #endif /* SOFTBUS_BROADCAST_ADAPTER_TYPE_H */ 214