1 /*
2  * Copyright (c) 2021-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 /**
17  * @addtogroup SoftBus
18  * @{
19  *
20  * @brief Provides high-speed, secure communication between devices.
21  *
22  * This module implements unified distributed communication capability management between nearby devices, and provides
23  * link-independent device discovery and transmission interfaces to support service publishing and data transmission.
24  *
25  * @since 1.0
26  * @version 1.0
27  */
28 /** @} */
29 
30 /**
31  * @file softbus_bus_center.h
32  *
33  * @brief Declares functions and constants for the bus center of the Intelligent Soft Bus.
34  *
35  * The functions are used to perform
36  * the following operations: \n
37  * <ul>
38  * <li>Adding a device to and removing a device from a LNN</li>
39  * <li>Listening for device online, offline, and information change events</li>
40  *
41  * @since 1.0
42  * @version 1.0
43  */
44 
45 #ifndef SOFTBUS_BUS_CENTER_H
46 #define SOFTBUS_BUS_CENTER_H
47 
48 #include <stdbool.h>
49 #include <stdint.h>
50 
51 #include "softbus_common.h"
52 
53 #ifdef __cplusplus
54 extern "C" {
55 #endif
56 
57 /**
58  * @brief Indicates the length of a device name buffer, including the terminating null character <b>\0</b>.
59  *
60  * @since 1.0
61  * @version 1.0
62  */
63 #define DEVICE_NAME_BUF_LEN 128
64 
65 /**
66  * @brief Indicates the mask bit for a device online event.
67  * If you want to receive such events, set the mask bit in {@link INodeStateCb.events}.
68  *
69  * @since 1.0
70  * @version 1.0
71  */
72 #define EVENT_NODE_STATE_ONLINE 0x1
73 
74 /**
75  * @brief Indicates the mask bit for a device offline event.
76  * If you want to receive such events, set the mask bit in {@link INodeStateCb.events}.
77  *
78  * @since 1.0
79  * @version 1.0
80  */
81 #define EVENT_NODE_STATE_OFFLINE 0x02
82 
83 /**
84  * @brief Indicates the mask bit for a peer device information change event.
85  * If you want to receive such events, set the mask bit in {@link INodeStateCb.events}.
86  *
87  * @since 1.0
88  * @version 1.0
89  */
90 #define EVENT_NODE_STATE_INFO_CHANGED 0x04
91 
92 /**
93  * @brief Indicates the mask bit for a LNN node running status change event.
94  * If you want to receive such events, set the mask bit in {@link INodeStateCb.events}.
95  *
96  * @since 1.0
97  * @version 1.0
98  */
99 #define EVENT_NODE_STATUS_CHANGED 0x08
100 
101 /**
102  * @brief Indicates the mask bit for a LNN node network status change event.
103  * If you want to receive such events, set the mask bit in {@link INodeStateCb.events}.
104  *
105  * @since 1.0
106  * @version 1.0
107  */
108 #define EVENT_NODE_STATE_NETWORK_CHANGED 0x10
109 
110 /**
111  * @brief Indicates mask bits for {@link INodeStateCb.events}.
112  *
113  * @since 1.0
114  * @version 1.0
115  */
116 #define EVENT_NODE_STATE_MASK 0xF
117 
118 /**
119  * @brief Indicates the mask bit for a peer device hichain proof exception event.
120  * If you want to receive such events, set the mask bit in {@link INodeStateCb.events}.
121  *
122  * @since 1.0
123  * @version 1.0
124  */
125 #define EVENT_NODE_HICHAIN_PROOF_EXCEPTION 0x20
126 
127 /**
128  * @brief The maximum length of meta node bypass info {@link MetaNodeConfigInfo.bypassInfo}.
129  *
130  * @since 1.0
131  * @version 1.0
132  */
133 #define META_NODE_BYPASS_INFO_LEN 64
134 
135 /**
136  * @brief Indicates the maximum length of the callerId, including the terminating null character <b>\0</b>.
137  *
138  * @since 1.0
139  * @version 1.0
140  */
141 #define CALLER_ID_MAX_LEN 128
142 
143 /**
144  * @brief Indicates the maximum length of the custom user data.
145  *
146  * @since 1.0
147  * @version 1.0
148  */
149 #define USER_DATA_MAX_LEN 256
150 
151 /**
152  * @brief The maximum of meta node {@link MetaNodeConfigInfo.bypassInfo}.
153  *
154  * @since 1.0
155  * @version 1.0
156  */
157 #define MAX_META_NODE_NUM 3
158 
159 /**
160  * @brief Indicates the length of os version buffer, including the terminating null character <b>\0</b>.
161  *
162  * @since 1.0
163  * @version 1.0
164  */
165 #define OS_VERSION_BUF_LEN 128
166 
167 /**
168  * @brief Enumerates keys for an online device.
169  * The key can be obtained via {@link GetNodeKeyInfo}.
170  *
171  * @since 1.0
172  * @version 1.0
173  */
174 typedef enum {
175     NODE_KEY_UDID = 0,               /**< UDID in string format*/
176     NODE_KEY_UUID,                   /**< UUID in string format */
177     NODE_KEY_MASTER_UDID,            /**< UDID of device in string format */
178     NODE_KEY_BR_MAC,                 /**< BR MAC in string format */
179     NODE_KEY_IP_ADDRESS,             /**< IP address in string format */
180     NODE_KEY_DEV_NAME,               /**< Device name in string format */
181     NODE_KEY_NETWORK_CAPABILITY,     /**< Network capability in number format */
182     NODE_KEY_NETWORK_TYPE,           /**< Network type in number format */
183     NODE_KEY_BLE_OFFLINE_CODE,       /**< Ble offlinecode in string format */
184     NODE_KEY_DATA_CHANGE_FLAG,       /**< Device info change flag in number format */
185     NODE_KEY_NODE_ADDRESS,           /**< Node address in string format */
186     NODE_KEY_P2P_IP_ADDRESS,         /**< P2P IP address in string format */
187     NODE_KEY_DEVICE_SECURITY_LEVEL,  /**< device security level in number format */
188     NODE_KEY_DEVICE_SCREEN_STATUS,   /**< device screen status in bool format */
189 } NodeDeviceInfoKey;
190 
191 /**
192  * @brief Enumerates supported network capabilities.
193  *
194  * @since 1.0
195  * @version 1.0
196  */
197 typedef enum {
198     BIT_BLE = 0,    /**< Support BLE */
199     BIT_BR,         /**< Support BR */
200     BIT_WIFI,       /**< Support WIFI */
201     BIT_WIFI_P2P,   /**< Support WIFI P2P */
202     BIT_WIFI_24G,   /**< Support WIFI 2.4G */
203     BIT_WIFI_5G,    /**< Support WIFI 5G */
204     BIT_ETH,        /**< Support ETH */
205     BIT_COUNT,      /**< Invalid type */
206 } NetCapability;
207 
208 /**
209  * @brief Enumerates network types for an online device.
210  *
211  * @since 1.0
212  * @version 1.0
213  */
214 typedef enum {
215     BIT_NETWORK_TYPE_UNKNOWN = 0,  /**< Unknown network type */
216     BIT_NETWORK_TYPE_WIFI,         /**< WIFI network type */
217     BIT_NETWORK_TYPE_BLE,          /**< BLE network type */
218     BIT_NETWORK_TYPE_BR,           /**< BR network type */
219     BIT_NETWORK_TYPE_P2P,          /**< P2P network type */
220     BIT_NETWORK_TYPE_COUNT,        /**< Invalid type */
221 } NetworkType;
222 
223 /**
224  * @brief Enumerates accuracy for time synchronize among device.
225  *
226  * @since 1.0
227  * @version 1.0
228  */
229 typedef enum {
230     LOW_ACCURACY = 0,              /**< Low accuracy */
231     NORMAL_ACCURACY,               /**< Normal accuracy */
232     HIGH_ACCURACY,                 /**< High accuracy */
233     SUPER_HIGH_ACCURACY,           /**< Super high accuracy */
234     UNAVAIL_ACCURACY = 0xFFFF,     /**< Invalid accuracy */
235 } TimeSyncAccuracy;
236 
237 /**
238  * @brief Enumerates time synchronize period among device.
239  *
240  * @since 1.0
241  * @version 1.0
242  */
243 typedef enum {
244     SHORT_PERIOD = 0,  /**< Short accuracy */
245     NORMAL_PERIOD,     /**< Normal accuracy */
246     LONG_PERIOD,       /**< Long accuracy */
247 } TimeSyncPeriod;
248 
249 /**
250  * @brief Enumerates time synchronize flag.
251  *
252  * @since 1.0
253  * @version 1.0
254  */
255 typedef enum {
256     NODE_SPECIFIC = 0,  /**< Time sync in a specific mode */
257     ALL_LNN,            /**< Time sync during the entire networking */
258     WRITE_RTC,          /**< Write RTC synchronization */
259 } TimeSyncFlag;
260 
261 /**
262  * @brief Defines the basic information of a device.
263  *
264  * @since 1.0
265  * @version 1.0
266  */
267 typedef struct {
268     char networkId[NETWORK_ID_BUF_LEN];    /**< Device network id */
269     char deviceName[DEVICE_NAME_BUF_LEN];  /**< Device name */
270     uint16_t deviceTypeId;                 /**< Device type id */
271     int32_t osType;                        /**< Os type */
272     char osVersion[OS_VERSION_BUF_LEN];    /**< Os version */
273 } NodeBasicInfo;
274 
275 /**
276  * @brief Enumerates device information change types. For details, see {@link INodeStateCb.onNodeBasicInfoChanged}.
277  *
278  * @since 1.0
279  * @version 1.0
280  */
281 typedef enum {
282     TYPE_NETWORK_ID = 0,  /**< Network ID change */
283     TYPE_DEVICE_NAME,     /**< Device name change */
284     TYPE_NETWORK_INFO,    /**< Device network info change */
285 } NodeBasicInfoType;
286 
287 /**
288  * @brief Defines the running status about a device. see {@link INodeStateCb.onNodeStatusChanged}
289  *
290  * @since 1.0
291  * @version 1.0
292  */
293 typedef struct {
294     NodeBasicInfo basicInfo;     /**< The basic info of device */
295     uint16_t authStatus;         /**< The auth state of device */
296     uint16_t dataBaseStatus;     /**< The data base state of device */
297     uint16_t meshType;           /**< The mesh type of device */
298     uint16_t reserved[NODE_STATUS_MAX_NUM - 3];  /**< The reserved data of device */
299 } NodeStatus;
300 
301 /**
302  * @brief Enumerates device information change types. For details, see {@link INodeStateCb.onNodeStatusChanged}.
303  *
304  * @since 1.0
305  * @version 1.0
306  */
307 typedef enum {
308     TYPE_AUTH_STATUS = 2,     /**< Certify status change */
309     TYPE_DATABASE_STATUS = 3, /**< Database  change */
310     TYPE_MESH_TYPE = 4,       /**< Lnn mesh type change */
311     TYPE_SCREEN_STATUS = 5,   /**< Screen status change */
312     TYPE_STATUS_MAX = 6,      /**< Max num */
313 } NodeStatusType;
314 
315 /**
316  * @brief Defines time synchronize result.
317  *
318  * @since 1.0
319  * @version 1.0
320  */
321 typedef struct {
322     int32_t millisecond;        /**< Number of milli second */
323     int32_t microsecond;        /**< Number of micro second */
324     TimeSyncAccuracy accuracy;  /**< Time sync accuracy */
325 } TimeSyncResult;
326 
327 /**
328  * @brief Defines time synchronize result info.
329  *
330  * @since 1.0
331  * @version 1.0
332  */
333 typedef struct {
334     TimeSyncResult result;    /**< Time synchronize result */
335     TimeSyncFlag flag;        /**< Time synchronize flag */
336     union {
337         char targetNetworkId[NETWORK_ID_BUF_LEN];  /**< The network id of time sync target device */
338         char masterNetworkId[NETWORK_ID_BUF_LEN];  /**< The network id of node */
339     } target;
340 } TimeSyncResultInfo;
341 
342 /**
343  * @brief Enumerates error codes for service publishing failures.
344  *
345  * The error codes are returned to the caller through <b>IPublishCallback</b>.
346  *
347  * @since 1.0
348  * @version 1.0
349  */
350 typedef enum {
351     PUBLISH_LNN_SUCCESS = 0,              /**< Publish success */
352     PUBLISH_LNN_NOT_SUPPORT_MEDIUM = 1,   /**< Unsupported medium */
353     PUBLISH_LNN_INTERNAL = 2,             /**< Internal error */
354     PUBLISH_LNN_UNKNOWN = 0xFF            /**< Unknown reason */
355 } PublishResult;
356 
357 /**
358  * @brief Enumerates error codes for service subscription failures.
359  *
360  * The error codes are returned to the caller through <b>IDiscoveryCallback</b>.
361  *
362  * @since 1.0
363  * @version 1.0
364  */
365 typedef enum {
366     REFRESH_LNN_SUCCESS = 0,             /**< Refresh success */
367     REFRESH_LNN_NOT_SUPPORT_MEDIUM = 1,  /**< Unsupported medium */
368     REFRESH_LNN_INTERNAL = 2,            /**< Internal error */
369     REFRESH_LNN_UNKNOWN = 0xFF           /**< Unknown error */
370 } RefreshResult;
371 
372 /**
373  * @brief Defines the callbacks for successful and failed service publishing.
374  *
375  * @since 1.0
376  * @version 1.0
377  */
378 typedef struct {
379     /**
380      * @brief Callback for publish result.
381      *
382      * @param publishId the publish Id which has been published.
383      * @param reason the publish result of this time.
384      *
385      * @since 1.0
386      * @version 1.0
387      */
388     void (*OnPublishResult)(int publishId, PublishResult reason);
389 } IPublishCb;
390 
391 /**
392  * @brief Defines a callback for service subscription.
393  *
394  * Three types of callbacks are available.
395  *
396  * @since 1.0
397  * @version 1.0
398  */
399 typedef struct {
400     /**
401      * @brief Callback that is invoked when a device is found.
402      *
403      * @param device Indicates the pointer to the device info about device.
404      * For details, see {@link DeviceInfo}.
405      *
406      * @since 1.0
407      * @version 1.0
408      */
409     void (*OnDeviceFound)(const DeviceInfo *device);
410     /**
411      * @brief Callback for a subscription result.
412      *
413      * @param refreshId Indicates the refresh Id which.
414      * @param reason Indicates the result of this time. For details, see {@link RefreshResult}.
415      *
416      * @since 1.0
417      * @version 1.0
418      */
419     void (*OnDiscoverResult)(int32_t refreshId, RefreshResult reason);
420 } IRefreshCallback;
421 
422 /**
423  * @brief Defines a callback that is invoked when the device state or information changes.
424  * For details, see {@link RegNodeDeviceStateCb}.
425  *
426  * @since 1.0
427  * @version 1.0
428  */
429 typedef struct {
430     /**
431      * Mask of an event that is listened for.
432      * The event can be received only if the corresponding mask bit is set and the callback is specified.
433      */
434     uint32_t events;
435     /**
436      * @brief Called when a specified device, rather than a specified ability, gets online.
437      *
438      * @param info Indicates the pointer to the basic information about the device.
439      * For details, see {@link NodeBasicInfo}.
440      *
441      * @since 1.0
442      * @version 1.0
443      */
444     void (*onNodeOnline)(NodeBasicInfo *info);
445     /**
446      * @brief Called when a specified device, rather than a specified ability, gets offline.
447      *
448      * @param info Indicates the pointer to the basic information about the device.
449      * For details, see {@link NodeBasicInfo}.
450      *
451      * @since 1.0
452      * @version 1.0
453      */
454     void (*onNodeOffline)(NodeBasicInfo *info);
455     /**
456      * @brief Called when the basic information of a device changes.
457      *
458      * @param type Indicates the device type. For details, see {@link NodeBasicInfoType}.
459      * @param info Indicates the pointer to the new basic information of the device.
460      * For details, see {@link NodeBasicInfo}.
461      *
462      * @since 1.0
463      * @version 1.0
464      */
465     void (*onNodeBasicInfoChanged)(NodeBasicInfoType type, NodeBasicInfo *info);
466     /**
467     * @brief Called when the local networkId of a device changes.
468     *
469     * @since 1.0
470     * @version 1.0
471     */
472     void (*onLocalNetworkIdChanged)(void);
473     /**
474     * @brief Called when the device is not trusted.
475     *
476     * @param msg Indicates the pointer to untrusted device information.
477     *
478     * @since 1.0
479     * @version 1.0
480     */
481     void (*onNodeDeviceNotTrusted)(const char *msg);
482     /**
483      * @brief Called when the running status of a device changes.
484      *
485      * @param type Indicates the device type. For details, see {@link NodeStatusType}.
486      * @param status Indicates the pointer to the new status of the device.
487      * For details, see {@link NodeStatus}.
488      *
489      * @since 1.0
490      * @version 1.0
491      */
492     void (*onNodeStatusChanged)(NodeStatusType type, NodeStatus *status);
493     /**
494      * @brief Called when the devices have non-consistent group relationship.
495      *
496      * @param proofInfo The device proof info.
497      * @param proofLen The device proof info length.
498      * @param deviceTypeId The device type id.
499      * @param errcode Indicates the result code.
500      *
501      * @since 1.0
502      * @version 1.0
503      */
504     void (*onHichainProofException)(
505         const char *proofInfo, uint32_t proofLen, uint16_t deviceTypeId, int32_t errCode);
506 } INodeStateCb;
507 
508 /**
509  * @brief Defines a callback that is invoked when the time synchronize has result.
510  *
511  * @since 1.0
512  * @version 1.0
513  */
514 typedef struct {
515     /**
516      * @brief Called when the time synchronize has result.
517      *
518      * @param info Contains the time synchronize result info, see {@link TimeSyncResultInfo}.
519      * @param retCode Indicates the result code. Value <b>0</b> indicates that the time synchronize is successful and
520      * result is valid, and any other value indicates the opposite.
521      *
522      * @since 1.0
523      * @version 1.0
524      */
525     void (*onTimeSyncResult)(const TimeSyncResultInfo *info, int32_t retCode);
526 } ITimeSyncCb;
527 
528 /**
529  * @brief Defines a meta node configuration, see {@link ActiveMetaNode}.
530  *
531  * @since 1.0
532  * @version 1.0
533  */
534 typedef struct {
535     char udid[UDID_BUF_LEN];                       /**< The udid of meta node */
536     char deviceName[DEVICE_NAME_BUF_LEN];          /**< The name of meta node */
537     uint16_t deviceTypeId;                         /**< The device type id of meta node */
538     uint8_t addrNum;                               /**< The connection addr type of meta node */
539     ConnectionAddr addr[CONNECTION_ADDR_MAX];      /**< The connection addr of meta node */
540     char bypassInfo[META_NODE_BYPASS_INFO_LEN];    /**< The pass info of meta node */
541 } MetaNodeConfigInfo;
542 
543 /**
544  * @brief Defines a meta node information, see {@link MetaNodeInfo}.
545  *
546  * @since 1.0
547  * @version 1.0
548  */
549 typedef struct {
550     char metaNodeId[NETWORK_ID_BUF_LEN];  /**< The id of meta node */
551     bool isOnline;                        /**< The online state of meta node */
552     MetaNodeConfigInfo configInfo;        /**< The node ConfigInfo of meta node */
553 } MetaNodeInfo;
554 
555 /**
556  * @brief Defines an action mode, see {@link ModeAction}.
557  *
558  * @since 1.0
559  * @version 1.0
560  */
561 typedef enum {
562     FLUSH_DEVICE_LIST,           /**< The action of flush device list */
563     CHANGE_TCP_KEEPALIVE,        /**< The action of change tcp keepalive */
564     ACTION_MAX                   /**< The action max */
565 } ModeAction;
566 
567 /**
568  * @brief Defines heartbeat mode parameter, see {@link GearMode}.
569  *
570  * @since 1.0
571  * @version 1.0
572  */
573 typedef struct {
574     ModeCycle cycle;        /**< Heartbeat mode cycle */
575     ModeDuration duration;  /**< Heartbeat mode duration */
576     bool wakeupFlag;        /**< Heartbeat wakeup peer device or not */
577     ModeAction action;      /**< Heartbeat mode action */
578 } GearMode;
579 
580 /**
581  * @brief Called when a device is added to a LNN via {@link JoinLNN}.
582  *
583  * @param addr Indicates the pointer to the address of the peer device.
584  * @param networkId Indicates the pointer to the network ID of the device if it is successfully added to the LNN.
585  * This parameter makes no sense if the device fails to be added to the LNN.
586  * @param retCode Indicates the result code. Value <b>0</b> indicates that the device is successfully added to the LNN,
587  * and any other value indicates the opposite.
588  *
589  * @since 1.0
590  * @version 1.0
591  */
592 typedef void (*OnJoinLNNResult)(ConnectionAddr *addr, const char *networkId, int32_t retCode);
593 
594 /**
595  * @brief Called when a device is removed from a LNN via {@link LeaveLNN}.
596  *
597  * @param networkId Indicates the pointer to the network ID of the device.
598  * @param retCode Indicates the result code. Value <b>0</b> indicates that the device is successfully
599  * removed from the LNN, and any other value indicates the opposite.
600  *
601  * @since 1.0
602  * @version 1.0
603  */
604 typedef void (*OnLeaveLNNResult)(const char *networkId, int32_t retCode);
605 
606 /**
607  * @brief Adds the current device to the LNN where a specified device resides.
608  *
609  * @param pkgName Indicates the pointer to the caller ID, for example, the package name.
610  * For the same caller, the value of this parameter must be the same for all functions.
611  * @param target Indicates the pointer to the address of the specified device. For details, see {@link ConnectionAddr}.
612  * @param cb Indicates the callback for the result. If you set this parameter to NULL, you will not receive the result.
613  *
614  * @return Returns <b>0</b> if the request to add the device is accepted, and the result can be obtained from the
615  * callback; returns any other value if the device fails to be added to the network, in which case you will not receive
616  * the result.
617  *
618  * @since 1.0
619  * @version 1.0
620  */
621 int32_t JoinLNN(const char *pkgName, ConnectionAddr *target, OnJoinLNNResult cb);
622 
623 /**
624  * @brief Removes the current device from the LNN.
625  *
626  * @param pkgName Indicates the pointer to the caller ID, for example, the package name.
627  * For the same caller, the value of this parameter must be the same for all functions.
628  * @param networkId Indicates the pointer to the network ID that is returned
629  * after the device is added to the LNN via {@link JoinLNN}.
630  * @param cb Indicates the callback for the result. If you set this parameter to <b>NULL</b>,
631  * you will not receive the result.
632  *
633  * @return Returns <b>0</b> if the request to remove the device is accepted, and the result can be obtained from the
634  * callback; returns any other value if the device fails to be removed from the network, in which case you will not
635  * receive the result.
636  *
637  * @since 1.0
638  * @version 1.0
639  */
640 int32_t LeaveLNN(const char *pkgName, const char *networkId, OnLeaveLNNResult cb);
641 
642 /**
643  * @brief Registers a callback for device state changes, rather than a specified ability, gets online.
644  *
645  * @param pkgName Indicates the pointer to the caller ID, for example, the package name.
646  * For the same caller, the value of this parameter must be the same for all functions.
647  * @param callback Indicates the pointer to the callback to register. For details, see {@link INodeStateCb}.
648  *
649  * @return Returns <b>0</b> if the registration is successful; returns any other value otherwise.
650  *
651  * @since 1.0
652  * @version 1.0
653  */
654 int32_t RegNodeDeviceStateCb(const char *pkgName, INodeStateCb *callback);
655 
656 /**
657  * @brief Unregisters a callback for device state changes.
658  *
659  * @param callback Indicates the pointer to the callback to unregister. For details, see {@link INodeStateCb}.
660  *
661  * @return Returns <b>0</b> if the unregistration is successful; returns any other value otherwise.
662  *
663  * @since 1.0
664  * @version 1.0
665  */
666 int32_t UnregNodeDeviceStateCb(INodeStateCb *callback);
667 
668 /**
669  * @brief Obtains basic information about all the online devices.
670  *
671  * @param pkgName Indicates the pointer to the caller ID, for example, the package name.
672  * For the same caller, the value of this parameter must be the same for all functions.
673  * @param info Indicates the double pointer to the memory that stores the obtained basic information.
674  * @param infoNum Indicates the pointer to the number of devices.
675  *
676  * @return Returns <b>0</b> if the basic information is obtained, in which case <b>info</b> and <b>infoNum</b> are
677  * valid; returns any other value otherwise.
678  *
679  * @since 1.0
680  * @version 1.0
681  */
682 int32_t GetAllNodeDeviceInfo(const char *pkgName, NodeBasicInfo **info, int32_t *infoNum);
683 
684 /**
685  * @brief Releases the memory returned by {@link GetAllNodeDeviceInfo}.
686  *
687  * @param info Indicates the pointer to the memory returned by {@link GetAllNodeDeviceInfo}.
688  *
689  * @since 1.0
690  * @version 1.0
691  */
692 void FreeNodeInfo(NodeBasicInfo *info);
693 
694 /**
695  * @brief Obtains basic information about the current device.
696  *
697  * @param pkgName Indicates the pointer to the caller ID, for example, the package name.
698  * For the same caller, the value of this parameter must be the same for all functions.
699  * @param info Indicates the double pointer to the memory that stores the obtained basic information.
700  *
701  * @return Returns <b>0</b> if the basic information is obtained, in which case <b>info</b> is valid;
702  * returns any other value otherwise.
703  *
704  * @since 1.0
705  * @version 1.0
706  */
707 int32_t GetLocalNodeDeviceInfo(const char *pkgName, NodeBasicInfo *info);
708 
709 /**
710  * @brief Set the Node Data Change Flag object.
711  *
712  * @param pkgName Indicates the pointer to the caller ID, for example, the package name.
713  * For the same caller, the value of this parameter must be the same for all functions.
714  * @param networkId Indicates the pointer to the network ID of the device.
715  * @param dataChangeFlag Indicates the data change flag.
716  *
717  * @return Returns <b>0</b> if set change flag success, returns any other value otherwise.
718  *
719  * @since 1.0
720  * @version 1.0
721  */
722 int32_t SetNodeDataChangeFlag(const char *pkgName, const char *networkId, uint16_t dataChangeFlag);
723 
724 /**
725  * @brief Obtains a specified {@link NodeDeviceInfoKey} of an online device.
726  *
727  * @param pkgName Indicates the pointer to the caller ID, for example, the package name.
728  * For the same caller, the value of this parameter must be the same for all functions.
729  * @param networkId Indicates the pointer to the network ID of the device.
730  * @param key Indicates the key to be obtained.
731  * @param info Indicates the pointer to the buffer that stores the obtained key.
732  * @param infoLen Indicates the buffer length.
733  *
734  * @return Returns <b>0</b> if the {@link NodeDeviceInfoKey} is obtained, in which case <b>info</b> is valid;
735  * returns any other value otherwise.
736  *
737  * @since 1.0
738  * @version 1.0
739  */
740 int32_t GetNodeKeyInfo(const char *pkgName, const char *networkId,
741     NodeDeviceInfoKey key, uint8_t *info, int32_t infoLen);
742 
743 /**
744  * @brief Start the time synchronize with specific target node.
745  *
746  * @param pkgName Indicates the pointer to the caller ID, for example, the package name.
747  * For the same caller, the value of this parameter must be the same for all functions.
748  * @param targetNetworkId Indicates the pointer to the address of the specified device.
749  * @param accuracy Time synchronize accuracy.
750  * @param period Time synchronize period
751  * @param cb Indicates the callback for the result.
752  *
753  * @return Returns <b>0</b> if the request is accepted, and the result can be obtained from the
754  * callback; returns any other value if the request fails, in which case you will not receive
755  * the result.
756  *
757  * @since 1.0
758  * @version 1.0
759  */
760 int32_t StartTimeSync(const char *pkgName, const char *targetNetworkId, TimeSyncAccuracy accuracy,
761     TimeSyncPeriod period, ITimeSyncCb *cb);
762 
763 /**
764  * @brief Stop the time synchronize with specific target node.
765  *
766  * @param pkgName Indicates the pointer to the caller ID, for example, the package name.
767  * For the same caller, the value of this parameter must be the same for all functions.
768  * @param targetNetworkId Indicates the pointer to the address of the specified device.
769  *
770  * @return Returns <b>0</b> if the request is removed; returns any other value if the request fails.
771  *
772  * @since 1.0
773  * @version 1.0
774  */
775 int32_t StopTimeSync(const char *pkgName, const char *targetNetworkId);
776 
777 /**
778  * @brief Publishes a specified service.
779  *
780  * Peer devices in the same LAN as the device that publishes this service can discover this service as needed.
781  * The service is identified by <b>publicId</b> and <b>pkgName</b>.
782  *
783  * @param pkgName Indicates the pointer to the service package name, which can contain a maximum of 64 bytes.
784  * @param info Indicates the pointer to the service publishing information. For details, see {@link PublishInfo}.
785  * @param cb Indicates the pointer to the service publishing callback {@link IPublishCb}.
786  *
787  * @return Returns <b>SOFTBUS_INVALID_PARAM</b> if any parameter is null or invalid.
788  * @return Returns <b>SOFTBUS_DISCOVER_NOT_INIT</b> if the Intelligent Soft Bus client fails to be initialized.
789  * @return Returns <b>SOFTBUS_LOCK_ERR</b> if the mutex fails to be locked.
790  * @return Returns <b>SOFTBUS_OK</b> if the service is successfully published.
791  *
792  * @since 1.0
793  * @version 1.0
794  */
795 int32_t PublishLNN(const char *pkgName, const PublishInfo *info, const IPublishCb *cb);
796 
797 /**
798  * @brief stoppublishes a specified service.
799  *
800  * @param pkgName Indicates the pointer to the service package name, which can contain a maximum of 64 bytes.
801  * @param publishId Indicates the service ID.
802  *
803  * @return Returns <b>SOFTBUS_INVALID_PARAM</b> if <b>pkgName</b> is invalid.
804  * @return Returns <b>SOFTBUS_DISCOVER_NOT_INIT</b> if the Intelligent Soft Bus client fails to be initialized.
805  * @return Returns <b>SOFTBUS_OK</b> if the service is successfully unpublished.
806  *
807  * @since 1.0
808  * @version 1.0
809  */
810 int32_t StopPublishLNN(const char *pkgName, int32_t publishId);
811 
812 /**
813  * @brief Subscribes to a specified service.
814  *
815  * Information about the device that publishes the service will be reported to the device that subscribes to
816  * the service.
817  * The service is identified by <b>subscribeId</b> and <b>pkgName</b>.
818  *
819  * @param pkgName Indicates the pointer to the service package name, which can contain a maximum of 64 bytes.
820  * @param info Indicates the pointer to the service subscription information. For details, see {@link SubscribeInfo}.
821  * @param cb Indicates the service subscription callback {@link IRefreshCallback}.
822  *
823  * @return Returns <b>SOFTBUS_INVALID_PARAM</b> if any parameter is null or invalid.
824  * @return Returns <b>SOFTBUS_DISCOVER_NOT_INIT</b> if the Intelligent Soft Bus client fails to be initialized.
825  * @return Returns <b>SOFTBUS_LOCK_ERR</b> if the mutex fails to be locked.
826  * @return Returns <b>SOFTBUS_OK</b> if the service subscription is successful.
827  *
828  * @since 1.0
829  * @version 1.0
830  */
831 int32_t RefreshLNN(const char *pkgName, const SubscribeInfo *info, const IRefreshCallback *cb);
832 
833 /**
834  * @brief Unsubscribes from a specified service.
835  *
836  * @param pkgName Indicates the pointer to the service package name, which can contain a maximum of 64 bytes.
837  * @param refreshId Indicates the service ID.
838  *
839  * @return Returns <b>SOFTBUS_INVALID_PARAM</b> if <b>pkgName</b> is invalid.
840  * @return Returns <b>SOFTBUS_DISCOVER_NOT_INIT</b> if the Intelligent Soft Bus client fails to be initialized.
841  * @return Returns <b>SOFTBUS_OK</b> if the service unsubscription is successful.
842  *
843  * @since 1.0
844  * @version 1.0
845  */
846 int32_t StopRefreshLNN(const char *pkgName, int32_t refreshId);
847 
848 /**
849  * @brief Active meta node. The meta node online status will be notified by {@link INodeStateCb}
850  *
851  * @param pkgName Indicates the pointer to the caller ID, for example, the package name.
852  * For the same caller, the value of this parameter must be the same for all functions.
853  * @param info Meta node configuration information, see {@link MetaNodeConfigInfo}.
854  * @param metaNodeId Save meta node ID when it is activated successfully, its buffer length must be not
855  * less then NETWORK_ID_BUF_LEN.
856  *
857  * @return Returns <b>0</b> if the meta node is activated; returns any other value if the request fails.
858  *
859  * @since 1.0
860  * @version 1.0
861  */
862 int32_t ActiveMetaNode(const char *pkgName, const MetaNodeConfigInfo *info, char *metaNodeId);
863 
864 /**
865  * @brief Deactive meta node. The meta node will be removed.
866  *
867  * @param pkgName Indicates the pointer to the caller ID, for example, the package name.
868  * For the same caller, the value of this parameter must be the same for all functions.
869  * @param metaNodeId The meta node ID which deactivated, it's obtained by {@link ActiveMetaNode}.
870  *
871  * @return Returns <b>0</b> if the meta node is deactivated; returns any other value if the request fails.
872  *
873  * @since 1.0
874  * @version 1.0
875  */
876 int32_t DeactiveMetaNode(const char *pkgName, const char *metaNodeId);
877 
878 /**
879  * @brief Get all meta node by {@link ActiveMetaNode}.
880  *
881  * @param pkgName Indicates the pointer to the caller ID, for example, the package name.
882  * For the same caller, the value of this parameter must be the same for all functions.
883  * @param infos The buffer for save meta node info.
884  * @param infoNum The infos buffer num which maximum is {@link MAX_META_NODE_NUM}.
885  *
886  * @return Returns <b>0</b> if the call is success; returns any other value if it fails.
887  *
888  * @since 1.0
889  * @version 1.0
890  */
891 int32_t GetAllMetaNodeInfo(const char *pkgName, MetaNodeInfo *infos, int32_t *infoNum);
892 
893 /**
894  * @brief Modify heartbeat parameters and trigger a temporary heartbeat.
895  *
896  * @param pkgName Indicates the pointer to the caller ID, for example, the package name.
897  * For the same caller, the value of this parameter must be the same for all functions.
898  * @param callerId The id of the caller, whitch cannot be <b>NULL</b>, and maxium length is {@link CALLER_ID_MAX_LEN}.
899  * @param targetNetworkId The networkId of the target device to refresh online state, and could be <b>NULL</b>.
900  * @param mode The duration or cycle parameter of heartbeat. For details, see {@link GearMode}.
901  *
902  * @return Returns <b>0</b> if the call is success; returns any other value if it fails.
903  *
904  * @since 1.0
905  * @version 1.0
906  */
907 int32_t ShiftLNNGear(const char *pkgName, const char *callerId, const char *targetNetworkId, const GearMode *mode);
908 
909 #ifdef __cplusplus
910 }
911 #endif
912 
913 #endif
914