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