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 BROADCAST_STRUCT_H 17 #define BROADCAST_STRUCT_H 18 19 #include <stdint.h> 20 #include <stdbool.h> 21 22 #include "softbus_common.h" 23 24 #ifdef __cplusplus 25 extern "C" { 26 #endif 27 28 typedef uint32_t BroadCastAddr; 29 #define BROADCAST_TARGET_AREA 0xfffffffe 30 31 typedef enum : uint8_t { 32 CLIP_BROAD_COPIED = 0, 33 FOREGROUND_APP, 34 ORIENTATION_RANGE, 35 EVENT_TYPE_MAX, 36 } EventType; 37 38 typedef enum : uint8_t { 39 EVENT_LOW_FREQ = 0, // send 200ms or receive 2% 40 EVENT_MID_FREQ, // send 100ms or receive 10% 41 EVENT_HIGH_FREQ, // send 60ms or receive 25% 42 EVENT_SUPER_HIGH_FREQ, // send 20ms or receive 50% 43 EVENT_FREQ_BUTT, 44 } EventFreq; 45 46 typedef struct { 47 EventType event; 48 EventFreq freq; 49 unsigned char *data; 50 uint32_t dataLen; 51 bool screenOff; 52 } EventData; 53 54 typedef struct { 55 EventType event; 56 char senderNetworkId[NETWORK_ID_BUF_LEN]; 57 char uidHash[MAX_ACCOUNT_HASH_LEN]; 58 char version; 59 bool isEncrpted; 60 uint16_t seqNo; 61 unsigned char *data; 62 uint32_t dataLen; 63 } EventNotify; 64 65 typedef struct { 66 EventType event; 67 EventFreq freq; 68 bool deduplicate; 69 void (*OnEventRecived)(const EventNotify *event); 70 } EventListener; 71 72 typedef struct { 73 void (*OnLinkEventReceived)(const char *networkId, const char *localNetworkId, uint16_t seqNum); 74 } LinkEventListener; 75 76 #ifdef __cplusplus 77 } 78 #endif 79 #endif // BROADCAST_STRUCT_H