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