HomeDocs
Skip to main content

dlt.openBluetoothAdapter

Introduction

Initialize the Bluetooth module.

Parameters

Object object

PropertyTypeDefaultRequiredDescription
successfunctionNoThe callback function for a successful API call.
failfunctionNoThe callback function for a failed API call.
completefunctionNoThe callback function that is called when the API call ends (whether it succeeds or fails).

object.success Callback Function

Parameters

Object res

PropertyTypeDescription
successstringtrue - Success

object.fail Callback Function

Parameters

Object res

PropertyTypeDescription
successstringfalse - Failure
errCodestringError code

Explanation of Error Codes

Error CodeDescription
-1Failed
0Normal
10000Bluetooth adapter uninitialized
10001Bluetooth not available
10002Device not found
10003Connection failed
10004Already connected
10005Characteristic not found
10006Descriptor not found
10007Location access required
10008System reports an exception
10013Invalid data
10014Permission not granted
10015Adapter already initialized

Sample Code

dlt.openBluetoothAdapter({
success(res) {
console.log('openBluetoothAdapter success', res);
},
});

In the sample code provided, dlt.openBluetoothAdapter is used to initialize the Bluetooth module. When the initialization is successful, the success callback function is called, and it logs a success message to the console.

Privacy agreementDeveloper agreementcontact us: developer_service.mi@transsion.com © 2024 MiniApp. All Rights Reserved.