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 * Controls the actions of Bluetooth peripherals. 1171 * 1172 * @permission ohos.permission.ACCESS_BLUETOOTH and ohos.permission.MANAGE_BLUETOOTH 1173 * @param { ControlDeviceActionParams } controlDeviceActionParams - Indicates the action for Bluetooth peripherals. 1174 * @returns { Promise<void> } Returns the promise object. 1175 * @throws { BusinessError } 201 - Permission denied. 1176 * @throws { BusinessError } 202 - Non-system applications are not allowed to use system APIs. 1177 * @throws { BusinessError } 401 - Invalid parameter. Possible causes: 1. Mandatory parameters are left unspecified. 1178 * <br>2. Incorrect parameter types. 3. Parameter verification failed. 1179 * @throws { BusinessError } 801 - Capability not supported. 1180 * @throws { BusinessError } 2900001 - Service stopped. 1181 * @throws { BusinessError } 2900003 - Bluetooth disabled. 1182 * @throws { BusinessError } 2900099 - Operation failed. 1183 * @syscap SystemCapability.Communication.Bluetooth.Core 1184 * @systemapi 1185 * @since 15 1186 */ 1187 function controlDeviceAction(controlDeviceActionParams: ControlDeviceActionParams): Promise<void>; 1188 1189 /** 1190 * Get latest connection time of device. 1191 * 1192 * @param { string } deviceId - Indicates device ID. For example, "11:22:33:AA:BB:FF". 1193 * @returns { Promise<number> } Returns latest connection time. 1194 * @throws { BusinessError } 401 - Invalid parameter. Possible causes: 1. Mandatory parameters are left unspecified. 1195 * <br>2. Incorrect parameter types. 3. Parameter verification failed. 1196 * @throws { BusinessError } 801 - Capability not supported. 1197 * @throws { BusinessError } 2900001 - Service stopped. 1198 * @throws { BusinessError } 2900003 - Bluetooth disabled. 1199 * @throws { BusinessError } 2900099 - Operation failed. 1200 * @syscap SystemCapability.Communication.Bluetooth.Core 1201 * @since 15 1202 */ 1203 function getLastConnectionTime(deviceId: string): Promise<number>; 1204 1205 /** 1206 * update cloud devices. 1207 * 1208 * @permission ohos.permission.ACCESS_BLUETOOTH and ohos.permission.MANAGE_BLUETOOTH 1209 * @param { TrustedPairedDevices } trustedPairedDevices - Indicates the cloud devices. 1210 * @returns { Promise<void> } Returns the promise object. 1211 * @throws { BusinessError } 201 - Permission denied. 1212 * @throws { BusinessError } 202 - Non-system applications are not allowed to use system APIs. 1213 * @throws { BusinessError } 401 - Invalid parameter. Possible causes: 1. Mandatory parameters are left unspecified. 1214 * <br>2. Incorrect parameter types. 3. Parameter verification failed. 1215 * @throws { BusinessError } 801 - Capability not supported. 1216 * @throws { BusinessError } 2900001 - Service stopped. 1217 * @throws { BusinessError } 2900003 - Bluetooth disabled. 1218 * @throws { BusinessError } 2900099 - Operation failed. 1219 * @syscap SystemCapability.Communication.Bluetooth.Core 1220 * @systemapi 1221 * @since 15 1222 */ 1223 function updateCloudBluetoothDevice(trustedPairedDevices: TrustedPairedDevices): Promise<void>; 1224 1225 /** 1226 * Subscribe the event reported when a remote Bluetooth device is discovered. 1227 * 1228 * @permission ohos.permission.ACCESS_BLUETOOTH 1229 * @param { 'bluetoothDeviceFind' } type - Type of the discovering event to listen for. 1230 * @param { Callback<Array<string>> } callback - Callback used to listen for the discovering event. 1231 * @throws { BusinessError } 201 - Permission denied. 1232 * @throws { BusinessError } 401 - Invalid parameter. Possible causes: 1. Mandatory parameters are left unspecified. 1233 * <br>2. Incorrect parameter types. 3. Parameter verification failed. 1234 * @throws { BusinessError } 801 - Capability not supported. 1235 * @throws { BusinessError } 2900099 - Operation failed. 1236 * @syscap SystemCapability.Communication.Bluetooth.Core 1237 * @since 10 1238 */ 1239 /** 1240 * Subscribe the event reported when a remote Bluetooth device is discovered. 1241 * 1242 * @permission ohos.permission.ACCESS_BLUETOOTH 1243 * @param { 'bluetoothDeviceFind' } type - Type of the discovering event to listen for. 1244 * @param { Callback<Array<string>> } callback - Callback used to listen for the discovering event. 1245 * @throws { BusinessError } 201 - Permission denied. 1246 * @throws { BusinessError } 401 - Invalid parameter. Possible causes: 1. Mandatory parameters are left unspecified. 1247 * <br>2. Incorrect parameter types. 3. Parameter verification failed. 1248 * @throws { BusinessError } 801 - Capability not supported. 1249 * @throws { BusinessError } 2900099 - Operation failed. 1250 * @syscap SystemCapability.Communication.Bluetooth.Core 1251 * @atomicservice 1252 * @since 12 1253 */ 1254 /** 1255 * Subscribe the event reported when a remote Bluetooth device is discovered. 1256 * 1257 * @permission ohos.permission.ACCESS_BLUETOOTH 1258 * @param { 'bluetoothDeviceFind' } type - Type of the discovering event to listen for. 1259 * @param { Callback<Array<string>> } callback - Callback used to listen for the discovering event. 1260 * @throws { BusinessError } 201 - Permission denied. 1261 * @throws { BusinessError } 401 - Invalid parameter. Possible causes: 1. Mandatory parameters are left unspecified. 1262 * <br>2. Incorrect parameter types. 3. Parameter verification failed. 1263 * @throws { BusinessError } 801 - Capability not supported. 1264 * @throws { BusinessError } 2900099 - Operation failed. 1265 * @syscap SystemCapability.Communication.Bluetooth.Core 1266 * @crossplatform 1267 * @atomicservice 1268 * @since 13 1269 */ 1270 function on(type: 'bluetoothDeviceFind', callback: Callback<Array<string>>): void; 1271 1272 /** 1273 * Unsubscribe the event reported when a remote Bluetooth device is discovered. 1274 * 1275 * @permission ohos.permission.ACCESS_BLUETOOTH 1276 * @param { 'bluetoothDeviceFind' } type - Type of the discovering event to listen for. 1277 * @param { Callback<Array<string>> } callback - Callback used to listen for the discovering event. 1278 * @throws { BusinessError } 201 - Permission denied. 1279 * @throws { BusinessError } 801 - Capability not supported. 1280 * @throws { BusinessError } 2900099 - Operation failed. 1281 * @syscap SystemCapability.Communication.Bluetooth.Core 1282 * @since 10 1283 */ 1284 /** 1285 * Unsubscribe the event reported when a remote Bluetooth device is discovered. 1286 * 1287 * @permission ohos.permission.ACCESS_BLUETOOTH 1288 * @param { 'bluetoothDeviceFind' } type - Type of the discovering event to listen for. 1289 * @param { Callback<Array<string>> } callback - Callback used to listen for the discovering event. 1290 * @throws { BusinessError } 201 - Permission denied. 1291 * @throws { BusinessError } 801 - Capability not supported. 1292 * @throws { BusinessError } 2900099 - Operation failed. 1293 * @syscap SystemCapability.Communication.Bluetooth.Core 1294 * @atomicservice 1295 * @since 12 1296 */ 1297 /** 1298 * Unsubscribe the event reported when a remote Bluetooth device is discovered. 1299 * 1300 * @permission ohos.permission.ACCESS_BLUETOOTH 1301 * @param { 'bluetoothDeviceFind' } type - Type of the discovering event to listen for. 1302 * @param { Callback<Array<string>> } callback - Callback used to listen for the discovering event. 1303 * @throws { BusinessError } 201 - Permission denied. 1304 * @throws { BusinessError } 801 - Capability not supported. 1305 * @throws { BusinessError } 2900099 - Operation failed. 1306 * @syscap SystemCapability.Communication.Bluetooth.Core 1307 * @crossplatform 1308 * @atomicservice 1309 * @since 13 1310 */ 1311 function off(type: 'bluetoothDeviceFind', callback?: Callback<Array<string>>): void; 1312 1313 /** 1314 * Subscribe the event reported when a remote Bluetooth device is discovered. 1315 * 1316 * @permission ohos.permission.ACCESS_BLUETOOTH and ohos.permission.GET_BLUETOOTH_PEERS_MAC 1317 * @param { 'discoveryResult' } type - Type of the discovering event to listen for. 1318 * @param { Callback<Array<DiscoveryResult>> } callback - Callback used to listen for the discovering event. 1319 * @throws { BusinessError } 201 - Permission denied. 1320 * @throws { BusinessError } 401 - Invalid parameter. Possible causes: 1. Mandatory parameters are left unspecified. 1321 * <br>2. Incorrect parameter types. 3. Parameter verification failed. 1322 * @throws { BusinessError } 801 - Capability not supported. 1323 * @throws { BusinessError } 2900099 - Operation failed. 1324 * @syscap SystemCapability.Communication.Bluetooth.Core 1325 * @systemapi 1326 * @since 12 1327 */ 1328 function on(type: 'discoveryResult', callback: Callback<Array<DiscoveryResult>>): void; 1329 1330 /** 1331 * Unsubscribe the event reported when a remote Bluetooth device is discovered. 1332 * 1333 * @permission ohos.permission.ACCESS_BLUETOOTH and ohos.permission.GET_BLUETOOTH_PEERS_MAC 1334 * @param { 'discoveryResult' } type - Type of the discovering event to listen for. 1335 * @param { Callback<Array<DiscoveryResult>> } callback - Callback used to listen for the discovering event. 1336 * @throws { BusinessError } 201 - Permission denied. 1337 * @throws { BusinessError } 801 - Capability not supported. 1338 * @throws { BusinessError } 2900099 - Operation failed. 1339 * @syscap SystemCapability.Communication.Bluetooth.Core 1340 * @systemapi 1341 * @since 12 1342 */ 1343 function off(type: 'discoveryResult', callback?: Callback<Array<DiscoveryResult>>): void; 1344 1345 /** 1346 * Subscribe the event reported when a remote Bluetooth device is bonded. 1347 * 1348 * @permission ohos.permission.ACCESS_BLUETOOTH 1349 * @param { 'bondStateChange' } type - Type of the bond state event to listen for. 1350 * @param { Callback<BondStateParam> } callback - Callback used to listen for the bond state event. 1351 * @throws { BusinessError } 201 - Permission denied. 1352 * @throws { BusinessError } 401 - Invalid parameter. Possible causes: 1. Mandatory parameters are left unspecified. 1353 * <br>2. Incorrect parameter types. 3. Parameter verification failed. 1354 * @throws { BusinessError } 801 - Capability not supported. 1355 * @throws { BusinessError } 2900099 - Operation failed. 1356 * @syscap SystemCapability.Communication.Bluetooth.Core 1357 * @since 10 1358 */ 1359 /** 1360 * Subscribe the event reported when a remote Bluetooth device is bonded. 1361 * 1362 * @permission ohos.permission.ACCESS_BLUETOOTH 1363 * @param { 'bondStateChange' } type - Type of the bond state event to listen for. 1364 * @param { Callback<BondStateParam> } callback - Callback used to listen for the bond state event. 1365 * @throws { BusinessError } 201 - Permission denied. 1366 * @throws { BusinessError } 401 - Invalid parameter. Possible causes: 1. Mandatory parameters are left unspecified. 1367 * <br>2. Incorrect parameter types. 3. Parameter verification failed. 1368 * @throws { BusinessError } 801 - Capability not supported. 1369 * @throws { BusinessError } 2900099 - Operation failed. 1370 * @syscap SystemCapability.Communication.Bluetooth.Core 1371 * @crossplatform 1372 * @since 13 1373 */ 1374 function on(type: 'bondStateChange', callback: Callback<BondStateParam>): void; 1375 1376 /** 1377 * Unsubscribe the event reported when a remote Bluetooth device is bonded. 1378 * 1379 * @permission ohos.permission.ACCESS_BLUETOOTH 1380 * @param { 'bondStateChange' } type - Type of the bond state event to listen for. 1381 * @param { Callback<BondStateParam> } callback - Callback used to listen for the bond state event. 1382 * @throws { BusinessError } 201 - Permission denied. 1383 * @throws { BusinessError } 401 - Invalid parameter. Possible causes: 1. Mandatory parameters are left unspecified. 1384 * <br>2. Incorrect parameter types. 3. Parameter verification failed. 1385 * @throws { BusinessError } 801 - Capability not supported. 1386 * @throws { BusinessError } 2900099 - Operation failed. 1387 * @syscap SystemCapability.Communication.Bluetooth.Core 1388 * @since 10 1389 */ 1390 /** 1391 * Unsubscribe the event reported when a remote Bluetooth device is bonded. 1392 * 1393 * @permission ohos.permission.ACCESS_BLUETOOTH 1394 * @param { 'bondStateChange' } type - Type of the bond state event to listen for. 1395 * @param { Callback<BondStateParam> } callback - Callback used to listen for the bond state event. 1396 * @throws { BusinessError } 201 - Permission denied. 1397 * @throws { BusinessError } 401 - Invalid parameter. Possible causes: 1. Mandatory parameters are left unspecified. 1398 * <br>2. Incorrect parameter types. 3. Parameter verification failed. 1399 * @throws { BusinessError } 801 - Capability not supported. 1400 * @throws { BusinessError } 2900099 - Operation failed. 1401 * @syscap SystemCapability.Communication.Bluetooth.Core 1402 * @crossplatform 1403 * @since 13 1404 */ 1405 function off(type: 'bondStateChange', callback?: Callback<BondStateParam>): void; 1406 1407 /** 1408 * Subscribe the event of a pairing request from a remote Bluetooth device. 1409 * 1410 * @permission ohos.permission.ACCESS_BLUETOOTH 1411 * @param { 'pinRequired' } type - Type of the pairing request event to listen for. 1412 * @param { Callback<PinRequiredParam> } callback - Callback used to listen for the pairing request event. 1413 * @throws { BusinessError } 201 - Permission denied. 1414 * @throws { BusinessError } 401 - Invalid parameter. Possible causes: 1. Mandatory parameters are left unspecified. 1415 * <br>2. Incorrect parameter types. 3. Parameter verification failed. 1416 * @throws { BusinessError } 801 - Capability not supported. 1417 * @throws { BusinessError } 2900099 - Operation failed. 1418 * @syscap SystemCapability.Communication.Bluetooth.Core 1419 * @since 10 1420 */ 1421 function on(type: 'pinRequired', callback: Callback<PinRequiredParam>): void; 1422 1423 /** 1424 * Unsubscribe the event of a pairing request from a remote Bluetooth device. 1425 * 1426 * @permission ohos.permission.ACCESS_BLUETOOTH 1427 * @param { 'pinRequired' } type - Type of the pairing request event to listen for. 1428 * @param { Callback<PinRequiredParam> } callback - Callback used to listen for the pairing request event. 1429 * @throws { BusinessError } 201 - Permission denied. 1430 * @throws { BusinessError } 401 - Invalid parameter. Possible causes: 1. Mandatory parameters are left unspecified. 1431 * <br>2. Incorrect parameter types. 3. Parameter verification failed. 1432 * @throws { BusinessError } 801 - Capability not supported. 1433 * @throws { BusinessError } 2900099 - Operation failed. 1434 * @syscap SystemCapability.Communication.Bluetooth.Core 1435 * @since 10 1436 */ 1437 function off(type: 'pinRequired', callback?: Callback<PinRequiredParam>): void; 1438 1439 /** 1440 * Subscribe the event of battery state changed from a remote device. 1441 * 1442 * @permission ohos.permission.ACCESS_BLUETOOTH 1443 * @param { 'batteryChange' } type - Type of the battery event to listen for. 1444 * @param { Callback<BatteryInfo> } callback - Callback used to listen. 1445 * @throws { BusinessError } 201 - Permission denied. 1446 * @throws { BusinessError } 2900099 - Operation failed. 1447 * @syscap SystemCapability.Communication.Bluetooth.Core 1448 * @since 12 1449 */ 1450 function on(type: 'batteryChange', callback: Callback<BatteryInfo>): void; 1451 1452 /** 1453 * Unsubscribe the event of battery state changed from a remote device. 1454 * 1455 * @permission ohos.permission.ACCESS_BLUETOOTH 1456 * @param { 'batteryChange' } type - Type of the battery event to listen for. 1457 * @param { Callback<BatteryInfo> } callback - Callback used to listen. 1458 * @throws { BusinessError } 201 - Permission denied. 1459 * @throws { BusinessError } 2900099 - Operation failed. 1460 * @syscap SystemCapability.Communication.Bluetooth.Core 1461 * @since 12 1462 */ 1463 function off(type: 'batteryChange', callback?: Callback<BatteryInfo>): void; 1464 1465 /** 1466 * Describes the class of a bluetooth device. 1467 * 1468 * @typedef BondStateParam 1469 * @syscap SystemCapability.Communication.Bluetooth.Core 1470 * @since 10 1471 */ 1472 /** 1473 * Describes the class of a bluetooth device. 1474 * 1475 * @typedef BondStateParam 1476 * @syscap SystemCapability.Communication.Bluetooth.Core 1477 * @crossplatform 1478 * @since 13 1479 */ 1480 interface BondStateParam { 1481 /** 1482 * Address of a Bluetooth device. 1483 * 1484 * @type { string } 1485 * @syscap SystemCapability.Communication.Bluetooth.Core 1486 * @since 10 1487 */ 1488 /** 1489 * Address of a Bluetooth device. 1490 * 1491 * @type { string } 1492 * @syscap SystemCapability.Communication.Bluetooth.Core 1493 * @crossplatform 1494 * @since 13 1495 */ 1496 deviceId: string; 1497 /** 1498 * Profile connection state of the device. 1499 * 1500 * @type { BondState } 1501 * @syscap SystemCapability.Communication.Bluetooth.Core 1502 * @since 10 1503 */ 1504 /** 1505 * Profile connection state of the device. 1506 * 1507 * @type { BondState } 1508 * @syscap SystemCapability.Communication.Bluetooth.Core 1509 * @crossplatform 1510 * @since 13 1511 */ 1512 state: BondState; 1513 /** 1514 * Cause of unbond. 1515 * 1516 * @type { UnbondCause } 1517 * @syscap SystemCapability.Communication.Bluetooth.Core 1518 * @since 12 1519 */ 1520 /** 1521 * Cause of unbond. 1522 * 1523 * @type { UnbondCause } 1524 * @syscap SystemCapability.Communication.Bluetooth.Core 1525 * @crossplatform 1526 * @since 13 1527 */ 1528 cause: UnbondCause; 1529 } 1530 1531 /** 1532 * Describes the bond key param. 1533 * 1534 * @typedef PinRequiredParam 1535 * @syscap SystemCapability.Communication.Bluetooth.Core 1536 * @since 10 1537 */ 1538 interface PinRequiredParam { 1539 /** 1540 * ID of the device to pair. 1541 * 1542 * @type { string } 1543 * @syscap SystemCapability.Communication.Bluetooth.Core 1544 * @since 10 1545 */ 1546 deviceId: string; 1547 /** 1548 * Key for the device pairing. 1549 * 1550 * @type { string } 1551 * @syscap SystemCapability.Communication.Bluetooth.Core 1552 * @since 10 1553 */ 1554 pinCode: string; 1555 /** 1556 * Indicates the pairing type to a peer device. 1557 * 1558 * @type { PinType } 1559 * @syscap SystemCapability.Communication.Bluetooth.Core 1560 * @systemapi 1561 * @since 10 1562 */ 1563 pinType: PinType; 1564 } 1565 1566 /** 1567 * Describes the class of a bluetooth device. 1568 * 1569 * @typedef DeviceClass 1570 * @syscap SystemCapability.Communication.Bluetooth.Core 1571 * @since 10 1572 */ 1573 /** 1574 * Describes the class of a bluetooth device. 1575 * 1576 * @typedef DeviceClass 1577 * @syscap SystemCapability.Communication.Bluetooth.Core 1578 * @crossplatform 1579 * @since 13 1580 */ 1581 interface DeviceClass { 1582 /** 1583 * Major classes of Bluetooth devices. 1584 * 1585 * @type { MajorClass } 1586 * @syscap SystemCapability.Communication.Bluetooth.Core 1587 * @since 10 1588 */ 1589 /** 1590 * Major classes of Bluetooth devices. 1591 * 1592 * @type { MajorClass } 1593 * @syscap SystemCapability.Communication.Bluetooth.Core 1594 * @crossplatform 1595 * @since 13 1596 */ 1597 majorClass: MajorClass; 1598 /** 1599 * Major and minor classes of Bluetooth devices. 1600 * 1601 * @type { MajorMinorClass } 1602 * @syscap SystemCapability.Communication.Bluetooth.Core 1603 * @since 10 1604 */ 1605 /** 1606 * Major and minor classes of Bluetooth devices. 1607 * 1608 * @type { MajorMinorClass } 1609 * @syscap SystemCapability.Communication.Bluetooth.Core 1610 * @crossplatform 1611 * @since 13 1612 */ 1613 majorMinorClass: MajorMinorClass; 1614 /** 1615 * Class of the device. 1616 * 1617 * @type { number } 1618 * @syscap SystemCapability.Communication.Bluetooth.Core 1619 * @since 10 1620 */ 1621 /** 1622 * Class of the device. 1623 * 1624 * @type { number } 1625 * @syscap SystemCapability.Communication.Bluetooth.Core 1626 * @crossplatform 1627 * @since 13 1628 */ 1629 classOfDevice: number; 1630 } 1631 1632 /** 1633 * Enum for the transport of a remote device 1634 * 1635 * @enum { number } 1636 * @syscap SystemCapability.Communication.Bluetooth.Core 1637 * @since 10 1638 */ 1639 enum BluetoothTransport { 1640 /** 1641 * The value of bluetooth transport BR/EDR. 1642 * 1643 * @syscap SystemCapability.Communication.Bluetooth.Core 1644 * @since 10 1645 */ 1646 TRANSPORT_BR_EDR = 0, 1647 /** 1648 * The value of bluetooth transport LE. 1649 * 1650 * @syscap SystemCapability.Communication.Bluetooth.Core 1651 * @since 10 1652 */ 1653 TRANSPORT_LE = 1 1654 } 1655 1656 /** 1657 * The enum of BR scan mode. 1658 * 1659 * @enum { number } 1660 * @syscap SystemCapability.Communication.Bluetooth.Core 1661 * @since 10 1662 */ 1663 /** 1664 * The enum of BR scan mode. 1665 * 1666 * @enum { number } 1667 * @syscap SystemCapability.Communication.Bluetooth.Core 1668 * @crossplatform 1669 * @since 13 1670 */ 1671 enum ScanMode { 1672 /** 1673 * Indicates the scan mode is none 1674 * 1675 * @syscap SystemCapability.Communication.Bluetooth.Core 1676 * @since 10 1677 */ 1678 /** 1679 * Indicates the scan mode is none 1680 * 1681 * @syscap SystemCapability.Communication.Bluetooth.Core 1682 * @crossplatform 1683 * @since 13 1684 */ 1685 SCAN_MODE_NONE = 0, 1686 /** 1687 * Indicates the scan mode is connectable 1688 * 1689 * @syscap SystemCapability.Communication.Bluetooth.Core 1690 * @since 10 1691 */ 1692 /** 1693 * Indicates the scan mode is connectable 1694 * 1695 * @syscap SystemCapability.Communication.Bluetooth.Core 1696 * @crossplatform 1697 * @since 13 1698 */ 1699 SCAN_MODE_CONNECTABLE = 1, 1700 /** 1701 * Indicates the scan mode is general discoverable 1702 * 1703 * @syscap SystemCapability.Communication.Bluetooth.Core 1704 * @since 10 1705 */ 1706 SCAN_MODE_GENERAL_DISCOVERABLE = 2, 1707 /** 1708 * Indicates the scan mode is limited discoverable 1709 * 1710 * @syscap SystemCapability.Communication.Bluetooth.Core 1711 * @since 10 1712 */ 1713 SCAN_MODE_LIMITED_DISCOVERABLE = 3, 1714 /** 1715 * Indicates the scan mode is connectable and general discoverable 1716 * 1717 * @syscap SystemCapability.Communication.Bluetooth.Core 1718 * @since 10 1719 */ 1720 /** 1721 * Indicates the scan mode is connectable and general discoverable 1722 * 1723 * @syscap SystemCapability.Communication.Bluetooth.Core 1724 * @crossplatform 1725 * @since 13 1726 */ 1727 SCAN_MODE_CONNECTABLE_GENERAL_DISCOVERABLE = 4, 1728 /** 1729 * Indicates the scan mode is connectable and limited discoverable 1730 * 1731 * @syscap SystemCapability.Communication.Bluetooth.Core 1732 * @since 10 1733 */ 1734 SCAN_MODE_CONNECTABLE_LIMITED_DISCOVERABLE = 5 1735 } 1736 1737 /** 1738 * The enum of bond state. 1739 * 1740 * @enum { number } 1741 * @syscap SystemCapability.Communication.Bluetooth.Core 1742 * @since 10 1743 */ 1744 /** 1745 * The enum of bond state. 1746 * 1747 * @enum { number } 1748 * @syscap SystemCapability.Communication.Bluetooth.Core 1749 * @atomicservice 1750 * @since 12 1751 */ 1752 /** 1753 * The enum of bond state. 1754 * 1755 * @enum { number } 1756 * @syscap SystemCapability.Communication.Bluetooth.Core 1757 * @crossplatform 1758 * @atomicservice 1759 * @since 13 1760 */ 1761 enum BondState { 1762 /** 1763 * Indicate the bond state is invalid 1764 * 1765 * @syscap SystemCapability.Communication.Bluetooth.Core 1766 * @since 10 1767 */ 1768 /** 1769 * Indicate the bond state is invalid 1770 * 1771 * @syscap SystemCapability.Communication.Bluetooth.Core 1772 * @atomicservice 1773 * @since 12 1774 */ 1775 /** 1776 * Indicate the bond state is invalid 1777 * 1778 * @syscap SystemCapability.Communication.Bluetooth.Core 1779 * @crossplatform 1780 * @atomicservice 1781 * @since 13 1782 */ 1783 BOND_STATE_INVALID = 0, 1784 /** 1785 * Indicate the bond state is bonding 1786 * 1787 * @syscap SystemCapability.Communication.Bluetooth.Core 1788 * @since 10 1789 */ 1790 /** 1791 * Indicate the bond state is bonding 1792 * 1793 * @syscap SystemCapability.Communication.Bluetooth.Core 1794 * @atomicservice 1795 * @since 12 1796 */ 1797 /** 1798 * Indicate the bond state is bonding 1799 * 1800 * @syscap SystemCapability.Communication.Bluetooth.Core 1801 * @crossplatform 1802 * @atomicservice 1803 * @since 13 1804 */ 1805 BOND_STATE_BONDING = 1, 1806 /** 1807 * Indicate the bond state is bonded 1808 * 1809 * @syscap SystemCapability.Communication.Bluetooth.Core 1810 * @since 10 1811 */ 1812 /** 1813 * Indicate the bond state is bonded 1814 * 1815 * @syscap SystemCapability.Communication.Bluetooth.Core 1816 * @atomicservice 1817 * @since 12 1818 */ 1819 /** 1820 * Indicate the bond state is bonded 1821 * 1822 * @syscap SystemCapability.Communication.Bluetooth.Core 1823 * @crossplatform 1824 * @atomicservice 1825 * @since 13 1826 */ 1827 BOND_STATE_BONDED = 2 1828 } 1829 1830 /** 1831 * Enum for the type of pairing to a remote device 1832 * 1833 * @enum { number } 1834 * @syscap SystemCapability.Communication.Bluetooth.Core 1835 * @systemapi 1836 * @since 10 1837 */ 1838 enum PinType { 1839 /** 1840 * The user needs to enter the pin code displayed on the peer device. 1841 * 1842 * @syscap SystemCapability.Communication.Bluetooth.Core 1843 * @systemapi 1844 * @since 10 1845 */ 1846 PIN_TYPE_ENTER_PIN_CODE = 0, 1847 /** 1848 * The user needs to enter the passkey displayed on the peer device. 1849 * 1850 * @syscap SystemCapability.Communication.Bluetooth.Core 1851 * @systemapi 1852 * @since 10 1853 */ 1854 PIN_TYPE_ENTER_PASSKEY = 1, 1855 /** 1856 * The user needs to confirm the passkey displayed on the local device. 1857 * 1858 * @syscap SystemCapability.Communication.Bluetooth.Core 1859 * @systemapi 1860 * @since 10 1861 */ 1862 PIN_TYPE_CONFIRM_PASSKEY = 2, 1863 /** 1864 * The user needs to accept or deny the pairing request. 1865 * 1866 * @syscap SystemCapability.Communication.Bluetooth.Core 1867 * @systemapi 1868 * @since 10 1869 */ 1870 PIN_TYPE_NO_PASSKEY_CONSENT = 3, 1871 /** 1872 * The user needs to enter the passkey displayed on the local device on the peer device. 1873 * 1874 * @syscap SystemCapability.Communication.Bluetooth.Core 1875 * @systemapi 1876 * @since 10 1877 */ 1878 PIN_TYPE_NOTIFY_PASSKEY = 4, 1879 /** 1880 * The user needs to enter the pin code displayed on the peer device, used for bluetooth 2.0. 1881 * 1882 * @syscap SystemCapability.Communication.Bluetooth.Core 1883 * @systemapi 1884 * @since 10 1885 */ 1886 PIN_TYPE_DISPLAY_PIN_CODE = 5, 1887 /** 1888 * The user needs to accept or deny the OOB pairing request. 1889 * 1890 * @syscap SystemCapability.Communication.Bluetooth.Core 1891 * @systemapi 1892 * @since 10 1893 */ 1894 PIN_TYPE_OOB_CONSENT = 6, 1895 /** 1896 * The user needs to enter the 16-digit pin code displayed on the peer device. 1897 * 1898 * @syscap SystemCapability.Communication.Bluetooth.Core 1899 * @systemapi 1900 * @since 10 1901 */ 1902 PIN_TYPE_PIN_16_DIGITS = 7 1903 } 1904 1905 /** 1906 * Describes the contents of the discovery results 1907 * 1908 * @typedef DiscoveryResult 1909 * @syscap SystemCapability.Communication.Bluetooth.Core 1910 * @systemapi 1911 * @since 12 1912 */ 1913 interface DiscoveryResult { 1914 /** 1915 * Identify of the discovery device 1916 * 1917 * @type { string } 1918 * @syscap SystemCapability.Communication.Bluetooth.Core 1919 * @systemapi 1920 * @since 12 1921 */ 1922 deviceId: string; 1923 /** 1924 * RSSI of the remote device 1925 * 1926 * @type { number } 1927 * @syscap SystemCapability.Communication.Bluetooth.Core 1928 * @systemapi 1929 * @since 12 1930 */ 1931 rssi: number; 1932 /** 1933 * The local name of the device 1934 * 1935 * @type { string } 1936 * @syscap SystemCapability.Communication.Bluetooth.Core 1937 * @systemapi 1938 * @since 12 1939 */ 1940 deviceName: string; 1941 /** 1942 * The class of the device 1943 * 1944 * @type { DeviceClass } 1945 * @syscap SystemCapability.Communication.Bluetooth.Core 1946 * @systemapi 1947 * @since 12 1948 */ 1949 deviceClass: DeviceClass; 1950 } 1951 1952 /** 1953 * Describes the contents of the battery information. 1954 * 1955 * @typedef BatteryInfo 1956 * @syscap SystemCapability.Communication.Bluetooth.Core 1957 * @since 12 1958 */ 1959 interface BatteryInfo { 1960 /** 1961 * Identify of the discovery device. 1962 * 1963 * @type { string } 1964 * @syscap SystemCapability.Communication.Bluetooth.Core 1965 * @systemapi 1966 * @since 12 1967 */ 1968 deviceId: string; 1969 /** 1970 * Electricity value of the general device. {@code -1} means no power information. 1971 * 1972 * @type { number } 1973 * @syscap SystemCapability.Communication.Bluetooth.Core 1974 * @since 12 1975 */ 1976 batteryLevel: number; 1977 /** 1978 * Electricity value of the left ear. {@code -1} means no power information. 1979 * 1980 * @type { number } 1981 * @syscap SystemCapability.Communication.Bluetooth.Core 1982 * @since 12 1983 */ 1984 leftEarBatteryLevel: number; 1985 /** 1986 * The charge state of the left ear. 1987 * 1988 * @type { DeviceChargeState } 1989 * @syscap SystemCapability.Communication.Bluetooth.Core 1990 * @since 12 1991 */ 1992 leftEarChargeState: DeviceChargeState; 1993 /** 1994 * Electricity value of the right ear. {@code -1} means no power information. 1995 * 1996 * @type { number } 1997 * @syscap SystemCapability.Communication.Bluetooth.Core 1998 * @since 12 1999 */ 2000 rightEarBatteryLevel: number; 2001 /** 2002 * The charge state of the right ear. 2003 * 2004 * @type { DeviceChargeState } 2005 * @syscap SystemCapability.Communication.Bluetooth.Core 2006 * @since 12 2007 */ 2008 rightEarChargeState: DeviceChargeState; 2009 /** 2010 * Electricity value of the box. {@code -1} means no power information. 2011 * 2012 * @type { number } 2013 * @syscap SystemCapability.Communication.Bluetooth.Core 2014 * @since 12 2015 */ 2016 boxBatteryLevel: number; 2017 /** 2018 * The charge state of the box. 2019 * 2020 * @type { DeviceChargeState } 2021 * @syscap SystemCapability.Communication.Bluetooth.Core 2022 * @since 12 2023 */ 2024 boxChargeState: DeviceChargeState; 2025 } 2026 2027 /** 2028 * Enum for the charge state. 2029 * 2030 * @enum { number } 2031 * @syscap SystemCapability.Communication.Bluetooth.Core 2032 * @since 12 2033 */ 2034 enum DeviceChargeState { 2035 /** 2036 * Not support super charge, and not charged. 2037 * 2038 * @syscap SystemCapability.Communication.Bluetooth.Core 2039 * @since 12 2040 */ 2041 DEVICE_NORMAL_CHARGE_NOT_CHARGED = 0, 2042 /** 2043 * Not support super charge, and in charging. 2044 * 2045 * @syscap SystemCapability.Communication.Bluetooth.Core 2046 * @since 12 2047 */ 2048 DEVICE_NORMAL_CHARGE_IN_CHARGING = 1, 2049 /** 2050 * Support super charge, and not charged. 2051 * 2052 * @syscap SystemCapability.Communication.Bluetooth.Core 2053 * @since 12 2054 */ 2055 DEVICE_SUPER_CHARGE_NOT_CHARGED = 2, 2056 /** 2057 * Support super charge, and in charging. 2058 * 2059 * @syscap SystemCapability.Communication.Bluetooth.Core 2060 * @since 12 2061 */ 2062 DEVICE_SUPER_CHARGE_IN_CHARGING = 3 2063 } 2064 2065 /** 2066 * Enum for the custom type of remote device. 2067 * 2068 * @enum { number } 2069 * @syscap SystemCapability.Communication.Bluetooth.Core 2070 * @systemapi 2071 * @since 12 2072 */ 2073 enum DeviceType { 2074 /** 2075 * Default type, the type is consistent with COD. 2076 * 2077 * @syscap SystemCapability.Communication.Bluetooth.Core 2078 * @systemapi 2079 * @since 12 2080 */ 2081 DEVICE_TYPE_DEFAULT = 0, 2082 /** 2083 * Car bluetooth. 2084 * 2085 * @syscap SystemCapability.Communication.Bluetooth.Core 2086 * @systemapi 2087 * @since 12 2088 */ 2089 DEVICE_TYPE_CAR = 1, 2090 /** 2091 * Headset bluetooth. 2092 * 2093 * @syscap SystemCapability.Communication.Bluetooth.Core 2094 * @systemapi 2095 * @since 12 2096 */ 2097 DEVICE_TYPE_HEADSET = 2, 2098 /** 2099 * Hearing Aid. 2100 * 2101 * @syscap SystemCapability.Communication.Bluetooth.Core 2102 * @systemapi 2103 * @since 12 2104 */ 2105 DEVICE_TYPE_HEARING = 3, 2106 /** 2107 * Glasses device. 2108 * 2109 * @syscap SystemCapability.Communication.Bluetooth.Core 2110 * @systemapi 2111 * @since 12 2112 */ 2113 DEVICE_TYPE_GLASSES = 4, 2114 /** 2115 * Watch device. 2116 * 2117 * @syscap SystemCapability.Communication.Bluetooth.Core 2118 * @systemapi 2119 * @since 12 2120 */ 2121 DEVICE_TYPE_WATCH = 5, 2122 /** 2123 * Speaker device. 2124 * 2125 * @syscap SystemCapability.Communication.Bluetooth.Core 2126 * @systemapi 2127 * @since 12 2128 */ 2129 DEVICE_TYPE_SPEAKER = 6, 2130 /** 2131 * Others bluetooth. 2132 * 2133 * @syscap SystemCapability.Communication.Bluetooth.Core 2134 * @systemapi 2135 * @since 12 2136 */ 2137 DEVICE_TYPE_OTHERS = 7 2138 } 2139 2140 /** 2141 * Enum for cause of unbond. 2142 * 2143 * @enum { number } 2144 * @syscap SystemCapability.Communication.Bluetooth.Core 2145 * @since 12 2146 */ 2147 /** 2148 * Enum for cause of unbond. 2149 * 2150 * @enum { number } 2151 * @syscap SystemCapability.Communication.Bluetooth.Core 2152 * @crossplatform 2153 * @since 13 2154 */ 2155 enum UnbondCause { 2156 /** 2157 * User proactively removed device. 2158 * 2159 * @syscap SystemCapability.Communication.Bluetooth.Core 2160 * @since 12 2161 */ 2162 /** 2163 * User proactively removed device. 2164 * 2165 * @syscap SystemCapability.Communication.Bluetooth.Core 2166 * @crossplatform 2167 * @since 13 2168 */ 2169 USER_REMOVED = 0, 2170 /** 2171 * Remote device shut down. 2172 * 2173 * @syscap SystemCapability.Communication.Bluetooth.Core 2174 * @since 12 2175 */ 2176 REMOTE_DEVICE_DOWN = 1, 2177 /** 2178 * Wrong PIN code. 2179 * 2180 * @syscap SystemCapability.Communication.Bluetooth.Core 2181 * @since 12 2182 */ 2183 AUTH_FAILURE = 2, 2184 /** 2185 * Remote device rejected. 2186 * 2187 * @syscap SystemCapability.Communication.Bluetooth.Core 2188 * @since 12 2189 */ 2190 AUTH_REJECTED = 3, 2191 /** 2192 * Internal error. 2193 * 2194 * @syscap SystemCapability.Communication.Bluetooth.Core 2195 * @since 12 2196 */ 2197 INTERNAL_ERROR = 4 2198 } 2199 /** 2200 * Describes information about controlling the Bluetooth peripheral. 2201 * 2202 * @typedef ControlDeviceActionParams 2203 * @syscap SystemCapability.Communication.Bluetooth.Core 2204 * @systemapi 2205 * @since 15 2206 */ 2207 interface ControlDeviceActionParams { 2208 /** 2209 * Indicates the address of the peripheral. 2210 * 2211 * @type { string } 2212 * @syscap SystemCapability.Communication.Bluetooth.Core 2213 * @systemapi 2214 * @since 15 2215 */ 2216 deviceId: string; 2217 /** 2218 * Indicates the control type. 2219 * 2220 * @type { ControlType } 2221 * @syscap SystemCapability.Communication.Bluetooth.Core 2222 * @systemapi 2223 * @since 15 2224 */ 2225 type: ControlType; 2226 /** 2227 * Indicates the control value. 2228 * 2229 * @type { ControlTypeValue } 2230 * @syscap SystemCapability.Communication.Bluetooth.Core 2231 * @systemapi 2232 * @since 15 2233 */ 2234 typeValue: ControlTypeValue; 2235 /** 2236 * Indicates the control object. 2237 * 2238 * @type { ControlObject } 2239 * @syscap SystemCapability.Communication.Bluetooth.Core 2240 * @systemapi 2241 * @since 15 2242 */ 2243 controlObject: ControlObject; 2244 } 2245 2246 /** 2247 * Describes the control type. 2248 * 2249 * @enum { number } 2250 * @syscap SystemCapability.Communication.Bluetooth.Core 2251 * @systemapi 2252 * @since 15 2253 */ 2254 enum ControlType { 2255 /** 2256 * Indicates the control command of play. 2257 * 2258 * @syscap SystemCapability.Communication.Bluetooth.Core 2259 * @systemapi 2260 * @since 15 2261 */ 2262 PLAY = 0, 2263 /** 2264 * Indicates the control command of vibration. 2265 * 2266 * @syscap SystemCapability.Communication.Bluetooth.Core 2267 * @systemapi 2268 * @since 15 2269 */ 2270 VIBRATE = 1, 2271 /** 2272 * Indicates the control command of flash. 2273 * 2274 * @syscap SystemCapability.Communication.Bluetooth.Core 2275 * @systemapi 2276 * @since 15 2277 */ 2278 FLASH = 2, 2279 /** 2280 * Indicates the control command of lock. 2281 * 2282 * @syscap SystemCapability.Communication.Bluetooth.Core 2283 * @systemapi 2284 * @since 15 2285 */ 2286 LOCK = 3, 2287 /** 2288 * Indicates the control command of erase. 2289 * 2290 * @syscap SystemCapability.Communication.Bluetooth.Core 2291 * @systemapi 2292 * @since 15 2293 */ 2294 ERASE = 4, 2295 } 2296 2297 /** 2298 * Describes the control type value. 2299 * 2300 * @enum { number } 2301 * @syscap SystemCapability.Communication.Bluetooth.Core 2302 * @systemapi 2303 * @since 15 2304 */ 2305 enum ControlTypeValue { 2306 /** 2307 * Indicates the action of disable. 2308 * 2309 * @syscap SystemCapability.Communication.Bluetooth.Core 2310 * @systemapi 2311 * @since 15 2312 */ 2313 DISABLE = 0, 2314 /** 2315 * Indicates the action of enable. 2316 * 2317 * @syscap SystemCapability.Communication.Bluetooth.Core 2318 * @systemapi 2319 * @since 15 2320 */ 2321 ENABLE = 1, 2322 /** 2323 * Indicates the action of query. 2324 * 2325 * @syscap SystemCapability.Communication.Bluetooth.Core 2326 * @systemapi 2327 * @since 15 2328 */ 2329 QUERY = 2, 2330 } 2331 2332 /** 2333 * Describes the control object. 2334 * 2335 * @enum { number } 2336 * @syscap SystemCapability.Communication.Bluetooth.Core 2337 * @systemapi 2338 * @since 15 2339 */ 2340 enum ControlObject { 2341 /** 2342 * Control object of left ear. 2343 * 2344 * @syscap SystemCapability.Communication.Bluetooth.Core 2345 * @systemapi 2346 * @since 15 2347 */ 2348 LEFT_EAR = 0, 2349 /** 2350 * Control object of right ear. 2351 * 2352 * @syscap SystemCapability.Communication.Bluetooth.Core 2353 * @systemapi 2354 * @since 15 2355 */ 2356 RIGHT_EAR = 1, 2357 /** 2358 * Control object of left and right ear. 2359 * 2360 * @syscap SystemCapability.Communication.Bluetooth.Core 2361 * @systemapi 2362 * @since 15 2363 */ 2364 LEFT_RIGHT_EAR = 2, 2365 } 2366 2367 /** 2368 * Describes the cloud pair device. 2369 * 2370 * @typedef TrustedPairedDevices 2371 * @syscap SystemCapability.Communication.Bluetooth.Core 2372 * @systemapi 2373 * @since 15 2374 */ 2375 interface TrustedPairedDevices { 2376 /** 2377 * The list of cloud pair devices. 2378 * 2379 * @type { Array<TrustedPairedDevice> } 2380 * @syscap SystemCapability.Communication.Bluetooth.Core 2381 * @systemapi 2382 * @since 15 2383 */ 2384 trustedPairedDevices: Array<TrustedPairedDevice>; 2385 } 2386 2387 /** 2388 * Describes device of cloud pair. 2389 * 2390 * @typedef TrustedPairedDevice 2391 * @syscap SystemCapability.Communication.Bluetooth.Core 2392 * @systemapi 2393 * @since 15 2394 */ 2395 interface TrustedPairedDevice { 2396 /** 2397 * Indicates the device identify. 2398 * 2399 * @type { string } 2400 * @syscap SystemCapability.Communication.Bluetooth.Core 2401 * @systemapi 2402 * @since 15 2403 */ 2404 sn: string; 2405 /** 2406 * Indicates the device type of the peripheral. 2407 * 2408 * @type { string } 2409 * @syscap SystemCapability.Communication.Bluetooth.Core 2410 * @systemapi 2411 * @since 15 2412 */ 2413 deviceType: string; 2414 /** 2415 * Indicates the modelId of the peripheral. 2416 * 2417 * @type { string } 2418 * @syscap SystemCapability.Communication.Bluetooth.Core 2419 * @systemapi 2420 * @since 15 2421 */ 2422 modelId: string; 2423 /** 2424 * Indicates the manufactory of the peripheral. 2425 * 2426 * @type { string } 2427 * @syscap SystemCapability.Communication.Bluetooth.Core 2428 * @systemapi 2429 * @since 15 2430 */ 2431 manufactory: string; 2432 /** 2433 * Indicates the productId of the peripheral. 2434 * 2435 * @type { string } 2436 * @syscap SystemCapability.Communication.Bluetooth.Core 2437 * @systemapi 2438 * @since 15 2439 */ 2440 productId: string; 2441 /** 2442 * Indicates the HiLink version of the peripheral. 2443 * 2444 * @type { string } 2445 * @syscap SystemCapability.Communication.Bluetooth.Core 2446 * @systemapi 2447 * @since 15 2448 */ 2449 hiLinkVersion: string; 2450 /** 2451 * Indicates the macAddress of the peripheral. 2452 * 2453 * @type { string } 2454 * @syscap SystemCapability.Communication.Bluetooth.Core 2455 * @systemapi 2456 * @since 15 2457 */ 2458 macAddress: string; 2459 /** 2460 * Indicates the service type of the peripheral. 2461 * 2462 * @type { string } 2463 * @syscap SystemCapability.Communication.Bluetooth.Core 2464 * @systemapi 2465 * @since 15 2466 */ 2467 serviceType: string; 2468 /** 2469 * Indicates the service id of the peripheral. 2470 * 2471 * @type { string } 2472 * @syscap SystemCapability.Communication.Bluetooth.Core 2473 * @systemapi 2474 * @since 15 2475 */ 2476 serviceId: string; 2477 /** 2478 * The local name of the device 2479 * 2480 * @type { string } 2481 * @syscap SystemCapability.Communication.Bluetooth.Core 2482 * @systemapi 2483 * @since 15 2484 */ 2485 deviceName: string; 2486 /** 2487 * Indicates the uuid of the peripheral. 2488 * 2489 * @type { string } 2490 * @syscap SystemCapability.Communication.Bluetooth.Core 2491 * @systemapi 2492 * @since 15 2493 */ 2494 uuids: string; 2495 /** 2496 * Indicates the bluetoothClass of the peripheral. 2497 * 2498 * @type { number } 2499 * @syscap SystemCapability.Communication.Bluetooth.Core 2500 * @systemapi 2501 * @since 15 2502 */ 2503 bluetoothClass: number; 2504 /** 2505 * Indicates the token of the peripheral. 2506 * 2507 * @type { ArrayBuffer } 2508 * @syscap SystemCapability.Communication.Bluetooth.Core 2509 * @systemapi 2510 * @since 15 2511 */ 2512 token: ArrayBuffer; 2513 /** 2514 * Indicates the deviceNameTime of the peripheral. 2515 * 2516 * @type { number } 2517 * @syscap SystemCapability.Communication.Bluetooth.Core 2518 * @systemapi 2519 * @since 15 2520 */ 2521 deviceNameTime: number; 2522 /** 2523 * Indicates the securityAdvInfo of the peripheral. 2524 * 2525 * @type { ArrayBuffer } 2526 * @syscap SystemCapability.Communication.Bluetooth.Core 2527 * @systemapi 2528 * @since 15 2529 */ 2530 secureAdvertisingInfo: ArrayBuffer; 2531 /** 2532 * Indicates the pairState of the peripheral. 2533 * 2534 * @type { number } 2535 * @syscap SystemCapability.Communication.Bluetooth.Core 2536 * @systemapi 2537 * @since 15 2538 */ 2539 pairState: number; 2540 } 2541} 2542export default connection;