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 #ifndef LINK_BROADCAST_MANAGER_STRUCT_H 17 #define LINK_BROADCAST_MANAGER_STRUCT_H 18 19 #ifdef __cplusplus 20 #if __cplusplus 21 extern "C" { 22 #endif 23 #endif 24 25 #define WIFI_MAC_SIZE 6 26 #define SLE_MAC_SIZE 6 27 #define SLG_SPARK_ID_SIZE 8 28 #define MAX_SLG_ADV_DATA_LEN 11 29 30 typedef enum { 31 BLE_GATT_MASTER = 0, 32 BLE_GATT_SLAVE, 33 BLE_COC_MASTER, 34 BLE_COC_SLAVE, 35 } BleDirectRole; 36 37 typedef enum { 38 SLE_SSAP_MASTER = 0, 39 SLE_SSAP_SLAVE, 40 } SleDirectRole; 41 42 typedef enum { 43 WIFI_HML = 0, 44 WIFI_P2P_GO, 45 WIFI_P2P_GC, 46 } WiFiDirectRole; 47 48 typedef struct { 49 BleDirectRole role; 50 uint8_t psm; 51 } BleDirectParam; 52 53 typedef struct { 54 WiFiDirectRole role; 55 bool channelFlag; 56 bool isSupportActionChannel; 57 bool isSupport160M; 58 uint8_t channel; 59 uint8_t mac[WIFI_MAC_SIZE]; 60 uint8_t psm; 61 } WiFiDirectParam; 62 63 typedef struct { 64 int32_t resultCode; 65 } WiFiDirectRspParam; 66 67 typedef struct { 68 SleDirectRole role; 69 uint8_t mac[SLE_MAC_SIZE]; 70 } SleDirectParam; 71 72 typedef struct { 73 uint8_t sparkId[SLG_SPARK_ID_SIZE]; 74 } SlgParam; 75 76 typedef enum { 77 LINK_BLE_DIRECT = 0, /* Note: Cannot modify value */ 78 LINK_WIFI_DIRECT = 1, 79 LINK_WIFI_DIRECT_RSP = 2, 80 LINK_SLE_DIRECT = 3, 81 LINK_SLE_SLG = 4, 82 LINK_SPARKLINK_DIRECT = 5, 83 LINK_SPARKLINK_DIRECT_RSP = 6, 84 LINK_TYPE_BUTT, 85 } LinkBroadcastType; 86 87 typedef enum { 88 ADV_NON_CONNECTABLE = 0, 89 ADV_CONNECTABLE_RANDOM_ADDR, 90 ADV_TYPE_BUTT, 91 } LinkBroadcastAdvType; 92 93 typedef struct { 94 bool withSrcId; 95 uint16_t challengeCode; 96 LinkBroadcastType type; 97 union { 98 BleDirectParam bleDirect; 99 WiFiDirectParam wifiDirect; 100 WiFiDirectRspParam wifiDirectRsp; 101 SleDirectParam sleDirect; 102 SlgParam slgInfo; 103 }; 104 } LinkBroadcastOption; 105 106 typedef struct { 107 uint8_t sleMac[SLE_MAC_SIZE]; 108 uint8_t advData[MAX_SLG_ADV_DATA_LEN]; 109 } SlgRecordAdvData; 110 111 typedef struct { 112 void (*onSendResult)(const char *networkId, LinkBroadcastType type, int32_t resultCode); 113 } AdvSendListener; 114 115 typedef void (*LinkBroadcastListener)(const char *networkId, 116 const LinkBroadcastOption *option, const char *remoteMac); 117 118 #ifdef __cplusplus 119 #if __cplusplus 120 } 121 #endif 122 #endif 123 #endif