1/* 2 * Copyright (C) 2022-2023 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 16import { AsyncCallback, Callback } from './basic'; 17 18/** 19 * Provides methods to operate or manage Wi-Fi. 20 * @namespace wifiManager 21 * @since 9 22 */ 23declare namespace wifiManager { 24 /** 25 * Enable Wi-Fi. 26 * 27 * @since 9 28 * @throws {BusinessError} 201 - Permission denied. 29 * @throws {BusinessError} 202 - System API is not allowed called by Non-system application. 30 * @throws {BusinessError} 801 - Capability not supported. 31 * @throws {BusinessError} 2501000 - Operation failed. 32 * @throws {BusinessError} 2501003 - Failed for wifi is closing. 33 * @syscap SystemCapability.Communication.WiFi.STA 34 * @permission ohos.permission.SET_WIFI_INFO and ohos.permission.MANAGE_WIFI_CONNECTION 35 * @systemapi Hide this for inner system use. 36 */ 37 function enableWifi(): void; 38 39 /** 40 * Disable Wi-Fi. 41 * 42 * @since 9 43 * @throws {BusinessError} 201 - Permission denied. 44 * @throws {BusinessError} 202 - System API is not allowed called by Non-system application. 45 * @throws {BusinessError} 801 - Capability not supported. 46 * @throws {BusinessError} 2501000 - Operation failed. 47 * @throws {BusinessError} 2501004 - Failed for wifi is opening. 48 * @syscap SystemCapability.Communication.WiFi.STA 49 * @permission ohos.permission.SET_WIFI_INFO and ohos.permission.MANAGE_WIFI_CONNECTION 50 * @systemapi Hide this for inner system use. 51 */ 52 function disableWifi(): void; 53 54 /** 55 * Query the Wi-Fi status 56 * 57 * @returns Returns {@code true} if the Wi-Fi is active, returns {@code false} otherwise. 58 * 59 * @since 9 60 * @throws {BusinessError} 201 - Permission denied. 61 * @throws {BusinessError} 801 - Capability not supported. 62 * @throws {BusinessError} 2501000 - Operation failed. 63 * @syscap SystemCapability.Communication.WiFi.STA 64 * @permission ohos.permission.GET_WIFI_INFO 65 */ 66 function isWifiActive(): boolean; 67 68 /** 69 * Scan Wi-Fi hotspot. 70 * 71 * <p>This API works in asynchronous mode.</p> 72 * 73 * @since 9 74 * @throws {BusinessError} 201 - Permission denied. 75 * @throws {BusinessError} 801 - Capability not supported. 76 * @throws {BusinessError} 2501000 - Operation failed. 77 * @syscap SystemCapability.Communication.WiFi.STA 78 * @permission ohos.permission.SET_WIFI_INFO and ohos.permission.LOCATION 79 */ 80 function scan(): void; 81 82 /** 83 * Obtain the scanned sta list. 84 * 85 * @returns Returns information about scanned Wi-Fi hotspot if any. 86 * 87 * @since 9 88 * @throws {BusinessError} 201 - Permission denied. 89 * @throws {BusinessError} 801 - Capability not supported. 90 * @throws {BusinessError} 2501000 - Operation failed. 91 * @syscap SystemCapability.Communication.WiFi.STA 92 * @permission ohos.permission.GET_WIFI_INFO and (ohos.permission.GET_WIFI_PEERS_MAC or ohos.permission.LOCATION) 93 */ 94 function getScanResults(): Promise<Array<WifiScanInfo>>; 95 function getScanResults(callback: AsyncCallback<Array<WifiScanInfo>>): void; 96 97 /** 98 * Obtain the scanned results. 99 * 100 * @returns Returns information about scanned Wi-Fi hotspot if any. 101 * 102 * @since 9 103 * @throws {BusinessError} 201 - Permission denied. 104 * @throws {BusinessError} 801 - Capability not supported. 105 * @throws {BusinessError} 2501000 - Operation failed. 106 * @syscap SystemCapability.Communication.WiFi.STA 107 * @permission ohos.permission.GET_WIFI_INFO and (ohos.permission.GET_WIFI_PEERS_MAC or ohos.permission.LOCATION) 108 */ 109 function getScanResultsSync(): Array<WifiScanInfo>; 110 111 /** 112 * Add Wi-Fi connection configuration to the device. 113 * 114 * <p>The configuration will be updated when the configuration is added.</p> 115 * 116 * @param config Indicates the device configuration for connection to the Wi-Fi network. 117 * @returns Returns {@code networkId} if the configuration is added; returns {@code -1} otherwise. 118 * 119 * @since 9 120 * @throws {BusinessError} 201 - Permission denied. 121 * @throws {BusinessError} 202 - System API is not allowed called by Non-system application. 122 * @throws {BusinessError} 401 - Invalid parameters. 123 * @throws {BusinessError} 801 - Capability not supported. 124 * @throws {BusinessError} 2501000 - Operation failed. 125 * @syscap SystemCapability.Communication.WiFi.STA 126 * @permission ohos.permission.SET_WIFI_INFO and ohos.permission.SET_WIFI_CONFIG 127 * @systemapi Hide this for inner system use. 128 */ 129 function addDeviceConfig(config: WifiDeviceConfig): Promise<number>; 130 function addDeviceConfig(config: WifiDeviceConfig, callback: AsyncCallback<number>): void; 131 132 /** 133 * Add a specified candidate hotspot configuration and returns the networkId. 134 * 135 * <p>This method adds one configuration at a time. After this configuration is added, 136 * your device will determine whether to connect to the hotspot. 137 * 138 * @param config - candidate config. 139 * @returns Returns {@code networkId} if the configuration is added; returns {@code -1} otherwise. 140 * 141 * @since 9 142 * @throws {BusinessError} 201 - Permission denied. 143 * @throws {BusinessError} 401 - Invalid parameters. 144 * @throws {BusinessError} 801 - Capability not supported. 145 * @throws {BusinessError} 2501000 - Operation failed. 146 * @syscap SystemCapability.Communication.WiFi.STA 147 * @permission ohos.permission.SET_WIFI_INFO 148 */ 149 function addCandidateConfig(config: WifiDeviceConfig): Promise<number>; 150 function addCandidateConfig(config: WifiDeviceConfig, callback: AsyncCallback<number>): void; 151 152 /** 153 * Remove a specified candidate hotspot configuration, only the configuration which is added by ourself is allowed 154 * to be removed. 155 * 156 * @param networkId - Network ID which will be removed. 157 * @returns {@code true} if the candidate hotspot configuration is removed, returns {@code false} otherwise. 158 * 159 * @since 9 160 * @throws {BusinessError} 201 - Permission denied. 161 * @throws {BusinessError} 401 - Invalid parameters. 162 * @throws {BusinessError} 801 - Capability not supported. 163 * @throws {BusinessError} 2501000 - Operation failed. 164 * @syscap SystemCapability.Communication.WiFi.STA 165 * @permission ohos.permission.SET_WIFI_INFO 166 */ 167 function removeCandidateConfig(networkId: number): Promise<void>; 168 function removeCandidateConfig(networkId: number, callback: AsyncCallback<void>): void; 169 170 /** 171 * Obtain the list of all existed candidate Wi-Fi configurations which added by ourself. 172 * 173 * <p>You can obtain only the Wi-Fi configurations you created on your own application. 174 * 175 * @returns Returns the list of all existed Wi-Fi configurations you created on your application. 176 * 177 * @since 9 178 * @throws {BusinessError} 201 - Permission denied. 179 * @throws {BusinessError} 801 - Capability not supported. 180 * @throws {BusinessError} 2501000 - Operation failed. 181 * @syscap SystemCapability.Communication.WiFi.STA 182 * @permission ohos.permission.GET_WIFI_INFO and ohos.permission.LOCATION 183 */ 184 function getCandidateConfigs(): Array<WifiDeviceConfig>; 185 186 /** 187 * Connect to a specified candidate hotspot by networkId, only the configuration which is added by ourself 188 * is allowed to be connected. 189 * 190 * <p>This method connect to a configuration at a time. 191 * 192 * @param networkId - Network ID which will be connected. 193 * @since 9 194 * @throws {BusinessError} 201 - Permission denied. 195 * @throws {BusinessError} 401 - Invalid parameters. 196 * @throws {BusinessError} 801 - Capability not supported. 197 * @throws {BusinessError} 2501000 - Operation failed. 198 * @throws {BusinessError} 2501001 - Wifi is closed. 199 * @syscap SystemCapability.Communication.WiFi.STA 200 * @permission ohos.permission.SET_WIFI_INFO 201 */ 202 function connectToCandidateConfig(networkId: number): void; 203 204 /** 205 * Connect to Wi-Fi hotspot by networkId. 206 * 207 * @param networkId ID of the connected network. 208 * 209 * @since 9 210 * @throws {BusinessError} 201 - Permission denied. 211 * @throws {BusinessError} 202 - System API is not allowed called by Non-system application. 212 * @throws {BusinessError} 401 - Invalid parameters. 213 * @throws {BusinessError} 801 - Capability not supported. 214 * @throws {BusinessError} 2501000 - Operation failed. 215 * @throws {BusinessError} 2501001 - Wifi is closed. 216 * @syscap SystemCapability.Communication.WiFi.STA 217 * @permission ohos.permission.MANAGE_WIFI_CONNECTION 218 * @systemapi Hide this for inner system use. 219 */ 220 function connectToNetwork(networkId: number): void; 221 222 /** 223 * Connect to Wi-Fi hotspot by WifiDeviceConfig. 224 * 225 * @param config Indicates the device configuration for connection to the Wi-Fi hotspot. 226 * 227 * @since 9 228 * @throws {BusinessError} 201 - Permission denied. 229 * @throws {BusinessError} 202 - System API is not allowed called by Non-system application. 230 * @throws {BusinessError} 401 - Invalid parameters. 231 * @throws {BusinessError} 801 - Capability not supported. 232 * @throws {BusinessError} 2501000 - Operation failed. 233 * @throws {BusinessError} 2501001 - Wifi is closed. 234 * @syscap SystemCapability.Communication.WiFi.STA 235 * @permission ohos.permission.SET_WIFI_INFO and ohos.permission.SET_WIFI_CONFIG and 236 * ohos.permission.MANAGE_WIFI_CONNECTION 237 * @systemapi Hide this for inner system use. 238 */ 239 function connectToDevice(config: WifiDeviceConfig): void; 240 241 /** 242 * Disconnect connection between sta and Wi-Fi hotspot. 243 * 244 * @since 9 245 * @throws {BusinessError} 201 - Permission denied. 246 * @throws {BusinessError} 202 - System API is not allowed called by Non-system application. 247 * @throws {BusinessError} 801 - Capability not supported. 248 * @throws {BusinessError} 2501000 - Operation failed. 249 * @syscap SystemCapability.Communication.WiFi.STA 250 * @permission ohos.permission.SET_WIFI_INFO and ohos.permission.MANAGE_WIFI_CONNECTION 251 * @systemapi Hide this for inner system use. 252 */ 253 function disconnect(): void; 254 255 /** 256 * Calculate the Wi-Fi signal level based on the Wi-Fi RSSI and frequency band. 257 * 258 * @param rssi Indicates the Wi-Fi RSSI. 259 * @param band Indicates the Wi-Fi frequency band. 260 * @returns Returns Wi-Fi signal level ranging from 0 to 4. 261 * 262 * @since 9 263 * @throws {BusinessError} 201 - Permission denied. 264 * @throws {BusinessError} 401 - Invalid parameters. 265 * @throws {BusinessError} 801 - Capability not supported. 266 * @throws {BusinessError} 2501000 - Operation failed. 267 * @syscap SystemCapability.Communication.WiFi.STA 268 * @permission ohos.permission.GET_WIFI_INFO 269 */ 270 function getSignalLevel(rssi: number, band: number): number; 271 272 /** 273 * Obtain connection information about the Wi-Fi connection. 274 * 275 * @since 9 276 * @throws {BusinessError} 201 - Permission denied. 277 * @throws {BusinessError} 202 - System API is not allowed called by Non-system application. 278 * @throws {BusinessError} 801 - Capability not supported. 279 * @throws {BusinessError} 2501000 - Operation failed. 280 * @throws {BusinessError} 2501001 - Wifi is closed. 281 * @syscap SystemCapability.Communication.WiFi.STA 282 * @permission ohos.permission.GET_WIFI_INFO 283 */ 284 function getLinkedInfo(): Promise<WifiLinkedInfo>; 285 function getLinkedInfo(callback: AsyncCallback<WifiLinkedInfo>): void; 286 287 /** 288 * Check whether the Wi-Fi connection has been set up. 289 * 290 * @returns Returns {@code true} if a Wi-Fi connection has been set up, returns {@code false} otherwise. 291 * @since 9 292 * @throws {BusinessError} 201 - Permission denied. 293 * @throws {BusinessError} 202 - System API is not allowed called by Non-system application. 294 * @throws {BusinessError} 801 - Capability not supported. 295 * @throws {BusinessError} 2501000 - Operation failed. 296 * @syscap SystemCapability.Communication.WiFi.STA 297 * @permission ohos.permission.GET_WIFI_INFO 298 */ 299 function isConnected(): boolean; 300 301 /** 302 * Obtain the features supported by the device. 303 * 304 * <p>To check whether this device supports a specified feature. 305 * 306 * @returns Returns the features supported by this device. 307 * @since 9 308 * @throws {BusinessError} 201 - Permission denied. 309 * @throws {BusinessError} 202 - System API is not allowed called by Non-system application. 310 * @throws {BusinessError} 801 - Capability not supported. 311 * @throws {BusinessError} 2401000 - Operation failed. 312 * @syscap SystemCapability.Communication.WiFi.Core 313 * @permission ohos.permission.GET_WIFI_INFO 314 * @systemapi Hide this for inner system use. 315 */ 316 function getSupportedFeatures(): number; 317 318 /** 319 * Check whether the device supports a specified feature. 320 * 321 * @param featureId Indicates the ID of the feature. 322 * @returns Returns {@code true} if this device supports the specified feature, returns {@code false} otherwise. 323 * @since 9 324 * @throws {BusinessError} 201 - Permission denied. 325 * @throws {BusinessError} 401 - Invalid parameters. 326 * @throws {BusinessError} 801 - Capability not supported. 327 * @throws {BusinessError} 2401000 - Operation failed. 328 * @syscap SystemCapability.Communication.WiFi.Core 329 * @permission ohos.permission.GET_WIFI_INFO 330 */ 331 function isFeatureSupported(featureId: number): boolean; 332 333 /** 334 * Obtain the MAC address of a Wi-Fi device. Wi-Fi must be enabled. 335 * 336 * <p>The MAC address is unique and cannot be changed. 337 * 338 * @returns Returns the MAC address of the Wi-Fi device. 339 * @since 9 340 * @throws {BusinessError} 201 - Permission denied. 341 * @throws {BusinessError} 202 - System API is not allowed called by Non-system application. 342 * @throws {BusinessError} 801 - Capability not supported. 343 * @throws {BusinessError} 2501000 - Operation failed. 344 * @throws {BusinessError} 2501001 - Wifi is closed. 345 * @syscap SystemCapability.Communication.WiFi.STA 346 * @permission ohos.permission.GET_WIFI_LOCAL_MAC and ohos.permission.GET_WIFI_INFO 347 * @systemapi Hide this for inner system use. 348 */ 349 function getDeviceMacAddress(): string[]; 350 351 /** 352 * Obtain the IP information of the Wi-Fi connection. 353 * 354 * <p>The IP information includes the host IP address, gateway address, and DNS information. 355 * 356 * @returns Returns the IP information of the Wi-Fi connection. 357 * @since 9 358 * @throws {BusinessError} 201 - Permission denied. 359 * @throws {BusinessError} 801 - Capability not supported. 360 * @throws {BusinessError} 2501000 - Operation failed. 361 * @syscap SystemCapability.Communication.WiFi.STA 362 * @permission ohos.permission.GET_WIFI_INFO 363 */ 364 function getIpInfo(): IpInfo; 365 366 /** 367 * Obtain the country code of the device. 368 * 369 * @returns Returns the country code of this device. 370 * @since 9 371 * @throws {BusinessError} 201 - Permission denied. 372 * @throws {BusinessError} 801 - Capability not supported. 373 * @throws {BusinessError} 2401000 - Operation failed. 374 * @syscap SystemCapability.Communication.WiFi.Core 375 * @permission ohos.permission.GET_WIFI_INFO 376 */ 377 function getCountryCode(): string; 378 379 /** 380 * Re-associate to current network. 381 * 382 * @since 9 383 * @throws {BusinessError} 201 - Permission denied. 384 * @throws {BusinessError} 202 - System API is not allowed called by Non-system application. 385 * @throws {BusinessError} 801 - Capability not supported. 386 * @throws {BusinessError} 2501000 - Operation failed. 387 * @throws {BusinessError} 2501001 - Wifi is closed. 388 * @syscap SystemCapability.Communication.WiFi.STA 389 * @permission ohos.permission.SET_WIFI_INFO and ohos.permission.MANAGE_WIFI_CONNECTION 390 * @systemapi Hide this for inner system use. 391 */ 392 function reassociate(): void; 393 394 /** 395 * Re-connect to current network. 396 * 397 * @since 9 398 * @throws {BusinessError} 201 - Permission denied. 399 * @throws {BusinessError} 202 - System API is not allowed called by Non-system application. 400 * @throws {BusinessError} 801 - Capability not supported. 401 * @throws {BusinessError} 2501000 - Operation failed. 402 * @throws {BusinessError} 2501001 - Wifi is closed. 403 * @syscap SystemCapability.Communication.WiFi.STA 404 * @permission ohos.permission.SET_WIFI_INFO and ohos.permission.MANAGE_WIFI_CONNECTION 405 * @systemapi Hide this for inner system use. 406 */ 407 function reconnect(): void; 408 409 /** 410 * Obtain the list of all existed Wi-Fi configurations. 411 * 412 * @returns Returns the list of all existing Wi-Fi configurations you created on your application. 413 * @since 9 414 * @throws {BusinessError} 201 - Permission denied. 415 * @throws {BusinessError} 202 - System API is not allowed called by Non-system application. 416 * @throws {BusinessError} 801 - Capability not supported. 417 * @throws {BusinessError} 2501000 - Operation failed. 418 * @syscap SystemCapability.Communication.WiFi.STA 419 * @permission ohos.permission.GET_WIFI_INFO and ohos.permission.LOCATION and ohos.permission.GET_WIFI_CONFIG 420 * @systemapi Hide this for inner system use. 421 */ 422 function getDeviceConfigs(): Array<WifiDeviceConfig>; 423 424 /** 425 * Update the specified Wi-Fi configuration. 426 * 427 * @param config Indicates the Wi-Fi configuration to update. 428 * 429 * @returns Returns the network ID in the updated Wi-Fi configuration if the update is successful; 430 * returns {@code -1} if the specified Wi-Fi configuration is not contained in the list. 431 * @since 9 432 * @throws {BusinessError} 201 - Permission denied. 433 * @throws {BusinessError} 202 - System API is not allowed called by Non-system application. 434 * @throws {BusinessError} 401 - Invalid parameters. 435 * @throws {BusinessError} 801 - Capability not supported. 436 * @throws {BusinessError} 2501000 - Operation failed. 437 * @syscap SystemCapability.Communication.WiFi.STA 438 * @permission ohos.permission.SET_WIFI_INFO and ohos.permission.SET_WIFI_CONFIG 439 * @systemapi Hide this for inner system use. 440 */ 441 function updateNetwork(config: WifiDeviceConfig): number; 442 443 /** 444 * Disable the specified DeviceConfig by networkId. 445 * 446 * <p>The disabled DeviceConfig will not be associated with again. 447 * 448 * @param networkId Identifies the network to disable. 449 * @since 9 450 * @throws {BusinessError} 201 - Permission denied. 451 * @throws {BusinessError} 202 - System API is not allowed called by Non-system application. 452 * @throws {BusinessError} 401 - Invalid parameters. 453 * @throws {BusinessError} 801 - Capability not supported. 454 * @throws {BusinessError} 2501000 - Operation failed. 455 * @syscap SystemCapability.Communication.WiFi.STA 456 * @permission ohos.permission.SET_WIFI_INFO and ohos.permission.MANAGE_WIFI_CONNECTION 457 * @systemapi Hide this for inner system use. 458 */ 459 function disableNetwork(netId: number): void; 460 461 /** 462 * Remove all the saved Wi-Fi configurations. 463 * 464 * @since 9 465 * @throws {BusinessError} 201 - Permission denied. 466 * @throws {BusinessError} 202 - System API is not allowed called by Non-system application. 467 * @throws {BusinessError} 801 - Capability not supported. 468 * @throws {BusinessError} 2501000 - Operation failed. 469 * @syscap SystemCapability.Communication.WiFi.STA 470 * @permission ohos.permission.SET_WIFI_INFO and ohos.permission.MANAGE_WIFI_CONNECTION 471 * @systemapi Hide this for inner system use. 472 */ 473 function removeAllNetwork(): void; 474 475 /** 476 * Remove a Wi-Fi DeviceConfig with networkId. 477 * 478 * <p>After a Wi-Fi DeviceConfig is removed, its configuration will be deleted from the list of Wi-Fi configurations. 479 * If the Wi-Fi DeviceConfig is being connected, the connection will be interrupted. 480 * The application can only delete Wi-Fi DeviceConfig it has created. 481 * 482 * @param networkId indicate the ID of the Wi-Fi DeviceConfig, 483 * which can be obtained using the {@link #addDeviceConfig} or {@link #getLinkedInfo} method. 484 * @since 9 485 * @throws {BusinessError} 201 - Permission denied. 486 * @throws {BusinessError} 202 - System API is not allowed called by Non-system application. 487 * @throws {BusinessError} 401 - Invalid parameters. 488 * @throws {BusinessError} 801 - Capability not supported. 489 * @throws {BusinessError} 2501000 - Operation failed. 490 * @syscap SystemCapability.Communication.WiFi.STA 491 * @permission ohos.permission.SET_WIFI_INFO and ohos.permission.MANAGE_WIFI_CONNECTION 492 * @systemapi Hide this for inner system use. 493 */ 494 function removeDevice(id: number): void; 495 496 /** 497 * Enable Wi-Fi hotspot function. 498 * 499 * <p>This method is asynchronous. After the Wi-Fi hotspot is enabled, Wi-Fi may be disabled. 500 * 501 * @since 9 502 * @throws {BusinessError} 201 - Permission denied. 503 * @throws {BusinessError} 202 - System API is not allowed called by Non-system application. 504 * @throws {BusinessError} 801 - Capability not supported. 505 * @throws {BusinessError} 2601000 - Operation failed. 506 * @syscap SystemCapability.Communication.WiFi.AP.Core 507 * @permission ohos.permission.MANAGE_WIFI_HOTSPOT 508 * @systemapi Hide this for inner system use. 509 */ 510 function enableHotspot(): void; 511 512 /** 513 * Disable Wi-Fi hotspot function. 514 * 515 * <p>This method is asynchronous. If Wi-Fi is enabled after the Wi-Fi hotspot is disabled, Wi-Fi may be re-enabled. 516 * 517 * @returns Returns {@code true} if this method is called successfully, returns {@code false} otherwise. 518 * @since 9 519 * @throws {BusinessError} 201 - Permission denied. 520 * @throws {BusinessError} 202 - System API is not allowed called by Non-system application. 521 * @throws {BusinessError} 801 - Capability not supported. 522 * @throws {BusinessError} 2601000 - Operation failed. 523 * @syscap SystemCapability.Communication.WiFi.AP.Core 524 * @permission ohos.permission.MANAGE_WIFI_HOTSPOT 525 * @systemapi Hide this for inner system use. 526 */ 527 function disableHotspot(): void; 528 529 /** 530 * Check whether a device serving as a Wi-Fi hotspot supports both the 2.4 GHz and 5 GHz Wi-Fi. 531 * 532 * @returns Returns {@code true} if the method is called successfully, returns {@code false} otherwise. 533 * @since 9 534 * @throws {BusinessError} 201 - Permission denied. 535 * @throws {BusinessError} 202 - System API is not allowed called by Non-system application. 536 * @throws {BusinessError} 801 - Capability not supported. 537 * @throws {BusinessError} 2601000 - Operation failed. 538 * @syscap SystemCapability.Communication.WiFi.AP.Core 539 * @permission ohos.permission.GET_WIFI_INFO and ohos.permission.MANAGE_WIFI_HOTSPOT 540 * @systemapi Hide this for inner system use. 541 */ 542 function isHotspotDualBandSupported(): boolean; 543 544 /** 545 * Check whether Wi-Fi hotspot is active on a device. 546 * 547 * @returns Returns {@code true} if Wi-Fi hotspot is enabled, returns {@code false} otherwise. 548 * @since 9 549 * @throws {BusinessError} 201 - Permission denied. 550 * @throws {BusinessError} 202 - System API is not allowed called by Non-system application. 551 * @throws {BusinessError} 801 - Capability not supported. 552 * @throws {BusinessError} 2601000 - Operation failed. 553 * @syscap SystemCapability.Communication.WiFi.AP.Core 554 * @permission ohos.permission.GET_WIFI_INFO 555 * @systemapi Hide this for inner system use. 556 */ 557 function isHotspotActive(): boolean; 558 559 /** 560 * Set the hotspot configuration for the device. 561 * 562 * @param config Indicates the Wi-Fi hotspot configuration. 563 * The SSID and {@code securityType} must be available and correct. 564 * If {@code securityType} is not {@code open}, {@code preSharedKey} must be available and correct. 565 * @returns Returns {@code true} if the method is called successfully, returns {@code false} otherwise. 566 * @since 9 567 * @throws {BusinessError} 201 - Permission denied. 568 * @throws {BusinessError} 202 - System API is not allowed called by Non-system application. 569 * @throws {BusinessError} 401 - Invalid parameters. 570 * @throws {BusinessError} 801 - Capability not supported. 571 * @throws {BusinessError} 2601000 - Operation failed. 572 * @syscap SystemCapability.Communication.WiFi.AP.Core 573 * @permission ohos.permission.SET_WIFI_INFO and ohos.permission.GET_WIFI_CONFIG 574 * @systemapi Hide this for inner system use. 575 */ 576 function setHotspotConfig(config: HotspotConfig): void; 577 578 /** 579 * Obtain the Wi-Fi hotspot configuration. 580 * 581 * @returns Returns the configuration of an existed or enabled Wi-Fi hotspot. 582 * @since 9 583 * @throws {BusinessError} 201 - Permission denied. 584 * @throws {BusinessError} 202 - System API is not allowed called by Non-system application. 585 * @throws {BusinessError} 801 - Capability not supported. 586 * @throws {BusinessError} 2601000 - Operation failed. 587 * @syscap SystemCapability.Communication.WiFi.AP.Core 588 * @permission ohos.permission.GET_WIFI_INFO and ohos.permission.GET_WIFI_CONFIG 589 * @systemapi Hide this for inner system use. 590 */ 591 function getHotspotConfig(): HotspotConfig; 592 593 /** 594 * Obtain the list of stations that are connected to the Wi-Fi hotspot. 595 * 596 * <p>This method can only be used on a device that serves as a Wi-Fi hotspot. 597 * 598 * @returns Returns the list of clients that are connected to the Wi-Fi hotspot. 599 * @since 9 600 * @throws {BusinessError} 201 - Permission denied. 601 * @throws {BusinessError} 202 - System API is not allowed called by Non-system application. 602 * @throws {BusinessError} 801 - Capability not supported. 603 * @throws {BusinessError} 2601000 - Operation failed. 604 * @syscap SystemCapability.Communication.WiFi.AP.Core 605 * @permission ohos.permission.GET_WIFI_INFO and ohos.permission.LOCATION and ohos.permission.MANAGE_WIFI_HOTSPOT 606 * @systemapi Hide this for inner system use. 607 */ 608 function getStations(): Array<StationInfo>; 609 610 /** 611 * Obtain information about the P2P connection. 612 * 613 * @returns Returns the P2P connection information. 614 * @since 9 615 * @throws {BusinessError} 201 - Permission denied. 616 * @throws {BusinessError} 801 - Capability not supported. 617 * @throws {BusinessError} 2801000 - Operation failed. 618 * @syscap SystemCapability.Communication.WiFi.P2P 619 * @permission ohos.permission.GET_WIFI_INFO 620 */ 621 function getP2pLinkedInfo(): Promise<WifiP2pLinkedInfo>; 622 function getP2pLinkedInfo(callback: AsyncCallback<WifiP2pLinkedInfo>): void; 623 624 /** 625 * Obtain information about the current p2p group. 626 * 627 * @returns Returns the current group information. 628 * @since 9 629 * @throws {BusinessError} 201 - Permission denied. 630 * @throws {BusinessError} 801 - Capability not supported. 631 * @throws {BusinessError} 2801000 - Operation failed. 632 * @syscap SystemCapability.Communication.WiFi.P2P 633 * @permission ohos.permission.GET_WIFI_INFO and ohos.permission.LOCATION 634 */ 635 function getCurrentGroup(): Promise<WifiP2pGroupInfo>; 636 function getCurrentGroup(callback: AsyncCallback<WifiP2pGroupInfo>): void; 637 638 /** 639 * Obtain the information about the found devices. 640 * 641 * @returns Returns the found devices list. 642 * @since 9 643 * @throws {BusinessError} 201 - Permission denied. 644 * @throws {BusinessError} 801 - Capability not supported. 645 * @throws {BusinessError} 2801000 - Operation failed. 646 * @syscap SystemCapability.Communication.WiFi.P2P 647 * @permission ohos.permission.GET_WIFI_INFO and ohos.permission.LOCATION 648 */ 649 function getP2pPeerDevices(): Promise<WifiP2pDevice[]>; 650 function getP2pPeerDevices(callback: AsyncCallback<WifiP2pDevice[]>): void; 651 652 /** 653 * Obtain the information about own device information. 654 * 655 * <p> deviceAddress in the returned WifiP2pDevice will be set "00:00:00:00:00:00", 656 * if ohos.permission.GET_WIFI_LOCAL_MAC is not granted. 657 * 658 * @returns Returns the information about own device info. 659 * @since 9 660 * @throws {BusinessError} 201 - Permission denied. 661 * @throws {BusinessError} 801 - Capability not supported. 662 * @throws {BusinessError} 2801000 - Operation failed. 663 * @syscap SystemCapability.Communication.WiFi.P2P 664 * @permission ohos.permission.GET_WIFI_INFO and ohos.permission.GET_WIFI_CONFIG 665 */ 666 function getP2pLocalDevice(): Promise<WifiP2pDevice>; 667 function getP2pLocalDevice(callback: AsyncCallback<WifiP2pDevice>): void; 668 669 /** 670 * Create a P2P group. 671 * 672 * @param config Indicates the configuration for a group. 673 * @since 9 674 * @throws {BusinessError} 201 - Permission denied. 675 * @throws {BusinessError} 401 - Invalid parameters. 676 * @throws {BusinessError} 801 - Capability not supported. 677 * @throws {BusinessError} 2801000 - Operation failed. 678 * @syscap SystemCapability.Communication.WiFi.P2P 679 * @permission ohos.permission.GET_WIFI_INFO 680 */ 681 function createGroup(config: WifiP2PConfig): void; 682 683 /** 684 * Remove a P2P group. 685 * 686 * @since 9 687 * @throws {BusinessError} 201 - Permission denied. 688 * @throws {BusinessError} 801 - Capability not supported. 689 * @throws {BusinessError} 2801000 - Operation failed. 690 * @syscap SystemCapability.Communication.WiFi.P2P 691 * @permission ohos.permission.GET_WIFI_INFO 692 */ 693 function removeGroup(): void; 694 695 /** 696 * Initiate a P2P connection to a device with the specified configuration. 697 * 698 * @param config Indicates the configuration for connecting to a specific group. 699 * @since 9 700 * @throws {BusinessError} 201 - Permission denied. 701 * @throws {BusinessError} 401 - Invalid parameters. 702 * @throws {BusinessError} 801 - Capability not supported. 703 * @throws {BusinessError} 2801000 - Operation failed. 704 * @syscap SystemCapability.Communication.WiFi.P2P 705 * @permission ohos.permission.GET_WIFI_INFO and ohos.permission.LOCATION 706 */ 707 function p2pConnect(config: WifiP2PConfig): void; 708 709 /** 710 * Stop an ongoing p2p connection that is being established. 711 * 712 * @since 9 713 * @throws {BusinessError} 201 - Permission denied. 714 * @throws {BusinessError} 801 - Capability not supported. 715 * @throws {BusinessError} 2801000 - Operation failed. 716 * @syscap SystemCapability.Communication.WiFi.P2P 717 * @permission ohos.permission.GET_WIFI_INFO 718 */ 719 function p2pCancelConnect(): void; 720 721 /** 722 * Start discover Wi-Fi P2P devices. 723 * 724 * @since 9 725 * @throws {BusinessError} 201 - Permission denied. 726 * @throws {BusinessError} 801 - Capability not supported. 727 * @throws {BusinessError} 2801000 - Operation failed. 728 * @syscap SystemCapability.Communication.WiFi.P2P 729 * @permission ohos.permission.GET_WIFI_INFO and ohos.permission.LOCATION 730 */ 731 function startDiscoverDevices(): void; 732 733 /** 734 * Stop discover Wi-Fi P2P devices. 735 * 736 * @since 9 737 * @throws {BusinessError} 201 - Permission denied. 738 * @throws {BusinessError} 801 - Capability not supported. 739 * @throws {BusinessError} 2801000 - Operation failed. 740 * @syscap SystemCapability.Communication.WiFi.P2P 741 * @permission ohos.permission.GET_WIFI_INFO 742 */ 743 function stopDiscoverDevices(): void; 744 745 /** 746 * Delete the persistent P2P group with the specified network ID. 747 * 748 * @param netId Indicates the network ID of the group to be deleted. 749 * @since 9 750 * @throws {BusinessError} 201 - Permission denied. 751 * @throws {BusinessError} 202 - System API is not allowed called by Non-system application. 752 * @throws {BusinessError} 401 - Invalid parameters. 753 * @throws {BusinessError} 801 - Capability not supported. 754 * @throws {BusinessError} 2801000 - Operation failed. 755 * @syscap SystemCapability.Communication.WiFi.P2P 756 * @permission ohos.permission.SET_WIFI_INFO and ohos.permission.MANAGE_WIFI_CONNECTION 757 * @systemapi Hide this for inner system use. 758 */ 759 function deletePersistentGroup(netId: number): void; 760 761 /** 762 * Obtain information about the groups. 763 * 764 * @returns Returns the groups information. 765 * @since 9 766 * @throws {BusinessError} 201 - Permission denied. 767 * @throws {BusinessError} 202 - System API is not allowed called by Non-system application. 768 * @throws {BusinessError} 801 - Capability not supported. 769 * @throws {BusinessError} 2801000 - Operation failed. 770 * @syscap SystemCapability.Communication.WiFi.P2P 771 * @permission ohos.permission.GET_WIFI_INFO and ohos.permission.LOCATION 772 * @systemapi Hide this for inner system use. 773 */ 774 function getP2pGroups(): Promise<Array<WifiP2pGroupInfo>>; 775 function getP2pGroups(callback: AsyncCallback<Array<WifiP2pGroupInfo>>): void; 776 777 /** 778 * Set the name of the Wi-Fi P2P device. 779 * 780 * @param devName Indicate the name to be set. 781 * @since 9 782 * @throws {BusinessError} 201 - Permission denied. 783 * @throws {BusinessError} 202 - System API is not allowed called by Non-system application. 784 * @throws {BusinessError} 401 - Invalid parameters. 785 * @throws {BusinessError} 801 - Capability not supported. 786 * @throws {BusinessError} 2801000 - Operation failed. 787 * @syscap SystemCapability.Communication.WiFi.P2P 788 * @permission ohos.permission.SET_WIFI_INFO and ohos.permission.MANAGE_WIFI_CONNECTION 789 * @systemapi Hide this for inner system use. 790 */ 791 function setDeviceName(devName: string): void; 792 793 /** 794 * Subscribe Wi-Fi status change events. 795 * 796 * @returns Returns 0: inactive, 1: active, 2: activating, 3: de-activating 797 * @since 9 798 * @throws {BusinessError} 201 - Permission denied. 799 * @throws {BusinessError} 401 - Invalid parameters. 800 * @throws {BusinessError} 801 - Capability not supported. 801 * @throws {BusinessError} 2501000 - Operation failed. 802 * @syscap SystemCapability.Communication.WiFi.STA 803 * @permission ohos.permission.GET_WIFI_INFO 804 */ 805 function on(type: "wifiStateChange", callback: Callback<number>): void; 806 807 /** 808 * Unsubscribe Wi-Fi status change events. 809 * 810 * <p>All callback functions will be deregistered If there is no specific callback parameter.</p> 811 * 812 * @since 9 813 * @throws {BusinessError} 201 - Permission denied. 814 * @throws {BusinessError} 401 - Invalid parameters. 815 * @throws {BusinessError} 801 - Capability not supported. 816 * @throws {BusinessError} 2501000 - Operation failed. 817 * @syscap SystemCapability.Communication.WiFi.STA 818 * @permission ohos.permission.GET_WIFI_INFO 819 */ 820 function off(type: "wifiStateChange", callback?: Callback<number>): void; 821 822 /** 823 * Subscribe Wi-Fi connection change events. 824 * 825 * @returns Returns 0: disconnected, 1: connected 826 * @since 9 827 * @throws {BusinessError} 201 - Permission denied. 828 * @throws {BusinessError} 401 - Invalid parameters. 829 * @throws {BusinessError} 801 - Capability not supported. 830 * @throws {BusinessError} 2501000 - Operation failed. 831 * @syscap SystemCapability.Communication.WiFi.STA 832 * @permission ohos.permission.GET_WIFI_INFO 833 */ 834 function on(type: "wifiConnectionChange", callback: Callback<number>): void; 835 836 /** 837 * Unsubscribe Wi-Fi connection change events. 838 * 839 * <p>All callback functions will be deregistered If there is no specific callback parameter.</p> 840 * 841 * @since 9 842 * @throws {BusinessError} 201 - Permission denied. 843 * @throws {BusinessError} 401 - Invalid parameters. 844 * @throws {BusinessError} 801 - Capability not supported. 845 * @throws {BusinessError} 2501000 - Operation failed. 846 * @syscap SystemCapability.Communication.WiFi.STA 847 * @permission ohos.permission.GET_WIFI_INFO 848 */ 849 function off(type: "wifiConnectionChange", callback?: Callback<number>): void; 850 851 /** 852 * Subscribe Wi-Fi scan status change events. 853 * 854 * @returns Returns 0: scan fail, 1: scan success 855 * @since 9 856 * @throws {BusinessError} 201 - Permission denied. 857 * @throws {BusinessError} 401 - Invalid parameters. 858 * @throws {BusinessError} 801 - Capability not supported. 859 * @throws {BusinessError} 2501000 - Operation failed. 860 * @syscap SystemCapability.Communication.WiFi.STA 861 * @permission ohos.permission.GET_WIFI_INFO 862 */ 863 function on(type: "wifiScanStateChange", callback: Callback<number>): void; 864 865 /** 866 * Unsubscribe Wi-Fi scan status change events. 867 * 868 * <p>All callback functions will be deregistered If there is no specific callback parameter.</p> 869 * 870 * @since 9 871 * @throws {BusinessError} 201 - Permission denied. 872 * @throws {BusinessError} 401 - Invalid parameters. 873 * @throws {BusinessError} 801 - Capability not supported. 874 * @throws {BusinessError} 2501000 - Operation failed. 875 * @syscap SystemCapability.Communication.WiFi.STA 876 * @permission ohos.permission.GET_WIFI_INFO 877 */ 878 function off(type: "wifiScanStateChange", callback?: Callback<number>): void; 879 880 /** 881 * Subscribe Wi-Fi rssi change events. 882 * 883 * @returns Returns RSSI value in dBm 884 * @since 9 885 * @throws {BusinessError} 201 - Permission denied. 886 * @throws {BusinessError} 401 - Invalid parameters. 887 * @throws {BusinessError} 801 - Capability not supported. 888 * @throws {BusinessError} 2501000 - Operation failed. 889 * @syscap SystemCapability.Communication.WiFi.STA 890 * @permission ohos.permission.GET_WIFI_INFO 891 */ 892 function on(type: "wifiRssiChange", callback: Callback<number>): void; 893 894 /** 895 * Unsubscribe Wi-Fi rssi change events. 896 * 897 * <p>All callback functions will be deregistered If there is no specific callback parameter.</p> 898 * 899 * @since 9 900 * @throws {BusinessError} 201 - Permission denied. 901 * @throws {BusinessError} 401 - Invalid parameters. 902 * @throws {BusinessError} 801 - Capability not supported. 903 * @throws {BusinessError} 2501000 - Operation failed. 904 * @syscap SystemCapability.Communication.WiFi.STA 905 * @permission ohos.permission.GET_WIFI_INFO 906 */ 907 function off(type: "wifiRssiChange", callback?: Callback<number>): void; 908 909 /** 910 * Subscribe Wi-Fi stream change events. 911 * 912 * @returns Returns 0: stream none, 1: stream down, 2: stream up, 3: stream bidirectional 913 * @since 9 914 * @throws {BusinessError} 201 - Permission denied. 915 * @throws {BusinessError} 202 - System API is not allowed called by Non-system application. 916 * @throws {BusinessError} 401 - Invalid parameters. 917 * @throws {BusinessError} 801 - Capability not supported. 918 * @throws {BusinessError} 2501000 - Operation failed. 919 * @syscap SystemCapability.Communication.WiFi.STA 920 * @permission ohos.permission.MANAGE_WIFI_CONNECTION 921 * @systemapi Hide this for inner system use. 922 */ 923 function on(type: "streamChange", callback: Callback<number>): void; 924 925 /** 926 * Unsubscribe Wi-Fi stream change events. 927 * 928 * <p>All callback functions will be deregistered If there is no specific callback parameter.</p> 929 * 930 * @since 9 931 * @throws {BusinessError} 201 - Permission denied. 932 * @throws {BusinessError} 202 - System API is not allowed called by Non-system application. 933 * @throws {BusinessError} 401 - Invalid parameters. 934 * @throws {BusinessError} 801 - Capability not supported. 935 * @throws {BusinessError} 2501000 - Operation failed. 936 * @syscap SystemCapability.Communication.WiFi.STA 937 * @permission ohos.permission.MANAGE_WIFI_CONNECTION 938 * @systemapi Hide this for inner system use. 939 */ 940 function off(type: "streamChange", callback?: Callback<number>): void; 941 942 /** 943 * Subscribe Wi-Fi device config change events. 944 * 945 * @returns Returns 0: config is added, 1: config is changed, 2: config is removed. 946 * @since 9 947 * @throws {BusinessError} 201 - Permission denied. 948 * @throws {BusinessError} 202 - System API is not allowed called by Non-system application. 949 * @throws {BusinessError} 401 - Invalid parameters. 950 * @throws {BusinessError} 801 - Capability not supported. 951 * @throws {BusinessError} 2501000 - Operation failed. 952 * @syscap SystemCapability.Communication.WiFi.STA 953 * @permission ohos.permission.GET_WIFI_INFO 954 * @systemapi Hide this for inner system use. 955 */ 956 function on(type: "deviceConfigChange", callback: Callback<number>): void; 957 958 /** 959 * Subscribe Wi-Fi device config change events. 960 * 961 * @returns Returns 0: config is added, 1: config is changed, 2: config is removed. 962 * @since 9 963 * @throws {BusinessError} 201 - Permission denied. 964 * @throws {BusinessError} 202 - System API is not allowed called by Non-system application. 965 * @throws {BusinessError} 401 - Invalid parameters. 966 * @throws {BusinessError} 801 - Capability not supported. 967 * @throws {BusinessError} 2501000 - Operation failed. 968 * @syscap SystemCapability.Communication.WiFi.STA 969 * @permission ohos.permission.GET_WIFI_INFO 970 * @systemapi Hide this for inner system use. 971 */ 972 function off(type: "deviceConfigChange", callback?: Callback<number>): void; 973 974 /** 975 * Subscribe Wi-Fi hotspot state change events. 976 * 977 * @returns Returns 0: inactive, 1: active, 2: activating, 3: de-activating 978 * @since 9 979 * @throws {BusinessError} 201 - Permission denied. 980 * @throws {BusinessError} 202 - System API is not allowed called by Non-system application. 981 * @throws {BusinessError} 401 - Invalid parameters. 982 * @throws {BusinessError} 801 - Capability not supported. 983 * @throws {BusinessError} 2601000 - Operation failed. 984 * @syscap SystemCapability.Communication.WiFi.AP.Core 985 * @permission ohos.permission.GET_WIFI_INFO 986 */ 987 function on(type: "hotspotStateChange", callback: Callback<number>): void; 988 989 /** 990 * Unsubscribe Wi-Fi hotspot state change events. 991 * 992 * <p>All callback functions will be deregistered If there is no specific callback parameter.</p> 993 * 994 * @since 9 995 * @throws {BusinessError} 201 - Permission denied. 996 * @throws {BusinessError} 202 - System API is not allowed called by Non-system application. 997 * @throws {BusinessError} 401 - Invalid parameters. 998 * @throws {BusinessError} 801 - Capability not supported. 999 * @throws {BusinessError} 2601000 - Operation failed. 1000 * @syscap SystemCapability.Communication.WiFi.AP.Core 1001 * @permission ohos.permission.GET_WIFI_INFO 1002 */ 1003 function off(type: "hotspotStateChange", callback?: Callback<number>): void; 1004 1005 /** 1006 * Subscribe Wi-Fi hotspot sta join events. 1007 * 1008 * @returns Returns StationInfo 1009 * @since 9 1010 * @throws {BusinessError} 201 - Permission denied. 1011 * @throws {BusinessError} 202 - System API is not allowed called by Non-system application. 1012 * @throws {BusinessError} 401 - Invalid parameters. 1013 * @throws {BusinessError} 801 - Capability not supported. 1014 * @throws {BusinessError} 2601000 - Operation failed. 1015 * @syscap SystemCapability.Communication.WiFi.AP.Core 1016 * @permission ohos.permission.MANAGE_WIFI_HOTSPOT 1017 * @systemapi Hide this for inner system use. 1018 */ 1019 function on(type: "hotspotStaJoin", callback: Callback<StationInfo>): void; 1020 1021 /** 1022 * Unsubscribe Wi-Fi hotspot sta join events. 1023 * 1024 * <p>All callback functions will be deregistered If there is no specific callback parameter.</p> 1025 * 1026 * @since 9 1027 * @throws {BusinessError} 201 - Permission denied. 1028 * @throws {BusinessError} 202 - System API is not allowed called by Non-system application. 1029 * @throws {BusinessError} 401 - Invalid parameters. 1030 * @throws {BusinessError} 801 - Capability not supported. 1031 * @throws {BusinessError} 2601000 - Operation failed. 1032 * @syscap SystemCapability.Communication.WiFi.AP.Core 1033 * @permission ohos.permission.MANAGE_WIFI_HOTSPOT 1034 * @systemapi Hide this for inner system use. 1035 */ 1036 function off(type: "hotspotStaJoin", callback?: Callback<StationInfo>): void; 1037 1038 /** 1039 * Subscribe Wi-Fi hotspot sta leave events. 1040 * 1041 * @returns Returns {@link #StationInfo} object 1042 * @since 9 1043 * @throws {BusinessError} 201 - Permission denied. 1044 * @throws {BusinessError} 202 - System API is not allowed called by Non-system application. 1045 * @throws {BusinessError} 401 - Invalid parameters. 1046 * @throws {BusinessError} 801 - Capability not supported. 1047 * @throws {BusinessError} 2601000 - Operation failed. 1048 * @syscap SystemCapability.Communication.WiFi.AP.Core 1049 * @permission ohos.permission.MANAGE_WIFI_HOTSPOT 1050 * @systemapi Hide this for inner system use. 1051 */ 1052 function on(type: "hotspotStaLeave", callback: Callback<StationInfo>): void; 1053 1054 /** 1055 * Unsubscribe Wi-Fi hotspot sta leave events. 1056 * 1057 * @returns Returns {@link #StationInfo} object 1058 * @since 9 1059 * @throws {BusinessError} 201 - Permission denied. 1060 * @throws {BusinessError} 202 - System API is not allowed called by Non-system application. 1061 * @throws {BusinessError} 401 - Invalid parameters. 1062 * @throws {BusinessError} 801 - Capability not supported. 1063 * @throws {BusinessError} 2601000 - Operation failed. 1064 * @syscap SystemCapability.Communication.WiFi.AP.Core 1065 * @permission ohos.permission.MANAGE_WIFI_HOTSPOT 1066 * @systemapi Hide this for inner system use. 1067 */ 1068 function off(type: "hotspotStaLeave", callback?: Callback<StationInfo>): void; 1069 1070 /** 1071 * Subscribe P2P status change events. 1072 * 1073 * @returns Returns 1: idle, 2: starting, 3:started, 4: closing, 5: closed 1074 * @since 9 1075 * @throws {BusinessError} 201 - Permission denied. 1076 * @throws {BusinessError} 401 - Invalid parameters. 1077 * @throws {BusinessError} 801 - Capability not supported. 1078 * @throws {BusinessError} 2801000 - Operation failed. 1079 * @syscap SystemCapability.Communication.WiFi.P2P 1080 * @permission ohos.permission.GET_WIFI_INFO 1081 */ 1082 function on(type: "p2pStateChange", callback: Callback<number>): void; 1083 1084 /** 1085 * Unsubscribe P2P status change events. 1086 * 1087 * @since 9 1088 * @throws {BusinessError} 201 - Permission denied. 1089 * @throws {BusinessError} 401 - Invalid parameters. 1090 * @throws {BusinessError} 801 - Capability not supported. 1091 * @throws {BusinessError} 2801000 - Operation failed. 1092 * @syscap SystemCapability.Communication.WiFi.P2P 1093 * @permission ohos.permission.GET_WIFI_INFO 1094 */ 1095 function off(type: "p2pStateChange", callback?: Callback<number>): void; 1096 1097 /** 1098 * Subscribe P2P connection change events. 1099 * 1100 * @returns Returns WifiP2pLinkedInfo 1101 * @since 9 1102 * @throws {BusinessError} 201 - Permission denied. 1103 * @throws {BusinessError} 401 - Invalid parameters. 1104 * @throws {BusinessError} 801 - Capability not supported. 1105 * @throws {BusinessError} 2801000 - Operation failed. 1106 * @syscap SystemCapability.Communication.WiFi.P2P 1107 * @permission ohos.permission.GET_WIFI_INFO 1108 */ 1109 function on(type: "p2pConnectionChange", callback: Callback<WifiP2pLinkedInfo>): void; 1110 1111 /** 1112 * Unsubscribe P2P connection change events. 1113 * 1114 * @since 9 1115 * @throws {BusinessError} 201 - Permission denied. 1116 * @throws {BusinessError} 401 - Invalid parameters. 1117 * @throws {BusinessError} 801 - Capability not supported. 1118 * @throws {BusinessError} 2801000 - Operation failed. 1119 * @syscap SystemCapability.Communication.WiFi.P2P 1120 * @permission ohos.permission.GET_WIFI_INFO 1121 */ 1122 function off(type: "p2pConnectionChange", callback?: Callback<WifiP2pLinkedInfo>): void; 1123 1124 /** 1125 * Subscribe P2P local device change events. 1126 * 1127 * @returns Returns WifiP2pDevice 1128 * @since 9 1129 * @throws {BusinessError} 201 - Permission denied. 1130 * @throws {BusinessError} 401 - Invalid parameters. 1131 * @throws {BusinessError} 801 - Capability not supported. 1132 * @throws {BusinessError} 2801000 - Operation failed. 1133 * @syscap SystemCapability.Communication.WiFi.P2P 1134 * @permission ohos.permission.GET_WIFI_INFO and ohos.permission.LOCATION 1135 */ 1136 function on(type: "p2pDeviceChange", callback: Callback<WifiP2pDevice>): void; 1137 1138 /** 1139 * Unsubscribe P2P local device change events. 1140 * 1141 * @returns Returns WifiP2pDevice 1142 * @since 9 1143 * @throws {BusinessError} 201 - Permission denied. 1144 * @throws {BusinessError} 401 - Invalid parameters. 1145 * @throws {BusinessError} 801 - Capability not supported. 1146 * @throws {BusinessError} 2801000 - Operation failed. 1147 * @syscap SystemCapability.Communication.WiFi.P2P 1148 * @permission ohos.permission.LOCATION 1149 */ 1150 function off(type: "p2pDeviceChange", callback?: Callback<WifiP2pDevice>): void; 1151 1152 /** 1153 * Subscribe P2P peer device change events. 1154 * 1155 * @returns Returns WifiP2pDevice[] 1156 * @since 9 1157 * @throws {BusinessError} 201 - Permission denied. 1158 * @throws {BusinessError} 401 - Invalid parameters. 1159 * @throws {BusinessError} 801 - Capability not supported. 1160 * @throws {BusinessError} 2801000 - Operation failed. 1161 * @syscap SystemCapability.Communication.WiFi.P2P 1162 * @permission ohos.permission.GET_WIFI_INFO and ohos.permission.LOCATION 1163 */ 1164 function on(type: "p2pPeerDeviceChange", callback: Callback<WifiP2pDevice[]>): void; 1165 1166 /** 1167 * Unsubscribe P2P peer device change events. 1168 * 1169 * @since 9 1170 * @throws {BusinessError} 201 - Permission denied. 1171 * @throws {BusinessError} 401 - Invalid parameters. 1172 * @throws {BusinessError} 801 - Capability not supported. 1173 * @throws {BusinessError} 2801000 - Operation failed. 1174 * @syscap SystemCapability.Communication.WiFi.P2P 1175 * @permission ohos.permission.LOCATION 1176 */ 1177 function off(type: "p2pPeerDeviceChange", callback?: Callback<WifiP2pDevice[]>): void; 1178 1179 /** 1180 * Subscribe P2P persistent group change events. 1181 * 1182 * @since 9 1183 * @throws {BusinessError} 201 - Permission denied. 1184 * @throws {BusinessError} 401 - Invalid parameters. 1185 * @throws {BusinessError} 801 - Capability not supported. 1186 * @throws {BusinessError} 2801000 - Operation failed. 1187 * @syscap SystemCapability.Communication.WiFi.P2P 1188 * @permission ohos.permission.GET_WIFI_INFO 1189 */ 1190 function on(type: "p2pPersistentGroupChange", callback: Callback<void>): void; 1191 1192 /** 1193 * Unsubscribe P2P persistent group change events. 1194 * 1195 * @since 9 1196 * @throws {BusinessError} 201 - Permission denied. 1197 * @throws {BusinessError} 401 - Invalid parameters. 1198 * @throws {BusinessError} 801 - Capability not supported. 1199 * @throws {BusinessError} 2801000 - Operation failed. 1200 * @syscap SystemCapability.Communication.WiFi.P2P 1201 * @permission ohos.permission.GET_WIFI_INFO 1202 */ 1203 function off(type: "p2pPersistentGroupChange", callback?: Callback<void>): void; 1204 1205 /** 1206 * Subscribe P2P discovery events. 1207 * 1208 * @returns Returns 0: initial state, 1: discovery succeeded 1209 * @since 9 1210 * @throws {BusinessError} 201 - Permission denied. 1211 * @throws {BusinessError} 401 - Invalid parameters. 1212 * @throws {BusinessError} 801 - Capability not supported. 1213 * @throws {BusinessError} 2801000 - Operation failed. 1214 * @syscap SystemCapability.Communication.WiFi.P2P 1215 * @permission ohos.permission.GET_WIFI_INFO 1216 */ 1217 function on(type: "p2pDiscoveryChange", callback: Callback<number>): void; 1218 1219 /** 1220 * Unsubscribe P2P discovery events. 1221 * 1222 * @since 9 1223 * @throws {BusinessError} 201 - Permission denied. 1224 * @throws {BusinessError} 401 - Invalid parameters. 1225 * @throws {BusinessError} 801 - Capability not supported. 1226 * @throws {BusinessError} 2801000 - Operation failed. 1227 * @syscap SystemCapability.Communication.WiFi.P2P 1228 * @permission ohos.permission.GET_WIFI_INFO 1229 */ 1230 function off(type: "p2pDiscoveryChange", callback?: Callback<number>): void; 1231 1232 /** 1233 * Wi-Fi EAP method. 1234 * 1235 * @since 9 1236 * @systemapi Hide this for inner system use. 1237 * @syscap SystemCapability.Communication.WiFi.STA 1238 */ 1239 enum EapMethod { 1240 EAP_NONE, 1241 EAP_PEAP, 1242 EAP_TLS, 1243 EAP_TTLS, 1244 EAP_PWD, 1245 EAP_SIM, 1246 EAP_AKA, 1247 EAP_AKA_PRIME, 1248 EAP_UNAUTH_TLS, 1249 } 1250 1251 /** 1252 * Wi-Fi phase 2 method. 1253 * 1254 * @since 9 1255 * @systemapi Hide this for inner system use. 1256 * @syscap SystemCapability.Communication.WiFi.STA 1257 */ 1258 enum Phase2Method { 1259 PHASE2_NONE, 1260 PHASE2_PAP, 1261 PHASE2_MSCHAP, 1262 PHASE2_MSCHAPV2, 1263 PHASE2_GTC, 1264 PHASE2_SIM, 1265 PHASE2_AKA, 1266 PHASE2_AKA_PRIME, 1267 } 1268 1269 /** 1270 * Wi-Fi EAP config. 1271 * 1272 * @since 9 1273 * @systemapi Hide this for inner system use. 1274 * @syscap SystemCapability.Communication.WiFi.STA 1275 */ 1276 interface WifiEapConfig { 1277 /** EAP authentication method */ 1278 eapMethod: EapMethod; 1279 1280 /** Phase 2 authentication method */ 1281 phase2Method: Phase2Method; 1282 1283 /** The identity */ 1284 identity: string; 1285 1286 /** Anonymous identity */ 1287 anonymousIdentity: string; 1288 1289 /** Password */ 1290 password: string; 1291 1292 /** CA certificate alias */ 1293 caCertAliases: string; 1294 1295 /** CA certificate path */ 1296 caPath: string; 1297 1298 /** Client certificate alias */ 1299 clientCertAliases: string; 1300 1301 /** content of user's certificate */ 1302 certEntry: Uint8Array; 1303 1304 /** Password of user's certificate */ 1305 certPassword: string; 1306 1307 /** Alternate subject match */ 1308 altSubjectMatch: string; 1309 1310 /** Domain suffix match */ 1311 domainSuffixMatch: string; 1312 1313 /** Realm for Passpoint credential */ 1314 realm: string; 1315 1316 /** Public Land Mobile Network of the provider of Passpoint credential */ 1317 plmn: string; 1318 1319 /** Sub ID of the SIM card */ 1320 eapSubId: number; 1321 } 1322 1323 /** 1324 * Wi-Fi device configuration information. 1325 * 1326 * @since 9 1327 * @syscap SystemCapability.Communication.WiFi.STA 1328 */ 1329 interface WifiDeviceConfig { 1330 /** Wi-Fi SSID: the maximum length is 32 */ 1331 ssid: string; 1332 1333 /** Wi-Fi bssid(MAC): the length is 6 */ 1334 bssid?: string; 1335 1336 /** Wi-Fi key: maximum length is 64 */ 1337 preSharedKey: string; 1338 1339 /** Hide SSID or not, false(default): not hide */ 1340 isHiddenSsid?: boolean; 1341 1342 /** Security type: reference definition of WifiSecurityType */ 1343 securityType: WifiSecurityType; 1344 1345 /** The UID of the Wi-Fi configuration creator */ 1346 /* @systemapi */ 1347 creatorUid?: number; 1348 1349 /** Disable reason */ 1350 /* @systemapi */ 1351 disableReason?: number; 1352 1353 /** Allocated networkId */ 1354 /* @systemapi */ 1355 netId?: number; 1356 1357 /** Random mac type */ 1358 /* @systemapi */ 1359 randomMacType?: number; 1360 1361 /** Random mac address, the length is 6 */ 1362 /* @systemapi */ 1363 randomMacAddr?: string; 1364 1365 /** IP Type */ 1366 /* @systemapi */ 1367 ipType?: IpType; 1368 1369 /** IP config of static */ 1370 /* @systemapi */ 1371 staticIp?: IpConfig; 1372 1373 /** 1374 * EAP config info. 1375 * @systemapi 1376 */ 1377 eapConfig?: WifiEapConfig; 1378 } 1379 1380 /** 1381 * Wi-Fi IP configuration information. 1382 * 1383 * @since 9 1384 * @systemapi Hide this for inner system use. 1385 * @syscap SystemCapability.Communication.WiFi.STA 1386 */ 1387 interface IpConfig { 1388 ipAddress: number; 1389 gateway: number; 1390 prefixLength: number; 1391 dnsServers: number[]; 1392 domains: Array<string>; 1393 } 1394 1395 /** 1396 * Wi-Fi information elements. 1397 * 1398 * @since 9 1399 * @syscap SystemCapability.Communication.WiFi.STA 1400 */ 1401 interface WifiInfoElem { 1402 /** Element id */ 1403 eid: number; 1404 /** Element content */ 1405 content: Uint8Array; 1406 } 1407 1408 /** 1409 * Describes the wifi channel width. 1410 * 1411 * @since 9 1412 * @syscap SystemCapability.Communication.WiFi.STA 1413 */ 1414 enum WifiChannelWidth { 1415 WIDTH_20MHZ = 0, 1416 WIDTH_40MHZ = 1, 1417 WIDTH_80MHZ = 2, 1418 WIDTH_160MHZ = 3, 1419 WIDTH_80MHZ_PLUS = 4, 1420 WIDTH_INVALID 1421 } 1422 1423 /** 1424 * Describes the scanned Wi-Fi information. 1425 * 1426 * @since 9 1427 * @syscap SystemCapability.Communication.WiFi.STA 1428 */ 1429 interface WifiScanInfo { 1430 /** Wi-Fi SSID: the maximum length is 32 */ 1431 ssid: string; 1432 1433 /** Wi-Fi bssid(MAC): the length is 6 */ 1434 bssid: string; 1435 1436 /** Hotspot capability */ 1437 capabilities: string; 1438 1439 /** Security type: reference definition of WifiSecurityType */ 1440 securityType: WifiSecurityType; 1441 1442 /** Received signal strength indicator (RSSI) */ 1443 rssi: number; 1444 1445 /** Frequency band, 1: 2.4G, 2: 5G */ 1446 band: number; 1447 1448 /** Frequency */ 1449 frequency: number; 1450 1451 /** Channel width */ 1452 channelWidth: number; 1453 1454 /** 1455 * Center frequency 0. 1456 * 1457 * @since 9 1458 * @syscap SystemCapability.Communication.WiFi.STA 1459 */ 1460 centerFrequency0: number; 1461 1462 /** 1463 * Center frequency 1. 1464 * 1465 * @since 9 1466 * @syscap SystemCapability.Communication.WiFi.STA 1467 */ 1468 centerFrequency1: number; 1469 1470 /** 1471 * Information elements. 1472 * 1473 * @since 9 1474 * @syscap SystemCapability.Communication.WiFi.STA 1475 */ 1476 infoElems: Array<WifiInfoElem>; 1477 1478 /** Time stamp */ 1479 timestamp: number; 1480 } 1481 1482 /** 1483 * Describes the wifi security type. 1484 * 1485 * @since 9 1486 * @syscap SystemCapability.Communication.WiFi.Core 1487 */ 1488 enum WifiSecurityType { 1489 /** Invalid security type */ 1490 WIFI_SEC_TYPE_INVALID = 0, 1491 1492 /** Open */ 1493 WIFI_SEC_TYPE_OPEN = 1, 1494 1495 /** Wired Equivalent Privacy (WEP) */ 1496 WIFI_SEC_TYPE_WEP = 2, 1497 1498 /** Pre-shared key (PSK) */ 1499 WIFI_SEC_TYPE_PSK = 3, 1500 1501 /** Simultaneous Authentication of Equals (SAE) */ 1502 WIFI_SEC_TYPE_SAE = 4, 1503 1504 /** 1505 * EAP authentication. 1506 * 1507 * @since 9 1508 * @syscap SystemCapability.Communication.WiFi.Core 1509 */ 1510 WIFI_SEC_TYPE_EAP = 5, 1511 1512 /** 1513 * SUITE_B_192 192 bit level. 1514 * 1515 * @since 9 1516 * @syscap SystemCapability.Communication.WiFi.Core 1517 */ 1518 WIFI_SEC_TYPE_EAP_SUITE_B = 6, 1519 1520 /** 1521 * Opportunistic Wireless Encryption. 1522 * 1523 * @since 9 1524 * @syscap SystemCapability.Communication.WiFi.Core 1525 */ 1526 WIFI_SEC_TYPE_OWE = 7, 1527 1528 /** 1529 * WAPI certificate to be specified. 1530 * 1531 * @since 9 1532 * @syscap SystemCapability.Communication.WiFi.Core 1533 */ 1534 WIFI_SEC_TYPE_WAPI_CERT = 8, 1535 1536 /** 1537 * WAPI pre-shared key to be specified. 1538 * 1539 * @since 9 1540 * @syscap SystemCapability.Communication.WiFi.Core 1541 */ 1542 WIFI_SEC_TYPE_WAPI_PSK = 9, 1543 } 1544 1545 /** 1546 * Wi-Fi connection information. 1547 * 1548 * @since 9 1549 * @syscap SystemCapability.Communication.WiFi.STA 1550 */ 1551 interface WifiLinkedInfo { 1552 /** The SSID of the Wi-Fi hotspot */ 1553 ssid: string; 1554 1555 /** The BSSID of the Wi-Fi hotspot */ 1556 bssid: string; 1557 1558 /** The ID(uniquely identifies) of a Wi-Fi connection. */ 1559 /* @systemapi */ 1560 networkId: number; 1561 1562 /** The RSSI(dBm) of a Wi-Fi access point. */ 1563 rssi: number; 1564 1565 /** The frequency band of a Wi-Fi access point. */ 1566 band: number; 1567 1568 /** The speed of a Wi-Fi access point. */ 1569 linkSpeed: number; 1570 1571 /** The frequency of a Wi-Fi access point. */ 1572 frequency: number; 1573 1574 /** Whether the SSID of the access point (AP) of this Wi-Fi connection is hidden. */ 1575 isHidden: boolean; 1576 1577 /** Whether this Wi-Fi connection restricts the data volume. */ 1578 isRestricted: boolean; 1579 1580 /** The load value of this Wi-Fi connection. A greater value indicates a higher load. */ 1581 /* @systemapi */ 1582 chload: number; 1583 1584 /** The signal-to-noise ratio (SNR) of this Wi-Fi connection. */ 1585 /* @systemapi */ 1586 snr: number; 1587 1588 /** 1589 * Type of macAddress: 0 - real mac, 1 - random mac. 1590 * 1591 * @since 9 1592 * @syscap SystemCapability.Communication.WiFi.STA 1593 */ 1594 macType: number; 1595 1596 /** The Wi-Fi MAC address of a device. */ 1597 macAddress: string; 1598 1599 /** The IP address of this Wi-Fi connection. */ 1600 ipAddress: number; 1601 1602 /** The state of the supplicant of this Wi-Fi connection. */ 1603 /* @systemapi */ 1604 suppState: SuppState; 1605 1606 /** The state of this Wi-Fi connection. */ 1607 connState: ConnState; 1608 } 1609 1610 /** 1611 * Wi-Fi IP information. 1612 * 1613 * @since 9 1614 * @syscap SystemCapability.Communication.WiFi.STA 1615 */ 1616 interface IpInfo { 1617 /** The IP address of the Wi-Fi connection */ 1618 ipAddress: number; 1619 1620 /** The gateway of the Wi-Fi connection */ 1621 gateway: number; 1622 1623 /** The network mask of the Wi-Fi connection */ 1624 netmask: number; 1625 1626 /** The primary DNS server IP address of the Wi-Fi connection */ 1627 primaryDns: number; 1628 1629 /** The secondary DNS server IP address of the Wi-Fi connection */ 1630 secondDns: number; 1631 1632 /** The DHCP server IP address of the Wi-Fi connection */ 1633 serverIp: number; 1634 1635 /** The IP address lease duration of the Wi-Fi connection */ 1636 leaseDuration: number; 1637 } 1638 1639 /** 1640 * Wi-Fi hotspot configuration information. 1641 * 1642 * @since 9 1643 * @systemapi Hide this for inner system use. 1644 * @syscap SystemCapability.Communication.WiFi.AP.Core 1645 */ 1646 interface HotspotConfig { 1647 /** The SSID of the Wi-Fi hotspot */ 1648 ssid: string; 1649 1650 /** The encryption mode of the Wi-Fi hotspot */ 1651 securityType: WifiSecurityType; 1652 1653 /** The frequency band of the Wi-Fi hotspot */ 1654 band: number; 1655 1656 /** The password of the Wi-Fi hotspot */ 1657 preSharedKey: string; 1658 1659 /** The maximum number of connections allowed by the Wi-Fi hotspot */ 1660 maxConn: number; 1661 } 1662 1663 /** 1664 * Wi-Fi station information. 1665 * 1666 * @since 9 1667 * @systemapi Hide this for inner system use. 1668 * @syscap SystemCapability.Communication.WiFi.AP.Core 1669 */ 1670 interface StationInfo { 1671 /** the network name of the Wi-Fi client */ 1672 name: string; 1673 1674 /** The MAC address of the Wi-Fi client */ 1675 macAddress: string; 1676 1677 /** The IP address of the Wi-Fi client */ 1678 ipAddress: string; 1679 } 1680 1681 /** 1682 * Wi-Fi IP type enumeration. 1683 * 1684 * @since 9 1685 * @systemapi Hide this for inner system use. 1686 * @syscap SystemCapability.Communication.WiFi.STA 1687 */ 1688 enum IpType { 1689 /** Use statically configured IP settings */ 1690 STATIC, 1691 1692 /** Use dynamically configured IP settings */ 1693 DHCP, 1694 1695 /** No IP details are assigned */ 1696 UNKNOWN, 1697 } 1698 1699 /** 1700 * The state of the supplicant enumeration. 1701 * 1702 * @since 9 1703 * @systemapi Hide this for inner system use. 1704 * @syscap SystemCapability.Communication.WiFi.STA 1705 */ 1706 export enum SuppState { 1707 /** The supplicant is not associated with or is disconnected from the AP. */ 1708 DISCONNECTED, 1709 1710 /** The network interface is disabled. */ 1711 INTERFACE_DISABLED, 1712 1713 /** The supplicant is disabled. */ 1714 INACTIVE, 1715 1716 /** The supplicant is scanning for a Wi-Fi connection. */ 1717 SCANNING, 1718 1719 /** The supplicant is authenticating with a specified AP. */ 1720 AUTHENTICATING, 1721 1722 /** The supplicant is associating with a specified AP. */ 1723 ASSOCIATING, 1724 1725 /** The supplicant is associated with a specified AP. */ 1726 ASSOCIATED, 1727 1728 /** The four-way handshake is ongoing. */ 1729 FOUR_WAY_HANDSHAKE, 1730 1731 /** The group handshake is ongoing. */ 1732 GROUP_HANDSHAKE, 1733 1734 /** All authentication is completed. */ 1735 COMPLETED, 1736 1737 /** Failed to establish a connection to the supplicant. */ 1738 UNINITIALIZED, 1739 1740 /** The supplicant is in an unknown or invalid state. */ 1741 INVALID 1742 } 1743 1744 /** 1745 * The state of Wi-Fi connection enumeration. 1746 * 1747 * @since 9 1748 * @syscap SystemCapability.Communication.WiFi.STA 1749 */ 1750 export enum ConnState { 1751 /** The device is searching for an available AP. */ 1752 SCANNING, 1753 1754 /** The Wi-Fi connection is being set up. */ 1755 CONNECTING, 1756 1757 /** The Wi-Fi connection is being authenticated. */ 1758 AUTHENTICATING, 1759 1760 /** The IP address of the Wi-Fi connection is being obtained. */ 1761 OBTAINING_IPADDR, 1762 1763 /** The Wi-Fi connection has been set up. */ 1764 CONNECTED, 1765 1766 /** The Wi-Fi connection is being torn down. */ 1767 DISCONNECTING, 1768 1769 /** The Wi-Fi connection has been torn down. */ 1770 DISCONNECTED, 1771 1772 /** Failed to set up the Wi-Fi connection. */ 1773 UNKNOWN 1774 } 1775 1776 /** 1777 * P2P device information. 1778 * 1779 * @since 9 1780 * @syscap SystemCapability.Communication.WiFi.P2P 1781 */ 1782 interface WifiP2pDevice { 1783 /** Device name */ 1784 deviceName: string; 1785 1786 /** Device mac address */ 1787 deviceAddress: string; 1788 1789 /** Primary device type */ 1790 primaryDeviceType: string; 1791 1792 /** Device status */ 1793 deviceStatus: P2pDeviceStatus; 1794 1795 /** Device group capabilities */ 1796 groupCapabilities: number; 1797 } 1798 1799 /** 1800 * P2P config. 1801 * 1802 * @since 9 1803 * @syscap SystemCapability.Communication.WiFi.P2P 1804 */ 1805 interface WifiP2PConfig { 1806 /** Device mac address */ 1807 deviceAddress: string; 1808 1809 /** 1810 * Group network ID. When creating a group, -1 indicates creates a temporary group, 1811 * -2: indicates creates a persistent group 1812 */ 1813 netId: number; 1814 1815 /* The passphrase of this {@code WifiP2pConfig} instance */ 1816 passphrase: string; 1817 1818 /** Group name */ 1819 groupName: string; 1820 1821 /** Group owner band */ 1822 goBand: GroupOwnerBand; 1823 } 1824 1825 /** 1826 * P2P group information. 1827 * 1828 * @since 9 1829 * @syscap SystemCapability.Communication.WiFi.P2P 1830 */ 1831 interface WifiP2pGroupInfo { 1832 /** Indicates whether it is group owner */ 1833 isP2pGo: boolean; 1834 1835 /** Group owner information */ 1836 ownerInfo: WifiP2pDevice; 1837 1838 /** The group passphrase */ 1839 passphrase: string; 1840 1841 /** Interface name */ 1842 interface: string; 1843 1844 /** Group name */ 1845 groupName: string; 1846 1847 /** Network ID */ 1848 networkId: number; 1849 1850 /** Frequency */ 1851 frequency: number; 1852 1853 /** Client list */ 1854 clientDevices: WifiP2pDevice[]; 1855 1856 /** Group owner IP address */ 1857 goIpAddress: string; 1858 } 1859 1860 /** 1861 * P2P connection status. 1862 * 1863 * @since 9 1864 * @syscap SystemCapability.Communication.WiFi.P2P 1865 */ 1866 enum P2pConnectState { 1867 DISCONNECTED = 0, 1868 CONNECTED = 1, 1869 } 1870 1871 /** 1872 * P2P linked information. 1873 * 1874 * @since 9 1875 * @syscap SystemCapability.Communication.WiFi.P2P 1876 */ 1877 interface WifiP2pLinkedInfo { 1878 /** Connection status */ 1879 connectState: P2pConnectState; 1880 1881 /** Indicates whether it is group owner */ 1882 isGroupOwner: boolean; 1883 1884 /** Group owner address */ 1885 groupOwnerAddr: string; 1886 } 1887 1888 /** 1889 * P2P device status. 1890 * 1891 * @since 9 1892 * @syscap SystemCapability.Communication.WiFi.P2P 1893 */ 1894 enum P2pDeviceStatus { 1895 CONNECTED = 0, 1896 INVITED = 1, 1897 FAILED = 2, 1898 AVAILABLE = 3, 1899 UNAVAILABLE = 4, 1900 } 1901 1902 /** 1903 * P2P group owner band. 1904 * 1905 * @since 9 1906 * @syscap SystemCapability.Communication.WiFi.P2P 1907 */ 1908 enum GroupOwnerBand { 1909 GO_BAND_AUTO = 0, 1910 GO_BAND_2GHZ = 1, 1911 GO_BAND_5GHZ = 2, 1912 } 1913} 1914 1915export default wifiManager; 1916