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 arkts {'1.1':'13','1.2':'20'} 47 * @arkts 1.1&1.2 48 */ 49declare namespace connection { 50 /** 51 * Indicate the profile connection state. 52 * 53 * @typedef { constant.ProfileConnectionState } ProfileConnectionState 54 * @syscap SystemCapability.Communication.Bluetooth.Core 55 * @since 10 56 */ 57 /** 58 * Indicate the profile connection state. 59 * 60 * @typedef { constant.ProfileConnectionState } ProfileConnectionState 61 * @syscap SystemCapability.Communication.Bluetooth.Core 62 * @crossplatform 63 * @since 13 64 */ 65 type ProfileConnectionState = constant.ProfileConnectionState; 66 67 /** 68 * Indicate the profile id. 69 * 70 * @typedef { constant.ProfileId } ProfileId 71 * @syscap SystemCapability.Communication.Bluetooth.Core 72 * @since 10 73 */ 74 /** 75 * Indicate the profile id. 76 * 77 * @typedef { constant.ProfileId } ProfileId 78 * @syscap SystemCapability.Communication.Bluetooth.Core 79 * @crossplatform 80 * @since 13 81 */ 82 type ProfileId = constant.ProfileId; 83 84 /** 85 * Indicate the profile uuid. 86 * 87 * @typedef { constant.ProfileUuids } ProfileUuids 88 * @syscap SystemCapability.Communication.Bluetooth.Core 89 * @systemapi 90 * @since 10 91 */ 92 /** 93 * Indicate the profile uuid. 94 * 95 * @typedef { constant.ProfileUuids } ProfileUuids 96 * @syscap SystemCapability.Communication.Bluetooth.Core 97 * @since 12 98 */ 99 /** 100 * Indicate the profile uuid. 101 * 102 * @typedef { constant.ProfileUuids } ProfileUuids 103 * @syscap SystemCapability.Communication.Bluetooth.Core 104 * @crossplatform 105 * @since 13 106 */ 107 type ProfileUuids = constant.ProfileUuids; 108 109 /** 110 * Indicate the major class of a bluetooth device. 111 * 112 * @typedef { constant.MajorClass } MajorClass 113 * @syscap SystemCapability.Communication.Bluetooth.Core 114 * @since 10 115 */ 116 /** 117 * Indicate the major class of a bluetooth device. 118 * 119 * @typedef { constant.MajorClass } MajorClass 120 * @syscap SystemCapability.Communication.Bluetooth.Core 121 * @crossplatform 122 * @since arkts {'1.1':'13','1.2':'20'} 123 * @arkts 1.1&1.2 124 */ 125 type MajorClass = constant.MajorClass; 126 127 /** 128 * Indicate the major minor class of a bluetooth device. 129 * 130 * @typedef { constant.MajorMinorClass } MajorMinorClass 131 * @syscap SystemCapability.Communication.Bluetooth.Core 132 * @since 10 133 */ 134 /** 135 * Indicate the major minor class of a bluetooth device. 136 * 137 * @typedef { constant.MajorMinorClass } MajorMinorClass 138 * @syscap SystemCapability.Communication.Bluetooth.Core 139 * @crossplatform 140 * @since arkts {'1.1':'13','1.2':'20'} 141 * @arkts 1.1&1.2 142 */ 143 type MajorMinorClass = constant.MajorMinorClass; 144 145 /** 146 * Get the profile connection state of the current device. 147 * 148 * @permission ohos.permission.ACCESS_BLUETOOTH 149 * @param { ProfileId } [profileId] - Indicate the profile id. This is an optional parameter. 150 * With profileId, returns the current connection state of this profile, {@link ProfileConnectionState}. 151 * Without profileId, if any profile is connected, {@link ProfileConnectionState#STATE_CONNECTED} is returned. 152 * Otherwise, {@link ProfileConnectionState#STATE_DISCONNECTED} is returned. 153 * @returns { ProfileConnectionState } Returns the connection state. 154 * @throws { BusinessError } 201 - Permission denied. 155 * @throws { BusinessError } 401 - Invalid parameter. Possible causes: 1. Incorrect parameter types. 156 * @throws { BusinessError } 801 - Capability not supported. 157 * @throws { BusinessError } 2900001 - Service stopped. 158 * @throws { BusinessError } 2900003 - Bluetooth disabled. 159 * @throws { BusinessError } 2900004 - Profile not supported. 160 * @throws { BusinessError } 2900099 - Operation failed. 161 * @syscap SystemCapability.Communication.Bluetooth.Core 162 * @since 10 163 */ 164 /** 165 * Get the profile connection state of the current device. 166 * 167 * @permission ohos.permission.ACCESS_BLUETOOTH 168 * @param { ProfileId } [profileId] - Indicate the profile id. This is an optional parameter. 169 * With profileId, returns the current connection state of this profile, {@link ProfileConnectionState}. 170 * Without profileId, if any profile is connected, {@link ProfileConnectionState#STATE_CONNECTED} is returned. 171 * Otherwise, {@link ProfileConnectionState#STATE_DISCONNECTED} is returned. 172 * @returns { ProfileConnectionState } Returns the connection state. 173 * @throws { BusinessError } 201 - Permission denied. 174 * @throws { BusinessError } 401 - Invalid parameter. Possible causes: 1. Incorrect parameter types. 175 * @throws { BusinessError } 801 - Capability not supported. 176 * @throws { BusinessError } 2900001 - Service stopped. 177 * @throws { BusinessError } 2900003 - Bluetooth disabled. 178 * @throws { BusinessError } 2900004 - Profile not supported. 179 * @throws { BusinessError } 2900099 - Operation failed. 180 * @syscap SystemCapability.Communication.Bluetooth.Core 181 * @crossplatform 182 * @since 13 183 */ 184 function getProfileConnectionState(profileId?: ProfileId): ProfileConnectionState; 185 186 /** 187 * Starts pairing with a remote Bluetooth device. 188 * 189 * @permission ohos.permission.ACCESS_BLUETOOTH 190 * @param { string } deviceId - Indicates device ID. For example, "11:22:33:AA:BB:FF". 191 * @param { AsyncCallback<void> } callback - the callback of pairDevice. 192 * @throws { BusinessError } 201 - Permission denied. 193 * @throws { BusinessError } 401 - Invalid parameter. Possible causes: 1. Mandatory parameters are left unspecified. 194 * <br>2. Incorrect parameter types. 3. Parameter verification failed. 195 * @throws { BusinessError } 801 - Capability not supported. 196 * @throws { BusinessError } 2900001 - Service stopped. 197 * @throws { BusinessError } 2900003 - Bluetooth disabled. 198 * @throws { BusinessError } 2900099 - Operation failed. 199 * @syscap SystemCapability.Communication.Bluetooth.Core 200 * @since 10 201 */ 202 /** 203 * Starts pairing with a remote Bluetooth device. 204 * 205 * @permission ohos.permission.ACCESS_BLUETOOTH 206 * @param { string } deviceId - Indicates device ID. For example, "11:22:33:AA:BB:FF". 207 * @param { AsyncCallback<void> } callback - the callback of pairDevice. 208 * @throws { BusinessError } 201 - Permission denied. 209 * @throws { BusinessError } 401 - Invalid parameter. Possible causes: 1. Mandatory parameters are left unspecified. 210 * <br>2. Incorrect parameter types. 3. Parameter verification failed. 211 * @throws { BusinessError } 801 - Capability not supported. 212 * @throws { BusinessError } 2900001 - Service stopped. 213 * @throws { BusinessError } 2900003 - Bluetooth disabled. 214 * @throws { BusinessError } 2900099 - Operation failed. 215 * @syscap SystemCapability.Communication.Bluetooth.Core 216 * @atomicservice 217 * @since 12 218 */ 219 /** 220 * Starts pairing with a remote Bluetooth device. 221 * 222 * @permission ohos.permission.ACCESS_BLUETOOTH 223 * @param { string } deviceId - Indicates device ID. For example, "11:22:33:AA:BB:FF". 224 * @param { AsyncCallback<void> } callback - the callback of pairDevice. 225 * @throws { BusinessError } 201 - Permission denied. 226 * @throws { BusinessError } 401 - Invalid parameter. Possible causes: 1. Mandatory parameters are left unspecified. 227 * <br>2. Incorrect parameter types. 3. Parameter verification failed. 228 * @throws { BusinessError } 801 - Capability not supported. 229 * @throws { BusinessError } 2900001 - Service stopped. 230 * @throws { BusinessError } 2900003 - Bluetooth disabled. 231 * @throws { BusinessError } 2900099 - Operation failed. 232 * @syscap SystemCapability.Communication.Bluetooth.Core 233 * @crossplatform 234 * @atomicservice 235 * @since 13 236 */ 237 function pairDevice(deviceId: string, callback: AsyncCallback<void>): void; 238 239 /** 240 * Starts pairing with a remote Bluetooth device. 241 * 242 * @permission ohos.permission.ACCESS_BLUETOOTH 243 * @param { string } deviceId - Indicates device ID. For example, "11:22:33:AA:BB:FF". 244 * @returns { Promise<void> } Returns the promise object. 245 * @throws { BusinessError } 201 - Permission denied. 246 * @throws { BusinessError } 401 - Invalid parameter. Possible causes: 1. Mandatory parameters are left unspecified. 247 * <br>2. Incorrect parameter types. 3. Parameter verification failed. 248 * @throws { BusinessError } 801 - Capability not supported. 249 * @throws { BusinessError } 2900001 - Service stopped. 250 * @throws { BusinessError } 2900003 - Bluetooth disabled. 251 * @throws { BusinessError } 2900099 - Operation failed. 252 * @syscap SystemCapability.Communication.Bluetooth.Core 253 * @since 10 254 */ 255 /** 256 * Starts pairing with a remote Bluetooth device. 257 * 258 * @permission ohos.permission.ACCESS_BLUETOOTH 259 * @param { string } deviceId - Indicates device ID. For example, "11:22:33:AA:BB:FF". 260 * @returns { Promise<void> } Returns the promise object. 261 * @throws { BusinessError } 201 - Permission denied. 262 * @throws { BusinessError } 401 - Invalid parameter. Possible causes: 1. Mandatory parameters are left unspecified. 263 * <br>2. Incorrect parameter types. 3. Parameter verification failed. 264 * @throws { BusinessError } 801 - Capability not supported. 265 * @throws { BusinessError } 2900001 - Service stopped. 266 * @throws { BusinessError } 2900003 - Bluetooth disabled. 267 * @throws { BusinessError } 2900099 - Operation failed. 268 * @syscap SystemCapability.Communication.Bluetooth.Core 269 * @atomicservice 270 * @since 12 271 */ 272 /** 273 * Starts pairing with a remote Bluetooth device. 274 * 275 * @permission ohos.permission.ACCESS_BLUETOOTH 276 * @param { string } deviceId - Indicates device ID. For example, "11:22:33:AA:BB:FF". 277 * @returns { Promise<void> } Returns the promise object. 278 * @throws { BusinessError } 201 - Permission denied. 279 * @throws { BusinessError } 401 - Invalid parameter. Possible causes: 1. Mandatory parameters are left unspecified. 280 * <br>2. Incorrect parameter types. 3. Parameter verification failed. 281 * @throws { BusinessError } 801 - Capability not supported. 282 * @throws { BusinessError } 2900001 - Service stopped. 283 * @throws { BusinessError } 2900003 - Bluetooth disabled. 284 * @throws { BusinessError } 2900099 - Operation failed. 285 * @syscap SystemCapability.Communication.Bluetooth.Core 286 * @crossplatform 287 * @atomicservice 288 * @since 13 289 */ 290 function pairDevice(deviceId: string): Promise<void>; 291 292 /** 293 * Starts pairing with a credible remote Bluetooth device with transport. 294 * This interface does not trigger a dialog box and does not require user authorization. 295 * Only specific system application can use this function. 296 * 297 * @permission ohos.permission.ACCESS_BLUETOOTH and ohos.permission.MANAGE_BLUETOOTH 298 * @param { string } deviceId - Indicates device ID. For example, "11:22:33:AA:BB:FF". 299 * @param { BluetoothTransport } transport - the transport of the remote device to pair. 300 * @param { AsyncCallback<void> } callback - the callback of pairCredibleDevice. 301 * @throws { BusinessError } 201 - Permission denied. 302 * @throws { BusinessError } 202 - Non-system applications are not allowed to use system APIs. 303 * @throws { BusinessError } 401 - Invalid parameter. Possible causes: 1. Mandatory parameters are left unspecified. 304 * <br>2. Incorrect parameter types. 3. Parameter verification failed. 305 * @throws { BusinessError } 801 - Capability not supported. 306 * @throws { BusinessError } 2900001 - Service stopped. 307 * @throws { BusinessError } 2900003 - Bluetooth disabled. 308 * @throws { BusinessError } 2900099 - Operation failed. 309 * @syscap SystemCapability.Communication.Bluetooth.Core 310 * @systemapi 311 * @since 10 312 */ 313 function pairCredibleDevice(deviceId: string, transport: BluetoothTransport, callback: AsyncCallback<void>): void; 314 315 /** 316 * Starts pairing with a credible remote Bluetooth device with transport. 317 * This interface does not trigger a dialog box and does not require user authorization. 318 * Only specific system application can use this function. 319 * 320 * @permission ohos.permission.ACCESS_BLUETOOTH and ohos.permission.MANAGE_BLUETOOTH 321 * @param { string } deviceId - Indicates device ID. For example, "11:22:33:AA:BB:FF". 322 * @param { BluetoothTransport } transport - the transport of the remote device to pair. 323 * @returns { Promise<void> } Returns the promise object. 324 * @throws { BusinessError } 201 - Permission denied. 325 * @throws { BusinessError } 202 - Non-system applications are not allowed to use system APIs. 326 * @throws { BusinessError } 401 - Invalid parameter. Possible causes: 1. Mandatory parameters are left unspecified. 327 * <br>2. Incorrect parameter types. 3. Parameter verification failed. 328 * @throws { BusinessError } 801 - Capability not supported. 329 * @throws { BusinessError } 2900001 - Service stopped. 330 * @throws { BusinessError } 2900003 - Bluetooth disabled. 331 * @throws { BusinessError } 2900099 - Operation failed. 332 * @syscap SystemCapability.Communication.Bluetooth.Core 333 * @systemapi 334 * @since 10 335 */ 336 function pairCredibleDevice(deviceId: string, transport: BluetoothTransport): Promise<void>; 337 338 /** 339 * Remove a paired remote device. 340 * 341 * @permission ohos.permission.ACCESS_BLUETOOTH 342 * @param { string } deviceId - Indicates device ID. For example, "11:22:33:AA:BB:FF". 343 * @param { AsyncCallback<void> } callback - the callback of cancelPairedDevice. 344 * @throws { BusinessError } 201 - Permission denied. 345 * @throws { BusinessError } 202 - Non-system applications are not allowed to use system APIs. 346 * @throws { BusinessError } 401 - Invalid parameter. Possible causes: 1. Mandatory parameters are left unspecified. 347 * <br>2. Incorrect parameter types. 3. Parameter verification failed. 348 * @throws { BusinessError } 801 - Capability not supported. 349 * @throws { BusinessError } 2900001 - Service stopped. 350 * @throws { BusinessError } 2900003 - Bluetooth disabled. 351 * @throws { BusinessError } 2900099 - Operation failed. 352 * @syscap SystemCapability.Communication.Bluetooth.Core 353 * @systemapi 354 * @since 10 355 */ 356 function cancelPairedDevice(deviceId: string, callback: AsyncCallback<void>): void; 357 358 /** 359 * Remove a paired remote device. 360 * 361 * @permission ohos.permission.ACCESS_BLUETOOTH 362 * @param { string } deviceId - Indicates device ID. For example, "11:22:33:AA:BB:FF". 363 * @returns { Promise<void> } Returns the promise object. 364 * @throws { BusinessError } 201 - Permission denied. 365 * @throws { BusinessError } 202 - Non-system applications are not allowed to use system APIs. 366 * @throws { BusinessError } 401 - Invalid parameter. Possible causes: 1. Mandatory parameters are left unspecified. 367 * <br>2. Incorrect parameter types. 3. Parameter verification failed. 368 * @throws { BusinessError } 801 - Capability not supported. 369 * @throws { BusinessError } 2900001 - Service stopped. 370 * @throws { BusinessError } 2900003 - Bluetooth disabled. 371 * @throws { BusinessError } 2900099 - Operation failed. 372 * @syscap SystemCapability.Communication.Bluetooth.Core 373 * @systemapi 374 * @since 10 375 */ 376 function cancelPairedDevice(deviceId: string): Promise<void>; 377 378 /** 379 * Remove a pairing remote device. 380 * 381 * @permission ohos.permission.ACCESS_BLUETOOTH 382 * @param { string } deviceId - Indicates device ID. For example, "11:22:33:AA:BB:FF". 383 * @param { AsyncCallback<void> } callback - the callback of cancelPairingDevice. 384 * @throws { BusinessError } 201 - Permission denied. 385 * @throws { BusinessError } 202 - Non-system applications are not allowed to use system APIs. 386 * @throws { BusinessError } 401 - Invalid parameter. Possible causes: 1. Mandatory parameters are left unspecified. 387 * <br>2. Incorrect parameter types. 3. Parameter verification failed. 388 * @throws { BusinessError } 801 - Capability not supported. 389 * @throws { BusinessError } 2900001 - Service stopped. 390 * @throws { BusinessError } 2900003 - Bluetooth disabled. 391 * @throws { BusinessError } 2900099 - Operation failed. 392 * @syscap SystemCapability.Communication.Bluetooth.Core 393 * @systemapi 394 * @since 10 395 */ 396 function cancelPairingDevice(deviceId: string, callback: AsyncCallback<void>): void; 397 398 /** 399 * Remove a pairing remote device. 400 * 401 * @permission ohos.permission.ACCESS_BLUETOOTH 402 * @param { string } deviceId - Indicates device ID. For example, "11:22:33:AA:BB:FF". 403 * @returns { Promise<void> } Returns the promise object. 404 * @throws { BusinessError } 201 - Permission denied. 405 * @throws { BusinessError } 202 - Non-system applications are not allowed to use system APIs. 406 * @throws { BusinessError } 401 - Invalid parameter. Possible causes: 1. Mandatory parameters are left unspecified. 407 * <br>2. Incorrect parameter types. 3. Parameter verification failed. 408 * @throws { BusinessError } 801 - Capability not supported. 409 * @throws { BusinessError } 2900001 - Service stopped. 410 * @throws { BusinessError } 2900003 - Bluetooth disabled. 411 * @throws { BusinessError } 2900099 - Operation failed. 412 * @syscap SystemCapability.Communication.Bluetooth.Core 413 * @systemapi 414 * @since 10 415 */ 416 function cancelPairingDevice(deviceId: string): Promise<void>; 417 418 /** 419 * Obtains the name of a peer Bluetooth device. 420 * 421 * @permission ohos.permission.ACCESS_BLUETOOTH 422 * @param { string } deviceId - Indicates device ID. For example, "11:22:33:AA:BB:FF". 423 * @returns { string } Returns the device name in character string format. 424 * @throws { BusinessError } 201 - Permission denied. 425 * @throws { BusinessError } 401 - Invalid parameter. Possible causes: 1. Mandatory parameters are left unspecified. 426 * <br>2. Incorrect parameter types. 3. Parameter verification failed. 427 * @throws { BusinessError } 801 - Capability not supported. 428 * @throws { BusinessError } 2900001 - Service stopped. 429 * @throws { BusinessError } 2900003 - Bluetooth disabled. 430 * @throws { BusinessError } 2900099 - Operation failed. 431 * @syscap SystemCapability.Communication.Bluetooth.Core 432 * @since 10 433 */ 434 /** 435 * Obtains the name of a peer Bluetooth device. 436 * 437 * @permission ohos.permission.ACCESS_BLUETOOTH 438 * @param { string } deviceId - Indicates device ID. For example, "11:22:33:AA:BB:FF". 439 * @returns { string } Returns the device name in character string format. 440 * @throws { BusinessError } 201 - Permission denied. 441 * @throws { BusinessError } 401 - Invalid parameter. Possible causes: 1. Mandatory parameters are left unspecified. 442 * <br>2. Incorrect parameter types. 3. Parameter verification failed. 443 * @throws { BusinessError } 801 - Capability not supported. 444 * @throws { BusinessError } 2900001 - Service stopped. 445 * @throws { BusinessError } 2900003 - Bluetooth disabled. 446 * @throws { BusinessError } 2900099 - Operation failed. 447 * @syscap SystemCapability.Communication.Bluetooth.Core 448 * @atomicservice 449 * @since 12 450 */ 451 /** 452 * Obtains the name of a peer Bluetooth device. 453 * 454 * @permission ohos.permission.ACCESS_BLUETOOTH 455 * @param { string } deviceId - Indicates device ID. For example, "11:22:33:AA:BB:FF". 456 * @returns { string } Returns the device name in character string format. 457 * @throws { BusinessError } 201 - Permission denied. 458 * @throws { BusinessError } 401 - Invalid parameter. Possible causes: 1. Mandatory parameters are left unspecified. 459 * <br>2. Incorrect parameter types. 3. Parameter verification failed. 460 * @throws { BusinessError } 801 - Capability not supported. 461 * @throws { BusinessError } 2900001 - Service stopped. 462 * @throws { BusinessError } 2900003 - Bluetooth disabled. 463 * @throws { BusinessError } 2900099 - Operation failed. 464 * @syscap SystemCapability.Communication.Bluetooth.Core 465 * @crossplatform 466 * @atomicservice 467 * @since arkts {'1.1':'13','1.2':'20'} 468 * @arkts 1.1&1.2 469 */ 470 function getRemoteDeviceName(deviceId: string): string; 471 472 /** 473 * Obtains the name or alias of the Bluetooth peer device. 474 * 475 * @permission ohos.permission.ACCESS_BLUETOOTH 476 * @param { string } deviceId - Indicates device ID. For example, "11:22:33:AA:BB:FF". 477 * @param { boolean } [alias] - Indicates whether to obtain the device alias. If the parameter is not provided, the device alias is obtained by default. 478 * @returns { string } Returns the device name in character string format. 479 * @throws { BusinessError } 201 - Permission denied. 480 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 481 * 2. Incorrect parameter types. 3. Parameter verification failed. 482 * @throws { BusinessError } 801 - Capability not supported. 483 * @throws { BusinessError } 2900001 - Service stopped. 484 * @throws { BusinessError } 2900003 - Bluetooth disabled. 485 * @throws { BusinessError } 2900099 - Failed to obtain the name or alias of the peer Bluetooth device. 486 * @syscap SystemCapability.Communication.Bluetooth.Core 487 * @atomicservice 488 * @since arkts {'1.1':'16','1.2':'20'} 489 * @arkts 1.1&1.2 490 */ 491 function getRemoteDeviceName(deviceId: string, alias?: boolean): string; 492 493 /** 494 * Obtains the class of a peer Bluetooth device. 495 * 496 * @permission ohos.permission.ACCESS_BLUETOOTH 497 * @param { string } deviceId - Indicates device ID. For example, "11:22:33:AA:BB:FF". 498 * @returns { DeviceClass } The class of the remote device. 499 * @throws { BusinessError } 201 - Permission denied. 500 * @throws { BusinessError } 401 - Invalid parameter. Possible causes: 1. Mandatory parameters are left unspecified. 501 * <br>2. Incorrect parameter types. 3. Parameter verification failed. 502 * @throws { BusinessError } 801 - Capability not supported. 503 * @throws { BusinessError } 2900001 - Service stopped. 504 * @throws { BusinessError } 2900003 - Bluetooth disabled. 505 * @throws { BusinessError } 2900099 - Operation failed. 506 * @syscap SystemCapability.Communication.Bluetooth.Core 507 * @since 10 508 */ 509 /** 510 * Obtains the class of a peer Bluetooth device. 511 * 512 * @permission ohos.permission.ACCESS_BLUETOOTH 513 * @param { string } deviceId - Indicates device ID. For example, "11:22:33:AA:BB:FF". 514 * @returns { DeviceClass } The class of the remote device. 515 * @throws { BusinessError } 201 - Permission denied. 516 * @throws { BusinessError } 401 - Invalid parameter. Possible causes: 1. Mandatory parameters are left unspecified. 517 * <br>2. Incorrect parameter types. 3. Parameter verification failed. 518 * @throws { BusinessError } 801 - Capability not supported. 519 * @throws { BusinessError } 2900001 - Service stopped. 520 * @throws { BusinessError } 2900003 - Bluetooth disabled. 521 * @throws { BusinessError } 2900099 - Operation failed. 522 * @syscap SystemCapability.Communication.Bluetooth.Core 523 * @crossplatform 524 * @since 13 525 */ 526 /** 527 * Obtains the class of a peer Bluetooth device. 528 * 529 * @param { string } deviceId - Indicates device ID. For example, "11:22:33:AA:BB:FF". 530 * @returns { DeviceClass } The class of the remote device. 531 * @throws { BusinessError } 401 - Invalid parameter. Possible causes: 1. Mandatory parameters are left unspecified. 532 * <br>2. Incorrect parameter types. 3. Parameter verification failed. 533 * @throws { BusinessError } 801 - Capability not supported. 534 * @throws { BusinessError } 2900001 - Service stopped. 535 * @throws { BusinessError } 2900003 - Bluetooth disabled. 536 * @throws { BusinessError } 2900099 - Operation failed. 537 * @syscap SystemCapability.Communication.Bluetooth.Core 538 * @crossplatform 539 * @since arkts {'1.1':'18','1.2':'20'} 540 * @arkts 1.1&1.2 541 */ 542 function getRemoteDeviceClass(deviceId: string): DeviceClass; 543 544 /** 545 * Get the transport of the bluetooth device. 546 * 547 * @param { string } deviceId - Indicates device ID. For example, "11:22:33:AA:BB:FF". 548 * @returns { BluetoothTransport } The transport of bluetooth device. 549 * @throws { BusinessError } 801 - Capability not supported. 550 * @throws { BusinessError } 2900001 - Service stopped. 551 * @throws { BusinessError } 2900003 - Bluetooth disabled. 552 * @throws { BusinessError } 2900099 - Get transport failed. 553 * @syscap SystemCapability.Communication.Bluetooth.Core 554 * @since 20 555 */ 556 function getRemoteDeviceTransport(deviceId: string): BluetoothTransport; 557 558 /** 559 * Obtains the Bluetooth local name of a device. 560 * 561 * @permission ohos.permission.ACCESS_BLUETOOTH 562 * @returns { string } Returns the name the device. 563 * @throws { BusinessError } 201 - Permission denied. 564 * @throws { BusinessError } 801 - Capability not supported. 565 * @throws { BusinessError } 2900001 - Service stopped. 566 * @throws { BusinessError } 2900099 - Operation failed. 567 * @syscap SystemCapability.Communication.Bluetooth.Core 568 * @since 10 569 */ 570 /** 571 * Obtains the Bluetooth local name of a device. 572 * 573 * @permission ohos.permission.ACCESS_BLUETOOTH 574 * @returns { string } Returns the name the device. 575 * @throws { BusinessError } 201 - Permission denied. 576 * @throws { BusinessError } 801 - Capability not supported. 577 * @throws { BusinessError } 2900001 - Service stopped. 578 * @throws { BusinessError } 2900099 - Operation failed. 579 * @syscap SystemCapability.Communication.Bluetooth.Core 580 * @crossplatform 581 * @since 13 582 */ 583 function getLocalName(): string; 584 585 /** 586 * Obtains the list of Bluetooth devices that have been paired with the current device. 587 * 588 * @permission ohos.permission.ACCESS_BLUETOOTH 589 * @returns { Array<string> } Returns a list of paired Bluetooth devices's address. 590 * @throws { BusinessError } 201 - Permission denied. 591 * @throws { BusinessError } 801 - Capability not supported. 592 * @throws { BusinessError } 2900001 - Service stopped. 593 * @throws { BusinessError } 2900003 - Bluetooth disabled. 594 * @throws { BusinessError } 2900099 - Operation failed. 595 * @syscap SystemCapability.Communication.Bluetooth.Core 596 * @since 10 597 */ 598 /** 599 * Obtains the list of Bluetooth devices that have been paired with the current device. 600 * 601 * @permission ohos.permission.ACCESS_BLUETOOTH 602 * @returns { Array<string> } Returns a list of paired Bluetooth devices's address. 603 * @throws { BusinessError } 201 - Permission denied. 604 * @throws { BusinessError } 801 - Capability not supported. 605 * @throws { BusinessError } 2900001 - Service stopped. 606 * @throws { BusinessError } 2900003 - Bluetooth disabled. 607 * @throws { BusinessError } 2900099 - Operation failed. 608 * @syscap SystemCapability.Communication.Bluetooth.Core 609 * @atomicservice 610 * @since 12 611 */ 612 /** 613 * Obtains the list of Bluetooth devices that have been paired with the current device. 614 * 615 * @permission ohos.permission.ACCESS_BLUETOOTH 616 * @returns { Array<string> } Returns a list of paired Bluetooth devices's address. 617 * @throws { BusinessError } 201 - Permission denied. 618 * @throws { BusinessError } 801 - Capability not supported. 619 * @throws { BusinessError } 2900001 - Service stopped. 620 * @throws { BusinessError } 2900003 - Bluetooth disabled. 621 * @throws { BusinessError } 2900099 - Operation failed. 622 * @syscap SystemCapability.Communication.Bluetooth.Core 623 * @crossplatform 624 * @atomicservice 625 * @since arkts {'1.1':'13','1.2':'20'} 626 * @arkts 1.1&1.2 627 */ 628 function getPairedDevices(): Array<string>; 629 630 /** 631 * Obtains the pair state of a specified device. 632 * 633 * @permission ohos.permission.ACCESS_BLUETOOTH 634 * @param { string } deviceId - Indicates device ID. For example, "11:22:33:AA:BB:FF". 635 * @returns { BondState } Returns the pair state. 636 * @throws { BusinessError } 201 - Permission denied. 637 * @throws { BusinessError } 401 - Invalid parameter. Possible causes: 1. Mandatory parameters are left unspecified. 638 * <br>2. Incorrect parameter types. 3. Parameter verification failed. 639 * @throws { BusinessError } 801 - Capability not supported. 640 * @throws { BusinessError } 2900001 - Service stopped. 641 * @throws { BusinessError } 2900003 - Bluetooth disabled. 642 * @throws { BusinessError } 2900099 - Operation failed. 643 * @syscap SystemCapability.Communication.Bluetooth.Core 644 * @since 11 645 */ 646 /** 647 * Obtains the pair state of a specified device. 648 * 649 * @permission ohos.permission.ACCESS_BLUETOOTH 650 * @param { string } deviceId - Indicates device ID. For example, "11:22:33:AA:BB:FF". 651 * @returns { BondState } Returns the pair state. 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 * @atomicservice 661 * @since 12 662 */ 663 /** 664 * Obtains the pair state of a specified device. 665 * 666 * @permission ohos.permission.ACCESS_BLUETOOTH 667 * @param { string } deviceId - Indicates device ID. For example, "11:22:33:AA:BB:FF". 668 * @returns { BondState } Returns the pair state. 669 * @throws { BusinessError } 201 - Permission denied. 670 * @throws { BusinessError } 401 - Invalid parameter. Possible causes: 1. Mandatory parameters are left unspecified. 671 * <br>2. Incorrect parameter types. 3. Parameter verification failed. 672 * @throws { BusinessError } 801 - Capability not supported. 673 * @throws { BusinessError } 2900001 - Service stopped. 674 * @throws { BusinessError } 2900003 - Bluetooth disabled. 675 * @throws { BusinessError } 2900099 - Operation failed. 676 * @syscap SystemCapability.Communication.Bluetooth.Core 677 * @crossplatform 678 * @atomicservice 679 * @since 13 680 */ 681 function getPairState(deviceId: string): BondState; 682 683 /** 684 * Sets the confirmation of pairing with a certain device. 685 * 686 * @permission ohos.permission.ACCESS_BLUETOOTH and ohos.permission.MANAGE_BLUETOOTH 687 * @param { string } deviceId - Indicates device ID. For example, "11:22:33:AA:BB:FF". 688 * @param { boolean } accept - Indicates whether to accept the pairing request, {@code true} indicates accept or {@code false} otherwise. 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 */ 699 function setDevicePairingConfirmation(deviceId: string, accept: boolean): void; 700 701 /** 702 * Set the pin during pairing when the pin type is PIN_TYPE_ENTER_PIN_CODE. 703 * 704 * @permission ohos.permission.ACCESS_BLUETOOTH 705 * @param { string } deviceId - Indicates device ID. For example, "11:22:33:AA:BB:FF". 706 * @param { string } code - The pin code entered by the user. 707 * @param { AsyncCallback<void> } callback - the callback of setDevicePinCode. 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 setDevicePinCode(deviceId: string, code: string, callback: AsyncCallback<void>): void; 719 720 /** 721 * Set the pin during pairing when the pin type is PIN_TYPE_ENTER_PIN_CODE. 722 * 723 * @permission ohos.permission.ACCESS_BLUETOOTH 724 * @param { string } deviceId - Indicates device ID. For example, "11:22:33:AA:BB:FF". 725 * @param { string } code - The pin code entered by the user. 726 * @returns { Promise<void> } Returns the promise object. 727 * @throws { BusinessError } 201 - Permission denied. 728 * @throws { BusinessError } 401 - Invalid parameter. Possible causes: 1. Mandatory parameters are left unspecified. 729 * <br>2. Incorrect parameter types. 3. Parameter verification failed. 730 * @throws { BusinessError } 801 - Capability not supported. 731 * @throws { BusinessError } 2900001 - Service stopped. 732 * @throws { BusinessError } 2900003 - Bluetooth disabled. 733 * @throws { BusinessError } 2900099 - Operation failed. 734 * @syscap SystemCapability.Communication.Bluetooth.Core 735 * @since 10 736 */ 737 function setDevicePinCode(deviceId: string, code: string): Promise<void>; 738 739 /** 740 * Sets the Bluetooth friendly name of a device. It is used only by system applications for security. 741 * If a non-system application invokes the interface, exception 801 is thrown. 742 * 743 * @permission ohos.permission.ACCESS_BLUETOOTH 744 * @param { string } name - Indicates a valid Bluetooth name. 745 * @throws { BusinessError } 201 - Permission denied. 746 * @throws { BusinessError } 401 - Invalid parameter. Possible causes: 1. Mandatory parameters are left unspecified. 747 * <br>2. Incorrect parameter types. 3. Parameter verification failed. 748 * @throws { BusinessError } 801 - Capability not supported. 749 * @throws { BusinessError } 2900001 - Service stopped. 750 * @throws { BusinessError } 2900003 - Bluetooth disabled. 751 * @throws { BusinessError } 2900099 - Operation failed. 752 * @syscap SystemCapability.Communication.Bluetooth.Core 753 * @since 10 754 * @deprecated since 12 755 */ 756 function setLocalName(name: string): void; 757 758 /** 759 * Sets the Bluetooth scan mode for a device. 760 * 761 * @permission ohos.permission.ACCESS_BLUETOOTH 762 * @param { ScanMode } mode - Indicates the Bluetooth scan mode to set. 763 * @param { number } duration - Indicates the duration in seconds, in which the host is discoverable. 764 * @throws { BusinessError } 201 - Permission denied. 765 * @throws { BusinessError } 401 - Invalid parameter. Possible causes: 1. Mandatory parameters are left unspecified. 766 * <br>2. Incorrect parameter types. 3. Parameter verification failed. 767 * @throws { BusinessError } 801 - Capability not supported. 768 * @throws { BusinessError } 2900001 - Service stopped. 769 * @throws { BusinessError } 2900003 - Bluetooth disabled. 770 * @throws { BusinessError } 2900099 - Operation failed. 771 * @syscap SystemCapability.Communication.Bluetooth.Core 772 * @since arkts {'1.1':'10','1.2':'20'} 773 * @arkts 1.1&1.2 774 */ 775 function setBluetoothScanMode(mode: ScanMode, duration: number): void; 776 777 /** 778 * Obtains the Bluetooth scanning mode of a device. 779 * 780 * @permission ohos.permission.ACCESS_BLUETOOTH 781 * @returns { ScanMode } Returns the Bluetooth scanning mode. 782 * @throws { BusinessError } 201 - Permission denied. 783 * @throws { BusinessError } 801 - Capability not supported. 784 * @throws { BusinessError } 2900001 - Service stopped. 785 * @throws { BusinessError } 2900003 - Bluetooth disabled. 786 * @throws { BusinessError } 2900099 - Operation failed. 787 * @syscap SystemCapability.Communication.Bluetooth.Core 788 * @since 10 789 */ 790 /** 791 * Obtains the Bluetooth scanning mode of a device. 792 * 793 * @permission ohos.permission.ACCESS_BLUETOOTH 794 * @returns { ScanMode } Returns the Bluetooth scanning mode. 795 * @throws { BusinessError } 201 - Permission denied. 796 * @throws { BusinessError } 801 - Capability not supported. 797 * @throws { BusinessError } 2900001 - Service stopped. 798 * @throws { BusinessError } 2900003 - Bluetooth disabled. 799 * @throws { BusinessError } 2900099 - Operation failed. 800 * @syscap SystemCapability.Communication.Bluetooth.Core 801 * @crossplatform 802 * @since 13 803 */ 804 function getBluetoothScanMode(): ScanMode; 805 806 /** 807 * Starts scanning Bluetooth devices. 808 * 809 * @permission ohos.permission.ACCESS_BLUETOOTH 810 * @throws { BusinessError } 201 - Permission denied. 811 * @throws { BusinessError } 801 - Capability not supported. 812 * @throws { BusinessError } 2900001 - Service stopped. 813 * @throws { BusinessError } 2900003 - Bluetooth disabled. 814 * @throws { BusinessError } 2900099 - Operation failed. 815 * @syscap SystemCapability.Communication.Bluetooth.Core 816 * @since 10 817 */ 818 /** 819 * Starts scanning Bluetooth devices. 820 * 821 * @permission ohos.permission.ACCESS_BLUETOOTH 822 * @throws { BusinessError } 201 - Permission denied. 823 * @throws { BusinessError } 801 - Capability not supported. 824 * @throws { BusinessError } 2900001 - Service stopped. 825 * @throws { BusinessError } 2900003 - Bluetooth disabled. 826 * @throws { BusinessError } 2900099 - Operation failed. 827 * @syscap SystemCapability.Communication.Bluetooth.Core 828 * @atomicservice 829 * @since 12 830 */ 831 /** 832 * Starts scanning Bluetooth devices. 833 * 834 * @permission ohos.permission.ACCESS_BLUETOOTH 835 * @throws { BusinessError } 201 - Permission denied. 836 * @throws { BusinessError } 801 - Capability not supported. 837 * @throws { BusinessError } 2900001 - Service stopped. 838 * @throws { BusinessError } 2900003 - Bluetooth disabled. 839 * @throws { BusinessError } 2900099 - Operation failed. 840 * @syscap SystemCapability.Communication.Bluetooth.Core 841 * @crossplatform 842 * @atomicservice 843 * @since 13 844 */ 845 function startBluetoothDiscovery(): void; 846 847 /** 848 * Stops Bluetooth device scanning. 849 * 850 * @permission ohos.permission.ACCESS_BLUETOOTH 851 * @throws { BusinessError } 201 - Permission denied. 852 * @throws { BusinessError } 801 - Capability not supported. 853 * @throws { BusinessError } 2900001 - Service stopped. 854 * @throws { BusinessError } 2900003 - Bluetooth disabled. 855 * @throws { BusinessError } 2900099 - Operation failed. 856 * @syscap SystemCapability.Communication.Bluetooth.Core 857 * @since 10 858 */ 859 /** 860 * Stops Bluetooth device scanning. 861 * 862 * @permission ohos.permission.ACCESS_BLUETOOTH 863 * @throws { BusinessError } 201 - Permission denied. 864 * @throws { BusinessError } 801 - Capability not supported. 865 * @throws { BusinessError } 2900001 - Service stopped. 866 * @throws { BusinessError } 2900003 - Bluetooth disabled. 867 * @throws { BusinessError } 2900099 - Operation failed. 868 * @syscap SystemCapability.Communication.Bluetooth.Core 869 * @atomicservice 870 * @since 12 871 */ 872 /** 873 * Stops Bluetooth device scanning. 874 * 875 * @permission ohos.permission.ACCESS_BLUETOOTH 876 * @throws { BusinessError } 201 - Permission denied. 877 * @throws { BusinessError } 801 - Capability not supported. 878 * @throws { BusinessError } 2900001 - Service stopped. 879 * @throws { BusinessError } 2900003 - Bluetooth disabled. 880 * @throws { BusinessError } 2900099 - Operation failed. 881 * @syscap SystemCapability.Communication.Bluetooth.Core 882 * @crossplatform 883 * @atomicservice 884 * @since 13 885 */ 886 function stopBluetoothDiscovery(): void; 887 888 /** 889 * Check if bluetooth is discovering. 890 * 891 * @permission ohos.permission.ACCESS_BLUETOOTH 892 * @returns { boolean } Returns {@code true} if the local device is discovering; returns {@code false} otherwise. 893 * @throws { BusinessError } 201 - Permission denied. 894 * @throws { BusinessError } 801 - Capability not supported. 895 * @throws { BusinessError } 2900001 - Service stopped. 896 * @throws { BusinessError } 2900003 - Bluetooth disabled. 897 * @throws { BusinessError } 2900099 - Operation failed. 898 * @syscap SystemCapability.Communication.Bluetooth.Core 899 * @since 11 900 */ 901 /** 902 * Check if bluetooth is discovering. 903 * 904 * @permission ohos.permission.ACCESS_BLUETOOTH 905 * @returns { boolean } Returns {@code true} if the local device is discovering; returns {@code false} otherwise. 906 * @throws { BusinessError } 201 - Permission denied. 907 * @throws { BusinessError } 801 - Capability not supported. 908 * @throws { BusinessError } 2900001 - Service stopped. 909 * @throws { BusinessError } 2900003 - Bluetooth disabled. 910 * @throws { BusinessError } 2900099 - Operation failed. 911 * @syscap SystemCapability.Communication.Bluetooth.Core 912 * @crossplatform 913 * @since 13 914 */ 915 function isBluetoothDiscovering(): boolean; 916 917 /** 918 * Obtains the profile UUIDs supported by the local device. 919 * 920 * @permission ohos.permission.ACCESS_BLUETOOTH 921 * @param { AsyncCallback<Array<ProfileUuids>> } callback - the callback of getLocalProfileUuids. 922 * @throws { BusinessError } 201 - Permission denied. 923 * @throws { BusinessError } 202 - Non-system applications are not allowed to use system APIs. 924 * @throws { BusinessError } 401 - Invalid parameter. Possible causes: 1. Mandatory parameters are left unspecified. 925 * <br>2. Incorrect parameter types. 926 * @throws { BusinessError } 801 - Capability not supported. 927 * @throws { BusinessError } 2900001 - Service stopped. 928 * @throws { BusinessError } 2900003 - Bluetooth disabled. 929 * @throws { BusinessError } 2900099 - Operation failed. 930 * @syscap SystemCapability.Communication.Bluetooth.Core 931 * @systemapi 932 * @since 10 933 */ 934 function getLocalProfileUuids(callback: AsyncCallback<Array<ProfileUuids>>): void; 935 936 /** 937 * Obtains the profile UUIDs supported by the local device. 938 * 939 * @permission ohos.permission.ACCESS_BLUETOOTH 940 * @returns { Promise<Array<ProfileUuids>> } Returns the promise object. 941 * @throws { BusinessError } 201 - Permission denied. 942 * @throws { BusinessError } 202 - Non-system applications are not allowed to use system APIs. 943 * @throws { BusinessError } 401 - Invalid parameter. Possible causes: 1. Mandatory parameters are left unspecified. 944 * <br>2. Incorrect parameter types. 3. Parameter verification failed. 945 * @throws { BusinessError } 801 - Capability not supported. 946 * @throws { BusinessError } 2900001 - Service stopped. 947 * @throws { BusinessError } 2900003 - Bluetooth disabled. 948 * @throws { BusinessError } 2900099 - Operation failed. 949 * @syscap SystemCapability.Communication.Bluetooth.Core 950 * @systemapi 951 * @since 10 952 */ 953 function getLocalProfileUuids(): Promise<Array<ProfileUuids>>; 954 955 /** 956 * Obtains the profile UUIDs supported by the remote device. 957 * 958 * @permission ohos.permission.ACCESS_BLUETOOTH 959 * @param { string } deviceId - Indicates device ID. For example, "11:22:33:AA:BB:FF". 960 * @param { AsyncCallback<Array<ProfileUuids>> } callback - the callback of getRemoteProfileUuids. 961 * @throws { BusinessError } 201 - Permission denied. 962 * @throws { BusinessError } 202 - Non-system applications are not allowed to use system APIs. 963 * @throws { BusinessError } 401 - Invalid parameter. Possible causes: 1. Mandatory parameters are left unspecified. 964 * <br>2. Incorrect parameter types. 3. Parameter verification failed. 965 * @throws { BusinessError } 801 - Capability not supported. 966 * @throws { BusinessError } 2900001 - Service stopped. 967 * @throws { BusinessError } 2900003 - Bluetooth disabled. 968 * @throws { BusinessError } 2900099 - Operation failed. 969 * @syscap SystemCapability.Communication.Bluetooth.Core 970 * @systemapi 971 * @since 10 972 */ 973 /** 974 * Obtains the profile UUIDs supported by the remote device. 975 * 976 * @permission ohos.permission.ACCESS_BLUETOOTH 977 * @param { string } deviceId - Indicates device ID. For example, "11:22:33:AA:BB:FF". 978 * @param { AsyncCallback<Array<ProfileUuids>> } callback - the callback of getRemoteProfileUuids. 979 * @throws { BusinessError } 201 - Permission denied. 980 * @throws { BusinessError } 401 - Invalid parameter. 981 * @throws { BusinessError } 801 - Capability not supported. 982 * @throws { BusinessError } 2900001 - Service stopped. 983 * @throws { BusinessError } 2900003 - Bluetooth disabled. 984 * @throws { BusinessError } 2900099 - Operation failed. 985 * @syscap SystemCapability.Communication.Bluetooth.Core 986 * @since 12 987 */ 988 /** 989 * Obtains the profile UUIDs supported by the remote device. 990 * 991 * @permission ohos.permission.ACCESS_BLUETOOTH 992 * @param { string } deviceId - Indicates device ID. For example, "11:22:33:AA:BB:FF". 993 * @param { AsyncCallback<Array<ProfileUuids>> } callback - the callback of getRemoteProfileUuids. 994 * @throws { BusinessError } 201 - Permission denied. 995 * @throws { BusinessError } 401 - Invalid parameter. 996 * @throws { BusinessError } 801 - Capability not supported. 997 * @throws { BusinessError } 2900001 - Service stopped. 998 * @throws { BusinessError } 2900003 - Bluetooth disabled. 999 * @throws { BusinessError } 2900099 - Operation failed. 1000 * @syscap SystemCapability.Communication.Bluetooth.Core 1001 * @crossplatform 1002 * @since 13 1003 */ 1004 function getRemoteProfileUuids(deviceId: string, callback: AsyncCallback<Array<ProfileUuids>>): void; 1005 1006 /** 1007 * Obtains the profile UUIDs supported by the remote device. 1008 * 1009 * @permission ohos.permission.ACCESS_BLUETOOTH 1010 * @param { string } deviceId - Indicates device ID. For example, "11:22:33:AA:BB:FF". 1011 * @returns { Promise<Array<ProfileUuids>> } Returns the promise object. 1012 * @throws { BusinessError } 201 - Permission denied. 1013 * @throws { BusinessError } 202 - Non-system applications are not allowed to use system APIs. 1014 * @throws { BusinessError } 401 - Invalid parameter. Possible causes: 1. Mandatory parameters are left unspecified. 1015 * <br>2. Incorrect parameter types. 3. Parameter verification failed. 1016 * @throws { BusinessError } 801 - Capability not supported. 1017 * @throws { BusinessError } 2900001 - Service stopped. 1018 * @throws { BusinessError } 2900003 - Bluetooth disabled. 1019 * @throws { BusinessError } 2900099 - Operation failed. 1020 * @syscap SystemCapability.Communication.Bluetooth.Core 1021 * @systemapi 1022 * @since 10 1023 */ 1024 /** 1025 * Obtains the profile UUIDs supported by the remote device. 1026 * 1027 * @permission ohos.permission.ACCESS_BLUETOOTH 1028 * @param { string } deviceId - Indicates device ID. For example, "11:22:33:AA:BB:FF". 1029 * @returns { Promise<Array<ProfileUuids>> } Returns the promise object. 1030 * @throws { BusinessError } 201 - Permission denied. 1031 * @throws { BusinessError } 401 - Invalid parameter. 1032 * @throws { BusinessError } 801 - Capability not supported. 1033 * @throws { BusinessError } 2900001 - Service stopped. 1034 * @throws { BusinessError } 2900003 - Bluetooth disabled. 1035 * @throws { BusinessError } 2900099 - Operation failed. 1036 * @syscap SystemCapability.Communication.Bluetooth.Core 1037 * @since 12 1038 */ 1039 /** 1040 * Obtains the profile UUIDs supported by the remote device. 1041 * 1042 * @permission ohos.permission.ACCESS_BLUETOOTH 1043 * @param { string } deviceId - Indicates device ID. For example, "11:22:33:AA:BB:FF". 1044 * @returns { Promise<Array<ProfileUuids>> } Returns the promise object. 1045 * @throws { BusinessError } 201 - Permission denied. 1046 * @throws { BusinessError } 401 - Invalid parameter. 1047 * @throws { BusinessError } 801 - Capability not supported. 1048 * @throws { BusinessError } 2900001 - Service stopped. 1049 * @throws { BusinessError } 2900003 - Bluetooth disabled. 1050 * @throws { BusinessError } 2900099 - Operation failed. 1051 * @syscap SystemCapability.Communication.Bluetooth.Core 1052 * @crossplatform 1053 * @since 13 1054 */ 1055 function getRemoteProfileUuids(deviceId: string): Promise<Array<ProfileUuids>>; 1056 1057 /** 1058 * Connects all allowed bluetooth profiles between the local and remote device. 1059 * 1060 * @permission ohos.permission.ACCESS_BLUETOOTH and ohos.permission.MANAGE_BLUETOOTH 1061 * @param { string } deviceId - Indicates device ID. For example, "11:22:33:AA:BB:FF". 1062 * @param { AsyncCallback<void> } callback - the callback result. 1063 * @throws { BusinessError } 201 - Permission denied. 1064 * @throws { BusinessError } 202 - Non-system applications are not allowed to use system APIs. 1065 * @throws { BusinessError } 401 - Invalid parameter. Possible causes: 1. Mandatory parameters are left unspecified. 1066 * <br>2. Incorrect parameter types. 3. Parameter verification failed. 1067 * @throws { BusinessError } 801 - Capability not supported. 1068 * @throws { BusinessError } 2900001 - Service stopped. 1069 * @throws { BusinessError } 2900003 - Bluetooth disabled. 1070 * @throws { BusinessError } 2900099 - Operation failed. 1071 * @syscap SystemCapability.Communication.Bluetooth.Core 1072 * @systemapi 1073 * @since 11 1074 */ 1075 /** 1076 * Connects all allowed bluetooth profiles between the local and remote device. 1077 * 1078 * @permission ohos.permission.ACCESS_BLUETOOTH 1079 * @param { string } deviceId - Indicates device ID. For example, "11:22:33:AA:BB:FF". 1080 * @param { AsyncCallback<void> } callback - the callback result. 1081 * @throws { BusinessError } 201 - Permission denied. 1082 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 1083 * 2. Incorrect parameter types. 3. Parameter verification failed. 1084 * @throws { BusinessError } 801 - Capability not supported. 1085 * @throws { BusinessError } 2900001 - Service stopped. 1086 * @throws { BusinessError } 2900003 - Bluetooth disabled. 1087 * @throws { BusinessError } 2900099 - Operation failed. 1088 * @syscap SystemCapability.Communication.Bluetooth.Core 1089 * @since 16 1090 */ 1091 function connectAllowedProfiles(deviceId: string, callback: AsyncCallback<void>): void; 1092 1093 /** 1094 * Connects all allowed bluetooth profiles between the local and remote device. 1095 * 1096 * @permission ohos.permission.ACCESS_BLUETOOTH and ohos.permission.MANAGE_BLUETOOTH 1097 * @param { string } deviceId - Indicates device ID. For example, "11:22:33:AA:BB:FF". 1098 * @returns { Promise<void> } Returns the promise object. 1099 * @throws { BusinessError } 201 - Permission denied. 1100 * @throws { BusinessError } 202 - Non-system applications are not allowed to use system APIs. 1101 * @throws { BusinessError } 401 - Invalid parameter. Possible causes: 1. Mandatory parameters are left unspecified. 1102 * <br>2. Incorrect parameter types. 3. Parameter verification failed. 1103 * @throws { BusinessError } 801 - Capability not supported. 1104 * @throws { BusinessError } 2900001 - Service stopped. 1105 * @throws { BusinessError } 2900003 - Bluetooth disabled. 1106 * @throws { BusinessError } 2900099 - Operation failed. 1107 * @syscap SystemCapability.Communication.Bluetooth.Core 1108 * @systemapi 1109 * @since 11 1110 */ 1111 /** 1112 * Connects all allowed bluetooth profiles between the local and remote device. 1113 * 1114 * @permission ohos.permission.ACCESS_BLUETOOTH 1115 * @param { string } deviceId - Indicates device ID. For example, "11:22:33:AA:BB:FF". 1116 * @returns { Promise<void> } Returns the promise object. 1117 * @throws { BusinessError } 201 - Permission denied. 1118 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 1119 * 2. Incorrect parameter types. 3. Parameter verification failed. 1120 * @throws { BusinessError } 801 - Capability not supported. 1121 * @throws { BusinessError } 2900001 - Service stopped. 1122 * @throws { BusinessError } 2900003 - Bluetooth disabled. 1123 * @throws { BusinessError } 2900099 - Operation failed. 1124 * @syscap SystemCapability.Communication.Bluetooth.Core 1125 * @since 16 1126 */ 1127 function connectAllowedProfiles(deviceId: string): Promise<void>; 1128 1129 /** 1130 * Disconnects all allowed bluetooth profiles between the local and remote device. 1131 * 1132 * @permission ohos.permission.ACCESS_BLUETOOTH and ohos.permission.MANAGE_BLUETOOTH 1133 * @param { string } deviceId - Indicates device ID. For example, "11:22:33:AA:BB:FF". 1134 * @param { AsyncCallback<void> } callback - the callback result. 1135 * @throws { BusinessError } 201 - Permission denied. 1136 * @throws { BusinessError } 202 - Non-system applications are not allowed to use system APIs. 1137 * @throws { BusinessError } 401 - Invalid parameter. Possible causes: 1. Mandatory parameters are left unspecified. 1138 * <br>2. Incorrect parameter types. 3. Parameter verification failed. 1139 * @throws { BusinessError } 801 - Capability not supported. 1140 * @throws { BusinessError } 2900001 - Service stopped. 1141 * @throws { BusinessError } 2900003 - Bluetooth disabled. 1142 * @throws { BusinessError } 2900099 - Operation failed. 1143 * @syscap SystemCapability.Communication.Bluetooth.Core 1144 * @systemapi 1145 * @since 11 1146 */ 1147 function disconnectAllowedProfiles(deviceId: string, callback: AsyncCallback<void>): void; 1148 1149 /** 1150 * Get remote device battery information. 1151 * 1152 * @permission ohos.permission.ACCESS_BLUETOOTH 1153 * @param { string } deviceId - Indicates device ID. For example, "11:22:33:AA:BB:FF". 1154 * @returns { Promise<BatteryInfo> } Returns battery info. 1155 * @throws { BusinessError } 201 - Permission denied. 1156 * @throws { BusinessError } 401 - Invalid parameter. Possible causes: 1. Mandatory parameters are left unspecified. 1157 * <br>2. Incorrect parameter types. 3. Parameter verification failed. 1158 * @throws { BusinessError } 2900001 - Service stopped. 1159 * @throws { BusinessError } 2900003 - Bluetooth disabled. 1160 * @syscap SystemCapability.Communication.Bluetooth.Core 1161 * @since 12 1162 */ 1163 function getRemoteDeviceBatteryInfo(deviceId: string): Promise<BatteryInfo>; 1164 1165 /** 1166 * Obtains the product ID of a remote device. 1167 * 1168 * @permission ohos.permission.ACCESS_BLUETOOTH and ohos.permission.MANAGE_BLUETOOTH 1169 * @param { string } deviceId - Indicates device ID. For example, "11:22:33:AA:BB:FF". 1170 * @returns { string } Returns the remote device's product ID. 1171 * @throws { BusinessError } 201 - Permission denied. 1172 * @throws { BusinessError } 202 - Non-system applications are not allowed to use system APIs. 1173 * @throws { BusinessError } 401 - Invalid parameter. Possible causes: 1. Mandatory parameters are left unspecified. 1174 * <br>2. Incorrect parameter types. 3. Parameter verification failed. 1175 * @throws { BusinessError } 801 - Capability not supported. 1176 * @throws { BusinessError } 2900001 - Service stopped. 1177 * @throws { BusinessError } 2900003 - Bluetooth disabled. 1178 * @throws { BusinessError } 2900099 - Operation failed. 1179 * @syscap SystemCapability.Communication.Bluetooth.Core 1180 * @systemapi 1181 * @since 11 1182 */ 1183 /** 1184 * Obtains the product ID of a remote device. 1185 * 1186 * @param { string } deviceId - Indicates device ID. For example, "11:22:33:AA:BB:FF". 1187 * @returns { string } Returns the remote device's product ID. 1188 * @throws { BusinessError } 202 - Non-system applications are not allowed to use system APIs. 1189 * @throws { BusinessError } 401 - Invalid parameter. Possible causes: 1. Mandatory parameters are left unspecified. 1190 * <br>2. Incorrect parameter types. 3. Parameter verification failed. 1191 * @throws { BusinessError } 801 - Capability not supported. 1192 * @throws { BusinessError } 2900001 - Service stopped. 1193 * @throws { BusinessError } 2900003 - Bluetooth disabled. 1194 * @throws { BusinessError } 2900099 - Operation failed. 1195 * @syscap SystemCapability.Communication.Bluetooth.Core 1196 * @systemapi 1197 * @since arkts {'1.1':'16','1.2':'20'} 1198 * @arkts 1.1&1.2 1199 */ 1200 function getRemoteProductId(deviceId: string): string; 1201 1202 /** 1203 * Disconnects all allowed bluetooth profiles between the local and remote device. 1204 * 1205 * @permission ohos.permission.ACCESS_BLUETOOTH and ohos.permission.MANAGE_BLUETOOTH 1206 * @param { string } deviceId - Indicates device ID. For example, "11:22:33:AA:BB:FF". 1207 * @returns { Promise<void> } Returns the promise object. 1208 * @throws { BusinessError } 201 - Permission denied. 1209 * @throws { BusinessError } 202 - Non-system applications are not allowed to use system APIs. 1210 * @throws { BusinessError } 401 - Invalid parameter. Possible causes: 1. Mandatory parameters are left unspecified. 1211 * <br>2. Incorrect parameter types. 3. Parameter verification failed. 1212 * @throws { BusinessError } 801 - Capability not supported. 1213 * @throws { BusinessError } 2900001 - Service stopped. 1214 * @throws { BusinessError } 2900003 - Bluetooth disabled. 1215 * @throws { BusinessError } 2900099 - Operation failed. 1216 * @syscap SystemCapability.Communication.Bluetooth.Core 1217 * @systemapi 1218 * @since 11 1219 */ 1220 function disconnectAllowedProfiles(deviceId: string): Promise<void>; 1221 1222 /** 1223 * Modify remote device name. 1224 * 1225 * @permission ohos.permission.ACCESS_BLUETOOTH 1226 * @param { string } deviceId - Indicates device ID. For example, "11:22:33:AA:BB:FF". 1227 * @param { string } name - New device name. Max length is 64 bytes. 1228 * @returns { Promise<void> } Returns the promise object. 1229 * @throws { BusinessError } 201 - Permission denied. 1230 * @throws { BusinessError } 401 - Invalid parameter. Possible causes: 1. Mandatory parameters are left unspecified. 1231 * <br>2. Incorrect parameter types. 3. Parameter verification failed. 1232 * @throws { BusinessError } 2900001 - Service stopped. 1233 * @throws { BusinessError } 2900003 - Bluetooth disabled. 1234 * @syscap SystemCapability.Communication.Bluetooth.Core 1235 * @atomicservice 1236 * @since 12 1237 */ 1238 function setRemoteDeviceName(deviceId: string, name: string): Promise<void>; 1239 1240 /** 1241 * Set remote device custom type. 1242 * 1243 * @permission ohos.permission.ACCESS_BLUETOOTH 1244 * @param { string } deviceId - Indicates device ID. For example, "11:22:33:AA:BB:FF". 1245 * @param { DeviceType } type - Indicates device type. 1246 * @returns { Promise<void> } Returns the promise object. 1247 * @throws { BusinessError } 201 - Permission denied. 1248 * @throws { BusinessError } 401 - Invalid parameter. Possible causes: 1. Mandatory parameters are left unspecified. 1249 * <br>2. Incorrect parameter types. 3. Parameter verification failed. 1250 * @throws { BusinessError } 2900001 - Service stopped. 1251 * @throws { BusinessError } 2900003 - Bluetooth disabled. 1252 * @syscap SystemCapability.Communication.Bluetooth.Core 1253 * @systemapi 1254 * @since 12 1255 */ 1256 function setRemoteDeviceType(deviceId: string, type: DeviceType): Promise<void>; 1257 1258 /** 1259 * Get remote device custom type. 1260 * 1261 * @permission ohos.permission.ACCESS_BLUETOOTH 1262 * @param { string } deviceId - Indicates device ID. For example, "11:22:33:AA:BB:FF". 1263 * @returns { Promise<DeviceType> } Returns the device type. 1264 * @throws { BusinessError } 201 - Permission denied. 1265 * @throws { BusinessError } 401 - Invalid parameter. Possible causes: 1. Mandatory parameters are left unspecified. 1266 * <br>2. Incorrect parameter types. 3. Parameter verification failed. 1267 * @throws { BusinessError } 2900001 - Service stopped. 1268 * @throws { BusinessError } 2900003 - Bluetooth disabled. 1269 * @syscap SystemCapability.Communication.Bluetooth.Core 1270 * @systemapi 1271 * @since 12 1272 */ 1273 /** 1274 * Get remote device custom type. 1275 * 1276 * @param { string } deviceId - Indicates device ID. For example, "11:22:33:AA:BB:FF". 1277 * @returns { Promise<DeviceType> } Returns the device type. 1278 * @throws { BusinessError } 202 - Non-system applications are not allowed to use system APIs. 1279 * @throws { BusinessError } 401 - Invalid parameter. Possible causes: 1. Mandatory parameters are left unspecified. 1280 * <br>2. Incorrect parameter types. 3. Parameter verification failed. 1281 * @throws { BusinessError } 2900001 - Service stopped. 1282 * @throws { BusinessError } 2900003 - Bluetooth disabled. 1283 * @syscap SystemCapability.Communication.Bluetooth.Core 1284 * @systemapi 1285 * @since 18 1286 */ 1287 function getRemoteDeviceType(deviceId: string): Promise<DeviceType>; 1288 1289 /** 1290 * Controls the actions of Bluetooth peripherals. 1291 * 1292 * @permission ohos.permission.ACCESS_BLUETOOTH and ohos.permission.MANAGE_BLUETOOTH 1293 * @param { ControlDeviceActionParams } controlDeviceActionParams - Indicates the action for Bluetooth peripherals. 1294 * @returns { Promise<void> } Returns the promise object. 1295 * @throws { BusinessError } 201 - Permission denied. 1296 * @throws { BusinessError } 202 - Non-system applications are not allowed to use system APIs. 1297 * @throws { BusinessError } 401 - Invalid parameter. Possible causes: 1. Mandatory parameters are left unspecified. 1298 * <br>2. Incorrect parameter types. 3. Parameter verification failed. 1299 * @throws { BusinessError } 801 - Capability not supported. 1300 * @throws { BusinessError } 2900001 - Service stopped. 1301 * @throws { BusinessError } 2900003 - Bluetooth disabled. 1302 * @throws { BusinessError } 2900099 - Operation failed. 1303 * @syscap SystemCapability.Communication.Bluetooth.Core 1304 * @systemapi 1305 * @since 15 1306 */ 1307 function controlDeviceAction(controlDeviceActionParams: ControlDeviceActionParams): Promise<void>; 1308 1309 /** 1310 * Get latest connection time of device. 1311 * 1312 * @param { string } deviceId - Indicates device ID. For example, "11:22:33:AA:BB:FF". 1313 * @returns { Promise<number> } Returns latest connection time. 1314 * @throws { BusinessError } 401 - Invalid parameter. Possible causes: 1. Mandatory parameters are left unspecified. 1315 * <br>2. Incorrect parameter types. 3. Parameter verification failed. 1316 * @throws { BusinessError } 801 - Capability not supported. 1317 * @throws { BusinessError } 2900001 - Service stopped. 1318 * @throws { BusinessError } 2900003 - Bluetooth disabled. 1319 * @throws { BusinessError } 2900099 - Operation failed. 1320 * @syscap SystemCapability.Communication.Bluetooth.Core 1321 * @since 15 1322 */ 1323 function getLastConnectionTime(deviceId: string): Promise<number>; 1324 1325 /** 1326 * update cloud devices. 1327 * 1328 * @permission ohos.permission.ACCESS_BLUETOOTH and ohos.permission.MANAGE_BLUETOOTH 1329 * @param { TrustedPairedDevices } trustedPairedDevices - Indicates the cloud devices. 1330 * @returns { Promise<void> } Returns the promise object. 1331 * @throws { BusinessError } 201 - Permission denied. 1332 * @throws { BusinessError } 202 - Non-system applications are not allowed to use system APIs. 1333 * @throws { BusinessError } 401 - Invalid parameter. Possible causes: 1. Mandatory parameters are left unspecified. 1334 * <br>2. Incorrect parameter types. 3. Parameter verification failed. 1335 * @throws { BusinessError } 801 - Capability not supported. 1336 * @throws { BusinessError } 2900001 - Service stopped. 1337 * @throws { BusinessError } 2900003 - Bluetooth disabled. 1338 * @throws { BusinessError } 2900099 - Operation failed. 1339 * @syscap SystemCapability.Communication.Bluetooth.Core 1340 * @systemapi 1341 * @since 15 1342 */ 1343 function updateCloudBluetoothDevice(trustedPairedDevices: TrustedPairedDevices): Promise<void>; 1344 1345 1346 /** 1347 * Subscribe the event reported when a remote Bluetooth device is discovered. 1348 * 1349 * @permission ohos.permission.ACCESS_BLUETOOTH 1350 * @param { 'bluetoothDeviceFind' } type - Type of the discovering event to listen for. 1351 * @param { Callback<Array<string>> } callback - Callback used to listen for the discovering event. 1352 * @throws { BusinessError } 201 - Permission denied. 1353 * @throws { BusinessError } 401 - Invalid parameter. Possible causes: 1. Mandatory parameters are left unspecified. 1354 * <br>2. Incorrect parameter types. 3. Parameter verification failed. 1355 * @throws { BusinessError } 801 - Capability not supported. 1356 * @throws { BusinessError } 2900099 - Operation failed. 1357 * @syscap SystemCapability.Communication.Bluetooth.Core 1358 * @since 10 1359 */ 1360 /** 1361 * Subscribe the event reported when a remote Bluetooth device is discovered. 1362 * 1363 * @permission ohos.permission.ACCESS_BLUETOOTH 1364 * @param { 'bluetoothDeviceFind' } type - Type of the discovering event to listen for. 1365 * @param { Callback<Array<string>> } callback - Callback used to listen for the discovering event. 1366 * @throws { BusinessError } 201 - Permission denied. 1367 * @throws { BusinessError } 401 - Invalid parameter. Possible causes: 1. Mandatory parameters are left unspecified. 1368 * <br>2. Incorrect parameter types. 3. Parameter verification failed. 1369 * @throws { BusinessError } 801 - Capability not supported. 1370 * @throws { BusinessError } 2900099 - Operation failed. 1371 * @syscap SystemCapability.Communication.Bluetooth.Core 1372 * @atomicservice 1373 * @since 12 1374 */ 1375 /** 1376 * Subscribe the event reported when a remote Bluetooth device is discovered. 1377 * 1378 * @permission ohos.permission.ACCESS_BLUETOOTH 1379 * @param { 'bluetoothDeviceFind' } type - Type of the discovering event to listen for. 1380 * @param { Callback<Array<string>> } callback - Callback used to listen for the discovering event. 1381 * @throws { BusinessError } 201 - Permission denied. 1382 * @throws { BusinessError } 401 - Invalid parameter. Possible causes: 1. Mandatory parameters are left unspecified. 1383 * <br>2. Incorrect parameter types. 3. Parameter verification failed. 1384 * @throws { BusinessError } 801 - Capability not supported. 1385 * @throws { BusinessError } 2900099 - Operation failed. 1386 * @syscap SystemCapability.Communication.Bluetooth.Core 1387 * @crossplatform 1388 * @atomicservice 1389 * @since 13 1390 */ 1391 function on(type: 'bluetoothDeviceFind', callback: Callback<Array<string>>): void; 1392 1393 /** 1394 * Unsubscribe the event reported when a remote Bluetooth device is discovered. 1395 * 1396 * @permission ohos.permission.ACCESS_BLUETOOTH 1397 * @param { 'bluetoothDeviceFind' } type - Type of the discovering event to listen for. 1398 * @param { Callback<Array<string>> } callback - Callback used to listen for the discovering event. 1399 * @throws { BusinessError } 201 - Permission denied. 1400 * @throws { BusinessError } 801 - Capability not supported. 1401 * @throws { BusinessError } 2900099 - Operation failed. 1402 * @syscap SystemCapability.Communication.Bluetooth.Core 1403 * @since 10 1404 */ 1405 /** 1406 * Unsubscribe the event reported when a remote Bluetooth device is discovered. 1407 * 1408 * @permission ohos.permission.ACCESS_BLUETOOTH 1409 * @param { 'bluetoothDeviceFind' } type - Type of the discovering event to listen for. 1410 * @param { Callback<Array<string>> } callback - Callback used to listen for the discovering event. 1411 * @throws { BusinessError } 201 - Permission denied. 1412 * @throws { BusinessError } 801 - Capability not supported. 1413 * @throws { BusinessError } 2900099 - Operation failed. 1414 * @syscap SystemCapability.Communication.Bluetooth.Core 1415 * @atomicservice 1416 * @since 12 1417 */ 1418 /** 1419 * Unsubscribe the event reported when a remote Bluetooth device is discovered. 1420 * 1421 * @permission ohos.permission.ACCESS_BLUETOOTH 1422 * @param { 'bluetoothDeviceFind' } type - Type of the discovering event to listen for. 1423 * @param { Callback<Array<string>> } callback - Callback used to listen for the discovering event. 1424 * @throws { BusinessError } 201 - Permission denied. 1425 * @throws { BusinessError } 801 - Capability not supported. 1426 * @throws { BusinessError } 2900099 - Operation failed. 1427 * @syscap SystemCapability.Communication.Bluetooth.Core 1428 * @crossplatform 1429 * @atomicservice 1430 * @since 13 1431 */ 1432 function off(type: 'bluetoothDeviceFind', callback?: Callback<Array<string>>): void; 1433 1434 /** 1435 * Subscribe the event reported when a remote Bluetooth device is discovered. 1436 * 1437 * @permission ohos.permission.ACCESS_BLUETOOTH and ohos.permission.GET_BLUETOOTH_PEERS_MAC 1438 * @param { 'discoveryResult' } type - Type of the discovering event to listen for. 1439 * @param { Callback<Array<DiscoveryResult>> } callback - Callback used to listen for the discovering event. 1440 * @throws { BusinessError } 201 - Permission denied. 1441 * @throws { BusinessError } 401 - Invalid parameter. Possible causes: 1. Mandatory parameters are left unspecified. 1442 * <br>2. Incorrect parameter types. 3. Parameter verification failed. 1443 * @throws { BusinessError } 801 - Capability not supported. 1444 * @throws { BusinessError } 2900099 - Operation failed. 1445 * @syscap SystemCapability.Communication.Bluetooth.Core 1446 * @systemapi 1447 * @since 12 1448 */ 1449 /** 1450 * Subscribe the event reported when a remote Bluetooth device is discovered. 1451 * 1452 * @permission ohos.permission.ACCESS_BLUETOOTH 1453 * @param { 'discoveryResult' } type - Type of the discovering event to listen for. 1454 * @param { Callback<Array<DiscoveryResult>> } callback - Callback used to listen for the discovering event. 1455 * @throws { BusinessError } 201 - Permission denied. 1456 * @throws { BusinessError } 401 - Invalid parameter. Possible causes: 1. Mandatory parameters are left unspecified. 1457 * <br>2. Incorrect parameter types. 3. Parameter verification failed. 1458 * @throws { BusinessError } 801 - Capability not supported. 1459 * @throws { BusinessError } 2900099 - Operation failed. 1460 * @syscap SystemCapability.Communication.Bluetooth.Core 1461 * @since 18 1462 */ 1463 function on(type: 'discoveryResult', callback: Callback<Array<DiscoveryResult>>): void; 1464 1465 /** 1466 * Unsubscribe the event reported when a remote Bluetooth device is discovered. 1467 * 1468 * @permission ohos.permission.ACCESS_BLUETOOTH and ohos.permission.GET_BLUETOOTH_PEERS_MAC 1469 * @param { 'discoveryResult' } type - Type of the discovering event to listen for. 1470 * @param { Callback<Array<DiscoveryResult>> } callback - Callback used to listen for the discovering event. 1471 * @throws { BusinessError } 201 - Permission denied. 1472 * @throws { BusinessError } 801 - Capability not supported. 1473 * @throws { BusinessError } 2900099 - Operation failed. 1474 * @syscap SystemCapability.Communication.Bluetooth.Core 1475 * @systemapi 1476 * @since 12 1477 */ 1478 /** 1479 * Unsubscribe the event reported when a remote Bluetooth device is discovered. 1480 * 1481 * @permission ohos.permission.ACCESS_BLUETOOTH 1482 * @param { 'discoveryResult' } type - Type of the discovering event to listen for. 1483 * @param { Callback<Array<DiscoveryResult>> } callback - Callback used to listen for the discovering event. 1484 * @throws { BusinessError } 201 - Permission denied. 1485 * @throws { BusinessError } 801 - Capability not supported. 1486 * @throws { BusinessError } 2900099 - Operation failed. 1487 * @syscap SystemCapability.Communication.Bluetooth.Core 1488 * @since 18 1489 */ 1490 function off(type: 'discoveryResult', callback?: Callback<Array<DiscoveryResult>>): void; 1491 1492 /** 1493 * Subscribe the event reported when a remote Bluetooth device is bonded. 1494 * 1495 * @permission ohos.permission.ACCESS_BLUETOOTH 1496 * @param { 'bondStateChange' } type - Type of the bond state event to listen for. 1497 * @param { Callback<BondStateParam> } callback - Callback used to listen for the bond state event. 1498 * @throws { BusinessError } 201 - Permission denied. 1499 * @throws { BusinessError } 401 - Invalid parameter. Possible causes: 1. Mandatory parameters are left unspecified. 1500 * <br>2. Incorrect parameter types. 3. Parameter verification failed. 1501 * @throws { BusinessError } 801 - Capability not supported. 1502 * @throws { BusinessError } 2900099 - Operation failed. 1503 * @syscap SystemCapability.Communication.Bluetooth.Core 1504 * @since 10 1505 */ 1506 /** 1507 * Subscribe the event reported when a remote Bluetooth device is bonded. 1508 * 1509 * @permission ohos.permission.ACCESS_BLUETOOTH 1510 * @param { 'bondStateChange' } type - Type of the bond state event to listen for. 1511 * @param { Callback<BondStateParam> } callback - Callback used to listen for the bond state event. 1512 * @throws { BusinessError } 201 - Permission denied. 1513 * @throws { BusinessError } 401 - Invalid parameter. Possible causes: 1. Mandatory parameters are left unspecified. 1514 * <br>2. Incorrect parameter types. 3. Parameter verification failed. 1515 * @throws { BusinessError } 801 - Capability not supported. 1516 * @throws { BusinessError } 2900099 - Operation failed. 1517 * @syscap SystemCapability.Communication.Bluetooth.Core 1518 * @crossplatform 1519 * @since 13 1520 */ 1521 function on(type: 'bondStateChange', callback: Callback<BondStateParam>): void; 1522 1523 /** 1524 * Unsubscribe the event reported when a remote Bluetooth device is bonded. 1525 * 1526 * @permission ohos.permission.ACCESS_BLUETOOTH 1527 * @param { 'bondStateChange' } type - Type of the bond state event to listen for. 1528 * @param { Callback<BondStateParam> } callback - Callback used to listen for the bond state event. 1529 * @throws { BusinessError } 201 - Permission denied. 1530 * @throws { BusinessError } 401 - Invalid parameter. Possible causes: 1. Mandatory parameters are left unspecified. 1531 * <br>2. Incorrect parameter types. 3. Parameter verification failed. 1532 * @throws { BusinessError } 801 - Capability not supported. 1533 * @throws { BusinessError } 2900099 - Operation failed. 1534 * @syscap SystemCapability.Communication.Bluetooth.Core 1535 * @since 10 1536 */ 1537 /** 1538 * Unsubscribe the event reported when a remote Bluetooth device is bonded. 1539 * 1540 * @permission ohos.permission.ACCESS_BLUETOOTH 1541 * @param { 'bondStateChange' } type - Type of the bond state event to listen for. 1542 * @param { Callback<BondStateParam> } callback - Callback used to listen for the bond state event. 1543 * @throws { BusinessError } 201 - Permission denied. 1544 * @throws { BusinessError } 401 - Invalid parameter. Possible causes: 1. Mandatory parameters are left unspecified. 1545 * <br>2. Incorrect parameter types. 3. Parameter verification failed. 1546 * @throws { BusinessError } 801 - Capability not supported. 1547 * @throws { BusinessError } 2900099 - Operation failed. 1548 * @syscap SystemCapability.Communication.Bluetooth.Core 1549 * @crossplatform 1550 * @since 13 1551 */ 1552 function off(type: 'bondStateChange', callback?: Callback<BondStateParam>): void; 1553 1554 /** 1555 * Subscribe the event of a pairing request from a remote Bluetooth device. 1556 * 1557 * @permission ohos.permission.ACCESS_BLUETOOTH 1558 * @param { 'pinRequired' } type - Type of the pairing request event to listen for. 1559 * @param { Callback<PinRequiredParam> } callback - Callback used to listen for the pairing request event. 1560 * @throws { BusinessError } 201 - Permission denied. 1561 * @throws { BusinessError } 401 - Invalid parameter. Possible causes: 1. Mandatory parameters are left unspecified. 1562 * <br>2. Incorrect parameter types. 3. Parameter verification failed. 1563 * @throws { BusinessError } 801 - Capability not supported. 1564 * @throws { BusinessError } 2900099 - Operation failed. 1565 * @syscap SystemCapability.Communication.Bluetooth.Core 1566 * @since 10 1567 */ 1568 function on(type: 'pinRequired', callback: Callback<PinRequiredParam>): void; 1569 1570 /** 1571 * Unsubscribe the event of a pairing request from a remote Bluetooth device. 1572 * 1573 * @permission ohos.permission.ACCESS_BLUETOOTH 1574 * @param { 'pinRequired' } type - Type of the pairing request event to listen for. 1575 * @param { Callback<PinRequiredParam> } callback - Callback used to listen for the pairing request event. 1576 * @throws { BusinessError } 201 - Permission denied. 1577 * @throws { BusinessError } 401 - Invalid parameter. Possible causes: 1. Mandatory parameters are left unspecified. 1578 * <br>2. Incorrect parameter types. 3. Parameter verification failed. 1579 * @throws { BusinessError } 801 - Capability not supported. 1580 * @throws { BusinessError } 2900099 - Operation failed. 1581 * @syscap SystemCapability.Communication.Bluetooth.Core 1582 * @since 10 1583 */ 1584 function off(type: 'pinRequired', callback?: Callback<PinRequiredParam>): void; 1585 1586 /** 1587 * Subscribe the event of battery state changed from a remote device. 1588 * 1589 * @permission ohos.permission.ACCESS_BLUETOOTH 1590 * @param { 'batteryChange' } type - Type of the battery event to listen for. 1591 * @param { Callback<BatteryInfo> } callback - Callback used to listen. 1592 * @throws { BusinessError } 201 - Permission denied. 1593 * @throws { BusinessError } 2900099 - Operation failed. 1594 * @syscap SystemCapability.Communication.Bluetooth.Core 1595 * @since 12 1596 */ 1597 function on(type: 'batteryChange', callback: Callback<BatteryInfo>): void; 1598 1599 /** 1600 * Unsubscribe the event of battery state changed from a remote device. 1601 * 1602 * @permission ohos.permission.ACCESS_BLUETOOTH 1603 * @param { 'batteryChange' } type - Type of the battery event to listen for. 1604 * @param { Callback<BatteryInfo> } callback - Callback used to listen. 1605 * @throws { BusinessError } 201 - Permission denied. 1606 * @throws { BusinessError } 2900099 - Operation failed. 1607 * @syscap SystemCapability.Communication.Bluetooth.Core 1608 * @since 12 1609 */ 1610 function off(type: 'batteryChange', callback?: Callback<BatteryInfo>): void; 1611 1612 /** 1613 * Describes the class of a bluetooth device. 1614 * 1615 * @typedef BondStateParam 1616 * @syscap SystemCapability.Communication.Bluetooth.Core 1617 * @since 10 1618 */ 1619 /** 1620 * Describes the class of a bluetooth device. 1621 * 1622 * @typedef BondStateParam 1623 * @syscap SystemCapability.Communication.Bluetooth.Core 1624 * @crossplatform 1625 * @since arkts {'1.1':'13','1.2':'20'} 1626 * @arkts 1.1&1.2 1627 */ 1628 interface BondStateParam { 1629 /** 1630 * Address of a Bluetooth device. 1631 * 1632 * @type { string } 1633 * @syscap SystemCapability.Communication.Bluetooth.Core 1634 * @since 10 1635 */ 1636 /** 1637 * Address of a Bluetooth device. 1638 * 1639 * @type { string } 1640 * @syscap SystemCapability.Communication.Bluetooth.Core 1641 * @crossplatform 1642 * @since arkts {'1.1':'13','1.2':'20'} 1643 * @arkts 1.1&1.2 1644 */ 1645 deviceId: string; 1646 /** 1647 * Profile connection state of the device. 1648 * 1649 * @type { BondState } 1650 * @syscap SystemCapability.Communication.Bluetooth.Core 1651 * @since 10 1652 */ 1653 /** 1654 * Profile connection state of the device. 1655 * 1656 * @type { BondState } 1657 * @syscap SystemCapability.Communication.Bluetooth.Core 1658 * @crossplatform 1659 * @since arkts {'1.1':'13','1.2':'20'} 1660 * @arkts 1.1&1.2 1661 */ 1662 state: BondState; 1663 /** 1664 * Cause of unbond. 1665 * 1666 * @type { UnbondCause } 1667 * @syscap SystemCapability.Communication.Bluetooth.Core 1668 * @since 12 1669 */ 1670 /** 1671 * Cause of unbond. 1672 * 1673 * @type { UnbondCause } 1674 * @syscap SystemCapability.Communication.Bluetooth.Core 1675 * @crossplatform 1676 * @since 13 1677 */ 1678 cause: UnbondCause; 1679 } 1680 1681 /** 1682 * Describes the bond key param. 1683 * 1684 * @typedef PinRequiredParam 1685 * @syscap SystemCapability.Communication.Bluetooth.Core 1686 * @since arkts {'1.1':'10','1.2':'20'} 1687 * @arkts 1.1&1.2 1688 */ 1689 interface PinRequiredParam { 1690 /** 1691 * ID of the device to pair. 1692 * 1693 * @type { string } 1694 * @syscap SystemCapability.Communication.Bluetooth.Core 1695 * @since arkts {'1.1':'10','1.2':'20'} 1696 * @arkts 1.1&1.2 1697 */ 1698 deviceId: string; 1699 /** 1700 * Key for the device pairing. 1701 * 1702 * @type { string } 1703 * @syscap SystemCapability.Communication.Bluetooth.Core 1704 * @since 10 1705 */ 1706 pinCode: string; 1707 /** 1708 * Indicates the pairing type to a peer device. 1709 * 1710 * @type { PinType } 1711 * @syscap SystemCapability.Communication.Bluetooth.Core 1712 * @systemapi 1713 * @since 10 1714 */ 1715 pinType: PinType; 1716 } 1717 1718 /** 1719 * Describes the class of a bluetooth device. 1720 * 1721 * @typedef DeviceClass 1722 * @syscap SystemCapability.Communication.Bluetooth.Core 1723 * @since 10 1724 */ 1725 /** 1726 * Describes the class of a bluetooth device. 1727 * 1728 * @typedef DeviceClass 1729 * @syscap SystemCapability.Communication.Bluetooth.Core 1730 * @crossplatform 1731 * @since arkts {'1.1':'13','1.2':'20'} 1732 * @arkts 1.1&1.2 1733 */ 1734 interface DeviceClass { 1735 /** 1736 * Major classes of Bluetooth devices. 1737 * 1738 * @type { MajorClass } 1739 * @syscap SystemCapability.Communication.Bluetooth.Core 1740 * @since 10 1741 */ 1742 /** 1743 * Major classes of Bluetooth devices. 1744 * 1745 * @type { MajorClass } 1746 * @syscap SystemCapability.Communication.Bluetooth.Core 1747 * @crossplatform 1748 * @since arkts {'1.1':'13','1.2':'20'} 1749 * @arkts 1.1&1.2 1750 */ 1751 majorClass: MajorClass; 1752 /** 1753 * Major and minor classes of Bluetooth devices. 1754 * 1755 * @type { MajorMinorClass } 1756 * @syscap SystemCapability.Communication.Bluetooth.Core 1757 * @since 10 1758 */ 1759 /** 1760 * Major and minor classes of Bluetooth devices. 1761 * 1762 * @type { MajorMinorClass } 1763 * @syscap SystemCapability.Communication.Bluetooth.Core 1764 * @crossplatform 1765 * @since arkts {'1.1':'13','1.2':'20'} 1766 * @arkts 1.1&1.2 1767 */ 1768 majorMinorClass: MajorMinorClass; 1769 /** 1770 * Class of the device. 1771 * 1772 * @type { number } 1773 * @syscap SystemCapability.Communication.Bluetooth.Core 1774 * @since 10 1775 */ 1776 /** 1777 * Class of the device. 1778 * 1779 * @type { number } 1780 * @syscap SystemCapability.Communication.Bluetooth.Core 1781 * @crossplatform 1782 * @since 13 1783 */ 1784 classOfDevice: number; 1785 } 1786 1787 /** 1788 * Enum for the transport of a remote device 1789 * 1790 * @enum { number } 1791 * @syscap SystemCapability.Communication.Bluetooth.Core 1792 * @since 10 1793 */ 1794 enum BluetoothTransport { 1795 /** 1796 * The value of bluetooth transport BR/EDR. 1797 * 1798 * @syscap SystemCapability.Communication.Bluetooth.Core 1799 * @since 10 1800 */ 1801 TRANSPORT_BR_EDR = 0, 1802 /** 1803 * The value of bluetooth transport LE. 1804 * 1805 * @syscap SystemCapability.Communication.Bluetooth.Core 1806 * @since 10 1807 */ 1808 TRANSPORT_LE = 1, 1809 /** 1810 * The value of bluetooth transport DUAL. 1811 * 1812 * @syscap SystemCapability.Communication.Bluetooth.Core 1813 * @since 20 1814 */ 1815 TRANSPORT_DUAL = 2, 1816 /** 1817 * The unknown bluetooth transport. 1818 * 1819 * @syscap SystemCapability.Communication.Bluetooth.Core 1820 * @since 20 1821 */ 1822 TRANSPORT_UNKNOWN = 3 1823 } 1824 1825 /** 1826 * The enum of BR scan mode. 1827 * 1828 * @enum { number } 1829 * @syscap SystemCapability.Communication.Bluetooth.Core 1830 * @since 10 1831 */ 1832 /** 1833 * The enum of BR scan mode. 1834 * 1835 * @enum { number } 1836 * @syscap SystemCapability.Communication.Bluetooth.Core 1837 * @crossplatform 1838 * @since arkts {'1.1':'13','1.2':'20'} 1839 * @arkts 1.1&1.2 1840 */ 1841 enum ScanMode { 1842 /** 1843 * Indicates the scan mode is none 1844 * 1845 * @syscap SystemCapability.Communication.Bluetooth.Core 1846 * @since 10 1847 */ 1848 /** 1849 * Indicates the scan mode is none 1850 * 1851 * @syscap SystemCapability.Communication.Bluetooth.Core 1852 * @crossplatform 1853 * @since 13 1854 */ 1855 SCAN_MODE_NONE = 0, 1856 /** 1857 * Indicates the scan mode is connectable 1858 * 1859 * @syscap SystemCapability.Communication.Bluetooth.Core 1860 * @since 10 1861 */ 1862 /** 1863 * Indicates the scan mode is connectable 1864 * 1865 * @syscap SystemCapability.Communication.Bluetooth.Core 1866 * @crossplatform 1867 * @since 13 1868 */ 1869 SCAN_MODE_CONNECTABLE = 1, 1870 /** 1871 * Indicates the scan mode is general discoverable 1872 * 1873 * @syscap SystemCapability.Communication.Bluetooth.Core 1874 * @since 10 1875 */ 1876 SCAN_MODE_GENERAL_DISCOVERABLE = 2, 1877 /** 1878 * Indicates the scan mode is limited discoverable 1879 * 1880 * @syscap SystemCapability.Communication.Bluetooth.Core 1881 * @since 10 1882 */ 1883 SCAN_MODE_LIMITED_DISCOVERABLE = 3, 1884 /** 1885 * Indicates the scan mode is connectable and general discoverable 1886 * 1887 * @syscap SystemCapability.Communication.Bluetooth.Core 1888 * @since 10 1889 */ 1890 /** 1891 * Indicates the scan mode is connectable and general discoverable 1892 * 1893 * @syscap SystemCapability.Communication.Bluetooth.Core 1894 * @crossplatform 1895 * @since arkts {'1.1':'13','1.2':'20'} 1896 * @arkts 1.1&1.2 1897 */ 1898 SCAN_MODE_CONNECTABLE_GENERAL_DISCOVERABLE = 4, 1899 /** 1900 * Indicates the scan mode is connectable and limited discoverable 1901 * 1902 * @syscap SystemCapability.Communication.Bluetooth.Core 1903 * @since 10 1904 */ 1905 SCAN_MODE_CONNECTABLE_LIMITED_DISCOVERABLE = 5 1906 } 1907 1908 /** 1909 * The enum of bond state. 1910 * 1911 * @enum { number } 1912 * @syscap SystemCapability.Communication.Bluetooth.Core 1913 * @since 10 1914 */ 1915 /** 1916 * The enum of bond state. 1917 * 1918 * @enum { number } 1919 * @syscap SystemCapability.Communication.Bluetooth.Core 1920 * @atomicservice 1921 * @since 12 1922 */ 1923 /** 1924 * The enum of bond state. 1925 * 1926 * @enum { number } 1927 * @syscap SystemCapability.Communication.Bluetooth.Core 1928 * @crossplatform 1929 * @atomicservice 1930 * @since arkts {'1.1':'13','1.2':'20'} 1931 * @arkts 1.1&1.2 1932 */ 1933 enum BondState { 1934 /** 1935 * Indicate the bond state is invalid 1936 * 1937 * @syscap SystemCapability.Communication.Bluetooth.Core 1938 * @since 10 1939 */ 1940 /** 1941 * Indicate the bond state is invalid 1942 * 1943 * @syscap SystemCapability.Communication.Bluetooth.Core 1944 * @atomicservice 1945 * @since 12 1946 */ 1947 /** 1948 * Indicate the bond state is invalid 1949 * 1950 * @syscap SystemCapability.Communication.Bluetooth.Core 1951 * @crossplatform 1952 * @atomicservice 1953 * @since 13 1954 */ 1955 BOND_STATE_INVALID = 0, 1956 /** 1957 * Indicate the bond state is bonding 1958 * 1959 * @syscap SystemCapability.Communication.Bluetooth.Core 1960 * @since 10 1961 */ 1962 /** 1963 * Indicate the bond state is bonding 1964 * 1965 * @syscap SystemCapability.Communication.Bluetooth.Core 1966 * @atomicservice 1967 * @since 12 1968 */ 1969 /** 1970 * Indicate the bond state is bonding 1971 * 1972 * @syscap SystemCapability.Communication.Bluetooth.Core 1973 * @crossplatform 1974 * @atomicservice 1975 * @since 13 1976 */ 1977 BOND_STATE_BONDING = 1, 1978 /** 1979 * Indicate the bond state is bonded 1980 * 1981 * @syscap SystemCapability.Communication.Bluetooth.Core 1982 * @since 10 1983 */ 1984 /** 1985 * Indicate the bond state is bonded 1986 * 1987 * @syscap SystemCapability.Communication.Bluetooth.Core 1988 * @atomicservice 1989 * @since 12 1990 */ 1991 /** 1992 * Indicate the bond state is bonded 1993 * 1994 * @syscap SystemCapability.Communication.Bluetooth.Core 1995 * @crossplatform 1996 * @atomicservice 1997 * @since arkts {'1.1':'13','1.2':'20'} 1998 * @arkts 1.1&1.2 1999 */ 2000 BOND_STATE_BONDED = 2 2001 } 2002 2003 /** 2004 * Enum for the type of pairing to a remote device 2005 * 2006 * @enum { number } 2007 * @syscap SystemCapability.Communication.Bluetooth.Core 2008 * @systemapi 2009 * @since 10 2010 */ 2011 enum PinType { 2012 /** 2013 * The user needs to enter the pin code displayed on the peer device. 2014 * 2015 * @syscap SystemCapability.Communication.Bluetooth.Core 2016 * @systemapi 2017 * @since 10 2018 */ 2019 PIN_TYPE_ENTER_PIN_CODE = 0, 2020 /** 2021 * The user needs to enter the passkey displayed on the peer device. 2022 * 2023 * @syscap SystemCapability.Communication.Bluetooth.Core 2024 * @systemapi 2025 * @since 10 2026 */ 2027 PIN_TYPE_ENTER_PASSKEY = 1, 2028 /** 2029 * The user needs to confirm the passkey displayed on the local device. 2030 * 2031 * @syscap SystemCapability.Communication.Bluetooth.Core 2032 * @systemapi 2033 * @since 10 2034 */ 2035 PIN_TYPE_CONFIRM_PASSKEY = 2, 2036 /** 2037 * The user needs to accept or deny the pairing request. 2038 * 2039 * @syscap SystemCapability.Communication.Bluetooth.Core 2040 * @systemapi 2041 * @since 10 2042 */ 2043 PIN_TYPE_NO_PASSKEY_CONSENT = 3, 2044 /** 2045 * The user needs to enter the passkey displayed on the local device on the peer device. 2046 * 2047 * @syscap SystemCapability.Communication.Bluetooth.Core 2048 * @systemapi 2049 * @since 10 2050 */ 2051 PIN_TYPE_NOTIFY_PASSKEY = 4, 2052 /** 2053 * The user needs to enter the pin code displayed on the peer device, used for bluetooth 2.0. 2054 * 2055 * @syscap SystemCapability.Communication.Bluetooth.Core 2056 * @systemapi 2057 * @since 10 2058 */ 2059 PIN_TYPE_DISPLAY_PIN_CODE = 5, 2060 /** 2061 * The user needs to accept or deny the OOB pairing request. 2062 * 2063 * @syscap SystemCapability.Communication.Bluetooth.Core 2064 * @systemapi 2065 * @since 10 2066 */ 2067 PIN_TYPE_OOB_CONSENT = 6, 2068 /** 2069 * The user needs to enter the 16-digit pin code displayed on the peer device. 2070 * 2071 * @syscap SystemCapability.Communication.Bluetooth.Core 2072 * @systemapi 2073 * @since 10 2074 */ 2075 PIN_TYPE_PIN_16_DIGITS = 7 2076 } 2077 2078 /** 2079 * Describes the contents of the discovery results 2080 * 2081 * @typedef DiscoveryResult 2082 * @syscap SystemCapability.Communication.Bluetooth.Core 2083 * @systemapi 2084 * @since 12 2085 */ 2086 /** 2087 * Describes the contents of the discovery results 2088 * 2089 * @typedef DiscoveryResult 2090 * @syscap SystemCapability.Communication.Bluetooth.Core 2091 * @since arkts {'1.1':'18','1.2':'20'} 2092 * @arkts 1.1&1.2 2093 */ 2094 interface DiscoveryResult { 2095 /** 2096 * Identify of the discovery device 2097 * 2098 * @type { string } 2099 * @syscap SystemCapability.Communication.Bluetooth.Core 2100 * @systemapi 2101 * @since 12 2102 */ 2103 /** 2104 * Identify of the discovery device 2105 * 2106 * @type { string } 2107 * @syscap SystemCapability.Communication.Bluetooth.Core 2108 * @since arkts {'1.1':'18','1.2':'20'} 2109 * @arkts 1.1&1.2 2110 */ 2111 deviceId: string; 2112 /** 2113 * RSSI of the remote device 2114 * 2115 * @type { number } 2116 * @syscap SystemCapability.Communication.Bluetooth.Core 2117 * @systemapi 2118 * @since 12 2119 */ 2120 /** 2121 * RSSI of the remote device 2122 * 2123 * @type { number } 2124 * @syscap SystemCapability.Communication.Bluetooth.Core 2125 * @since 18 2126 */ 2127 rssi: number; 2128 /** 2129 * The local name of the device 2130 * 2131 * @type { string } 2132 * @syscap SystemCapability.Communication.Bluetooth.Core 2133 * @systemapi 2134 * @since 12 2135 */ 2136 /** 2137 * The local name of the device 2138 * 2139 * @type { string } 2140 * @syscap SystemCapability.Communication.Bluetooth.Core 2141 * @since 18 2142 */ 2143 deviceName: string; 2144 /** 2145 * The class of the device 2146 * 2147 * @type { DeviceClass } 2148 * @syscap SystemCapability.Communication.Bluetooth.Core 2149 * @systemapi 2150 * @since 12 2151 */ 2152 /** 2153 * The class of the device 2154 * 2155 * @type { DeviceClass } 2156 * @syscap SystemCapability.Communication.Bluetooth.Core 2157 * @since 18 2158 */ 2159 deviceClass: DeviceClass; 2160 } 2161 2162 /** 2163 * Describes the contents of the battery information. 2164 * 2165 * @typedef BatteryInfo 2166 * @syscap SystemCapability.Communication.Bluetooth.Core 2167 * @since arkts {'1.1':'12','1.2':'20'} 2168 * @arkts 1.1&1.2 2169 */ 2170 interface BatteryInfo { 2171 /** 2172 * Identify of the discovery device. 2173 * 2174 * @type { string } 2175 * @syscap SystemCapability.Communication.Bluetooth.Core 2176 * @systemapi 2177 * @since arkts {'1.1':'12','1.2':'20'} 2178 * @arkts 1.1&1.2 2179 */ 2180 deviceId: string; 2181 /** 2182 * Electricity value of the general device. {@code -1} means no power information. 2183 * 2184 * @type { number } 2185 * @syscap SystemCapability.Communication.Bluetooth.Core 2186 * @since 12 2187 */ 2188 batteryLevel: number; 2189 /** 2190 * Electricity value of the left ear. {@code -1} means no power information. 2191 * 2192 * @type { number } 2193 * @syscap SystemCapability.Communication.Bluetooth.Core 2194 * @since 12 2195 */ 2196 leftEarBatteryLevel: number; 2197 /** 2198 * The charge state of the left ear. 2199 * 2200 * @type { DeviceChargeState } 2201 * @syscap SystemCapability.Communication.Bluetooth.Core 2202 * @since 12 2203 */ 2204 leftEarChargeState: DeviceChargeState; 2205 /** 2206 * Electricity value of the right ear. {@code -1} means no power information. 2207 * 2208 * @type { number } 2209 * @syscap SystemCapability.Communication.Bluetooth.Core 2210 * @since 12 2211 */ 2212 rightEarBatteryLevel: number; 2213 /** 2214 * The charge state of the right ear. 2215 * 2216 * @type { DeviceChargeState } 2217 * @syscap SystemCapability.Communication.Bluetooth.Core 2218 * @since 12 2219 */ 2220 rightEarChargeState: DeviceChargeState; 2221 /** 2222 * Electricity value of the box. {@code -1} means no power information. 2223 * 2224 * @type { number } 2225 * @syscap SystemCapability.Communication.Bluetooth.Core 2226 * @since 12 2227 */ 2228 boxBatteryLevel: number; 2229 /** 2230 * The charge state of the box. 2231 * 2232 * @type { DeviceChargeState } 2233 * @syscap SystemCapability.Communication.Bluetooth.Core 2234 * @since 12 2235 */ 2236 boxChargeState: DeviceChargeState; 2237 } 2238 2239 /** 2240 * Enum for the charge state. 2241 * 2242 * @enum { number } 2243 * @syscap SystemCapability.Communication.Bluetooth.Core 2244 * @since 12 2245 */ 2246 enum DeviceChargeState { 2247 /** 2248 * Not support super charge, and not charged. 2249 * 2250 * @syscap SystemCapability.Communication.Bluetooth.Core 2251 * @since 12 2252 */ 2253 DEVICE_NORMAL_CHARGE_NOT_CHARGED = 0, 2254 /** 2255 * Not support super charge, and in charging. 2256 * 2257 * @syscap SystemCapability.Communication.Bluetooth.Core 2258 * @since 12 2259 */ 2260 DEVICE_NORMAL_CHARGE_IN_CHARGING = 1, 2261 /** 2262 * Support super charge, and not charged. 2263 * 2264 * @syscap SystemCapability.Communication.Bluetooth.Core 2265 * @since 12 2266 */ 2267 DEVICE_SUPER_CHARGE_NOT_CHARGED = 2, 2268 /** 2269 * Support super charge, and in charging. 2270 * 2271 * @syscap SystemCapability.Communication.Bluetooth.Core 2272 * @since 12 2273 */ 2274 DEVICE_SUPER_CHARGE_IN_CHARGING = 3 2275 } 2276 2277 /** 2278 * Enum for the custom type of remote device. 2279 * 2280 * @enum { number } 2281 * @syscap SystemCapability.Communication.Bluetooth.Core 2282 * @systemapi 2283 * @since 12 2284 */ 2285 enum DeviceType { 2286 /** 2287 * Default type, the type is consistent with COD. 2288 * 2289 * @syscap SystemCapability.Communication.Bluetooth.Core 2290 * @systemapi 2291 * @since 12 2292 */ 2293 DEVICE_TYPE_DEFAULT = 0, 2294 /** 2295 * Car bluetooth. 2296 * 2297 * @syscap SystemCapability.Communication.Bluetooth.Core 2298 * @systemapi 2299 * @since 12 2300 */ 2301 DEVICE_TYPE_CAR = 1, 2302 /** 2303 * Headset bluetooth. 2304 * 2305 * @syscap SystemCapability.Communication.Bluetooth.Core 2306 * @systemapi 2307 * @since 12 2308 */ 2309 DEVICE_TYPE_HEADSET = 2, 2310 /** 2311 * Hearing Aid. 2312 * 2313 * @syscap SystemCapability.Communication.Bluetooth.Core 2314 * @systemapi 2315 * @since 12 2316 */ 2317 DEVICE_TYPE_HEARING = 3, 2318 /** 2319 * Glasses device. 2320 * 2321 * @syscap SystemCapability.Communication.Bluetooth.Core 2322 * @systemapi 2323 * @since 12 2324 */ 2325 DEVICE_TYPE_GLASSES = 4, 2326 /** 2327 * Watch device. 2328 * 2329 * @syscap SystemCapability.Communication.Bluetooth.Core 2330 * @systemapi 2331 * @since 12 2332 */ 2333 DEVICE_TYPE_WATCH = 5, 2334 /** 2335 * Speaker device. 2336 * 2337 * @syscap SystemCapability.Communication.Bluetooth.Core 2338 * @systemapi 2339 * @since 12 2340 */ 2341 DEVICE_TYPE_SPEAKER = 6, 2342 /** 2343 * Others bluetooth. 2344 * 2345 * @syscap SystemCapability.Communication.Bluetooth.Core 2346 * @systemapi 2347 * @since 12 2348 */ 2349 DEVICE_TYPE_OTHERS = 7 2350 } 2351 2352 /** 2353 * Enum for cause of unbond. 2354 * 2355 * @enum { number } 2356 * @syscap SystemCapability.Communication.Bluetooth.Core 2357 * @since 12 2358 */ 2359 /** 2360 * Enum for cause of unbond. 2361 * 2362 * @enum { number } 2363 * @syscap SystemCapability.Communication.Bluetooth.Core 2364 * @crossplatform 2365 * @since 13 2366 */ 2367 enum UnbondCause { 2368 /** 2369 * User proactively removed device. 2370 * 2371 * @syscap SystemCapability.Communication.Bluetooth.Core 2372 * @since 12 2373 */ 2374 /** 2375 * User proactively removed device. 2376 * 2377 * @syscap SystemCapability.Communication.Bluetooth.Core 2378 * @crossplatform 2379 * @since 13 2380 */ 2381 USER_REMOVED = 0, 2382 /** 2383 * Remote device shut down. 2384 * 2385 * @syscap SystemCapability.Communication.Bluetooth.Core 2386 * @since 12 2387 */ 2388 REMOTE_DEVICE_DOWN = 1, 2389 /** 2390 * Wrong PIN code. 2391 * 2392 * @syscap SystemCapability.Communication.Bluetooth.Core 2393 * @since 12 2394 */ 2395 AUTH_FAILURE = 2, 2396 /** 2397 * Remote device rejected. 2398 * 2399 * @syscap SystemCapability.Communication.Bluetooth.Core 2400 * @since 12 2401 */ 2402 AUTH_REJECTED = 3, 2403 /** 2404 * Internal error. 2405 * 2406 * @syscap SystemCapability.Communication.Bluetooth.Core 2407 * @since 12 2408 */ 2409 INTERNAL_ERROR = 4 2410 } 2411 /** 2412 * Describes information about controlling the Bluetooth peripheral. 2413 * 2414 * @typedef ControlDeviceActionParams 2415 * @syscap SystemCapability.Communication.Bluetooth.Core 2416 * @systemapi 2417 * @since 15 2418 */ 2419 interface ControlDeviceActionParams { 2420 /** 2421 * Indicates the address of the peripheral. 2422 * 2423 * @type { string } 2424 * @syscap SystemCapability.Communication.Bluetooth.Core 2425 * @systemapi 2426 * @since arkts {'1.1':'15','1.2':'20'} 2427 * @arkts 1.1&1.2 2428 */ 2429 deviceId: string; 2430 /** 2431 * Indicates the control type. 2432 * 2433 * @type { ControlType } 2434 * @syscap SystemCapability.Communication.Bluetooth.Core 2435 * @systemapi 2436 * @since 15 2437 */ 2438 type: ControlType; 2439 /** 2440 * Indicates the control value. 2441 * 2442 * @type { ControlTypeValue } 2443 * @syscap SystemCapability.Communication.Bluetooth.Core 2444 * @systemapi 2445 * @since 15 2446 */ 2447 typeValue: ControlTypeValue; 2448 /** 2449 * Indicates the control object. 2450 * 2451 * @type { ControlObject } 2452 * @syscap SystemCapability.Communication.Bluetooth.Core 2453 * @systemapi 2454 * @since 15 2455 */ 2456 controlObject: ControlObject; 2457 } 2458 2459 /** 2460 * Describes the control type. 2461 * 2462 * @enum { number } 2463 * @syscap SystemCapability.Communication.Bluetooth.Core 2464 * @systemapi 2465 * @since 15 2466 */ 2467 enum ControlType { 2468 /** 2469 * Indicates the control command of play. 2470 * 2471 * @syscap SystemCapability.Communication.Bluetooth.Core 2472 * @systemapi 2473 * @since 15 2474 */ 2475 PLAY = 0, 2476 /** 2477 * Indicates the control command of vibration. 2478 * 2479 * @syscap SystemCapability.Communication.Bluetooth.Core 2480 * @systemapi 2481 * @since 15 2482 */ 2483 VIBRATE = 1, 2484 /** 2485 * Indicates the control command of flash. 2486 * 2487 * @syscap SystemCapability.Communication.Bluetooth.Core 2488 * @systemapi 2489 * @since 15 2490 */ 2491 FLASH = 2, 2492 /** 2493 * Indicates the control command of lock. 2494 * 2495 * @syscap SystemCapability.Communication.Bluetooth.Core 2496 * @systemapi 2497 * @since 15 2498 */ 2499 LOCK = 3, 2500 /** 2501 * Indicates the control command of erase. 2502 * 2503 * @syscap SystemCapability.Communication.Bluetooth.Core 2504 * @systemapi 2505 * @since 15 2506 */ 2507 ERASE = 4, 2508 } 2509 2510 /** 2511 * Describes the control type value. 2512 * 2513 * @enum { number } 2514 * @syscap SystemCapability.Communication.Bluetooth.Core 2515 * @systemapi 2516 * @since 15 2517 */ 2518 enum ControlTypeValue { 2519 /** 2520 * Indicates the action of disable. 2521 * 2522 * @syscap SystemCapability.Communication.Bluetooth.Core 2523 * @systemapi 2524 * @since 15 2525 */ 2526 DISABLE = 0, 2527 /** 2528 * Indicates the action of enable. 2529 * 2530 * @syscap SystemCapability.Communication.Bluetooth.Core 2531 * @systemapi 2532 * @since 15 2533 */ 2534 ENABLE = 1, 2535 /** 2536 * Indicates the action of query. 2537 * 2538 * @syscap SystemCapability.Communication.Bluetooth.Core 2539 * @systemapi 2540 * @since 15 2541 */ 2542 QUERY = 2, 2543 } 2544 2545 /** 2546 * Describes the control object. 2547 * 2548 * @enum { number } 2549 * @syscap SystemCapability.Communication.Bluetooth.Core 2550 * @systemapi 2551 * @since 15 2552 */ 2553 enum ControlObject { 2554 /** 2555 * Control object of left ear. 2556 * 2557 * @syscap SystemCapability.Communication.Bluetooth.Core 2558 * @systemapi 2559 * @since 15 2560 */ 2561 LEFT_EAR = 0, 2562 /** 2563 * Control object of right ear. 2564 * 2565 * @syscap SystemCapability.Communication.Bluetooth.Core 2566 * @systemapi 2567 * @since 15 2568 */ 2569 RIGHT_EAR = 1, 2570 /** 2571 * Control object of left and right ear. 2572 * 2573 * @syscap SystemCapability.Communication.Bluetooth.Core 2574 * @systemapi 2575 * @since 15 2576 */ 2577 LEFT_RIGHT_EAR = 2, 2578 } 2579 2580 /** 2581 * Describes the cloud pair device. 2582 * 2583 * @typedef TrustedPairedDevices 2584 * @syscap SystemCapability.Communication.Bluetooth.Core 2585 * @systemapi 2586 * @since 15 2587 */ 2588 interface TrustedPairedDevices { 2589 /** 2590 * The list of cloud pair devices. 2591 * 2592 * @type { Array<TrustedPairedDevice> } 2593 * @syscap SystemCapability.Communication.Bluetooth.Core 2594 * @systemapi 2595 * @since 15 2596 */ 2597 trustedPairedDevices: Array<TrustedPairedDevice>; 2598 } 2599 2600 /** 2601 * Describes device of cloud pair. 2602 * 2603 * @typedef TrustedPairedDevice 2604 * @syscap SystemCapability.Communication.Bluetooth.Core 2605 * @systemapi 2606 * @since 15 2607 */ 2608 interface TrustedPairedDevice { 2609 /** 2610 * Indicates the device identify. 2611 * 2612 * @type { string } 2613 * @syscap SystemCapability.Communication.Bluetooth.Core 2614 * @systemapi 2615 * @since 15 2616 */ 2617 sn: string; 2618 /** 2619 * Indicates the device type of the peripheral. 2620 * 2621 * @type { string } 2622 * @syscap SystemCapability.Communication.Bluetooth.Core 2623 * @systemapi 2624 * @since 15 2625 */ 2626 deviceType: string; 2627 /** 2628 * Indicates the modelId of the peripheral. 2629 * 2630 * @type { string } 2631 * @syscap SystemCapability.Communication.Bluetooth.Core 2632 * @systemapi 2633 * @since 15 2634 */ 2635 modelId: string; 2636 /** 2637 * Indicates the manufactory of the peripheral. 2638 * 2639 * @type { string } 2640 * @syscap SystemCapability.Communication.Bluetooth.Core 2641 * @systemapi 2642 * @since 15 2643 */ 2644 manufactory: string; 2645 /** 2646 * Indicates the productId of the peripheral. 2647 * 2648 * @type { string } 2649 * @syscap SystemCapability.Communication.Bluetooth.Core 2650 * @systemapi 2651 * @since 15 2652 */ 2653 productId: string; 2654 /** 2655 * Indicates the HiLink version of the peripheral. 2656 * 2657 * @type { string } 2658 * @syscap SystemCapability.Communication.Bluetooth.Core 2659 * @systemapi 2660 * @since 15 2661 */ 2662 hiLinkVersion: string; 2663 /** 2664 * Indicates the macAddress of the peripheral. 2665 * 2666 * @type { string } 2667 * @syscap SystemCapability.Communication.Bluetooth.Core 2668 * @systemapi 2669 * @since 15 2670 */ 2671 macAddress: string; 2672 /** 2673 * Indicates the service type of the peripheral. 2674 * 2675 * @type { string } 2676 * @syscap SystemCapability.Communication.Bluetooth.Core 2677 * @systemapi 2678 * @since 15 2679 */ 2680 serviceType: string; 2681 /** 2682 * Indicates the service id of the peripheral. 2683 * 2684 * @type { string } 2685 * @syscap SystemCapability.Communication.Bluetooth.Core 2686 * @systemapi 2687 * @since 15 2688 */ 2689 serviceId: string; 2690 /** 2691 * The local name of the device 2692 * 2693 * @type { string } 2694 * @syscap SystemCapability.Communication.Bluetooth.Core 2695 * @systemapi 2696 * @since 15 2697 */ 2698 deviceName: string; 2699 /** 2700 * Indicates the uuid of the peripheral. 2701 * 2702 * @type { string } 2703 * @syscap SystemCapability.Communication.Bluetooth.Core 2704 * @systemapi 2705 * @since 15 2706 */ 2707 uuids: string; 2708 /** 2709 * Indicates the bluetoothClass of the peripheral. 2710 * 2711 * @type { number } 2712 * @syscap SystemCapability.Communication.Bluetooth.Core 2713 * @systemapi 2714 * @since 15 2715 */ 2716 bluetoothClass: number; 2717 /** 2718 * Indicates the token of the peripheral. 2719 * 2720 * @type { ArrayBuffer } 2721 * @syscap SystemCapability.Communication.Bluetooth.Core 2722 * @systemapi 2723 * @since 15 2724 */ 2725 token: ArrayBuffer; 2726 /** 2727 * Indicates the deviceNameTime of the peripheral. 2728 * 2729 * @type { number } 2730 * @syscap SystemCapability.Communication.Bluetooth.Core 2731 * @systemapi 2732 * @since 15 2733 */ 2734 deviceNameTime: number; 2735 /** 2736 * Indicates the securityAdvInfo of the peripheral. 2737 * 2738 * @type { ArrayBuffer } 2739 * @syscap SystemCapability.Communication.Bluetooth.Core 2740 * @systemapi 2741 * @since 15 2742 */ 2743 secureAdvertisingInfo: ArrayBuffer; 2744 /** 2745 * Indicates the pairState of the peripheral. 2746 * 2747 * @type { number } 2748 * @syscap SystemCapability.Communication.Bluetooth.Core 2749 * @systemapi 2750 * @since 15 2751 */ 2752 pairState: number; 2753 } 2754} 2755export default connection;