mh-two-thousand-and-two
2024-04-12 3d2ec2fd0578d3ba0a414b0cc4e4a2ae60878596
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
import {
  warpPlusEvent,
  warpPlusMethod
} from '../util'
 
export const onBluetoothDeviceFound = warpPlusEvent('bluetooth', 'onBluetoothDeviceFound')
export const onBluetoothAdapterStateChange = warpPlusEvent('bluetooth', 'onBluetoothAdapterStateChange')
export const onBLEConnectionStateChange = warpPlusEvent('bluetooth', 'onBLEConnectionStateChange')
export const onBLECharacteristicValueChange = warpPlusEvent('bluetooth', 'onBLECharacteristicValueChange')
 
function toUpperCase (options = {}) {
  const deviceId = options.deviceId
  if (deviceId) {
    options.deviceId = deviceId.toUpperCase()
  }
  const serviceId = options.serviceId
  if (serviceId) {
    options.serviceId = serviceId.toUpperCase()
  }
  return options
}
 
export const openBluetoothAdapter = warpPlusMethod('bluetooth', 'openBluetoothAdapter')
export const closeBluetoothAdapter = warpPlusMethod('bluetooth', 'closeBluetoothAdapter')
export const getBluetoothAdapterState = warpPlusMethod('bluetooth', 'getBluetoothAdapterState')
export const startBluetoothDevicesDiscovery = warpPlusMethod('bluetooth', 'startBluetoothDevicesDiscovery', toUpperCase)
export const stopBluetoothDevicesDiscovery = warpPlusMethod('bluetooth', 'stopBluetoothDevicesDiscovery')
export const getBluetoothDevices = warpPlusMethod('bluetooth', 'getBluetoothDevices')
export const getConnectedBluetoothDevices = warpPlusMethod('bluetooth', 'getConnectedBluetoothDevices', toUpperCase)
export const createBLEConnection = warpPlusMethod('bluetooth', 'createBLEConnection', toUpperCase)
export const closeBLEConnection = warpPlusMethod('bluetooth', 'closeBLEConnection', toUpperCase)
export const getBLEDeviceServices = warpPlusMethod('bluetooth', 'getBLEDeviceServices', toUpperCase)
export const getBLEDeviceCharacteristics = warpPlusMethod('bluetooth', 'getBLEDeviceCharacteristics', toUpperCase)
export const notifyBLECharacteristicValueChange = warpPlusMethod('bluetooth', 'notifyBLECharacteristicValueChange', toUpperCase)
export const readBLECharacteristicValue = warpPlusMethod('bluetooth', 'readBLECharacteristicValue', toUpperCase)
export const writeBLECharacteristicValue = warpPlusMethod('bluetooth', 'writeBLECharacteristicValue', toUpperCase)
export const setBLEMTU = warpPlusMethod('bluetooth', 'setBLEMTU', toUpperCase)
export const getBLEDeviceRSSI = warpPlusMethod('bluetooth', 'getBLEDeviceRSSI', toUpperCase)