From 084509ad59662c8490537aa160197e175b703de1 Mon Sep 17 00:00:00 2001 From: wangyaqi Date: Fri, 20 Mar 2020 15:58:40 +0800 Subject: [PATCH] fix: ble ArrayBuffer --- .../app-plus/service/api/device/bluetooth.js | 31 +++---------------- 1 file changed, 5 insertions(+), 26 deletions(-) diff --git a/src/platforms/app-plus/service/api/device/bluetooth.js b/src/platforms/app-plus/service/api/device/bluetooth.js index 9c4fd18e0..8aa054006 100644 --- a/src/platforms/app-plus/service/api/device/bluetooth.js +++ b/src/platforms/app-plus/service/api/device/bluetooth.js @@ -1,8 +1,6 @@ import { invoke, - publish, - arrayBufferToBase64, - base64ToArrayBuffer + publish } from '../../bridge' /** @@ -53,16 +51,6 @@ function bluetoothOn (method, beforeSuccess) { return true } -function checkDevices (data) { - data.devices = data.devices.map(device => { - var advertisData = device.advertisData - if (advertisData && typeof advertisData !== 'string') { - device.advertisData = arrayBufferToBase64(advertisData) - } - return device - }) -} - var onBluetoothAdapterStateChange var onBluetoothDeviceFound var onBLEConnectionStateChange @@ -83,7 +71,7 @@ export function getBluetoothAdapterState (data, callbackId) { } export function startBluetoothDevicesDiscovery (data, callbackId) { - onBluetoothDeviceFound = onBluetoothDeviceFound || bluetoothOn('onBluetoothDeviceFound', checkDevices) + onBluetoothDeviceFound = onBluetoothDeviceFound || bluetoothOn('onBluetoothDeviceFound') bluetoothExec('startBluetoothDevicesDiscovery', callbackId, data) } @@ -92,7 +80,7 @@ export function stopBluetoothDevicesDiscovery (data, callbackId) { } export function getBluetoothDevices (data, callbackId) { - bluetoothExec('getBluetoothDevices', callbackId, {}, checkDevices) + bluetoothExec('getBluetoothDevices', callbackId, {}) } export function getConnectedBluetoothDevices (data, callbackId) { @@ -118,18 +106,12 @@ export function getBLEDeviceCharacteristics (data, callbackId) { } export function notifyBLECharacteristicValueChange (data, callbackId) { - onBLECharacteristicValueChange = onBLECharacteristicValueChange || bluetoothOn('onBLECharacteristicValueChange', - data => { - data.value = arrayBufferToBase64(data.value) - }) + onBLECharacteristicValueChange = onBLECharacteristicValueChange || bluetoothOn('onBLECharacteristicValueChange') bluetoothExec('notifyBLECharacteristicValueChange', callbackId, data) } export function notifyBLECharacteristicValueChanged (data, callbackId) { - onBLECharacteristicValueChange = onBLECharacteristicValueChange || bluetoothOn('onBLECharacteristicValueChange', - data => { - data.value = arrayBufferToBase64(data.value) - }) + onBLECharacteristicValueChange = onBLECharacteristicValueChange || bluetoothOn('onBLECharacteristicValueChange') bluetoothExec('notifyBLECharacteristicValueChanged', callbackId, data) } @@ -139,8 +121,5 @@ export function readBLECharacteristicValue (data, callbackId) { } export function writeBLECharacteristicValue (data, callbackId) { - if (typeof data.value === 'string') { - data.value = base64ToArrayBuffer(data.value) - } bluetoothExec('writeBLECharacteristicValue', callbackId, data) } -- GitLab