1 /* 2 * Copyright (c) 2021-2024 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 Enumerates error codes for trust relationship change type. 424 * 425 * @since 1.0 426 * @version 1.0 427 */ 428 typedef enum { 429 DEVICE_NOT_TRUSTED = 0, /**< device not trusted */ 430 DEVICE_TRUST_RELATIONSHIP_CHANGE = 1, /**< device trust relationship change */ 431 } TrustChangeType; 432 433 /** 434 * @brief Defines a callback that is invoked when the device state or information changes. 435 * For details, see {@link RegNodeDeviceStateCb}. 436 * 437 * @since 1.0 438 * @version 1.0 439 */ 440 typedef struct { 441 /** 442 * Mask of an event that is listened for. 443 * The event can be received only if the corresponding mask bit is set and the callback is specified. 444 */ 445 uint32_t events; 446 /** 447 * @brief Called when a specified device, rather than a specified ability, gets online. 448 * 449 * @param info Indicates the pointer to the basic information about the device. 450 * For details, see {@link NodeBasicInfo}. 451 * 452 * @since 1.0 453 * @version 1.0 454 */ 455 void (*onNodeOnline)(NodeBasicInfo *info); 456 /** 457 * @brief Called when a specified device, rather than a specified ability, gets offline. 458 * 459 * @param info Indicates the pointer to the basic information about the device. 460 * For details, see {@link NodeBasicInfo}. 461 * 462 * @since 1.0 463 * @version 1.0 464 */ 465 void (*onNodeOffline)(NodeBasicInfo *info); 466 /** 467 * @brief Called when the basic information of a device changes. 468 * 469 * @param type Indicates the device type. For details, see {@link NodeBasicInfoType}. 470 * @param info Indicates the pointer to the new basic information of the device. 471 * For details, see {@link NodeBasicInfo}. 472 * 473 * @since 1.0 474 * @version 1.0 475 */ 476 void (*onNodeBasicInfoChanged)(NodeBasicInfoType type, NodeBasicInfo *info); 477 /** 478 * @brief Called when the local networkId of a device changes. 479 * 480 * @since 1.0 481 * @version 1.0 482 */ 483 void (*onLocalNetworkIdChanged)(void); 484 /** 485 * @brief Called when the device trust relationship change. 486 * 487 * @param type type Indicates the trust relationship change type. 488 * @param msg Indicates the pointer to relationship change information. 489 * @param msgLen The length of msg. 490 * 491 * @since 1.0 492 * @version 1.0 493 */ 494 void (*onNodeDeviceTrustedChange)(TrustChangeType type, const char *msg, uint32_t msgLen); 495 /** 496 * @brief Called when the running status of a device changes. 497 * 498 * @param type Indicates the device type. For details, see {@link NodeStatusType}. 499 * @param status Indicates the pointer to the new status of the device. 500 * For details, see {@link NodeStatus}. 501 * 502 * @since 1.0 503 * @version 1.0 504 */ 505 void (*onNodeStatusChanged)(NodeStatusType type, NodeStatus *status); 506 /** 507 * @brief Called when the devices have non-consistent group relationship. 508 * 509 * @param deviceList The device list. 510 * @param deviceListLen The device list length. 511 * @param deviceTypeId The device type id. 512 * @param errcode Indicates the result code. 513 * 514 * @since 1.0 515 * @version 1.0 516 */ 517 void (*onHichainProofException)( 518 const char *deviceList, uint32_t deviceListLen, uint16_t deviceTypeId, int32_t errCode); 519 } INodeStateCb; 520 521 /** 522 * @brief Defines a callback that is invoked when the time synchronize has result. 523 * 524 * @since 1.0 525 * @version 1.0 526 */ 527 typedef struct { 528 /** 529 * @brief Called when the time synchronize has result. 530 * 531 * @param info Contains the time synchronize result info, see {@link TimeSyncResultInfo}. 532 * @param retCode Indicates the result code. Value <b>0</b> indicates that the time synchronize is successful and 533 * result is valid, and any other value indicates the opposite. 534 * 535 * @since 1.0 536 * @version 1.0 537 */ 538 void (*onTimeSyncResult)(const TimeSyncResultInfo *info, int32_t retCode); 539 } ITimeSyncCb; 540 541 /** 542 * @brief Defines a meta node configuration, see {@link ActiveMetaNode}. 543 * 544 * @since 1.0 545 * @version 1.0 546 */ 547 typedef struct { 548 char udid[UDID_BUF_LEN]; /**< The udid of meta node */ 549 char deviceName[DEVICE_NAME_BUF_LEN]; /**< The name of meta node */ 550 uint16_t deviceTypeId; /**< The device type id of meta node */ 551 uint8_t addrNum; /**< The connection addr type of meta node */ 552 ConnectionAddr addr[CONNECTION_ADDR_MAX]; /**< The connection addr of meta node */ 553 char bypassInfo[META_NODE_BYPASS_INFO_LEN]; /**< The pass info of meta node */ 554 } MetaNodeConfigInfo; 555 556 /** 557 * @brief Defines a meta node information, see {@link MetaNodeInfo}. 558 * 559 * @since 1.0 560 * @version 1.0 561 */ 562 typedef struct { 563 char metaNodeId[NETWORK_ID_BUF_LEN]; /**< The id of meta node */ 564 bool isOnline; /**< The online state of meta node */ 565 MetaNodeConfigInfo configInfo; /**< The node ConfigInfo of meta node */ 566 } MetaNodeInfo; 567 568 /** 569 * @brief Defines an action mode, see {@link ModeAction}. 570 * 571 * @since 1.0 572 * @version 1.0 573 */ 574 typedef enum { 575 FLUSH_DEVICE_LIST, /**< The action of flush device list */ 576 CHANGE_TCP_KEEPALIVE, /**< The action of change tcp keepalive */ 577 ACTION_MAX /**< The action max */ 578 } ModeAction; 579 580 /** 581 * @brief Defines heartbeat mode parameter, see {@link GearMode}. 582 * 583 * @since 1.0 584 * @version 1.0 585 */ 586 typedef struct { 587 ModeCycle cycle; /**< Heartbeat mode cycle */ 588 ModeDuration duration; /**< Heartbeat mode duration */ 589 bool wakeupFlag; /**< Heartbeat wakeup peer device or not */ 590 ModeAction action; /**< Heartbeat mode action */ 591 } GearMode; 592 593 /** 594 * @brief Called when a device is added to a LNN via {@link JoinLNN}. 595 * 596 * @param addr Indicates the pointer to the address of the peer device. 597 * @param networkId Indicates the pointer to the network ID of the device if it is successfully added to the LNN. 598 * This parameter makes no sense if the device fails to be added to the LNN. 599 * @param retCode Indicates the result code. Value <b>0</b> indicates that the device is successfully added to the LNN, 600 * and any other value indicates the opposite. 601 * 602 * @since 1.0 603 * @version 1.0 604 */ 605 typedef void (*OnJoinLNNResult)(ConnectionAddr *addr, const char *networkId, int32_t retCode); 606 607 /** 608 * @brief Called when a device is removed from a LNN via {@link LeaveLNN}. 609 * 610 * @param networkId Indicates the pointer to the network ID of the device. 611 * @param retCode Indicates the result code. Value <b>0</b> indicates that the device is successfully 612 * removed from the LNN, and any other value indicates the opposite. 613 * 614 * @since 1.0 615 * @version 1.0 616 */ 617 typedef void (*OnLeaveLNNResult)(const char *networkId, int32_t retCode); 618 619 /** 620 * @brief Adds the current device to the LNN where a specified device resides. 621 * 622 * @param pkgName Indicates the pointer to the caller ID, for example, the package name. 623 * For the same caller, the value of this parameter must be the same for all functions. 624 * @param target Indicates the pointer to the address of the specified device. For details, see {@link ConnectionAddr}. 625 * @param cb Indicates the callback for the result. If you set this parameter to NULL, you will not receive the result. 626 * 627 * @return Returns <b>0</b> if the request to add the device is accepted, and the result can be obtained from the 628 * callback; returns any other value if the device fails to be added to the network, in which case you will not receive 629 * the result. 630 * 631 * @since 1.0 632 * @version 1.0 633 */ 634 int32_t JoinLNN(const char *pkgName, ConnectionAddr *target, OnJoinLNNResult cb); 635 636 /** 637 * @brief Removes the current device from the LNN. 638 * 639 * @param pkgName Indicates the pointer to the caller ID, for example, the package name. 640 * For the same caller, the value of this parameter must be the same for all functions. 641 * @param networkId Indicates the pointer to the network ID that is returned 642 * after the device is added to the LNN via {@link JoinLNN}. 643 * @param cb Indicates the callback for the result. If you set this parameter to <b>NULL</b>, 644 * you will not receive the result. 645 * 646 * @return Returns <b>0</b> if the request to remove the device is accepted, and the result can be obtained from the 647 * callback; returns any other value if the device fails to be removed from the network, in which case you will not 648 * receive the result. 649 * 650 * @since 1.0 651 * @version 1.0 652 */ 653 int32_t LeaveLNN(const char *pkgName, const char *networkId, OnLeaveLNNResult cb); 654 655 /** 656 * @brief Registers a callback for device state changes, rather than a specified ability, gets online. 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 callback Indicates the pointer to the callback to register. For details, see {@link INodeStateCb}. 661 * 662 * @return Returns <b>0</b> if the registration is successful; returns any other value otherwise. 663 * 664 * @since 1.0 665 * @version 1.0 666 */ 667 int32_t RegNodeDeviceStateCb(const char *pkgName, INodeStateCb *callback); 668 669 /** 670 * @brief Unregisters a callback for device state changes. 671 * 672 * @param callback Indicates the pointer to the callback to unregister. For details, see {@link INodeStateCb}. 673 * 674 * @return Returns <b>0</b> if the unregistration is successful; returns any other value otherwise. 675 * 676 * @since 1.0 677 * @version 1.0 678 */ 679 int32_t UnregNodeDeviceStateCb(INodeStateCb *callback); 680 681 /** 682 * @brief Obtains basic information about all the online devices. 683 * 684 * @param pkgName Indicates the pointer to the caller ID, for example, the package name. 685 * For the same caller, the value of this parameter must be the same for all functions. 686 * @param info Indicates the double pointer to the memory that stores the obtained basic information. 687 * @param infoNum Indicates the pointer to the number of devices. 688 * 689 * @return Returns <b>0</b> if the basic information is obtained, in which case <b>info</b> and <b>infoNum</b> are 690 * valid; returns any other value otherwise. 691 * 692 * @since 1.0 693 * @version 1.0 694 */ 695 int32_t GetAllNodeDeviceInfo(const char *pkgName, NodeBasicInfo **info, int32_t *infoNum); 696 697 /** 698 * @brief Releases the memory returned by {@link GetAllNodeDeviceInfo}. 699 * 700 * @param info Indicates the pointer to the memory returned by {@link GetAllNodeDeviceInfo}. 701 * 702 * @since 1.0 703 * @version 1.0 704 */ 705 void FreeNodeInfo(NodeBasicInfo *info); 706 707 /** 708 * @brief Obtains basic information about the current device. 709 * 710 * @param pkgName Indicates the pointer to the caller ID, for example, the package name. 711 * For the same caller, the value of this parameter must be the same for all functions. 712 * @param info Indicates the double pointer to the memory that stores the obtained basic information. 713 * 714 * @return Returns <b>0</b> if the basic information is obtained, in which case <b>info</b> is valid; 715 * returns any other value otherwise. 716 * 717 * @since 1.0 718 * @version 1.0 719 */ 720 int32_t GetLocalNodeDeviceInfo(const char *pkgName, NodeBasicInfo *info); 721 722 /** 723 * @brief Set the Node Data Change Flag object. 724 * 725 * @param pkgName Indicates the pointer to the caller ID, for example, the package name. 726 * For the same caller, the value of this parameter must be the same for all functions. 727 * @param networkId Indicates the pointer to the network ID of the device. 728 * @param dataChangeFlag Indicates the data change flag. 729 * 730 * @return Returns <b>0</b> if set change flag success, returns any other value otherwise. 731 * 732 * @since 1.0 733 * @version 1.0 734 */ 735 int32_t SetNodeDataChangeFlag(const char *pkgName, const char *networkId, uint16_t dataChangeFlag); 736 737 /** 738 * @brief Obtains a specified {@link NodeDeviceInfoKey} of an online device. 739 * 740 * @param pkgName Indicates the pointer to the caller ID, for example, the package name. 741 * For the same caller, the value of this parameter must be the same for all functions. 742 * @param networkId Indicates the pointer to the network ID of the device. 743 * @param key Indicates the key to be obtained. 744 * @param info Indicates the pointer to the buffer that stores the obtained key. 745 * @param infoLen Indicates the buffer length. 746 * 747 * @return Returns <b>0</b> if the {@link NodeDeviceInfoKey} is obtained, in which case <b>info</b> is valid; 748 * returns any other value otherwise. 749 * 750 * @since 1.0 751 * @version 1.0 752 */ 753 int32_t GetNodeKeyInfo(const char *pkgName, const char *networkId, 754 NodeDeviceInfoKey key, uint8_t *info, int32_t infoLen); 755 756 /** 757 * @brief Start the time synchronize with specific target node. 758 * 759 * @param pkgName Indicates the pointer to the caller ID, for example, the package name. 760 * For the same caller, the value of this parameter must be the same for all functions. 761 * @param targetNetworkId Indicates the pointer to the address of the specified device. 762 * @param accuracy Time synchronize accuracy. 763 * @param period Time synchronize period 764 * @param cb Indicates the callback for the result. 765 * 766 * @return Returns <b>0</b> if the request is accepted, and the result can be obtained from the 767 * callback; returns any other value if the request fails, in which case you will not receive 768 * the result. 769 * 770 * @since 1.0 771 * @version 1.0 772 */ 773 int32_t StartTimeSync(const char *pkgName, const char *targetNetworkId, TimeSyncAccuracy accuracy, 774 TimeSyncPeriod period, ITimeSyncCb *cb); 775 776 /** 777 * @brief Stop the time synchronize with specific target node. 778 * 779 * @param pkgName Indicates the pointer to the caller ID, for example, the package name. 780 * For the same caller, the value of this parameter must be the same for all functions. 781 * @param targetNetworkId Indicates the pointer to the address of the specified device. 782 * 783 * @return Returns <b>0</b> if the request is removed; returns any other value if the request fails. 784 * 785 * @since 1.0 786 * @version 1.0 787 */ 788 int32_t StopTimeSync(const char *pkgName, const char *targetNetworkId); 789 790 /** 791 * @brief Publishes a specified service. 792 * 793 * Peer devices in the same LAN as the device that publishes this service can discover this service as needed. 794 * The service is identified by <b>publicId</b> and <b>pkgName</b>. 795 * 796 * @param pkgName Indicates the pointer to the service package name, which can contain a maximum of 64 bytes. 797 * @param info Indicates the pointer to the service publishing information. For details, see {@link PublishInfo}. 798 * @param cb Indicates the pointer to the service publishing callback {@link IPublishCb}. 799 * 800 * @return Returns <b>SOFTBUS_INVALID_PARAM</b> if any parameter is null or invalid. 801 * @return Returns <b>SOFTBUS_DISCOVER_NOT_INIT</b> if the Intelligent Soft Bus client fails to be initialized. 802 * @return Returns <b>SOFTBUS_LOCK_ERR</b> if the mutex fails to be locked. 803 * @return Returns <b>SOFTBUS_OK</b> if the service is successfully published. 804 * 805 * @since 1.0 806 * @version 1.0 807 */ 808 int32_t PublishLNN(const char *pkgName, const PublishInfo *info, const IPublishCb *cb); 809 810 /** 811 * @brief stoppublishes a specified service. 812 * 813 * @param pkgName Indicates the pointer to the service package name, which can contain a maximum of 64 bytes. 814 * @param publishId Indicates the service ID. 815 * 816 * @return Returns <b>SOFTBUS_INVALID_PARAM</b> if <b>pkgName</b> is invalid. 817 * @return Returns <b>SOFTBUS_DISCOVER_NOT_INIT</b> if the Intelligent Soft Bus client fails to be initialized. 818 * @return Returns <b>SOFTBUS_OK</b> if the service is successfully unpublished. 819 * 820 * @since 1.0 821 * @version 1.0 822 */ 823 int32_t StopPublishLNN(const char *pkgName, int32_t publishId); 824 825 /** 826 * @brief Subscribes to a specified service. 827 * 828 * Information about the device that publishes the service will be reported to the device that subscribes to 829 * the service. 830 * The service is identified by <b>subscribeId</b> and <b>pkgName</b>. 831 * 832 * @param pkgName Indicates the pointer to the service package name, which can contain a maximum of 64 bytes. 833 * @param info Indicates the pointer to the service subscription information. For details, see {@link SubscribeInfo}. 834 * @param cb Indicates the service subscription callback {@link IRefreshCallback}. 835 * 836 * @return Returns <b>SOFTBUS_INVALID_PARAM</b> if any parameter is null or invalid. 837 * @return Returns <b>SOFTBUS_DISCOVER_NOT_INIT</b> if the Intelligent Soft Bus client fails to be initialized. 838 * @return Returns <b>SOFTBUS_LOCK_ERR</b> if the mutex fails to be locked. 839 * @return Returns <b>SOFTBUS_OK</b> if the service subscription is successful. 840 * 841 * @since 1.0 842 * @version 1.0 843 */ 844 int32_t RefreshLNN(const char *pkgName, const SubscribeInfo *info, const IRefreshCallback *cb); 845 846 /** 847 * @brief Unsubscribes from a specified service. 848 * 849 * @param pkgName Indicates the pointer to the service package name, which can contain a maximum of 64 bytes. 850 * @param refreshId Indicates the service ID. 851 * 852 * @return Returns <b>SOFTBUS_INVALID_PARAM</b> if <b>pkgName</b> is invalid. 853 * @return Returns <b>SOFTBUS_DISCOVER_NOT_INIT</b> if the Intelligent Soft Bus client fails to be initialized. 854 * @return Returns <b>SOFTBUS_OK</b> if the service unsubscription is successful. 855 * 856 * @since 1.0 857 * @version 1.0 858 */ 859 int32_t StopRefreshLNN(const char *pkgName, int32_t refreshId); 860 861 /** 862 * @brief Active meta node. The meta node online status will be notified by {@link INodeStateCb} 863 * 864 * @param pkgName Indicates the pointer to the caller ID, for example, the package name. 865 * For the same caller, the value of this parameter must be the same for all functions. 866 * @param info Meta node configuration information, see {@link MetaNodeConfigInfo}. 867 * @param metaNodeId Save meta node ID when it is activated successfully, its buffer length must be not 868 * less then NETWORK_ID_BUF_LEN. 869 * 870 * @return Returns <b>0</b> if the meta node is activated; returns any other value if the request fails. 871 * 872 * @since 1.0 873 * @version 1.0 874 */ 875 int32_t ActiveMetaNode(const char *pkgName, const MetaNodeConfigInfo *info, char *metaNodeId); 876 877 /** 878 * @brief Deactive meta node. The meta node will be removed. 879 * 880 * @param pkgName Indicates the pointer to the caller ID, for example, the package name. 881 * For the same caller, the value of this parameter must be the same for all functions. 882 * @param metaNodeId The meta node ID which deactivated, it's obtained by {@link ActiveMetaNode}. 883 * 884 * @return Returns <b>0</b> if the meta node is deactivated; returns any other value if the request fails. 885 * 886 * @since 1.0 887 * @version 1.0 888 */ 889 int32_t DeactiveMetaNode(const char *pkgName, const char *metaNodeId); 890 891 /** 892 * @brief Get all meta node by {@link ActiveMetaNode}. 893 * 894 * @param pkgName Indicates the pointer to the caller ID, for example, the package name. 895 * For the same caller, the value of this parameter must be the same for all functions. 896 * @param infos The buffer for save meta node info. 897 * @param infoNum The infos buffer num which maximum is {@link MAX_META_NODE_NUM}. 898 * 899 * @return Returns <b>0</b> if the call is success; returns any other value if it fails. 900 * 901 * @since 1.0 902 * @version 1.0 903 */ 904 int32_t GetAllMetaNodeInfo(const char *pkgName, MetaNodeInfo *infos, int32_t *infoNum); 905 906 /** 907 * @brief Modify heartbeat parameters and trigger a temporary heartbeat. 908 * 909 * @param pkgName Indicates the pointer to the caller ID, for example, the package name. 910 * For the same caller, the value of this parameter must be the same for all functions. 911 * @param callerId The id of the caller, whitch cannot be <b>NULL</b>, and maxium length is {@link CALLER_ID_MAX_LEN}. 912 * @param targetNetworkId The networkId of the target device to refresh online state, and could be <b>NULL</b>. 913 * @param mode The duration or cycle parameter of heartbeat. For details, see {@link GearMode}. 914 * 915 * @return Returns <b>0</b> if the call is success; returns any other value if it fails. 916 * 917 * @since 1.0 918 * @version 1.0 919 */ 920 int32_t ShiftLNNGear(const char *pkgName, const char *callerId, const char *targetNetworkId, const GearMode *mode); 921 922 /** 923 * @brief For dm use only. Broadcast notification of device trust relation changes. 924 * 925 * @param pkgName Indicates the pointer to the caller ID, for example, the package name. 926 * For the same caller, the value of this parameter must be the same for all functions. 927 * @param msg The value must be in JSON format and comply with the API usage restrictions. 928 * @param msgLen The length of msg. 929 * 930 * @return Returns <b>0</b> if the call is success; returns any other value if it fails. 931 * 932 * @since 1.0 933 * @version 1.0 934 */ 935 int32_t SyncTrustedRelationShip(const char *pkgName, const char *msg, uint32_t msgLen); 936 #ifdef __cplusplus 937 } 938 #endif 939 940 #endif 941