harmony 鸿蒙Bluetooth Subsystem Changelog
Bluetooth Subsystem Changelog
cl.bluetooth.1 Split of Bluetooth APIs by Profile
- Split ArkTS APIs in corresponding .d.ts files.
- Changed the interface permission to ohos.permission.ACCESS_BLUETOOTH. Some APIs also require the ohos.permission.MANAGE_BLUETOOTH permission.
Module | API Reference |
---|---|
@ohos.bluetooth.a2dp | js-apis-bluetooth-a2dp.md |
@ohos.bluetooth.access | js-apis-bluetooth-access.md |
@ohos.bluetooth.baseProfile | js-apis-bluetooth-baseProfile.md |
@ohos.bluetooth.ble | js-apis-bluetooth-ble.md |
@ohos.bluetooth.connection | js-apis-bluetooth-connection.md |
@ohos.bluetooth.constant | js-apis-bluetooth-constant.md |
@ohos.bluetooth.hfp | js-apis-bluetooth-hfp.md |
@ohos.bluetooth.hid | js-apis-bluetooth-hid.md |
@ohos.bluetooth.pan | js-apis-bluetooth-pan.md |
@ohos.bluetooth.socket | js-apis-bluetooth-socket.md |
APIs Requiring Dual-Permission Verification
Change Impact
- The module to import is changed.
- After the permission change, you only need to pay attention to the ohos.permission.ACCESS_BLUETOOTH and ohos.permission.MANAGE_BLUETOOTH permissions.
Key API/Component Changes
Before Change | After Change |
---|---|
bluetoothManager.enableBluetooth | access.enableBluetooth |
bluetoothManager.disableBluetooth | access.disableBluetooth |
bluetoothManager.getLocalName | connection.getLocalName |
bluetoothManager.getState | access.getState |
bluetoothManager.getBtConnectionState | connection.getProfileConnectionState |
bluetoothManager.setLocalName | connection.setLocalName |
bluetoothManager.pairDevice | connection.pairDevice |
bluetoothManager.getProfileConnectionState | connection.getProfileConnectionState |
bluetoothManager.cancelPairedDevice | connection.cancelPairedDevice |
bluetoothManager.getRemoteDeviceName | connection.getRemoteDeviceName |
bluetoothManager.getRemoteDeviceClass | connection.getRemoteDeviceClass |
bluetoothManager.getPairedDevices | connection.getPairedDevices |
bluetoothManager.setBluetoothScanMode | connection.setBluetoothScanMode |
bluetoothManager.getBluetoothScanMode | connection.getBluetoothScanMode |
bluetoothManager.startBluetoothDiscovery | connection.startBluetoothDiscovery |
bluetoothManager.stopBluetoothDiscovery | connection.stopBluetoothDiscovery |
bluetoothManager.setDevicePairingConfirmation | connection.setDevicePairingConfirmation |
bluetoothManager.on(‘bluetoothDeviceFind’) | connection.on(‘bluetoothDeviceFind’) |
bluetoothManager.off(‘bluetoothDeviceFind’) | connection.off(‘bluetoothDeviceFind’) |
bluetoothManager.on(‘pinRequired’) | connection.on(‘pinRequired’) |
bluetoothManager.off(‘pinRequired’) | connection.off(‘pinRequired’) |
bluetoothManager.on(‘bondStateChange’) | connection.on(‘bondStateChange’) |
bluetoothManager.off(‘bondStateChange’) | connection.off(‘bondStateChange’) |
bluetoothManager.on(‘stateChange’) | access.on(‘stateChange’) |
bluetoothManager.off(‘stateChange’) | access.off(‘stateChange’) |
bluetoothManager.sppListen | socket.sppListen |
bluetoothManager.sppAccept | socket.sppAccept |
bluetoothManager.sppConnect | socket.sppConnect |
bluetoothManager.sppCloseServerSocket | socket.sppCloseServerSocket |
bluetoothManager.sppCloseClientSocket | socket.sppCloseClientSocket |
bluetoothManager.sppWrite | socket.sppWrite |
bluetoothManager.on(‘sppRead’) | socket.on(‘sppRead’) |
bluetoothManager.off(‘sppRead’) | socket.off(‘sppRead’) |
bluetoothManager.getProfileInstance | Deprecated |
createGattServer | ble.createGattServer |
createGattClientDevice | ble.createGattClientDevice |
getConnectedBLEDevices | ble.getConnectedBLEDevices |
startBLEScan | ble.startBLEScan |
stopBLEScan | ble.stopBLEScan |
on(‘BLEDeviceFind’) | ble.on(‘BLEDeviceFind’) |
off(‘BLEDeviceFind’) | ble.off(‘BLEDeviceFind’) |
getConnectionDevices | baseProfile.getConnectedDevices |
getDeviceState | baseProfile.getConnectionState |
A2dpSourceProfile | A2dpSourceProfile |
connect(a2dp profile) | connect |
disconnect(a2dp profile) | disconnect |
on(‘connectionStateChange’) | baseProfile.on(‘connectionStateChange’) |
off(‘connectionStateChange’) | baseProfile.off(‘connectionStateChange’) |
getPlayingState | getPlayingState |
HandsFreeAudioGatewayProfile | HandsFreeAudioGatewayProfile |
connect(hfp profile) | connect |
disconnect(hfp profile) | disconnect |
on(‘connectionStateChange’)(hfp profile) | baseProfile.on(‘connectionStateChange’) |
off(‘connectionStateChange’)(hfp profile) | baseProfile.off(‘connectionStateChange’) |
connect(hid profile) | connect |
disconnect(hid profile) | disconnect |
on(‘connectionStateChange’)(hid profile) | baseProfile.on(‘connectionStateChange’) |
off(‘connectionStateChange’)(hid profile) | baseProfile.off(‘connectionStateChange’) |
disconnect(pan profile) | disconnect |
on(‘connectionStateChange’)(pan profile) | baseProfile.on(‘connectionStateChange’) |
off(‘connectionStateChange’)(pan profile) | baseProfile.off(‘connectionStateChange’) |
setTethering | setTethering |
isTetheringOn | isTetheringOn |
startAdvertising | ble.startAdvertising |
stopAdvertising | ble.stopAdvertising |
addService | addService |
removeService | removeService |
close | close |
notifyCharacteristicChanged | notifyCharacteristicChanged |
sendResponse | sendResponse |
on(‘characteristicRead’) | on(‘characteristicRead’) |
off(‘characteristicRead’) | off(‘characteristicRead’) |
on(‘characteristicWrite’) | on(‘characteristicWrite’) |
off(‘characteristicWrite’) | off(‘characteristicWrite’) |
on(‘descriptorRead’) | on(‘descriptorRead’) |
off(‘descriptorRead’) | off(‘descriptorRead’) |
on(‘descriptorWrite’) | on(‘descriptorWrite’) |
off(‘descriptorWrite’) | off(‘descriptorWrite’) |
on(‘connectStateChange’) | on(‘connectionStateChange’) |
off(‘connectStateChange’) | off(‘connectionStateChange’) |
connect | connect |
disconnect | disconnect |
close | close |
getServices(callback) | getServices |
getServices(promise) | getServices |
readCharacteristicValue(callback) | readCharacteristicValue |
readCharacteristicValue(promise) | readCharacteristicValue |
readDescriptorValue(callback) | readDescriptorValue |
readDescriptorValue(promise) | readDescriptorValue |
writeCharacteristicValue(callback) | writeCharacteristicValue |
writeDescriptorValue(promise) | writeCharacteristicValue |
setBLEMtuSize | setBLEMtuSize |
setNotifyCharacteristicChanged | setCharacteristicChangeNotification |
on(‘BLECharacteristicChange’) | on(‘BLECharacteristicChange’) |
off(‘BLECharacteristicChange’) | off(‘BLECharacteristicChange’) |
on(‘BLEConnectionStateChange’) | on(‘BLEConnectionStateChange’) |
off(‘BLEConnectionStateChange’) | off(‘BLEConnectionStateChange’) |
getDeviceName(callback) | getDeviceName |
getDeviceName(promise) | getDeviceName |
getRssiValue(callback) | getRssiValue |
getRssiValue(promise) | getRssiValue |
ScanMode | ScanMode |
BondState | BondState |
SppOption | SppOptions |
SppType | SppType |
GattService | GattService |
BLECharacteristic | BLECharacteristic |
BLEDescriptor | BLEDescriptor |
NotifyCharacteristic | NotifyCharacteristic |
CharacteristicReadRequest | CharacteristicReadRequest |
CharacteristicWriteRequest | CharacteristicWriteRequest |
DescriptorReadRequest | DescriptorReadRequest |
DescriptorWriteRequest | DescriptorWriteRequest |
ServerResponse | ServerResponse |
BLEConnectChangedState | BLEConnectionChangeState |
ProfileConnectionState | ProfileConnectionState |
ScanFilter | ScanFilter |
ScanOptions | ScanOptions |
ScanDuty | ScanDuty |
MatchMode | MatchMode |
ScanResult | ScanResult |
BluetoothState | BluetoothState |
AdvertiseSetting | AdvertiseSetting |
AdvertiseData | AdvertiseData |
ManufactureData | ManufactureData |
ServiceData | ServiceData |
PinRequiredParam | PinRequiredParam |
BondStateParam | BondStateParam |
StateChangeParam | StateChangeParam |
DeviceClass | DeviceClass |
MajorClass | MajorClass |
MajorMinorClass | MajorMinorClass |
PlayingState | PlayingState |
ProfileId | ProfileId |
Added APIs
APIs Added with Promise
Adaptation Guide
Determine the module to import based on the profile module. For some interfaces, multiple TS files need to be imported.
//For example, getConnectionState() in @ohos.bluetooth.baseProfile.
import a2dp from '@ohos.bluetooth.a2dp';
try {
let a2dpSrc = a2dp.createA2dpSrcProfile();
let ret = a2dpSrc.getConnectionState('XX:XX:XX:XX:XX:XX');
} catch (err) {
console.error('errCode: ' + err.code + ', errMessage: ' + err.message);
}
你可能感兴趣的鸿蒙文章
harmony 鸿蒙ArkUI Subsystem Changelog
harmony 鸿蒙Application Access Control Subsystem Changelog
harmony 鸿蒙Account Subsystem Changelog
harmony 鸿蒙Bundle Management Subsystem Changelog
harmony 鸿蒙Security Subsystem Changelog
harmony 鸿蒙Graphics Subsystem Changelog
harmony 鸿蒙Input Method Framework Subsystem – Input Method Framework Service Changelog
0
赞
- 所属分类: 后端技术
- 本文标签:
热门推荐
-
2、 - 优质文章
-
3、 gate.io
-
8、 golang
-
9、 openharmony
-
10、 Vue中input框自动聚焦