harmony 鸿蒙bluetooth子系统ChangeLog
bluetooth子系统ChangeLog
cl.bluetooth.1 蓝牙模块JS接口拆分,支持按profile加载接口能力。
- ArkTS接口,拆分在对应的.d.ts中。
- 权限变更,接口权限统一变更为ohos.permission.ACCESS_BLUETOOTH,部分接口额外需要ohos.permission.MANAGE_BLUETOOTH权限。
| 模块 | 接口文档 |
|---|---|
| @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 |
需要双权限校验的接口
变更影响
- TS拆分后,接口调用import文件发生改变。
- 权限变更后,只需关注ohos.permission.ACCESS_BLUETOOTH和ohos.permission.MANAGE_BLUETOOTH权限。
关键接口/组件变更
| 拆分前 | 拆分后 |
|---|---|
| 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 | 已废弃 |
| 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 |
新增接口声明
补充promise调用方式
适配指导
注意根据不同profile模块选择import方式,部分接口需要import多个TS文件。
//例如@ohos.bluetooth.baseProfile下getConnectionState接口。
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);
}
你可能感兴趣的鸿蒙文章
0
赞
- 所属分类: 后端技术
- 本文标签:
热门推荐
-
2、 - 优质文章
-
3、 gate.io
-
7、 openharmony
-
9、 golang