1/* 2 * Copyright (C) 2023-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 * @file 18 * @kit ConnectivityKit 19 */ 20 21import type { AsyncCallback, Callback } from './@ohos.base'; 22import type constant from './@ohos.bluetooth.constant'; 23 24/** 25 * Provides methods to operate or manage Bluetooth. 26 * 27 * @namespace connection 28 * @syscap SystemCapability.Communication.Bluetooth.Core 29 * @since 10 30 */ 31/** 32 * Provides methods to operate or manage Bluetooth. 33 * 34 * @namespace connection 35 * @syscap SystemCapability.Communication.Bluetooth.Core 36 * @atomicservice 37 * @since 12 38 */ 39/** 40 * Provides methods to operate or manage Bluetooth. 41 * 42 * @namespace connection 43 * @syscap SystemCapability.Communication.Bluetooth.Core 44 * @crossplatform 45 * @atomicservice 46 * @since 13 47 */ 48declare namespace connection { 49 /** 50 * Indicate the profile connection state. 51 * 52 * @typedef { constant.ProfileConnectionState } ProfileConnectionState 53 * @syscap SystemCapability.Communication.Bluetooth.Core 54 * @since 10 55 */ 56 /** 57 * Indicate the profile connection state. 58 * 59 * @typedef { constant.ProfileConnectionState } ProfileConnectionState 60 * @syscap SystemCapability.Communication.Bluetooth.Core 61 * @crossplatform 62 * @since 13 63 */ 64 type ProfileConnectionState = constant.ProfileConnectionState; 65 66 /** 67 * Indicate the profile id. 68 * 69 * @typedef { constant.ProfileId } ProfileId 70 * @syscap SystemCapability.Communication.Bluetooth.Core 71 * @since 10 72 */ 73 /** 74 * Indicate the profile id. 75 * 76 * @typedef { constant.ProfileId } ProfileId 77 * @syscap SystemCapability.Communication.Bluetooth.Core 78 * @crossplatform 79 * @since 13 80 */ 81 type ProfileId = constant.ProfileId; 82 83 /** 84 * Indicate the profile uuid. 85 * 86 * @typedef { constant.ProfileUuids } ProfileUuids 87 * @syscap SystemCapability.Communication.Bluetooth.Core 88 * @systemapi 89 * @since 10 90 */ 91 /** 92 * Indicate the profile uuid. 93 * 94 * @typedef { constant.ProfileUuids } ProfileUuids 95 * @syscap SystemCapability.Communication.Bluetooth.Core 96 * @since 12 97 */ 98 /** 99 * Indicate the profile uuid. 100 * 101 * @typedef { constant.ProfileUuids } ProfileUuids 102 * @syscap SystemCapability.Communication.Bluetooth.Core 103 * @crossplatform 104 * @since 13 105 */ 106 type ProfileUuids = constant.ProfileUuids; 107 108 /** 109 * Indicate the major class of a bluetooth device. 110 * 111 * @typedef { constant.MajorClass } MajorClass 112 * @syscap SystemCapability.Communication.Bluetooth.Core 113 * @since 10 114 */ 115 /** 116 * Indicate the major class of a bluetooth device. 117 * 118 * @typedef { constant.MajorClass } MajorClass 119 * @syscap SystemCapability.Communication.Bluetooth.Core 120 * @crossplatform 121 * @since 13 122 */ 123 type MajorClass = constant.MajorClass; 124 125 /** 126 * Indicate the major minor class of a bluetooth device. 127 * 128 * @typedef { constant.MajorMinorClass } MajorMinorClass 129 * @syscap SystemCapability.Communication.Bluetooth.Core 130 * @since 10 131 */ 132 /** 133 * Indicate the major minor class of a bluetooth device. 134 * 135 * @typedef { constant.MajorMinorClass } MajorMinorClass 136 * @syscap SystemCapability.Communication.Bluetooth.Core 137 * @crossplatform 138 * @since 13 139 */ 140 type MajorMinorClass = constant.MajorMinorClass; 141 142 /** 143 * Get the profile connection state of the current device. 144 * 145 * @permission ohos.permission.ACCESS_BLUETOOTH 146 * @param { ProfileId } [profileId] - Indicate the profile id. This is an optional parameter. 147 * With profileId, returns the current connection state of this profile, {@link ProfileConnectionState}. 148 * Without profileId, if any profile is connected, {@link ProfileConnectionState#STATE_CONNECTED} is returned. 149 * Otherwise, {@link ProfileConnectionState#STATE_DISCONNECTED} is returned. 150 * @returns { ProfileConnectionState } Returns the connection state. 151 * @throws { BusinessError } 201 - Permission denied. 152 * @throws { BusinessError } 401 - Invalid parameter. Possible causes: 1. Incorrect parameter types. 153 * @throws { BusinessError } 801 - Capability not supported. 154 * @throws { BusinessError } 2900001 - Service stopped. 155 * @throws { BusinessError } 2900003 - Bluetooth disabled. 156 * @throws { BusinessError } 2900004 - Profile not supported. 157 * @throws { BusinessError } 2900099 - Operation failed. 158 * @syscap SystemCapability.Communication.Bluetooth.Core 159 * @since 10 160 */ 161 /** 162 * Get the profile connection state of the current device. 163 * 164 * @permission ohos.permission.ACCESS_BLUETOOTH 165 * @param { ProfileId } [profileId] - Indicate the profile id. This is an optional parameter. 166 * With profileId, returns the current connection state of this profile, {@link ProfileConnectionState}. 167 * Without profileId, if any profile is connected, {@link ProfileConnectionState#STATE_CONNECTED} is returned. 168 * Otherwise, {@link ProfileConnectionState#STATE_DISCONNECTED} is returned. 169 * @returns { ProfileConnectionState } Returns the connection state. 170 * @throws { BusinessError } 201 - Permission denied. 171 * @throws { BusinessError } 401 - Invalid parameter. Possible causes: 1. Incorrect parameter types. 172 * @throws { BusinessError } 801 - Capability not supported. 173 * @throws { BusinessError } 2900001 - Service stopped. 174 * @throws { BusinessError } 2900003 - Bluetooth disabled. 175 * @throws { BusinessError } 2900004 - Profile not supported. 176 * @throws { BusinessError } 2900099 - Operation failed. 177 * @syscap SystemCapability.Communication.Bluetooth.Core 178 * @crossplatform 179 * @since 13 180 */ 181 function getProfileConnectionState(profileId?: ProfileId): ProfileConnectionState; 182 183 /** 184 * Starts pairing with a remote Bluetooth device. 185 * 186 * @permission ohos.permission.ACCESS_BLUETOOTH 187 * @param { string } deviceId - Indicates device ID. For example, "11:22:33:AA:BB:FF". 188 * @param { AsyncCallback<void> } callback - the callback of pairDevice. 189 * @throws { BusinessError } 201 - Permission denied. 190 * @throws { BusinessError } 401 - Invalid parameter. Possible causes: 1. Mandatory parameters are left unspecified. 191 * <br>2. Incorrect parameter types. 3. Parameter verification failed. 192 * @throws { BusinessError } 801 - Capability not supported. 193 * @throws { BusinessError } 2900001 - Service stopped. 194 * @throws { BusinessError } 2900003 - Bluetooth disabled. 195 * @throws { BusinessError } 2900099 - Operation failed. 196 * @syscap SystemCapability.Communication.Bluetooth.Core 197 * @since 10 198 */ 199 /** 200 * Starts pairing with a remote Bluetooth device. 201 * 202 * @permission ohos.permission.ACCESS_BLUETOOTH 203 * @param { string } deviceId - Indicates device ID. For example, "11:22:33:AA:BB:FF". 204 * @param { AsyncCallback<void> } callback - the callback of pairDevice. 205 * @throws { BusinessError } 201 - Permission denied. 206 * @throws { BusinessError } 401 - Invalid parameter. Possible causes: 1. Mandatory parameters are left unspecified. 207 * <br>2. Incorrect parameter types. 3. Parameter verification failed. 208 * @throws { BusinessError } 801 - Capability not supported. 209 * @throws { BusinessError } 2900001 - Service stopped. 210 * @throws { BusinessError } 2900003 - Bluetooth disabled. 211 * @throws { BusinessError } 2900099 - Operation failed. 212 * @syscap SystemCapability.Communication.Bluetooth.Core 213 * @atomicservice 214 * @since 12 215 */ 216 /** 217 * Starts pairing with a remote Bluetooth device. 218 * 219 * @permission ohos.permission.ACCESS_BLUETOOTH 220 * @param { string } deviceId - Indicates device ID. For example, "11:22:33:AA:BB:FF". 221 * @param { AsyncCallback<void> } callback - the callback of pairDevice. 222 * @throws { BusinessError } 201 - Permission denied. 223 * @throws { BusinessError } 401 - Invalid parameter. Possible causes: 1. Mandatory parameters are left unspecified. 224 * <br>2. Incorrect parameter types. 3. Parameter verification failed. 225 * @throws { BusinessError } 801 - Capability not supported. 226 * @throws { BusinessError } 2900001 - Service stopped. 227 * @throws { BusinessError } 2900003 - Bluetooth disabled. 228 * @throws { BusinessError } 2900099 - Operation failed. 229 * @syscap SystemCapability.Communication.Bluetooth.Core 230 * @crossplatform 231 * @atomicservice 232 * @since 13 233 */ 234 function pairDevice(deviceId: string, callback: AsyncCallback<void>): void; 235 236 /** 237 * Starts pairing with a remote Bluetooth device. 238 * 239 * @permission ohos.permission.ACCESS_BLUETOOTH 240 * @param { string } deviceId - Indicates device ID. For example, "11:22:33:AA:BB:FF". 241 * @returns { Promise<void> } Returns the promise object. 242 * @throws { BusinessError } 201 - Permission denied. 243 * @throws { BusinessError } 401 - Invalid parameter. Possible causes: 1. Mandatory parameters are left unspecified. 244 * <br>2. Incorrect parameter types. 3. Parameter verification failed. 245 * @throws { BusinessError } 801 - Capability not supported. 246 * @throws { BusinessError } 2900001 - Service stopped. 247 * @throws { BusinessError } 2900003 - Bluetooth disabled. 248 * @throws { BusinessError } 2900099 - Operation failed. 249 * @syscap SystemCapability.Communication.Bluetooth.Core 250 * @since 10 251 */ 252 /** 253 * Starts pairing with a remote Bluetooth device. 254 * 255 * @permission ohos.permission.ACCESS_BLUETOOTH 256 * @param { string } deviceId - Indicates device ID. For example, "11:22:33:AA:BB:FF". 257 * @returns { Promise<void> } Returns the promise object. 258 * @throws { BusinessError } 201 - Permission denied. 259 * @throws { BusinessError } 401 - Invalid parameter. Possible causes: 1. Mandatory parameters are left unspecified. 260 * <br>2. Incorrect parameter types. 3. Parameter verification failed. 261 * @throws { BusinessError } 801 - Capability not supported. 262 * @throws { BusinessError } 2900001 - Service stopped. 263 * @throws { BusinessError } 2900003 - Bluetooth disabled. 264 * @throws { BusinessError } 2900099 - Operation failed. 265 * @syscap SystemCapability.Communication.Bluetooth.Core 266 * @atomicservice 267 * @since 12 268 */ 269 /** 270 * Starts pairing with a remote Bluetooth device. 271 * 272 * @permission ohos.permission.ACCESS_BLUETOOTH 273 * @param { string } deviceId - Indicates device ID. For example, "11:22:33:AA:BB:FF". 274 * @returns { Promise<void> } Returns the promise object. 275 * @throws { BusinessError } 201 - Permission denied. 276 * @throws { BusinessError } 401 - Invalid parameter. Possible causes: 1. Mandatory parameters are left unspecified. 277 * <br>2. Incorrect parameter types. 3. Parameter verification failed. 278 * @throws { BusinessError } 801 - Capability not supported. 279 * @throws { BusinessError } 2900001 - Service stopped. 280 * @throws { BusinessError } 2900003 - Bluetooth disabled. 281 * @throws { BusinessError } 2900099 - Operation failed. 282 * @syscap SystemCapability.Communication.Bluetooth.Core 283 * @crossplatform 284 * @atomicservice 285 * @since 13 286 */ 287 function pairDevice(deviceId: string): Promise<void>; 288 289 /** 290 * Starts pairing with a credible remote Bluetooth device with transport. 291 * This interface does not trigger a dialog box and does not require user authorization. 292 * Only specific system application can use this function. 293 * 294 * @permission ohos.permission.ACCESS_BLUETOOTH and ohos.permission.MANAGE_BLUETOOTH 295 * @param { string } deviceId - Indicates device ID. For example, "11:22:33:AA:BB:FF". 296 * @param { BluetoothTransport } transport - the transport of the remote device to pair. 297 * @param { AsyncCallback<void> } callback - the callback of pairCredibleDevice. 298 * @throws { BusinessError } 201 - Permission denied. 299 * @throws { BusinessError } 202 - Non-system applications are not allowed to use system APIs. 300 * @throws { BusinessError } 401 - Invalid parameter. Possible causes: 1. Mandatory parameters are left unspecified. 301 * <br>2. Incorrect parameter types. 3. Parameter verification failed. 302 * @throws { BusinessError } 801 - Capability not supported. 303 * @throws { BusinessError } 2900001 - Service stopped. 304 * @throws { BusinessError } 2900003 - Bluetooth disabled. 305 * @throws { BusinessError } 2900099 - Operation failed. 306 * @syscap SystemCapability.Communication.Bluetooth.Core 307 * @systemapi 308 * @since 10 309 */ 310 function pairCredibleDevice(deviceId: string, transport: BluetoothTransport, callback: AsyncCallback<void>): void; 311 312 /** 313 * Starts pairing with a credible remote Bluetooth device with transport. 314 * This interface does not trigger a dialog box and does not require user authorization. 315 * Only specific system application can use this function. 316 * 317 * @permission ohos.permission.ACCESS_BLUETOOTH and ohos.permission.MANAGE_BLUETOOTH 318 * @param { string } deviceId - Indicates device ID. For example, "11:22:33:AA:BB:FF". 319 * @param { BluetoothTransport } transport - the transport of the remote device to pair. 320 * @returns { Promise<void> } Returns the promise object. 321 * @throws { BusinessError } 201 - Permission denied. 322 * @throws { BusinessError } 202 - Non-system applications are not allowed to use system APIs. 323 * @throws { BusinessError } 401 - Invalid parameter. Possible causes: 1. Mandatory parameters are left unspecified. 324 * <br>2. Incorrect parameter types. 3. Parameter verification failed. 325 * @throws { BusinessError } 801 - Capability not supported. 326 * @throws { BusinessError } 2900001 - Service stopped. 327 * @throws { BusinessError } 2900003 - Bluetooth disabled. 328 * @throws { BusinessError } 2900099 - Operation failed. 329 * @syscap SystemCapability.Communication.Bluetooth.Core 330 * @systemapi 331 * @since 10 332 */ 333 function pairCredibleDevice(deviceId: string, transport: BluetoothTransport): Promise<void>; 334 335 /** 336 * Remove a paired remote device. 337 * 338 * @permission ohos.permission.ACCESS_BLUETOOTH 339 * @param { string } deviceId - Indicates device ID. For example, "11:22:33:AA:BB:FF". 340 * @param { AsyncCallback<void> } callback - the callback of cancelPairedDevice. 341 * @throws { BusinessError } 201 - Permission denied. 342 * @throws { BusinessError } 202 - Non-system applications are not allowed to use system APIs. 343 * @throws { BusinessError } 401 - Invalid parameter. Possible causes: 1. Mandatory parameters are left unspecified. 344 * <br>2. Incorrect parameter types. 3. Parameter verification failed. 345 * @throws { BusinessError } 801 - Capability not supported. 346 * @throws { BusinessError } 2900001 - Service stopped. 347 * @throws { BusinessError } 2900003 - Bluetooth disabled. 348 * @throws { BusinessError } 2900099 - Operation failed. 349 * @syscap SystemCapability.Communication.Bluetooth.Core 350 * @systemapi 351 * @since 10 352 */ 353 function cancelPairedDevice(deviceId: string, callback: AsyncCallback<void>): void; 354 355 /** 356 * Remove a paired remote device. 357 * 358 * @permission ohos.permission.ACCESS_BLUETOOTH 359 * @param { string } deviceId - Indicates device ID. For example, "11:22:33:AA:BB:FF". 360 * @returns { Promise<void> } Returns the promise object. 361 * @throws { BusinessError } 201 - Permission denied. 362 * @throws { BusinessError } 202 - Non-system applications are not allowed to use system APIs. 363 * @throws { BusinessError } 401 - Invalid parameter. Possible causes: 1. Mandatory parameters are left unspecified. 364 * <br>2. Incorrect parameter types. 3. Parameter verification failed. 365 * @throws { BusinessError } 801 - Capability not supported. 366 * @throws { BusinessError } 2900001 - Service stopped. 367 * @throws { BusinessError } 2900003 - Bluetooth disabled. 368 * @throws { BusinessError } 2900099 - Operation failed. 369 * @syscap SystemCapability.Communication.Bluetooth.Core 370 * @systemapi 371 * @since 10 372 */ 373 function cancelPairedDevice(deviceId: string): Promise<void>; 374 375 /** 376 * Remove a pairing remote device. 377 * 378 * @permission ohos.permission.ACCESS_BLUETOOTH 379 * @param { string } deviceId - Indicates device ID. For example, "11:22:33:AA:BB:FF". 380 * @param { AsyncCallback<void> } callback - the callback of cancelPairingDevice. 381 * @throws { BusinessError } 201 - Permission denied. 382 * @throws { BusinessError } 202 - Non-system applications are not allowed to use system APIs. 383 * @throws { BusinessError } 401 - Invalid parameter. Possible causes: 1. Mandatory parameters are left unspecified. 384 * <br>2. Incorrect parameter types. 3. Parameter verification failed. 385 * @throws { BusinessError } 801 - Capability not supported. 386 * @throws { BusinessError } 2900001 - Service stopped. 387 * @throws { BusinessError } 2900003 - Bluetooth disabled. 388 * @throws { BusinessError } 2900099 - Operation failed. 389 * @syscap SystemCapability.Communication.Bluetooth.Core 390 * @systemapi 391 * @since 10 392 */ 393 function cancelPairingDevice(deviceId: string, callback: AsyncCallback<void>): void; 394 395 /** 396 * Remove a pairing remote device. 397 * 398 * @permission ohos.permission.ACCESS_BLUETOOTH 399 * @param { string } deviceId - Indicates device ID. For example, "11:22:33:AA:BB:FF". 400 * @returns { Promise<void> } Returns the promise object. 401 * @throws { BusinessError } 201 - Permission denied. 402 * @throws { BusinessError } 202 - Non-system applications are not allowed to use system APIs. 403 * @throws { BusinessError } 401 - Invalid parameter. Possible causes: 1. Mandatory parameters are left unspecified. 404 * <br>2. Incorrect parameter types. 3. Parameter verification failed. 405 * @throws { BusinessError } 801 - Capability not supported. 406 * @throws { BusinessError } 2900001 - Service stopped. 407 * @throws { BusinessError } 2900003 - Bluetooth disabled. 408 * @throws { BusinessError } 2900099 - Operation failed. 409 * @syscap SystemCapability.Communication.Bluetooth.Core 410 * @systemapi 411 * @since 10 412 */ 413 function cancelPairingDevice(deviceId: string): Promise<void>; 414 415 /** 416 * Obtains the name of a peer Bluetooth device. 417 * 418 * @permission ohos.permission.ACCESS_BLUETOOTH 419 * @param { string } deviceId - Indicates device ID. For example, "11:22:33:AA:BB:FF". 420 * @returns { string } Returns the device name in character string format. 421 * @throws { BusinessError } 201 - Permission denied. 422 * @throws { BusinessError } 401 - Invalid parameter. Possible causes: 1. Mandatory parameters are left unspecified. 423 * <br>2. Incorrect parameter types. 3. Parameter verification failed. 424 * @throws { BusinessError } 801 - Capability not supported. 425 * @throws { BusinessError } 2900001 - Service stopped. 426 * @throws { BusinessError } 2900003 - Bluetooth disabled. 427 * @throws { BusinessError } 2900099 - Operation failed. 428 * @syscap SystemCapability.Communication.Bluetooth.Core 429 * @since 10 430 */ 431 /** 432 * Obtains the name of a peer Bluetooth device. 433 * 434 * @permission ohos.permission.ACCESS_BLUETOOTH 435 * @param { string } deviceId - Indicates device ID. For example, "11:22:33:AA:BB:FF". 436 * @returns { string } Returns the device name in character string format. 437 * @throws { BusinessError } 201 - Permission denied. 438 * @throws { BusinessError } 401 - Invalid parameter. Possible causes: 1. Mandatory parameters are left unspecified. 439 * <br>2. Incorrect parameter types. 3. Parameter verification failed. 440 * @throws { BusinessError } 801 - Capability not supported. 441 * @throws { BusinessError } 2900001 - Service stopped. 442 * @throws { BusinessError } 2900003 - Bluetooth disabled. 443 * @throws { BusinessError } 2900099 - Operation failed. 444 * @syscap SystemCapability.Communication.Bluetooth.Core 445 * @atomicservice 446 * @since 12 447 */ 448 /** 449 * Obtains the name of a peer Bluetooth device. 450 * 451 * @permission ohos.permission.ACCESS_BLUETOOTH 452 * @param { string } deviceId - Indicates device ID. For example, "11:22:33:AA:BB:FF". 453 * @returns { string } Returns the device name in character string format. 454 * @throws { BusinessError } 201 - Permission denied. 455 * @throws { BusinessError } 401 - Invalid parameter. Possible causes: 1. Mandatory parameters are left unspecified. 456 * <br>2. Incorrect parameter types. 3. Parameter verification failed. 457 * @throws { BusinessError } 801 - Capability not supported. 458 * @throws { BusinessError } 2900001 - Service stopped. 459 * @throws { BusinessError } 2900003 - Bluetooth disabled. 460 * @throws { BusinessError } 2900099 - Operation failed. 461 * @syscap SystemCapability.Communication.Bluetooth.Core 462 * @crossplatform 463 * @atomicservice 464 * @since 13 465 */ 466 function getRemoteDeviceName(deviceId: string): string; 467 468 /** 469 * Obtains the class of a peer Bluetooth device. 470 * 471 * @permission ohos.permission.ACCESS_BLUETOOTH 472 * @param { string } deviceId - Indicates device ID. For example, "11:22:33:AA:BB:FF". 473 * @returns { DeviceClass } The class of the remote device. 474 * @throws { BusinessError } 201 - Permission denied. 475 * @throws { BusinessError } 401 - Invalid parameter. Possible causes: 1. Mandatory parameters are left unspecified. 476 * <br>2. Incorrect parameter types. 3. Parameter verification failed. 477 * @throws { BusinessError } 801 - Capability not supported. 478 * @throws { BusinessError } 2900001 - Service stopped. 479 * @throws { BusinessError } 2900003 - Bluetooth disabled. 480 * @throws { BusinessError } 2900099 - Operation failed. 481 * @syscap SystemCapability.Communication.Bluetooth.Core 482 * @since 10 483 */ 484 /** 485 * Obtains the class of a peer Bluetooth device. 486 * 487 * @permission ohos.permission.ACCESS_BLUETOOTH 488 * @param { string } deviceId - Indicates device ID. For example, "11:22:33:AA:BB:FF". 489 * @returns { DeviceClass } The class of the remote device. 490 * @throws { BusinessError } 201 - Permission denied. 491 * @throws { BusinessError } 401 - Invalid parameter. Possible causes: 1. Mandatory parameters are left unspecified. 492 * <br>2. Incorrect parameter types. 3. Parameter verification failed. 493 * @throws { BusinessError } 801 - Capability not supported. 494 * @throws { BusinessError } 2900001 - Service stopped. 495 * @throws { BusinessError } 2900003 - Bluetooth disabled. 496 * @throws { BusinessError } 2900099 - Operation failed. 497 * @syscap SystemCapability.Communication.Bluetooth.Core 498 * @crossplatform 499 * @since 13 500 */ 501 function getRemoteDeviceClass(deviceId: string): DeviceClass; 502 503 /** 504 * Obtains the Bluetooth local name of a device. 505 * 506 * @permission ohos.permission.ACCESS_BLUETOOTH 507 * @returns { string } Returns the name the device. 508 * @throws { BusinessError } 201 - Permission denied. 509 * @throws { BusinessError } 801 - Capability not supported. 510 * @throws { BusinessError } 2900001 - Service stopped. 511 * @throws { BusinessError } 2900099 - Operation failed. 512 * @syscap SystemCapability.Communication.Bluetooth.Core 513 * @since 10 514 */ 515 /** 516 * Obtains the Bluetooth local name of a device. 517 * 518 * @permission ohos.permission.ACCESS_BLUETOOTH 519 * @returns { string } Returns the name the device. 520 * @throws { BusinessError } 201 - Permission denied. 521 * @throws { BusinessError } 801 - Capability not supported. 522 * @throws { BusinessError } 2900001 - Service stopped. 523 * @throws { BusinessError } 2900099 - Operation failed. 524 * @syscap SystemCapability.Communication.Bluetooth.Core 525 * @crossplatform 526 * @since 13 527 */ 528 function getLocalName(): string; 529 530 /** 531 * Obtains the list of Bluetooth devices that have been paired with the current device. 532 * 533 * @permission ohos.permission.ACCESS_BLUETOOTH 534 * @returns { Array<string> } Returns a list of paired Bluetooth devices's address. 535 * @throws { BusinessError } 201 - Permission denied. 536 * @throws { BusinessError } 801 - Capability not supported. 537 * @throws { BusinessError } 2900001 - Service stopped. 538 * @throws { BusinessError } 2900003 - Bluetooth disabled. 539 * @throws { BusinessError } 2900099 - Operation failed. 540 * @syscap SystemCapability.Communication.Bluetooth.Core 541 * @since 10 542 */ 543 /** 544 * Obtains the list of Bluetooth devices that have been paired with the current device. 545 * 546 * @permission ohos.permission.ACCESS_BLUETOOTH 547 * @returns { Array<string> } Returns a list of paired Bluetooth devices's address. 548 * @throws { BusinessError } 201 - Permission denied. 549 * @throws { BusinessError } 801 - Capability not supported. 550 * @throws { BusinessError } 2900001 - Service stopped. 551 * @throws { BusinessError } 2900003 - Bluetooth disabled. 552 * @throws { BusinessError } 2900099 - Operation failed. 553 * @syscap SystemCapability.Communication.Bluetooth.Core 554 * @atomicservice 555 * @since 12 556 */ 557 /** 558 * Obtains the list of Bluetooth devices that have been paired with the current device. 559 * 560 * @permission ohos.permission.ACCESS_BLUETOOTH 561 * @returns { Array<string> } Returns a list of paired Bluetooth devices's address. 562 * @throws { BusinessError } 201 - Permission denied. 563 * @throws { BusinessError } 801 - Capability not supported. 564 * @throws { BusinessError } 2900001 - Service stopped. 565 * @throws { BusinessError } 2900003 - Bluetooth disabled. 566 * @throws { BusinessError } 2900099 - Operation failed. 567 * @syscap SystemCapability.Communication.Bluetooth.Core 568 * @crossplatform 569 * @atomicservice 570 * @since 13 571 */ 572 function getPairedDevices(): Array<string>; 573 574 /** 575 * Obtains the pair state of a specified device. 576 * 577 * @permission ohos.permission.ACCESS_BLUETOOTH 578 * @param { string } deviceId - Indicates device ID. For example, "11:22:33:AA:BB:FF". 579 * @returns { BondState } Returns the pair state. 580 * @throws { BusinessError } 201 - Permission denied. 581 * @throws { BusinessError } 401 - Invalid parameter. Possible causes: 1. Mandatory parameters are left unspecified. 582 * <br>2. Incorrect parameter types. 3. Parameter verification failed. 583 * @throws { BusinessError } 801 - Capability not supported. 584 * @throws { BusinessError } 2900001 - Service stopped. 585 * @throws { BusinessError } 2900003 - Bluetooth disabled. 586 * @throws { BusinessError } 2900099 - Operation failed. 587 * @syscap SystemCapability.Communication.Bluetooth.Core 588 * @since 11 589 */ 590 /** 591 * Obtains the pair state of a specified device. 592 * 593 * @permission ohos.permission.ACCESS_BLUETOOTH 594 * @param { string } deviceId - Indicates device ID. For example, "11:22:33:AA:BB:FF". 595 * @returns { BondState } Returns the pair state. 596 * @throws { BusinessError } 201 - Permission denied. 597 * @throws { BusinessError } 401 - Invalid parameter. Possible causes: 1. Mandatory parameters are left unspecified. 598 * <br>2. Incorrect parameter types. 3. Parameter verification failed. 599 * @throws { BusinessError } 801 - Capability not supported. 600 * @throws { BusinessError } 2900001 - Service stopped. 601 * @throws { BusinessError } 2900003 - Bluetooth disabled. 602 * @throws { BusinessError } 2900099 - Operation failed. 603 * @syscap SystemCapability.Communication.Bluetooth.Core 604 * @atomicservice 605 * @since 12 606 */ 607 /** 608 * Obtains the pair state of a specified device. 609 * 610 * @permission ohos.permission.ACCESS_BLUETOOTH 611 * @param { string } deviceId - Indicates device ID. For example, "11:22:33:AA:BB:FF". 612 * @returns { BondState } Returns the pair state. 613 * @throws { BusinessError } 201 - Permission denied. 614 * @throws { BusinessError } 401 - Invalid parameter. Possible causes: 1. Mandatory parameters are left unspecified. 615 * <br>2. Incorrect parameter types. 3. Parameter verification failed. 616 * @throws { BusinessError } 801 - Capability not supported. 617 * @throws { BusinessError } 2900001 - Service stopped. 618 * @throws { BusinessError } 2900003 - Bluetooth disabled. 619 * @throws { BusinessError } 2900099 - Operation failed. 620 * @syscap SystemCapability.Communication.Bluetooth.Core 621 * @crossplatform 622 * @atomicservice 623 * @since 13 624 */ 625 function getPairState(deviceId: string): BondState; 626 627 /** 628 * Sets the confirmation of pairing with a certain device. 629 * 630 * @permission ohos.permission.ACCESS_BLUETOOTH and ohos.permission.MANAGE_BLUETOOTH 631 * @param { string } deviceId - Indicates device ID. For example, "11:22:33:AA:BB:FF". 632 * @param { boolean } accept - Indicates whether to accept the pairing request, {@code true} indicates accept or {@code false} otherwise. 633 * @throws { BusinessError } 201 - Permission denied. 634 * @throws { BusinessError } 401 - Invalid parameter. Possible causes: 1. Mandatory parameters are left unspecified. 635 * <br>2. Incorrect parameter types. 3. Parameter verification failed. 636 * @throws { BusinessError } 801 - Capability not supported. 637 * @throws { BusinessError } 2900001 - Service stopped. 638 * @throws { BusinessError } 2900003 - Bluetooth disabled. 639 * @throws { BusinessError } 2900099 - Operation failed. 640 * @syscap SystemCapability.Communication.Bluetooth.Core 641 * @since 10 642 */ 643 function setDevicePairingConfirmation(deviceId: string, accept: boolean): void; 644 645 /** 646 * Set the pin during pairing when the pin type is PIN_TYPE_ENTER_PIN_CODE. 647 * 648 * @permission ohos.permission.ACCESS_BLUETOOTH 649 * @param { string } deviceId - Indicates device ID. For example, "11:22:33:AA:BB:FF". 650 * @param { string } code - The pin code entered by the user. 651 * @param { AsyncCallback<void> } callback - the callback of setDevicePinCode. 652 * @throws { BusinessError } 201 - Permission denied. 653 * @throws { BusinessError } 401 - Invalid parameter. Possible causes: 1. Mandatory parameters are left unspecified. 654 * <br>2. Incorrect parameter types. 3. Parameter verification failed. 655 * @throws { BusinessError } 801 - Capability not supported. 656 * @throws { BusinessError } 2900001 - Service stopped. 657 * @throws { BusinessError } 2900003 - Bluetooth disabled. 658 * @throws { BusinessError } 2900099 - Operation failed. 659 * @syscap SystemCapability.Communication.Bluetooth.Core 660 * @since 10 661 */ 662 function setDevicePinCode(deviceId: string, code: string, callback: AsyncCallback<void>): void; 663 664 /** 665 * Set the pin during pairing when the pin type is PIN_TYPE_ENTER_PIN_CODE. 666 * 667 * @permission ohos.permission.ACCESS_BLUETOOTH 668 * @param { string } deviceId - Indicates device ID. For example, "11:22:33:AA:BB:FF". 669 * @param { string } code - The pin code entered by the user. 670 * @returns { Promise<void> } Returns the promise object. 671 * @throws { BusinessError } 201 - Permission denied. 672 * @throws { BusinessError } 401 - Invalid parameter. Possible causes: 1. Mandatory parameters are left unspecified. 673 * <br>2. Incorrect parameter types. 3. Parameter verification failed. 674 * @throws { BusinessError } 801 - Capability not supported. 675 * @throws { BusinessError } 2900001 - Service stopped. 676 * @throws { BusinessError } 2900003 - Bluetooth disabled. 677 * @throws { BusinessError } 2900099 - Operation failed. 678 * @syscap SystemCapability.Communication.Bluetooth.Core 679 * @since 10 680 */ 681 function setDevicePinCode(deviceId: string, code: string): Promise<void>; 682 683 /** 684 * Sets the Bluetooth friendly name of a device. It is used only by system applications for security. 685 * If a non-system application invokes the interface, exception 801 is thrown. 686 * 687 * @permission ohos.permission.ACCESS_BLUETOOTH 688 * @param { string } name - Indicates a valid Bluetooth name. 689 * @throws { BusinessError } 201 - Permission denied. 690 * @throws { BusinessError } 401 - Invalid parameter. Possible causes: 1. Mandatory parameters are left unspecified. 691 * <br>2. Incorrect parameter types. 3. Parameter verification failed. 692 * @throws { BusinessError } 801 - Capability not supported. 693 * @throws { BusinessError } 2900001 - Service stopped. 694 * @throws { BusinessError } 2900003 - Bluetooth disabled. 695 * @throws { BusinessError } 2900099 - Operation failed. 696 * @syscap SystemCapability.Communication.Bluetooth.Core 697 * @since 10 698 * @deprecated since 12 699 */ 700 function setLocalName(name: string): void; 701 702 /** 703 * Sets the Bluetooth scan mode for a device. 704 * 705 * @permission ohos.permission.ACCESS_BLUETOOTH 706 * @param { ScanMode } mode - Indicates the Bluetooth scan mode to set. 707 * @param { number } duration - Indicates the duration in seconds, in which the host is discoverable. 708 * @throws { BusinessError } 201 - Permission denied. 709 * @throws { BusinessError } 401 - Invalid parameter. Possible causes: 1. Mandatory parameters are left unspecified. 710 * <br>2. Incorrect parameter types. 3. Parameter verification failed. 711 * @throws { BusinessError } 801 - Capability not supported. 712 * @throws { BusinessError } 2900001 - Service stopped. 713 * @throws { BusinessError } 2900003 - Bluetooth disabled. 714 * @throws { BusinessError } 2900099 - Operation failed. 715 * @syscap SystemCapability.Communication.Bluetooth.Core 716 * @since 10 717 */ 718 function setBluetoothScanMode(mode: ScanMode, duration: number): void; 719 720 /** 721 * Obtains the Bluetooth scanning mode of a device. 722 * 723 * @permission ohos.permission.ACCESS_BLUETOOTH 724 * @returns { ScanMode } Returns the Bluetooth scanning mode. 725 * @throws { BusinessError } 201 - Permission denied. 726 * @throws { BusinessError } 801 - Capability not supported. 727 * @throws { BusinessError } 2900001 - Service stopped. 728 * @throws { BusinessError } 2900003 - Bluetooth disabled. 729 * @throws { BusinessError } 2900099 - Operation failed. 730 * @syscap SystemCapability.Communication.Bluetooth.Core 731 * @since 10 732 */ 733 /** 734 * Obtains the Bluetooth scanning mode of a device. 735 * 736 * @permission ohos.permission.ACCESS_BLUETOOTH 737 * @returns { ScanMode } Returns the Bluetooth scanning mode. 738 * @throws { BusinessError } 201 - Permission denied. 739 * @throws { BusinessError } 801 - Capability not supported. 740 * @throws { BusinessError } 2900001 - Service stopped. 741 * @throws { BusinessError } 2900003 - Bluetooth disabled. 742 * @throws { BusinessError } 2900099 - Operation failed. 743 * @syscap SystemCapability.Communication.Bluetooth.Core 744 * @crossplatform 745 * @since 13 746 */ 747 function getBluetoothScanMode(): ScanMode; 748 749 /** 750 * Starts scanning Bluetooth devices. 751 * 752 * @permission ohos.permission.ACCESS_BLUETOOTH 753 * @throws { BusinessError } 201 - Permission denied. 754 * @throws { BusinessError } 801 - Capability not supported. 755 * @throws { BusinessError } 2900001 - Service stopped. 756 * @throws { BusinessError } 2900003 - Bluetooth disabled. 757 * @throws { BusinessError } 2900099 - Operation failed. 758 * @syscap SystemCapability.Communication.Bluetooth.Core 759 * @since 10 760 */ 761 /** 762 * Starts scanning Bluetooth devices. 763 * 764 * @permission ohos.permission.ACCESS_BLUETOOTH 765 * @throws { BusinessError } 201 - Permission denied. 766 * @throws { BusinessError } 801 - Capability not supported. 767 * @throws { BusinessError } 2900001 - Service stopped. 768 * @throws { BusinessError } 2900003 - Bluetooth disabled. 769 * @throws { BusinessError } 2900099 - Operation failed. 770 * @syscap SystemCapability.Communication.Bluetooth.Core 771 * @atomicservice 772 * @since 12 773 */ 774 /** 775 * Starts scanning Bluetooth devices. 776 * 777 * @permission ohos.permission.ACCESS_BLUETOOTH 778 * @throws { BusinessError } 201 - Permission denied. 779 * @throws { BusinessError } 801 - Capability not supported. 780 * @throws { BusinessError } 2900001 - Service stopped. 781 * @throws { BusinessError } 2900003 - Bluetooth disabled. 782 * @throws { BusinessError } 2900099 - Operation failed. 783 * @syscap SystemCapability.Communication.Bluetooth.Core 784 * @crossplatform 785 * @atomicservice 786 * @since 13 787 */ 788 function startBluetoothDiscovery(): void; 789 790 /** 791 * Stops Bluetooth device scanning. 792 * 793 * @permission ohos.permission.ACCESS_BLUETOOTH 794 * @throws { BusinessError } 201 - Permission denied. 795 * @throws { BusinessError } 801 - Capability not supported. 796 * @throws { BusinessError } 2900001 - Service stopped. 797 * @throws { BusinessError } 2900003 - Bluetooth disabled. 798 * @throws { BusinessError } 2900099 - Operation failed. 799 * @syscap SystemCapability.Communication.Bluetooth.Core 800 * @since 10 801 */ 802 /** 803 * Stops Bluetooth device scanning. 804 * 805 * @permission ohos.permission.ACCESS_BLUETOOTH 806 * @throws { BusinessError } 201 - Permission denied. 807 * @throws { BusinessError } 801 - Capability not supported. 808 * @throws { BusinessError } 2900001 - Service stopped. 809 * @throws { BusinessError } 2900003 - Bluetooth disabled. 810 * @throws { BusinessError } 2900099 - Operation failed. 811 * @syscap SystemCapability.Communication.Bluetooth.Core 812 * @atomicservice 813 * @since 12 814 */ 815 /** 816 * Stops Bluetooth device scanning. 817 * 818 * @permission ohos.permission.ACCESS_BLUETOOTH 819 * @throws { BusinessError } 201 - Permission denied. 820 * @throws { BusinessError } 801 - Capability not supported. 821 * @throws { BusinessError } 2900001 - Service stopped. 822 * @throws { BusinessError } 2900003 - Bluetooth disabled. 823 * @throws { BusinessError } 2900099 - Operation failed. 824 * @syscap SystemCapability.Communication.Bluetooth.Core 825 * @crossplatform 826 * @atomicservice 827 * @since 13 828 */ 829 function stopBluetoothDiscovery(): void; 830 831 /** 832 * Check if bluetooth is discovering. 833 * 834 * @permission ohos.permission.ACCESS_BLUETOOTH 835 * @returns { boolean } Returns {@code true} if the local device is discovering; returns {@code false} otherwise. 836 * @throws { BusinessError } 201 - Permission denied. 837 * @throws { BusinessError } 801 - Capability not supported. 838 * @throws { BusinessError } 2900001 - Service stopped. 839 * @throws { BusinessError } 2900003 - Bluetooth disabled. 840 * @throws { BusinessError } 2900099 - Operation failed. 841 * @syscap SystemCapability.Communication.Bluetooth.Core 842 * @since 11 843 */ 844 /** 845 * Check if bluetooth is discovering. 846 * 847 * @permission ohos.permission.ACCESS_BLUETOOTH 848 * @returns { boolean } Returns {@code true} if the local device is discovering; returns {@code false} otherwise. 849 * @throws { BusinessError } 201 - Permission denied. 850 * @throws { BusinessError } 801 - Capability not supported. 851 * @throws { BusinessError } 2900001 - Service stopped. 852 * @throws { BusinessError } 2900003 - Bluetooth disabled. 853 * @throws { BusinessError } 2900099 - Operation failed. 854 * @syscap SystemCapability.Communication.Bluetooth.Core 855 * @crossplatform 856 * @since 13 857 */ 858 function isBluetoothDiscovering(): boolean; 859 860 /** 861 * Obtains the profile UUIDs supported by the local device. 862 * 863 * @permission ohos.permission.ACCESS_BLUETOOTH 864 * @param { AsyncCallback<Array<ProfileUuids>> } callback - the callback of getLocalProfileUuids. 865 * @throws { BusinessError } 201 - Permission denied. 866 * @throws { BusinessError } 202 - Non-system applications are not allowed to use system APIs. 867 * @throws { BusinessError } 401 - Invalid parameter. Possible causes: 1. Mandatory parameters are left unspecified. 868 * <br>2. Incorrect parameter types. 869 * @throws { BusinessError } 801 - Capability not supported. 870 * @throws { BusinessError } 2900001 - Service stopped. 871 * @throws { BusinessError } 2900003 - Bluetooth disabled. 872 * @throws { BusinessError } 2900099 - Operation failed. 873 * @syscap SystemCapability.Communication.Bluetooth.Core 874 * @systemapi 875 * @since 10 876 */ 877 function getLocalProfileUuids(callback: AsyncCallback<Array<ProfileUuids>>): void; 878 879 /** 880 * Obtains the profile UUIDs supported by the local device. 881 * 882 * @permission ohos.permission.ACCESS_BLUETOOTH 883 * @returns { Promise<Array<ProfileUuids>> } Returns the promise object. 884 * @throws { BusinessError } 201 - Permission denied. 885 * @throws { BusinessError } 202 - Non-system applications are not allowed to use system APIs. 886 * @throws { BusinessError } 401 - Invalid parameter. Possible causes: 1. Mandatory parameters are left unspecified. 887 * <br>2. Incorrect parameter types. 3. Parameter verification failed. 888 * @throws { BusinessError } 801 - Capability not supported. 889 * @throws { BusinessError } 2900001 - Service stopped. 890 * @throws { BusinessError } 2900003 - Bluetooth disabled. 891 * @throws { BusinessError } 2900099 - Operation failed. 892 * @syscap SystemCapability.Communication.Bluetooth.Core 893 * @systemapi 894 * @since 10 895 */ 896 function getLocalProfileUuids(): Promise<Array<ProfileUuids>>; 897 898 /** 899 * Obtains the profile UUIDs supported by the remote device. 900 * 901 * @permission ohos.permission.ACCESS_BLUETOOTH 902 * @param { string } deviceId - Indicates device ID. For example, "11:22:33:AA:BB:FF". 903 * @param { AsyncCallback<Array<ProfileUuids>> } callback - the callback of getRemoteProfileUuids. 904 * @throws { BusinessError } 201 - Permission denied. 905 * @throws { BusinessError } 202 - Non-system applications are not allowed to use system APIs. 906 * @throws { BusinessError } 401 - Invalid parameter. Possible causes: 1. Mandatory parameters are left unspecified. 907 * <br>2. Incorrect parameter types. 3. Parameter verification failed. 908 * @throws { BusinessError } 801 - Capability not supported. 909 * @throws { BusinessError } 2900001 - Service stopped. 910 * @throws { BusinessError } 2900003 - Bluetooth disabled. 911 * @throws { BusinessError } 2900099 - Operation failed. 912 * @syscap SystemCapability.Communication.Bluetooth.Core 913 * @systemapi 914 * @since 10 915 */ 916 /** 917 * Obtains the profile UUIDs supported by the remote device. 918 * 919 * @permission ohos.permission.ACCESS_BLUETOOTH 920 * @param { string } deviceId - Indicates device ID. For example, "11:22:33:AA:BB:FF". 921 * @param { AsyncCallback<Array<ProfileUuids>> } callback - the callback of getRemoteProfileUuids. 922 * @throws { BusinessError } 201 - Permission denied. 923 * @throws { BusinessError } 401 - Invalid parameter. 924 * @throws { BusinessError } 801 - Capability not supported. 925 * @throws { BusinessError } 2900001 - Service stopped. 926 * @throws { BusinessError } 2900003 - Bluetooth disabled. 927 * @throws { BusinessError } 2900099 - Operation failed. 928 * @syscap SystemCapability.Communication.Bluetooth.Core 929 * @since 12 930 */ 931 /** 932 * Obtains the profile UUIDs supported by the remote device. 933 * 934 * @permission ohos.permission.ACCESS_BLUETOOTH 935 * @param { string } deviceId - Indicates device ID. For example, "11:22:33:AA:BB:FF". 936 * @param { AsyncCallback<Array<ProfileUuids>> } callback - the callback of getRemoteProfileUuids. 937 * @throws { BusinessError } 201 - Permission denied. 938 * @throws { BusinessError } 401 - Invalid parameter. 939 * @throws { BusinessError } 801 - Capability not supported. 940 * @throws { BusinessError } 2900001 - Service stopped. 941 * @throws { BusinessError } 2900003 - Bluetooth disabled. 942 * @throws { BusinessError } 2900099 - Operation failed. 943 * @syscap SystemCapability.Communication.Bluetooth.Core 944 * @crossplatform 945 * @since 13 946 */ 947 function getRemoteProfileUuids(deviceId: string, callback: AsyncCallback<Array<ProfileUuids>>): void; 948 949 /** 950 * Obtains the profile UUIDs supported by the remote device. 951 * 952 * @permission ohos.permission.ACCESS_BLUETOOTH 953 * @param { string } deviceId - Indicates device ID. For example, "11:22:33:AA:BB:FF". 954 * @returns { Promise<Array<ProfileUuids>> } Returns the promise object. 955 * @throws { BusinessError } 201 - Permission denied. 956 * @throws { BusinessError } 202 - Non-system applications are not allowed to use system APIs. 957 * @throws { BusinessError } 401 - Invalid parameter. Possible causes: 1. Mandatory parameters are left unspecified. 958 * <br>2. Incorrect parameter types. 3. Parameter verification failed. 959 * @throws { BusinessError } 801 - Capability not supported. 960 * @throws { BusinessError } 2900001 - Service stopped. 961 * @throws { BusinessError } 2900003 - Bluetooth disabled. 962 * @throws { BusinessError } 2900099 - Operation failed. 963 * @syscap SystemCapability.Communication.Bluetooth.Core 964 * @systemapi 965 * @since 10 966 */ 967 /** 968 * Obtains the profile UUIDs supported by the remote device. 969 * 970 * @permission ohos.permission.ACCESS_BLUETOOTH 971 * @param { string } deviceId - Indicates device ID. For example, "11:22:33:AA:BB:FF". 972 * @returns { Promise<Array<ProfileUuids>> } Returns the promise object. 973 * @throws { BusinessError } 201 - Permission denied. 974 * @throws { BusinessError } 401 - Invalid parameter. 975 * @throws { BusinessError } 801 - Capability not supported. 976 * @throws { BusinessError } 2900001 - Service stopped. 977 * @throws { BusinessError } 2900003 - Bluetooth disabled. 978 * @throws { BusinessError } 2900099 - Operation failed. 979 * @syscap SystemCapability.Communication.Bluetooth.Core 980 * @since 12 981 */ 982 /** 983 * Obtains the profile UUIDs supported by the remote device. 984 * 985 * @permission ohos.permission.ACCESS_BLUETOOTH 986 * @param { string } deviceId - Indicates device ID. For example, "11:22:33:AA:BB:FF". 987 * @returns { Promise<Array<ProfileUuids>> } Returns the promise object. 988 * @throws { BusinessError } 201 - Permission denied. 989 * @throws { BusinessError } 401 - Invalid parameter. 990 * @throws { BusinessError } 801 - Capability not supported. 991 * @throws { BusinessError } 2900001 - Service stopped. 992 * @throws { BusinessError } 2900003 - Bluetooth disabled. 993 * @throws { BusinessError } 2900099 - Operation failed. 994 * @syscap SystemCapability.Communication.Bluetooth.Core 995 * @crossplatform 996 * @since 13 997 */ 998 function getRemoteProfileUuids(deviceId: string): Promise<Array<ProfileUuids>>; 999 1000 /** 1001 * Connects all allowed bluetooth profiles between the local and remote device. 1002 * 1003 * @permission ohos.permission.ACCESS_BLUETOOTH and ohos.permission.MANAGE_BLUETOOTH 1004 * @param { string } deviceId - Indicates device ID. For example, "11:22:33:AA:BB:FF". 1005 * @param { AsyncCallback<void> } callback - the callback result. 1006 * @throws { BusinessError } 201 - Permission denied. 1007 * @throws { BusinessError } 202 - Non-system applications are not allowed to use system APIs. 1008 * @throws { BusinessError } 401 - Invalid parameter. Possible causes: 1. Mandatory parameters are left unspecified. 1009 * <br>2. Incorrect parameter types. 3. Parameter verification failed. 1010 * @throws { BusinessError } 801 - Capability not supported. 1011 * @throws { BusinessError } 2900001 - Service stopped. 1012 * @throws { BusinessError } 2900003 - Bluetooth disabled. 1013 * @throws { BusinessError } 2900099 - Operation failed. 1014 * @syscap SystemCapability.Communication.Bluetooth.Core 1015 * @systemapi 1016 * @since 11 1017 */ 1018 function connectAllowedProfiles(deviceId: string, callback: AsyncCallback<void>): void; 1019 1020 /** 1021 * Connects all allowed bluetooth profiles between the local and remote device. 1022 * 1023 * @permission ohos.permission.ACCESS_BLUETOOTH and ohos.permission.MANAGE_BLUETOOTH 1024 * @param { string } deviceId - Indicates device ID. For example, "11:22:33:AA:BB:FF". 1025 * @returns { Promise<void> } Returns the promise object. 1026 * @throws { BusinessError } 201 - Permission denied. 1027 * @throws { BusinessError } 202 - Non-system applications are not allowed to use system APIs. 1028 * @throws { BusinessError } 401 - Invalid parameter. Possible causes: 1. Mandatory parameters are left unspecified. 1029 * <br>2. Incorrect parameter types. 3. Parameter verification failed. 1030 * @throws { BusinessError } 801 - Capability not supported. 1031 * @throws { BusinessError } 2900001 - Service stopped. 1032 * @throws { BusinessError } 2900003 - Bluetooth disabled. 1033 * @throws { BusinessError } 2900099 - Operation failed. 1034 * @syscap SystemCapability.Communication.Bluetooth.Core 1035 * @systemapi 1036 * @since 11 1037 */ 1038 function connectAllowedProfiles(deviceId: string): Promise<void>; 1039 1040 /** 1041 * Disconnects all allowed bluetooth profiles between the local and remote device. 1042 * 1043 * @permission ohos.permission.ACCESS_BLUETOOTH and ohos.permission.MANAGE_BLUETOOTH 1044 * @param { string } deviceId - Indicates device ID. For example, "11:22:33:AA:BB:FF". 1045 * @param { AsyncCallback<void> } callback - the callback result. 1046 * @throws { BusinessError } 201 - Permission denied. 1047 * @throws { BusinessError } 202 - Non-system applications are not allowed to use system APIs. 1048 * @throws { BusinessError } 401 - Invalid parameter. Possible causes: 1. Mandatory parameters are left unspecified. 1049 * <br>2. Incorrect parameter types. 3. Parameter verification failed. 1050 * @throws { BusinessError } 801 - Capability not supported. 1051 * @throws { BusinessError } 2900001 - Service stopped. 1052 * @throws { BusinessError } 2900003 - Bluetooth disabled. 1053 * @throws { BusinessError } 2900099 - Operation failed. 1054 * @syscap SystemCapability.Communication.Bluetooth.Core 1055 * @systemapi 1056 * @since 11 1057 */ 1058 function disconnectAllowedProfiles(deviceId: string, callback: AsyncCallback<void>): void; 1059 1060 /** 1061 * Get remote device battery information. 1062 * 1063 * @permission ohos.permission.ACCESS_BLUETOOTH 1064 * @param { string } deviceId - Indicates device ID. For example, "11:22:33:AA:BB:FF". 1065 * @returns { Promise<BatteryInfo> } Returns battery info. 1066 * @throws { BusinessError } 201 - Permission denied. 1067 * @throws { BusinessError } 401 - Invalid parameter. Possible causes: 1. Mandatory parameters are left unspecified. 1068 * <br>2. Incorrect parameter types. 3. Parameter verification failed. 1069 * @throws { BusinessError } 2900001 - Service stopped. 1070 * @throws { BusinessError } 2900003 - Bluetooth disabled. 1071 * @syscap SystemCapability.Communication.Bluetooth.Core 1072 * @since 12 1073 */ 1074 function getRemoteDeviceBatteryInfo(deviceId: string): Promise<BatteryInfo>; 1075 1076 /** 1077 * Obtains the product ID of a remote device. 1078 * 1079 * @permission ohos.permission.ACCESS_BLUETOOTH and ohos.permission.MANAGE_BLUETOOTH 1080 * @param { string } deviceId - Indicates device ID. For example, "11:22:33:AA:BB:FF". 1081 * @returns { string } Returns the remote device's product ID. 1082 * @throws { BusinessError } 201 - Permission denied. 1083 * @throws { BusinessError } 202 - Non-system applications are not allowed to use system APIs. 1084 * @throws { BusinessError } 401 - Invalid parameter. Possible causes: 1. Mandatory parameters are left unspecified. 1085 * <br>2. Incorrect parameter types. 3. Parameter verification failed. 1086 * @throws { BusinessError } 801 - Capability not supported. 1087 * @throws { BusinessError } 2900001 - Service stopped. 1088 * @throws { BusinessError } 2900003 - Bluetooth disabled. 1089 * @throws { BusinessError } 2900099 - Operation failed. 1090 * @syscap SystemCapability.Communication.Bluetooth.Core 1091 * @systemapi 1092 * @since 11 1093 */ 1094 function getRemoteProductId(deviceId: string): string; 1095 1096 /** 1097 * Disconnects all allowed bluetooth profiles between the local and remote device. 1098 * 1099 * @permission ohos.permission.ACCESS_BLUETOOTH and ohos.permission.MANAGE_BLUETOOTH 1100 * @param { string } deviceId - Indicates device ID. For example, "11:22:33:AA:BB:FF". 1101 * @returns { Promise<void> } Returns the promise object. 1102 * @throws { BusinessError } 201 - Permission denied. 1103 * @throws { BusinessError } 202 - Non-system applications are not allowed to use system APIs. 1104 * @throws { BusinessError } 401 - Invalid parameter. Possible causes: 1. Mandatory parameters are left unspecified. 1105 * <br>2. Incorrect parameter types. 3. Parameter verification failed. 1106 * @throws { BusinessError } 801 - Capability not supported. 1107 * @throws { BusinessError } 2900001 - Service stopped. 1108 * @throws { BusinessError } 2900003 - Bluetooth disabled. 1109 * @throws { BusinessError } 2900099 - Operation failed. 1110 * @syscap SystemCapability.Communication.Bluetooth.Core 1111 * @systemapi 1112 * @since 11 1113 */ 1114 function disconnectAllowedProfiles(deviceId: string): Promise<void>; 1115 1116 /** 1117 * Modify remote device name. 1118 * 1119 * @permission ohos.permission.ACCESS_BLUETOOTH 1120 * @param { string } deviceId - Indicates device ID. For example, "11:22:33:AA:BB:FF". 1121 * @param { string } name - New device name. Max length is 64 bytes. 1122 * @returns { Promise<void> } Returns the promise object. 1123 * @throws { BusinessError } 201 - Permission denied. 1124 * @throws { BusinessError } 401 - Invalid parameter. Possible causes: 1. Mandatory parameters are left unspecified. 1125 * <br>2. Incorrect parameter types. 3. Parameter verification failed. 1126 * @throws { BusinessError } 2900001 - Service stopped. 1127 * @throws { BusinessError } 2900003 - Bluetooth disabled. 1128 * @syscap SystemCapability.Communication.Bluetooth.Core 1129 * @atomicservice 1130 * @since 12 1131 */ 1132 function setRemoteDeviceName(deviceId: string, name: string): Promise<void>; 1133 1134 /** 1135 * Set remote device custom type. 1136 * 1137 * @permission ohos.permission.ACCESS_BLUETOOTH 1138 * @param { string } deviceId - Indicates device ID. For example, "11:22:33:AA:BB:FF". 1139 * @param { DeviceType } type - Indicates device type. 1140 * @returns { Promise<void> } Returns the promise object. 1141 * @throws { BusinessError } 201 - Permission denied. 1142 * @throws { BusinessError } 401 - Invalid parameter. Possible causes: 1. Mandatory parameters are left unspecified. 1143 * <br>2. Incorrect parameter types. 3. Parameter verification failed. 1144 * @throws { BusinessError } 2900001 - Service stopped. 1145 * @throws { BusinessError } 2900003 - Bluetooth disabled. 1146 * @syscap SystemCapability.Communication.Bluetooth.Core 1147 * @systemapi 1148 * @since 12 1149 */ 1150 function setRemoteDeviceType(deviceId: string, type: DeviceType): Promise<void>; 1151 1152 /** 1153 * Get remote device custom type. 1154 * 1155 * @permission ohos.permission.ACCESS_BLUETOOTH 1156 * @param { string } deviceId - Indicates device ID. For example, "11:22:33:AA:BB:FF". 1157 * @returns { Promise<DeviceType> } Returns the device type. 1158 * @throws { BusinessError } 201 - Permission denied. 1159 * @throws { BusinessError } 401 - Invalid parameter. Possible causes: 1. Mandatory parameters are left unspecified. 1160 * <br>2. Incorrect parameter types. 3. Parameter verification failed. 1161 * @throws { BusinessError } 2900001 - Service stopped. 1162 * @throws { BusinessError } 2900003 - Bluetooth disabled. 1163 * @syscap SystemCapability.Communication.Bluetooth.Core 1164 * @systemapi 1165 * @since 12 1166 */ 1167 function getRemoteDeviceType(deviceId: string): Promise<DeviceType>; 1168 1169 /** 1170 * Subscribe the event reported when a remote Bluetooth device is discovered. 1171 * 1172 * @permission ohos.permission.ACCESS_BLUETOOTH 1173 * @param { 'bluetoothDeviceFind' } type - Type of the discovering event to listen for. 1174 * @param { Callback<Array<string>> } callback - Callback used to listen for the discovering event. 1175 * @throws { BusinessError } 201 - Permission denied. 1176 * @throws { BusinessError } 401 - Invalid parameter. Possible causes: 1. Mandatory parameters are left unspecified. 1177 * <br>2. Incorrect parameter types. 3. Parameter verification failed. 1178 * @throws { BusinessError } 801 - Capability not supported. 1179 * @throws { BusinessError } 2900099 - Operation failed. 1180 * @syscap SystemCapability.Communication.Bluetooth.Core 1181 * @since 10 1182 */ 1183 /** 1184 * Subscribe the event reported when a remote Bluetooth device is discovered. 1185 * 1186 * @permission ohos.permission.ACCESS_BLUETOOTH 1187 * @param { 'bluetoothDeviceFind' } type - Type of the discovering event to listen for. 1188 * @param { Callback<Array<string>> } callback - Callback used to listen for the discovering event. 1189 * @throws { BusinessError } 201 - Permission denied. 1190 * @throws { BusinessError } 401 - Invalid parameter. Possible causes: 1. Mandatory parameters are left unspecified. 1191 * <br>2. Incorrect parameter types. 3. Parameter verification failed. 1192 * @throws { BusinessError } 801 - Capability not supported. 1193 * @throws { BusinessError } 2900099 - Operation failed. 1194 * @syscap SystemCapability.Communication.Bluetooth.Core 1195 * @atomicservice 1196 * @since 12 1197 */ 1198 /** 1199 * Subscribe the event reported when a remote Bluetooth device is discovered. 1200 * 1201 * @permission ohos.permission.ACCESS_BLUETOOTH 1202 * @param { 'bluetoothDeviceFind' } type - Type of the discovering event to listen for. 1203 * @param { Callback<Array<string>> } callback - Callback used to listen for the discovering event. 1204 * @throws { BusinessError } 201 - Permission denied. 1205 * @throws { BusinessError } 401 - Invalid parameter. Possible causes: 1. Mandatory parameters are left unspecified. 1206 * <br>2. Incorrect parameter types. 3. Parameter verification failed. 1207 * @throws { BusinessError } 801 - Capability not supported. 1208 * @throws { BusinessError } 2900099 - Operation failed. 1209 * @syscap SystemCapability.Communication.Bluetooth.Core 1210 * @crossplatform 1211 * @atomicservice 1212 * @since 13 1213 */ 1214 function on(type: 'bluetoothDeviceFind', callback: Callback<Array<string>>): void; 1215 1216 /** 1217 * Unsubscribe the event reported when a remote Bluetooth device is discovered. 1218 * 1219 * @permission ohos.permission.ACCESS_BLUETOOTH 1220 * @param { 'bluetoothDeviceFind' } type - Type of the discovering event to listen for. 1221 * @param { Callback<Array<string>> } callback - Callback used to listen for the discovering event. 1222 * @throws { BusinessError } 201 - Permission denied. 1223 * @throws { BusinessError } 801 - Capability not supported. 1224 * @throws { BusinessError } 2900099 - Operation failed. 1225 * @syscap SystemCapability.Communication.Bluetooth.Core 1226 * @since 10 1227 */ 1228 /** 1229 * Unsubscribe the event reported when a remote Bluetooth device is discovered. 1230 * 1231 * @permission ohos.permission.ACCESS_BLUETOOTH 1232 * @param { 'bluetoothDeviceFind' } type - Type of the discovering event to listen for. 1233 * @param { Callback<Array<string>> } callback - Callback used to listen for the discovering event. 1234 * @throws { BusinessError } 201 - Permission denied. 1235 * @throws { BusinessError } 801 - Capability not supported. 1236 * @throws { BusinessError } 2900099 - Operation failed. 1237 * @syscap SystemCapability.Communication.Bluetooth.Core 1238 * @atomicservice 1239 * @since 12 1240 */ 1241 /** 1242 * Unsubscribe the event reported when a remote Bluetooth device is discovered. 1243 * 1244 * @permission ohos.permission.ACCESS_BLUETOOTH 1245 * @param { 'bluetoothDeviceFind' } type - Type of the discovering event to listen for. 1246 * @param { Callback<Array<string>> } callback - Callback used to listen for the discovering event. 1247 * @throws { BusinessError } 201 - Permission denied. 1248 * @throws { BusinessError } 801 - Capability not supported. 1249 * @throws { BusinessError } 2900099 - Operation failed. 1250 * @syscap SystemCapability.Communication.Bluetooth.Core 1251 * @crossplatform 1252 * @atomicservice 1253 * @since 13 1254 */ 1255 function off(type: 'bluetoothDeviceFind', callback?: Callback<Array<string>>): void; 1256 1257 /** 1258 * Subscribe the event reported when a remote Bluetooth device is discovered. 1259 * 1260 * @permission ohos.permission.ACCESS_BLUETOOTH and ohos.permission.GET_BLUETOOTH_PEERS_MAC 1261 * @param { 'discoveryResult' } type - Type of the discovering event to listen for. 1262 * @param { Callback<Array<DiscoveryResult>> } callback - Callback used to listen for the discovering event. 1263 * @throws { BusinessError } 201 - Permission denied. 1264 * @throws { BusinessError } 401 - Invalid parameter. Possible causes: 1. Mandatory parameters are left unspecified. 1265 * <br>2. Incorrect parameter types. 3. Parameter verification failed. 1266 * @throws { BusinessError } 801 - Capability not supported. 1267 * @throws { BusinessError } 2900099 - Operation failed. 1268 * @syscap SystemCapability.Communication.Bluetooth.Core 1269 * @systemapi 1270 * @since 12 1271 */ 1272 function on(type: 'discoveryResult', callback: Callback<Array<DiscoveryResult>>): void; 1273 1274 /** 1275 * Unsubscribe the event reported when a remote Bluetooth device is discovered. 1276 * 1277 * @permission ohos.permission.ACCESS_BLUETOOTH and ohos.permission.GET_BLUETOOTH_PEERS_MAC 1278 * @param { 'discoveryResult' } type - Type of the discovering event to listen for. 1279 * @param { Callback<Array<DiscoveryResult>> } callback - Callback used to listen for the discovering event. 1280 * @throws { BusinessError } 201 - Permission denied. 1281 * @throws { BusinessError } 801 - Capability not supported. 1282 * @throws { BusinessError } 2900099 - Operation failed. 1283 * @syscap SystemCapability.Communication.Bluetooth.Core 1284 * @systemapi 1285 * @since 12 1286 */ 1287 function off(type: 'discoveryResult', callback?: Callback<Array<DiscoveryResult>>): void; 1288 1289 /** 1290 * Subscribe the event reported when a remote Bluetooth device is bonded. 1291 * 1292 * @permission ohos.permission.ACCESS_BLUETOOTH 1293 * @param { 'bondStateChange' } type - Type of the bond state event to listen for. 1294 * @param { Callback<BondStateParam> } callback - Callback used to listen for the bond state event. 1295 * @throws { BusinessError } 201 - Permission denied. 1296 * @throws { BusinessError } 401 - Invalid parameter. Possible causes: 1. Mandatory parameters are left unspecified. 1297 * <br>2. Incorrect parameter types. 3. Parameter verification failed. 1298 * @throws { BusinessError } 801 - Capability not supported. 1299 * @throws { BusinessError } 2900099 - Operation failed. 1300 * @syscap SystemCapability.Communication.Bluetooth.Core 1301 * @since 10 1302 */ 1303 /** 1304 * Subscribe the event reported when a remote Bluetooth device is bonded. 1305 * 1306 * @permission ohos.permission.ACCESS_BLUETOOTH 1307 * @param { 'bondStateChange' } type - Type of the bond state event to listen for. 1308 * @param { Callback<BondStateParam> } callback - Callback used to listen for the bond state event. 1309 * @throws { BusinessError } 201 - Permission denied. 1310 * @throws { BusinessError } 401 - Invalid parameter. Possible causes: 1. Mandatory parameters are left unspecified. 1311 * <br>2. Incorrect parameter types. 3. Parameter verification failed. 1312 * @throws { BusinessError } 801 - Capability not supported. 1313 * @throws { BusinessError } 2900099 - Operation failed. 1314 * @syscap SystemCapability.Communication.Bluetooth.Core 1315 * @crossplatform 1316 * @since 13 1317 */ 1318 function on(type: 'bondStateChange', callback: Callback<BondStateParam>): void; 1319 1320 /** 1321 * Unsubscribe the event reported when a remote Bluetooth device is bonded. 1322 * 1323 * @permission ohos.permission.ACCESS_BLUETOOTH 1324 * @param { 'bondStateChange' } type - Type of the bond state event to listen for. 1325 * @param { Callback<BondStateParam> } callback - Callback used to listen for the bond state event. 1326 * @throws { BusinessError } 201 - Permission denied. 1327 * @throws { BusinessError } 401 - Invalid parameter. Possible causes: 1. Mandatory parameters are left unspecified. 1328 * <br>2. Incorrect parameter types. 3. Parameter verification failed. 1329 * @throws { BusinessError } 801 - Capability not supported. 1330 * @throws { BusinessError } 2900099 - Operation failed. 1331 * @syscap SystemCapability.Communication.Bluetooth.Core 1332 * @since 10 1333 */ 1334 /** 1335 * Unsubscribe the event reported when a remote Bluetooth device is bonded. 1336 * 1337 * @permission ohos.permission.ACCESS_BLUETOOTH 1338 * @param { 'bondStateChange' } type - Type of the bond state event to listen for. 1339 * @param { Callback<BondStateParam> } callback - Callback used to listen for the bond state event. 1340 * @throws { BusinessError } 201 - Permission denied. 1341 * @throws { BusinessError } 401 - Invalid parameter. Possible causes: 1. Mandatory parameters are left unspecified. 1342 * <br>2. Incorrect parameter types. 3. Parameter verification failed. 1343 * @throws { BusinessError } 801 - Capability not supported. 1344 * @throws { BusinessError } 2900099 - Operation failed. 1345 * @syscap SystemCapability.Communication.Bluetooth.Core 1346 * @crossplatform 1347 * @since 13 1348 */ 1349 function off(type: 'bondStateChange', callback?: Callback<BondStateParam>): void; 1350 1351 /** 1352 * Subscribe the event of a pairing request from a remote Bluetooth device. 1353 * 1354 * @permission ohos.permission.ACCESS_BLUETOOTH 1355 * @param { 'pinRequired' } type - Type of the pairing request event to listen for. 1356 * @param { Callback<PinRequiredParam> } callback - Callback used to listen for the pairing request event. 1357 * @throws { BusinessError } 201 - Permission denied. 1358 * @throws { BusinessError } 401 - Invalid parameter. Possible causes: 1. Mandatory parameters are left unspecified. 1359 * <br>2. Incorrect parameter types. 3. Parameter verification failed. 1360 * @throws { BusinessError } 801 - Capability not supported. 1361 * @throws { BusinessError } 2900099 - Operation failed. 1362 * @syscap SystemCapability.Communication.Bluetooth.Core 1363 * @since 10 1364 */ 1365 function on(type: 'pinRequired', callback: Callback<PinRequiredParam>): void; 1366 1367 /** 1368 * Unsubscribe the event of a pairing request from a remote Bluetooth device. 1369 * 1370 * @permission ohos.permission.ACCESS_BLUETOOTH 1371 * @param { 'pinRequired' } type - Type of the pairing request event to listen for. 1372 * @param { Callback<PinRequiredParam> } callback - Callback used to listen for the pairing request event. 1373 * @throws { BusinessError } 201 - Permission denied. 1374 * @throws { BusinessError } 401 - Invalid parameter. Possible causes: 1. Mandatory parameters are left unspecified. 1375 * <br>2. Incorrect parameter types. 3. Parameter verification failed. 1376 * @throws { BusinessError } 801 - Capability not supported. 1377 * @throws { BusinessError } 2900099 - Operation failed. 1378 * @syscap SystemCapability.Communication.Bluetooth.Core 1379 * @since 10 1380 */ 1381 function off(type: 'pinRequired', callback?: Callback<PinRequiredParam>): void; 1382 1383 /** 1384 * Subscribe the event of battery state changed from a remote device. 1385 * 1386 * @permission ohos.permission.ACCESS_BLUETOOTH 1387 * @param { 'batteryChange' } type - Type of the battery event to listen for. 1388 * @param { Callback<BatteryInfo> } callback - Callback used to listen. 1389 * @throws { BusinessError } 201 - Permission denied. 1390 * @throws { BusinessError } 2900099 - Operation failed. 1391 * @syscap SystemCapability.Communication.Bluetooth.Core 1392 * @since 12 1393 */ 1394 function on(type: 'batteryChange', callback: Callback<BatteryInfo>): void; 1395 1396 /** 1397 * Unsubscribe the event of battery state changed from a remote device. 1398 * 1399 * @permission ohos.permission.ACCESS_BLUETOOTH 1400 * @param { 'batteryChange' } type - Type of the battery event to listen for. 1401 * @param { Callback<BatteryInfo> } callback - Callback used to listen. 1402 * @throws { BusinessError } 201 - Permission denied. 1403 * @throws { BusinessError } 2900099 - Operation failed. 1404 * @syscap SystemCapability.Communication.Bluetooth.Core 1405 * @since 12 1406 */ 1407 function off(type: 'batteryChange', callback?: Callback<BatteryInfo>): void; 1408 1409 /** 1410 * Describes the class of a bluetooth device. 1411 * 1412 * @typedef BondStateParam 1413 * @syscap SystemCapability.Communication.Bluetooth.Core 1414 * @since 10 1415 */ 1416 /** 1417 * Describes the class of a bluetooth device. 1418 * 1419 * @typedef BondStateParam 1420 * @syscap SystemCapability.Communication.Bluetooth.Core 1421 * @crossplatform 1422 * @since 13 1423 */ 1424 interface BondStateParam { 1425 /** 1426 * Address of a Bluetooth device. 1427 * 1428 * @type { string } 1429 * @syscap SystemCapability.Communication.Bluetooth.Core 1430 * @since 10 1431 */ 1432 /** 1433 * Address of a Bluetooth device. 1434 * 1435 * @type { string } 1436 * @syscap SystemCapability.Communication.Bluetooth.Core 1437 * @crossplatform 1438 * @since 13 1439 */ 1440 deviceId: string; 1441 /** 1442 * Profile connection state of the device. 1443 * 1444 * @type { BondState } 1445 * @syscap SystemCapability.Communication.Bluetooth.Core 1446 * @since 10 1447 */ 1448 /** 1449 * Profile connection state of the device. 1450 * 1451 * @type { BondState } 1452 * @syscap SystemCapability.Communication.Bluetooth.Core 1453 * @crossplatform 1454 * @since 13 1455 */ 1456 state: BondState; 1457 /** 1458 * Cause of unbond. 1459 * 1460 * @type { UnbondCause } 1461 * @syscap SystemCapability.Communication.Bluetooth.Core 1462 * @since 12 1463 */ 1464 /** 1465 * Cause of unbond. 1466 * 1467 * @type { UnbondCause } 1468 * @syscap SystemCapability.Communication.Bluetooth.Core 1469 * @crossplatform 1470 * @since 13 1471 */ 1472 cause: UnbondCause; 1473 } 1474 1475 /** 1476 * Describes the bond key param. 1477 * 1478 * @typedef PinRequiredParam 1479 * @syscap SystemCapability.Communication.Bluetooth.Core 1480 * @since 10 1481 */ 1482 interface PinRequiredParam { 1483 /** 1484 * ID of the device to pair. 1485 * 1486 * @type { string } 1487 * @syscap SystemCapability.Communication.Bluetooth.Core 1488 * @since 10 1489 */ 1490 deviceId: string; 1491 /** 1492 * Key for the device pairing. 1493 * 1494 * @type { string } 1495 * @syscap SystemCapability.Communication.Bluetooth.Core 1496 * @since 10 1497 */ 1498 pinCode: string; 1499 /** 1500 * Indicates the pairing type to a peer device. 1501 * 1502 * @type { PinType } 1503 * @syscap SystemCapability.Communication.Bluetooth.Core 1504 * @systemapi 1505 * @since 10 1506 */ 1507 pinType: PinType; 1508 } 1509 1510 /** 1511 * Describes the class of a bluetooth device. 1512 * 1513 * @typedef DeviceClass 1514 * @syscap SystemCapability.Communication.Bluetooth.Core 1515 * @since 10 1516 */ 1517 /** 1518 * Describes the class of a bluetooth device. 1519 * 1520 * @typedef DeviceClass 1521 * @syscap SystemCapability.Communication.Bluetooth.Core 1522 * @crossplatform 1523 * @since 13 1524 */ 1525 interface DeviceClass { 1526 /** 1527 * Major classes of Bluetooth devices. 1528 * 1529 * @type { MajorClass } 1530 * @syscap SystemCapability.Communication.Bluetooth.Core 1531 * @since 10 1532 */ 1533 /** 1534 * Major classes of Bluetooth devices. 1535 * 1536 * @type { MajorClass } 1537 * @syscap SystemCapability.Communication.Bluetooth.Core 1538 * @crossplatform 1539 * @since 13 1540 */ 1541 majorClass: MajorClass; 1542 /** 1543 * Major and minor classes of Bluetooth devices. 1544 * 1545 * @type { MajorMinorClass } 1546 * @syscap SystemCapability.Communication.Bluetooth.Core 1547 * @since 10 1548 */ 1549 /** 1550 * Major and minor classes of Bluetooth devices. 1551 * 1552 * @type { MajorMinorClass } 1553 * @syscap SystemCapability.Communication.Bluetooth.Core 1554 * @crossplatform 1555 * @since 13 1556 */ 1557 majorMinorClass: MajorMinorClass; 1558 /** 1559 * Class of the device. 1560 * 1561 * @type { number } 1562 * @syscap SystemCapability.Communication.Bluetooth.Core 1563 * @since 10 1564 */ 1565 /** 1566 * Class of the device. 1567 * 1568 * @type { number } 1569 * @syscap SystemCapability.Communication.Bluetooth.Core 1570 * @crossplatform 1571 * @since 13 1572 */ 1573 classOfDevice: number; 1574 } 1575 1576 /** 1577 * Enum for the transport of a remote device 1578 * 1579 * @enum { number } 1580 * @syscap SystemCapability.Communication.Bluetooth.Core 1581 * @since 10 1582 */ 1583 enum BluetoothTransport { 1584 /** 1585 * The value of bluetooth transport BR/EDR. 1586 * 1587 * @syscap SystemCapability.Communication.Bluetooth.Core 1588 * @since 10 1589 */ 1590 TRANSPORT_BR_EDR = 0, 1591 /** 1592 * The value of bluetooth transport LE. 1593 * 1594 * @syscap SystemCapability.Communication.Bluetooth.Core 1595 * @since 10 1596 */ 1597 TRANSPORT_LE = 1 1598 } 1599 1600 /** 1601 * The enum of BR scan mode. 1602 * 1603 * @enum { number } 1604 * @syscap SystemCapability.Communication.Bluetooth.Core 1605 * @since 10 1606 */ 1607 /** 1608 * The enum of BR scan mode. 1609 * 1610 * @enum { number } 1611 * @syscap SystemCapability.Communication.Bluetooth.Core 1612 * @crossplatform 1613 * @since 13 1614 */ 1615 enum ScanMode { 1616 /** 1617 * Indicates the scan mode is none 1618 * 1619 * @syscap SystemCapability.Communication.Bluetooth.Core 1620 * @since 10 1621 */ 1622 /** 1623 * Indicates the scan mode is none 1624 * 1625 * @syscap SystemCapability.Communication.Bluetooth.Core 1626 * @crossplatform 1627 * @since 13 1628 */ 1629 SCAN_MODE_NONE = 0, 1630 /** 1631 * Indicates the scan mode is connectable 1632 * 1633 * @syscap SystemCapability.Communication.Bluetooth.Core 1634 * @since 10 1635 */ 1636 /** 1637 * Indicates the scan mode is connectable 1638 * 1639 * @syscap SystemCapability.Communication.Bluetooth.Core 1640 * @crossplatform 1641 * @since 13 1642 */ 1643 SCAN_MODE_CONNECTABLE = 1, 1644 /** 1645 * Indicates the scan mode is general discoverable 1646 * 1647 * @syscap SystemCapability.Communication.Bluetooth.Core 1648 * @since 10 1649 */ 1650 SCAN_MODE_GENERAL_DISCOVERABLE = 2, 1651 /** 1652 * Indicates the scan mode is limited discoverable 1653 * 1654 * @syscap SystemCapability.Communication.Bluetooth.Core 1655 * @since 10 1656 */ 1657 SCAN_MODE_LIMITED_DISCOVERABLE = 3, 1658 /** 1659 * Indicates the scan mode is connectable and general discoverable 1660 * 1661 * @syscap SystemCapability.Communication.Bluetooth.Core 1662 * @since 10 1663 */ 1664 /** 1665 * Indicates the scan mode is connectable and general discoverable 1666 * 1667 * @syscap SystemCapability.Communication.Bluetooth.Core 1668 * @crossplatform 1669 * @since 13 1670 */ 1671 SCAN_MODE_CONNECTABLE_GENERAL_DISCOVERABLE = 4, 1672 /** 1673 * Indicates the scan mode is connectable and limited discoverable 1674 * 1675 * @syscap SystemCapability.Communication.Bluetooth.Core 1676 * @since 10 1677 */ 1678 SCAN_MODE_CONNECTABLE_LIMITED_DISCOVERABLE = 5 1679 } 1680 1681 /** 1682 * The enum of bond state. 1683 * 1684 * @enum { number } 1685 * @syscap SystemCapability.Communication.Bluetooth.Core 1686 * @since 10 1687 */ 1688 /** 1689 * The enum of bond state. 1690 * 1691 * @enum { number } 1692 * @syscap SystemCapability.Communication.Bluetooth.Core 1693 * @atomicservice 1694 * @since 12 1695 */ 1696 /** 1697 * The enum of bond state. 1698 * 1699 * @enum { number } 1700 * @syscap SystemCapability.Communication.Bluetooth.Core 1701 * @crossplatform 1702 * @atomicservice 1703 * @since 13 1704 */ 1705 enum BondState { 1706 /** 1707 * Indicate the bond state is invalid 1708 * 1709 * @syscap SystemCapability.Communication.Bluetooth.Core 1710 * @since 10 1711 */ 1712 /** 1713 * Indicate the bond state is invalid 1714 * 1715 * @syscap SystemCapability.Communication.Bluetooth.Core 1716 * @atomicservice 1717 * @since 12 1718 */ 1719 /** 1720 * Indicate the bond state is invalid 1721 * 1722 * @syscap SystemCapability.Communication.Bluetooth.Core 1723 * @crossplatform 1724 * @atomicservice 1725 * @since 13 1726 */ 1727 BOND_STATE_INVALID = 0, 1728 /** 1729 * Indicate the bond state is bonding 1730 * 1731 * @syscap SystemCapability.Communication.Bluetooth.Core 1732 * @since 10 1733 */ 1734 /** 1735 * Indicate the bond state is bonding 1736 * 1737 * @syscap SystemCapability.Communication.Bluetooth.Core 1738 * @atomicservice 1739 * @since 12 1740 */ 1741 /** 1742 * Indicate the bond state is bonding 1743 * 1744 * @syscap SystemCapability.Communication.Bluetooth.Core 1745 * @crossplatform 1746 * @atomicservice 1747 * @since 13 1748 */ 1749 BOND_STATE_BONDING = 1, 1750 /** 1751 * Indicate the bond state is bonded 1752 * 1753 * @syscap SystemCapability.Communication.Bluetooth.Core 1754 * @since 10 1755 */ 1756 /** 1757 * Indicate the bond state is bonded 1758 * 1759 * @syscap SystemCapability.Communication.Bluetooth.Core 1760 * @atomicservice 1761 * @since 12 1762 */ 1763 /** 1764 * Indicate the bond state is bonded 1765 * 1766 * @syscap SystemCapability.Communication.Bluetooth.Core 1767 * @crossplatform 1768 * @atomicservice 1769 * @since 13 1770 */ 1771 BOND_STATE_BONDED = 2 1772 } 1773 1774 /** 1775 * Enum for the type of pairing to a remote device 1776 * 1777 * @enum { number } 1778 * @syscap SystemCapability.Communication.Bluetooth.Core 1779 * @systemapi 1780 * @since 10 1781 */ 1782 enum PinType { 1783 /** 1784 * The user needs to enter the pin code displayed on the peer device. 1785 * 1786 * @syscap SystemCapability.Communication.Bluetooth.Core 1787 * @systemapi 1788 * @since 10 1789 */ 1790 PIN_TYPE_ENTER_PIN_CODE = 0, 1791 /** 1792 * The user needs to enter the passkey displayed on the peer device. 1793 * 1794 * @syscap SystemCapability.Communication.Bluetooth.Core 1795 * @systemapi 1796 * @since 10 1797 */ 1798 PIN_TYPE_ENTER_PASSKEY = 1, 1799 /** 1800 * The user needs to confirm the passkey displayed on the local device. 1801 * 1802 * @syscap SystemCapability.Communication.Bluetooth.Core 1803 * @systemapi 1804 * @since 10 1805 */ 1806 PIN_TYPE_CONFIRM_PASSKEY = 2, 1807 /** 1808 * The user needs to accept or deny the pairing request. 1809 * 1810 * @syscap SystemCapability.Communication.Bluetooth.Core 1811 * @systemapi 1812 * @since 10 1813 */ 1814 PIN_TYPE_NO_PASSKEY_CONSENT = 3, 1815 /** 1816 * The user needs to enter the passkey displayed on the local device on the peer device. 1817 * 1818 * @syscap SystemCapability.Communication.Bluetooth.Core 1819 * @systemapi 1820 * @since 10 1821 */ 1822 PIN_TYPE_NOTIFY_PASSKEY = 4, 1823 /** 1824 * The user needs to enter the pin code displayed on the peer device, used for bluetooth 2.0. 1825 * 1826 * @syscap SystemCapability.Communication.Bluetooth.Core 1827 * @systemapi 1828 * @since 10 1829 */ 1830 PIN_TYPE_DISPLAY_PIN_CODE = 5, 1831 /** 1832 * The user needs to accept or deny the OOB pairing request. 1833 * 1834 * @syscap SystemCapability.Communication.Bluetooth.Core 1835 * @systemapi 1836 * @since 10 1837 */ 1838 PIN_TYPE_OOB_CONSENT = 6, 1839 /** 1840 * The user needs to enter the 16-digit pin code displayed on the peer device. 1841 * 1842 * @syscap SystemCapability.Communication.Bluetooth.Core 1843 * @systemapi 1844 * @since 10 1845 */ 1846 PIN_TYPE_PIN_16_DIGITS = 7 1847 } 1848 1849 /** 1850 * Describes the contents of the discovery results 1851 * 1852 * @typedef DiscoveryResult 1853 * @syscap SystemCapability.Communication.Bluetooth.Core 1854 * @systemapi 1855 * @since 12 1856 */ 1857 interface DiscoveryResult { 1858 /** 1859 * Identify of the discovery device 1860 * 1861 * @type { string } 1862 * @syscap SystemCapability.Communication.Bluetooth.Core 1863 * @systemapi 1864 * @since 12 1865 */ 1866 deviceId: string; 1867 /** 1868 * RSSI of the remote device 1869 * 1870 * @type { number } 1871 * @syscap SystemCapability.Communication.Bluetooth.Core 1872 * @systemapi 1873 * @since 12 1874 */ 1875 rssi: number; 1876 /** 1877 * The local name of the device 1878 * 1879 * @type { string } 1880 * @syscap SystemCapability.Communication.Bluetooth.Core 1881 * @systemapi 1882 * @since 12 1883 */ 1884 deviceName: string; 1885 /** 1886 * The class of the device 1887 * 1888 * @type { DeviceClass } 1889 * @syscap SystemCapability.Communication.Bluetooth.Core 1890 * @systemapi 1891 * @since 12 1892 */ 1893 deviceClass: DeviceClass; 1894 } 1895 1896 /** 1897 * Describes the contents of the battery information. 1898 * 1899 * @typedef BatteryInfo 1900 * @syscap SystemCapability.Communication.Bluetooth.Core 1901 * @since 12 1902 */ 1903 interface BatteryInfo { 1904 /** 1905 * Identify of the discovery device. 1906 * 1907 * @type { string } 1908 * @syscap SystemCapability.Communication.Bluetooth.Core 1909 * @systemapi 1910 * @since 12 1911 */ 1912 deviceId: string; 1913 /** 1914 * Electricity value of the general device. {@code -1} means no power information. 1915 * 1916 * @type { number } 1917 * @syscap SystemCapability.Communication.Bluetooth.Core 1918 * @since 12 1919 */ 1920 batteryLevel: number; 1921 /** 1922 * Electricity value of the left ear. {@code -1} means no power information. 1923 * 1924 * @type { number } 1925 * @syscap SystemCapability.Communication.Bluetooth.Core 1926 * @since 12 1927 */ 1928 leftEarBatteryLevel: number; 1929 /** 1930 * The charge state of the left ear. 1931 * 1932 * @type { DeviceChargeState } 1933 * @syscap SystemCapability.Communication.Bluetooth.Core 1934 * @since 12 1935 */ 1936 leftEarChargeState: DeviceChargeState; 1937 /** 1938 * Electricity value of the right ear. {@code -1} means no power information. 1939 * 1940 * @type { number } 1941 * @syscap SystemCapability.Communication.Bluetooth.Core 1942 * @since 12 1943 */ 1944 rightEarBatteryLevel: number; 1945 /** 1946 * The charge state of the right ear. 1947 * 1948 * @type { DeviceChargeState } 1949 * @syscap SystemCapability.Communication.Bluetooth.Core 1950 * @since 12 1951 */ 1952 rightEarChargeState: DeviceChargeState; 1953 /** 1954 * Electricity value of the box. {@code -1} means no power information. 1955 * 1956 * @type { number } 1957 * @syscap SystemCapability.Communication.Bluetooth.Core 1958 * @since 12 1959 */ 1960 boxBatteryLevel: number; 1961 /** 1962 * The charge state of the box. 1963 * 1964 * @type { DeviceChargeState } 1965 * @syscap SystemCapability.Communication.Bluetooth.Core 1966 * @since 12 1967 */ 1968 boxChargeState: DeviceChargeState; 1969 } 1970 1971 /** 1972 * Enum for the charge state. 1973 * 1974 * @enum { number } 1975 * @syscap SystemCapability.Communication.Bluetooth.Core 1976 * @since 12 1977 */ 1978 enum DeviceChargeState { 1979 /** 1980 * Not support super charge, and not charged. 1981 * 1982 * @syscap SystemCapability.Communication.Bluetooth.Core 1983 * @since 12 1984 */ 1985 DEVICE_NORMAL_CHARGE_NOT_CHARGED = 0, 1986 /** 1987 * Not support super charge, and in charging. 1988 * 1989 * @syscap SystemCapability.Communication.Bluetooth.Core 1990 * @since 12 1991 */ 1992 DEVICE_NORMAL_CHARGE_IN_CHARGING = 1, 1993 /** 1994 * Support super charge, and not charged. 1995 * 1996 * @syscap SystemCapability.Communication.Bluetooth.Core 1997 * @since 12 1998 */ 1999 DEVICE_SUPER_CHARGE_NOT_CHARGED = 2, 2000 /** 2001 * Support super charge, and in charging. 2002 * 2003 * @syscap SystemCapability.Communication.Bluetooth.Core 2004 * @since 12 2005 */ 2006 DEVICE_SUPER_CHARGE_IN_CHARGING = 3 2007 } 2008 2009 /** 2010 * Enum for the custom type of remote device. 2011 * 2012 * @enum { number } 2013 * @syscap SystemCapability.Communication.Bluetooth.Core 2014 * @systemapi 2015 * @since 12 2016 */ 2017 enum DeviceType { 2018 /** 2019 * Default type, the type is consistent with COD. 2020 * 2021 * @syscap SystemCapability.Communication.Bluetooth.Core 2022 * @systemapi 2023 * @since 12 2024 */ 2025 DEVICE_TYPE_DEFAULT = 0, 2026 /** 2027 * Car bluetooth. 2028 * 2029 * @syscap SystemCapability.Communication.Bluetooth.Core 2030 * @systemapi 2031 * @since 12 2032 */ 2033 DEVICE_TYPE_CAR = 1, 2034 /** 2035 * Headset bluetooth. 2036 * 2037 * @syscap SystemCapability.Communication.Bluetooth.Core 2038 * @systemapi 2039 * @since 12 2040 */ 2041 DEVICE_TYPE_HEADSET = 2, 2042 /** 2043 * Hearing Aid. 2044 * 2045 * @syscap SystemCapability.Communication.Bluetooth.Core 2046 * @systemapi 2047 * @since 12 2048 */ 2049 DEVICE_TYPE_HEARING = 3, 2050 /** 2051 * Glasses device. 2052 * 2053 * @syscap SystemCapability.Communication.Bluetooth.Core 2054 * @systemapi 2055 * @since 12 2056 */ 2057 DEVICE_TYPE_GLASSES = 4, 2058 /** 2059 * Watch device. 2060 * 2061 * @syscap SystemCapability.Communication.Bluetooth.Core 2062 * @systemapi 2063 * @since 12 2064 */ 2065 DEVICE_TYPE_WATCH = 5, 2066 /** 2067 * Speaker device. 2068 * 2069 * @syscap SystemCapability.Communication.Bluetooth.Core 2070 * @systemapi 2071 * @since 12 2072 */ 2073 DEVICE_TYPE_SPEAKER = 6, 2074 /** 2075 * Others bluetooth. 2076 * 2077 * @syscap SystemCapability.Communication.Bluetooth.Core 2078 * @systemapi 2079 * @since 12 2080 */ 2081 DEVICE_TYPE_OTHERS = 7 2082 } 2083 2084 /** 2085 * Enum for cause of unbond. 2086 * 2087 * @enum { number } 2088 * @syscap SystemCapability.Communication.Bluetooth.Core 2089 * @since 12 2090 */ 2091 /** 2092 * Enum for cause of unbond. 2093 * 2094 * @enum { number } 2095 * @syscap SystemCapability.Communication.Bluetooth.Core 2096 * @crossplatform 2097 * @since 13 2098 */ 2099 enum UnbondCause { 2100 /** 2101 * User proactively removed device. 2102 * 2103 * @syscap SystemCapability.Communication.Bluetooth.Core 2104 * @since 12 2105 */ 2106 /** 2107 * User proactively removed device. 2108 * 2109 * @syscap SystemCapability.Communication.Bluetooth.Core 2110 * @crossplatform 2111 * @since 13 2112 */ 2113 USER_REMOVED = 0, 2114 /** 2115 * Remote device shut down. 2116 * 2117 * @syscap SystemCapability.Communication.Bluetooth.Core 2118 * @since 12 2119 */ 2120 REMOTE_DEVICE_DOWN = 1, 2121 /** 2122 * Wrong PIN code. 2123 * 2124 * @syscap SystemCapability.Communication.Bluetooth.Core 2125 * @since 12 2126 */ 2127 AUTH_FAILURE = 2, 2128 /** 2129 * Remote device rejected. 2130 * 2131 * @syscap SystemCapability.Communication.Bluetooth.Core 2132 * @since 12 2133 */ 2134 AUTH_REJECTED = 3, 2135 /** 2136 * Internal error. 2137 * 2138 * @syscap SystemCapability.Communication.Bluetooth.Core 2139 * @since 12 2140 */ 2141 INTERNAL_ERROR = 4 2142 } 2143} 2144export default connection;