Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion packages/api-proxy/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,9 @@
"react-native-device-info": "*",
"react-native-get-location": "*",
"react-native-haptic-feedback": "*",
"react-native-safe-area-context": "*"
"react-native-safe-area-context": "*",
"react-native-ble-manager": "*",
"react-native-wifi-reborn": "*"
},
"peerDependenciesMeta": {
"@react-native-async-storage/async-storage": {
Expand All @@ -66,6 +68,12 @@
},
"react-native-haptic-feedback": {
"optional": true
},
"react-native-ble-manager": {
"optional": true
},
"react-native-wifi-reborn": {
"optional": true
}
}
}
69 changes: 67 additions & 2 deletions packages/api-proxy/src/platform/api/ble-connection/index.ali.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { ENV_OBJ } from '../../../common/js'
import { ENV_OBJ, envError } from '../../../common/js'

function closeBLEConnection (options = {}) {
return ENV_OBJ.disconnectBLEDevice(options)
Expand All @@ -12,8 +12,73 @@ function onBLEConnectionStateChange (callback) {
return ENV_OBJ.onBLEConnectionStateChanged(callback)
}

function offBLEConnectionStateChange (callback) {
return ENV_OBJ.offBLEConnectionStateChanged(callback)
}

const openBluetoothAdapter = ENV_OBJ.openBluetoothAdapter || envError('openBluetoothAdapter')

const closeBluetoothAdapter = ENV_OBJ.closeBluetoothAdapter || envError('closeBluetoothAdapter')

const startBluetoothDevicesDiscovery = ENV_OBJ.startBluetoothDevicesDiscovery || envError('startBluetoothDevicesDiscovery')

const stopBluetoothDevicesDiscovery = ENV_OBJ.stopBluetoothDevicesDiscovery || envError('stopBluetoothDevicesDiscovery')

const onBluetoothDeviceFound = ENV_OBJ.onBluetoothDeviceFound || envError('onBluetoothDeviceFound')

const offBluetoothDeviceFound = ENV_OBJ.offBluetoothDeviceFound || envError('offBluetoothDeviceFound')

const getConnectedBluetoothDevices = ENV_OBJ.getConnectedBluetoothDevices || envError('getConnectedBluetoothDevices')

const getBluetoothAdapterState = ENV_OBJ.getBluetoothAdapterState || envError('getBluetoothAdapterState')

const onBluetoothAdapterStateChange = ENV_OBJ.onBluetoothAdapterStateChange || envError('onBluetoothAdapterStateChange')

const offBluetoothAdapterStateChange = ENV_OBJ.offBluetoothAdapterStateChange || envError('offBluetoothAdapterStateChange')

const getBluetoothDevices = ENV_OBJ.getBluetoothDevices || envError('getBluetoothDevices')

const writeBLECharacteristicValue = ENV_OBJ.writeBLECharacteristicValue || envError('writeBLECharacteristicValue')

const readBLECharacteristicValue = ENV_OBJ.readBLECharacteristicValue || envError('readBLECharacteristicValue')

const notifyBLECharacteristicValueChange = ENV_OBJ.notifyBLECharacteristicValueChange || envError('notifyBLECharacteristicValueChange')

const onBLECharacteristicValueChange = ENV_OBJ.onBLECharacteristicValueChange || envError('onBLECharacteristicValueChange')

const offBLECharacteristicValueChange = ENV_OBJ.offBLECharacteristicValueChange || envError('offBLECharacteristicValueChange')

const setBLEMTU = ENV_OBJ.setBLEMTU || envError('setBLEMTU')

const getBLEDeviceRSSI = ENV_OBJ.getBLEDeviceRSSI || envError('getBLEDeviceRSSI')

const getBLEDeviceServices = ENV_OBJ.getBLEDeviceServices || envError('getBLEDeviceServices')

const getBLEDeviceCharacteristics = ENV_OBJ.getBLEDeviceCharacteristics || envError('getBLEDeviceCharacteristics')

export {
closeBLEConnection,
createBLEConnection,
onBLEConnectionStateChange
onBLEConnectionStateChange,
offBLEConnectionStateChange,
openBluetoothAdapter,
closeBluetoothAdapter,
startBluetoothDevicesDiscovery,
stopBluetoothDevicesDiscovery,
onBluetoothDeviceFound,
offBluetoothDeviceFound,
getConnectedBluetoothDevices,
getBluetoothAdapterState,
onBluetoothAdapterStateChange,
offBluetoothAdapterStateChange,
getBluetoothDevices,
writeBLECharacteristicValue,
readBLECharacteristicValue,
notifyBLECharacteristicValueChange,
onBLECharacteristicValueChange,
offBLECharacteristicValueChange,
setBLEMTU,
getBLEDeviceRSSI,
getBLEDeviceServices,
getBLEDeviceCharacteristics
}
Loading
Loading