1 /*
2  * Copyright (c) 2022 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 SOFTBUS_BUS_CENTER_H
17 #define SOFTBUS_BUS_CENTER_H
18 
19 #include <cstdint>
20 
21 #ifdef __cplusplus
22 extern "C" {
23 #endif
24 constexpr uint32_t MOCK_NETWORK_ID_BUF_LEN = 65;
25 constexpr uint32_t MOCK_DEVICE_NAME_BUF_LEN = 65;
26 /**
27  * @brief Defines the basic information about a device.
28  *
29  * @since 1.0
30  * @version 1.0
31  */
32 typedef struct {
33     char networkId[MOCK_NETWORK_ID_BUF_LEN];    /**< Device ID */
34     char deviceName[MOCK_DEVICE_NAME_BUF_LEN];  /**< Device name */
35     uint16_t deviceTypeId;
36 } NodeBasicInfo;
37 
38 typedef enum {
39     LOW_ACCURACY = 0,
40     NORMAL_ACCURACY,
41     HIGH_ACCURACY,
42     SUPER_HIGH_ACCURACY,
43     UNAVAIL_ACCURACY = 0xFFFF,
44 } TimeSyncAccuracy;
45 
46 typedef enum {
47     SHORT_PERIOD = 0,
48     NORMAL_PERIOD,
49     LONG_PERIOD,
50 } TimeSyncPeriod;
51 
52 typedef struct {
53     int32_t millisecond;
54     int32_t microsecond;
55     TimeSyncAccuracy accuracy;
56 } TimeSyncResult;
57 
58 typedef enum {
59     NODE_SPECIFIC = 0,
60     ALL_LNN,
61     WRITE_RTC,
62 } TimeSyncFlag;
63 typedef struct {
64     TimeSyncResult result;
65     TimeSyncFlag flag;
66     union {
67         char targetNetworkId[MOCK_NETWORK_ID_BUF_LEN];
68         char masterNetworkId[MOCK_NETWORK_ID_BUF_LEN];
69     } target;
70 } TimeSyncResultInfo;
71 
72 typedef struct {
73     void (*onTimeSyncResult)(const TimeSyncResultInfo *info, int32_t retCode);
74 } ITimeSyncCb;
75 
76 int32_t GetLocalNodeDeviceInfo(const char *pkgName, NodeBasicInfo *info);
77 #ifdef __cplusplus
78 }
79 #endif
80 #endif // SOFTBUS_BUS_CENTER_H