forked from nativescript-community/ble
-
Notifications
You must be signed in to change notification settings - Fork 0
/
bluetooth.android.js.map
1 lines (1 loc) · 63.1 KB
/
bluetooth.android.js.map
1
{"version":3,"sources":["bluetooth.android.ts"],"names":[],"mappings":"AAAA,yCAAyC;;AAEzC,IAAY,KAAK,WAAM,aACvB,CAAC,CADmC;AACpC,IAAY,WAAW,WAAM,aAAa,CAAC,CAAA;AAC3C,iCAAwB,oBAAoB,CAAC,CAAA;AAE7C,IAAI,8CAA8C,GAAG,GAAG,CAAC;AAEzD,IAAI,OAAO,EAAE,YAAY,CAAC;AAE1B;IAAwB,6BAAS;IAiD/B;QACE,iBAAO,CAAC;QAjBV;;;;;;;;;;;;;WAaG;QACH,iBAAY,GAAG,EAAE,CAAC;QAwElB,oDAAoD;QACpD,oBAAe,GAAG,OAAO,CAAC,SAAS,CAAC,qBAAqB,CAAC,MAAM,CAAC;YAC/D,wCAAwC;YAExC;;;;;;eAMG;YACH,uBAAuB,EAAE,UAAU,aAAa,EAAE,MAAM,EAAE,QAAQ;gBAChE,OAAO,CAAC,GAAG,CAAC,2DAA2D,GAAG,MAAM,GAAG,eAAe,GAAG,QAAQ,CAAC,CAAC;gBAE/G,qGAAqG;gBACrG,EAAE,CAAC,CAAC,QAAQ,IAAI,CAAC,CAAC,eAAe,IAAI,MAAM,KAAK,CAAC,CAAC,kBAAkB,CAAC,CAAC,CAAC;oBACrE,OAAO,CAAC,GAAG,CAAC,6BAA6B,CAAC,CAAC;oBAC3C,aAAa,CAAC,gBAAgB,EAAE,CAAC;gBACnC,CAAC;gBAAC,IAAI,CAAC,CAAC;oBACN,4EAA4E;oBAC5E,IAAI,CAAC,WAAW,CAAC,aAAa,CAAC,CAAC;gBAClC,CAAC;YACH,CAAC;YAED,oBAAoB,EAAE,UAAU,aAAa,EAAE,MAAM;gBACnD,OAAO,CAAC,GAAG,CAAC,oEAAoE,GAAG,MAAM,CAAC,CAAC;gBAE3F,EAAE,CAAC,CAAC,MAAM,KAAK,CAAC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oB,EAAE,kBAAkB,CAAC,CAAC;gBAC3G,OAAO,CAAC,GAAG,CAAC,8BAA8B,GAAG,2BAA2B,CAAC,CAAC;gBAE1E,EAAE,CAAC,CAAC,CAAC,2BAA2B,CAAC,CAAC,CAAC;oBACjC,MAAM,CAAC,0CAA0C,GAAG,GAAG,CAAC,kBAAkB,GAAG,wBAAwB,GAAG,GAAG,CAAC,WAAW,GAAG,2BAA2B,GAAG,GAAG,CAAC,cAAc,CAAC,CAAC;oBAC5K,MAAM,CAAC;gBACT,CAAC;gBAED,IAAI,WAAW,GAAG,IAAI,CAAC,YAAY,CAAC,GAAG,CAAC,cAAc,CAAC,CAAC;gBACxD,WAAW,CAAC,gBAAgB,GAAG,IAAI,CAAC;gBAEpC,EAAE,CAAC,CAAC,IAAI,CAAC,6BAA6B,CAAC,2BAA2B,EAAE,KAAK,CAAC,CAAC,CAAC,CAAC;oBAC3E,OAAO,EAAE,CAAC;gBACZ,CAAC;gBAAC,IAAI,CAAC,CAAC;oBACN,MAAM,CAAC,0DAA0D,GAAG,kBAAkB,CAAC,CAAC;gBAC1F,CAAC;YAEH,CAAE;YAAA,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;gBACZ,OAAO,CAAC,GAAG,CAAC,oCAAoC,GAAG,EAAE,CAAC,CAAC;gBACvD,MAAM,CAAC,EAAE,CAAC,CAAC;YACb,CAAC;QACH,CAAC,CAAC,CAAC;IACL,CAAC;;IAEH,gBAAC;AAAD,CAn0BA,AAm0BC,CAn0BuB,4BAAS,GAm0BhC","file":"bluetooth.android.js","sourcesContent":["///<reference path=\"_references.d.ts\" />\"\r\n\r\nimport * as utils from \"utils/utils\"\r\nimport * as application from \"application\";\r\nimport {bluetooth} from \"./bluetooth-common\";\r\n\r\nvar ACCESS_COARSE_LOCATION_PERMISSION_REQUEST_CODE = 222;\r\n\r\nvar adapter, onDiscovered;\r\n\r\nclass Bluetooth extends bluetooth {\r\n _scanCallback;\r\n\r\n _coarseLocationPermissionGranted() {\r\n var hasPermission = android.os.Build.VERSION.SDK_INT < 23; // Android M. (6.0)\r\n if (!hasPermission) {\r\n hasPermission = android.content.pm.PackageManager.PERMISSION_GRANTED ==\r\n android.support.v4.content.ContextCompat.checkSelfPermission(application.android.foregroundActivity, android.Manifest.permission.ACCESS_COARSE_LOCATION);\r\n }\r\n return hasPermission;\r\n };\r\n\r\n hasCoarseLocationPermission() {\r\n return new Promise(function (resolve) {\r\n resolve(this._coarseLocationPermissionGranted());\r\n });\r\n };\r\n\r\n requestCoarseLocationPermission() {\r\n return new Promise(function (resolve) {\r\n if (!this._coarseLocationPermissionGranted()) {\r\n // in a future version we could hook up the callback and change this flow a bit\r\n android.support.v4.app.ActivityCompat.requestPermissions( //https://developer.android.com/reference/android/support/v4/app/package-summary.html ******** Should use OnRequestPermissionsResultCallback ?\r\n application.android.foregroundActivity,\r\n [android.Manifest.permission.ACCESS_COARSE_LOCATION],\r\n ACCESS_COARSE_LOCATION_PERMISSION_REQUEST_CODE);\r\n // this is not the nicest solution as the user needs to initiate scanning again after granting permission,\r\n // so enhance this in a future version, but it's ok for now\r\n resolve();\r\n }\r\n });\r\n };\r\n\r\n /**\r\n * Connections are stored as key-val pairs of UUID-Connection.\r\n * So something like this:\r\n * [{\r\n * 34343-2434-5454: {\r\n * state: 'connected',\r\n * discoveredState: '',\r\n * operationConnect: someCallbackFunction\r\n * },\r\n * 1323213-21321323: {\r\n * ..\r\n * }\r\n * }, ..]\r\n */\r\n _connections = {};\r\n\r\n constructor() {\r\n super();\r\n var bluetoothManager = utils.ad.getApplicationContext().getSystemService(android.content.Context.BLUETOOTH_SERVICE);\r\n adapter = bluetoothManager.getAdapter();\r\n\r\n if (android.os.Build.VERSION.SDK_INT >= 21 /*android.os.Build.VERSION_CODES.LOLLIPOP*/) {\r\n var MyScanCallback = android.bluetooth.le.ScanCallback.extend({\r\n onBatchScanResults: function (results) {\r\n console.log(\"------- scanCallback.onBatchScanResults\");\r\n },\r\n onScanFailed: function (errorCode) {\r\n console.log(\"------- scanCallback.onScanFailed errorCode: \" + errorCode);\r\n var errorMessage;\r\n if (errorCode == android.bluetooth.le.ScanCallback.SCAN_FAILED_ALREADY_STARTED) {\r\n errorMessage = \"Scan already started\";\r\n } else if (errorCode == android.bluetooth.le.ScanCallback.SCAN_FAILED_APPLICATION_REGISTRATION_FAILED) {\r\n errorMessage = \"Application registration failed\";\r\n } else if (errorCode == android.bluetooth.le.ScanCallback.SCAN_FAILED_FEATURE_UNSUPPORTED) {\r\n errorMessage = \"Feature unsupported\";\r\n } else if (errorCode == android.bluetooth.le.ScanCallback.SCAN_FAILED_INTERNAL_ERROR) {\r\n errorMessage = \"Internal error\";\r\n } else {\r\n errorMessage = \"Scan failed to start\";\r\n }\r\n console.log(\"------- scanCallback.onScanFailed errorMessage: \" + errorMessage);\r\n },\r\n onScanResult: function (callbackType, result) {\r\n var stateObject = this._connections[result.getDevice().getAddress()];\r\n if (!stateObject) {\r\n this._connections[result.getDevice().getAddress()] = {\r\n state: 'disconnected'\r\n };\r\n var payload = {\r\n type: 'scanResult', // TODO or use different callback functions?\r\n UUID: result.getDevice().getAddress(),\r\n name: result.getDevice().getName(),\r\n RSSI: result.getRssi(),\r\n state: 'disconnected',\r\n advertisement: android.util.Base64.encodeToString(result.getScanRecord().getBytes(), android.util.Base64.NO_WRAP)\r\n };\r\n console.log(\"---- Lollipop+ scanCallback result: \" + JSON.stringify(payload));\r\n onDiscovered(payload);\r\n }\r\n }\r\n });\r\n this._scanCallback = new MyScanCallback();\r\n } else {\r\n this._scanCallback = new android.bluetooth.BluetoothAdapter.LeScanCallback(\r\n {\r\n onLeScan: function (device: android.bluetooth.BluetoothDevice, rssi: number, scanRecord: Array<number>) {\r\n var stateObject = this._connections[device.getAddress()];\r\n if (!stateObject) {\r\n this._connections[device.getAddress()] = {\r\n state: 'disconnected'\r\n };\r\n onDiscovered({\r\n type: 'scanResult', // TODO or use different callback functions?\r\n UUID: device.getAddress(), // TODO consider renaming to id (and iOS as well)\r\n name: device.getName(),\r\n RSSI: rssi,\r\n state: 'disconnected'\r\n });\r\n }\r\n }\r\n }\r\n // see https://github.com/randdusing/cordova-plugin-bluetoothle/blob/master/src/android/BluetoothLePlugin.java#L2181\r\n );\r\n }\r\n }\r\n \r\n // callback for connecting and read/write operations\r\n _MyGattCallback = android.bluetooth.BluetoothGattCallback.extend({\r\n // add constructor which gets a callback\r\n\r\n /**\r\n * newState (BluetoothProfile.state)\r\n * 0: disconnected\r\n * 1: connecting\r\n * 2: connected\r\n * 3: disconnecting\r\n */\r\n onConnectionStateChange: function (bluetoothGatt, status, newState) {\r\n console.log(\"------- _MyGattCallback.onConnectionStateChange, status: \" + status + \", new state: \" + newState);\r\n\r\n // https://github.com/don/cordova-plugin-ble-central/blob/master/src/android/Peripheral.java#L191 \r\n if (newState == 2 /* connected */ && status === 0 /* gatt success */) {\r\n console.log(\"---- discovering services..\");\r\n bluetoothGatt.discoverServices();\r\n } else {\r\n // perhaps the device was manually disconnected, or in use by another device\r\n this._disconnect(bluetoothGatt);\r\n }\r\n },\r\n\r\n onServicesDiscovered: function (bluetoothGatt, status) {\r\n console.log(\"------- _MyGattCallback.onServicesDiscovered, status (0=success): \" + status);\r\n\r\n if (status === 0 /* gatt success */) {\r\n // TODO grab from cached object and extend with services data?\r\n var services = bluetoothGatt.getServices();\r\n var servicesJs = [];\r\n var btChar = android.bluetooth.BluetoothGattCharacteristic;\r\n for (var i = 0; i < services.size(); i++) {\r\n var service = services.get(i);\r\n var characteristics = service.getCharacteristics();\r\n var characteristicsJs = [];\r\n for (var j = 0; j < characteristics.size(); j++) {\r\n var characteristic = characteristics.get(j);\r\n var props = characteristic.getProperties();\r\n var descriptors = characteristic.getDescriptors();\r\n var descriptorsJs = [];\r\n for (var k = 0; k < descriptors.size(); k++) {\r\n var descriptor = descriptors.get(k);\r\n var descriptorJs = {\r\n UUID: this._uuidToString(descriptor.getUuid()),\r\n value: descriptor.getValue(), // always empty btw\r\n permissions: null\r\n };\r\n var descPerms = descriptor.getPermissions();\r\n if (descPerms > 0) {\r\n descriptorJs.permissions = {\r\n read: (descPerms & btChar.PERMISSION_READ) !== 0,\r\n readEncrypted: (descPerms & btChar.PERMISSION_READ_ENCRYPTED) !== 0,\r\n readEncryptedMitm: (descPerms & btChar.PERMISSION_READ_ENCRYPTED_MITM) !== 0,\r\n write: (descPerms & btChar.PERMISSION_WRITE) !== 0,\r\n writeEncrypted: (descPerms & btChar.PERMISSION_WRITE_ENCRYPTED) !== 0,\r\n writeEncryptedMitm: (descPerms & btChar.PERMISSION_WRITE_ENCRYPTED_MITM) !== 0,\r\n writeSigned: (descPerms & btChar.PERMISSION_WRITE_SIGNED) !== 0,\r\n writeSignedMitm: (descPerms & btChar.PERMISSION_WRITE_SIGNED_MITM) !== 0\r\n };\r\n }\r\n descriptorsJs.push(descriptorJs);\r\n }\r\n\r\n var characteristicJs = {\r\n UUID: this._uuidToString(characteristic.getUuid()),\r\n name: this._uuidToString(characteristic.getUuid()), // there's no sep field on Android\r\n properties: {\r\n read: (props & btChar.PROPERTY_READ) !== 0,\r\n write: (props & btChar.PROPERTY_WRITE) !== 0,\r\n writeWithoutResponse: (props & btChar.PROPERTY_WRITE_NO_RESPONSE) !== 0,\r\n notify: (props & btChar.PROPERTY_NOTIFY) !== 0,\r\n indicate: (props & btChar.PROPERTY_INDICATE) !== 0,\r\n broadcast: (props & btChar.PROPERTY_BROADCAST) !== 0,\r\n authenticatedSignedWrites: (props & btChar.PROPERTY_SIGNED_WRITE) !== 0,\r\n extendedProperties: (props & btChar.PROPERTY_EXTENDED_PROPS) !== 0\r\n },\r\n descriptors: descriptorsJs,\r\n permissions: null\r\n };\r\n // permissions are usually not provided, so let's not return them in that case\r\n var charPerms = characteristic.getPermissions();\r\n if (charPerms > 0) {\r\n characteristicJs.permissions = {\r\n read: (charPerms & btChar.PERMISSION_READ) !== 0,\r\n readEncrypted: (charPerms & btChar.PERMISSION_READ_ENCRYPTED) !== 0,\r\n readEncryptedMitm: (charPerms & btChar.PERMISSION_READ_ENCRYPTED_MITM) !== 0,\r\n write: (charPerms & btChar.PERMISSION_WRITE) !== 0,\r\n writeEncrypted: (charPerms & btChar.PERMISSION_WRITE_ENCRYPTED) !== 0,\r\n writeEncryptedMitm: (charPerms & btChar.PERMISSION_WRITE_ENCRYPTED_MITM) !== 0,\r\n writeSigned: (charPerms & btChar.PERMISSION_WRITE_SIGNED) !== 0,\r\n writeSignedMitm: (charPerms & btChar.PERMISSION_WRITE_SIGNED_MITM) !== 0\r\n };\r\n }\r\n characteristicsJs.push(characteristicJs);\r\n }\r\n\r\n servicesJs.push({\r\n UUID: this._uuidToString(service.getUuid()),\r\n characteristics: characteristicsJs\r\n });\r\n }\r\n var device = bluetoothGatt.getDevice();\r\n var stateObject = this._connections[device.getAddress()];\r\n stateObject.onConnected({\r\n UUID: device.getAddress(), // TODO consider renaming to id (and iOS as well)\r\n name: device.getName(),\r\n state: 'connected', // this._getState(peripheral.state),\r\n services: servicesJs\r\n });\r\n }\r\n },\r\n\r\n _decodeValue: function (value) {\r\n if (value === null) {\r\n return null;\r\n }\r\n\r\n // value is of Java type: byte[]\r\n var b = android.util.Base64.encodeToString(value, android.util.Base64.NO_WRAP);\r\n return this._base64ToArrayBuffer(b);\r\n },\r\n\r\n onCharacteristicRead: function (bluetoothGatt, bluetoothGattCharacteristic, status) {\r\n console.log(\"------- _MyGattCallback.onCharacteristicRead\");\r\n\r\n var device = bluetoothGatt.getDevice();\r\n var stateObject = this._connections[device.getAddress()];\r\n if (!stateObject) {\r\n this._disconnect(bluetoothGatt);\r\n return;\r\n }\r\n\r\n if (stateObject.onReadPromise) {\r\n var value = bluetoothGattCharacteristic.getValue();\r\n stateObject.onReadPromise({\r\n valueRaw: value,\r\n value: this._decodeValue(value),\r\n characteristicUUID: bluetoothGattCharacteristic.getUuid()\r\n });\r\n }\r\n },\r\n\r\n onCharacteristicChanged: function (bluetoothGatt, bluetoothGattCharacteristic) {\r\n console.log(\"------- _MyGattCallback.onCharacteristicChanged\");\r\n\r\n var device = bluetoothGatt.getDevice();\r\n var stateObject = this._connections[device.getAddress()];\r\n if (!stateObject) {\r\n this._disconnect(bluetoothGatt);\r\n return;\r\n }\r\n\r\n if (stateObject.onNotifyCallback) {\r\n var value = bluetoothGattCharacteristic.getValue();\r\n stateObject.onNotifyCallback({\r\n valueRaw: value,\r\n value: this._decodeValue(value),\r\n characteristicUUID: bluetoothGattCharacteristic.getUuid()\r\n });\r\n }\r\n },\r\n\r\n onCharacteristicWrite: function (bluetoothGatt, bluetoothGattCharacteristic, status) {\r\n console.log(\"------- _MyGattCallback.onCharacteristicWrite\");\r\n\r\n var device = bluetoothGatt.getDevice();\r\n var stateObject = this._connections[device.getAddress()];\r\n if (!stateObject) {\r\n this._disconnect(bluetoothGatt);\r\n return;\r\n }\r\n\r\n console.log(bluetoothGattCharacteristic);\r\n\r\n if (stateObject.onWritePromise) {\r\n stateObject.onWritePromise({\r\n characteristicUUID: bluetoothGattCharacteristic.getUuid()\r\n });\r\n }\r\n },\r\n\r\n onDescriptorRead: function (bluetoothGatt, bluetoothGattDescriptor, status) {\r\n console.log(\"------- _MyGattCallback.onDescriptorRead\");\r\n },\r\n\r\n onDescriptorWrite: function (bluetoothGatt, bluetoothGattDescriptor, status) {\r\n console.log(\"------- _MyGattCallback.onDescriptorWrite\");\r\n },\r\n\r\n onReadRemoteRssi: function (bluetoothGatt, rssi, status) {\r\n console.log(\"------- _MyGattCallback.onReadRemoteRssi\");\r\n },\r\n\r\n onMtuChanged: function (bluetoothGatt, mtu, status) {\r\n console.log(\"------- _MyGattCallback.onMtuChanged\");\r\n }\r\n });\r\n\r\n _isEnabled(arg) {\r\n return adapter !== null && adapter.isEnabled();\r\n };\r\n\r\n isBluetoothEnabled(arg) {\r\n return new Promise(function (resolve, reject) {\r\n try {\r\n resolve(this._isEnabled());\r\n } catch (ex) {\r\n console.log(\"Error in Bluetooth.isBluetoothEnabled: \" + ex);\r\n reject(ex);\r\n }\r\n });\r\n };\r\n\r\n // Java UUID -> JS\r\n _uuidToString(uuid) {\r\n var uuidStr = uuid.toString();\r\n var pattern = java.util.regex.Pattern.compile(\"0000(.{4})-0000-1000-8000-00805f9b34fb\", 2);\r\n var matcher = pattern.matcher(uuidStr);\r\n return matcher.matches() ? matcher.group(1) : uuidStr;\r\n };\r\n\r\n // JS UUID -> Java\r\n _stringToUuid(uuidStr) {\r\n if (uuidStr.length === 4) {\r\n uuidStr = \"0000\" + uuidStr + \"-0000-1000-8000-00805f9b34fb\";\r\n }\r\n return java.util.UUID.fromString(uuidStr);\r\n };\r\n\r\n startScanning(arg) {\r\n return new Promise(function (resolve, reject) {\r\n try {\r\n if (!this._isEnabled()) {\r\n reject(\"Bluetooth is not enabled\");\r\n return;\r\n }\r\n // log a warning when on Android M and no permission has been granted (it's up to the dev to implement that flow though)\r\n if (!this._coarseLocationPermissionGranted()) {\r\n console.warn(\"Coarse location permission has not been granted; scanning for peripherals may fail.\");\r\n }\r\n\r\n this._connections = {};\r\n\r\n var serviceUUIDs = arg.serviceUUIDs || [];\r\n var uuids = [];\r\n for (var s in serviceUUIDs) {\r\n uuids.push(this._stringToUuid(serviceUUIDs[s]));\r\n }\r\n\r\n if (android.os.Build.VERSION.SDK_INT < 21 /*android.os.Build.VERSION_CODES.LOLLIPOP */) {\r\n var didStart = uuids.length === 0 ?\r\n adapter.startLeScan(this._scanCallback) :\r\n adapter.startLeScan(uuids, this._scanCallback);\r\n if (!didStart) {\r\n // TODO error msg, see https://github.com/randdusing/cordova-plugin-bluetoothle/blob/master/src/android/BluetoothLePlugin.java#L758\r\n reject(\"Scanning didn't start\");\r\n return;\r\n }\r\n } else {\r\n var scanFilters = null;\r\n if (uuids.length > 0) {\r\n scanFilters = new java.util.ArrayList();\r\n for (var u in uuids) {\r\n var theUuid = uuids[u];\r\n var scanFilterBuilder = new android.bluetooth.le.ScanFilter.Builder();\r\n scanFilterBuilder.setServiceUuid(new android.os.ParcelUuid(theUuid));\r\n scanFilters.add(scanFilterBuilder.build());\r\n }\r\n }\r\n // ga hier verder: https://github.com/randdusing/cordova-plugin-bluetoothle/blob/master/src/android/BluetoothLePlugin.java#L775\r\n var scanSettings = new android.bluetooth.le.ScanSettings.Builder();\r\n scanSettings.setReportDelay(0);\r\n\r\n var scanMode = arg.scanMode || android.bluetooth.le.ScanSettings.SCAN_MODE_LOW_LATENCY;\r\n scanSettings.setScanMode(scanMode);\r\n\r\n if (android.os.Build.VERSION.SDK_INT >= 23 /*android.os.Build.VERSION_CODES.M */) {\r\n var matchMode = arg.matchMode || android.bluetooth.le.ScanSettings.MATCH_MODE_AGGRESSIVE;\r\n scanSettings.setMatchMode(matchMode);\r\n\r\n var matchNum = arg.matchNum || android.bluetooth.le.ScanSettings.MATCH_NUM_MAX_ADVERTISEMENT;\r\n scanSettings.setNumOfMatches(matchNum);\r\n\r\n var callbackType = arg.callbackType || android.bluetooth.le.ScanSettings.CALLBACK_TYPE_ALL_MATCHES;\r\n scanSettings.setCallbackType(callbackType);\r\n }\r\n adapter.getBluetoothLeScanner().startScan(scanFilters, scanSettings.build(), this._scanCallback);\r\n }\r\n\r\n onDiscovered = arg.onDiscovered;\r\n\r\n if (arg.seconds) {\r\n setTimeout(function () {\r\n // note that by now a manual 'stop' may have been invoked, but that doesn't hurt\r\n if (android.os.Build.VERSION.SDK_INT < 21 /* android.os.Build.VERSION_CODES.LOLLIPOP */) {\r\n adapter.stopLeScan(this._scanCallback);\r\n } else {\r\n adapter.getBluetoothLeScanner().stopScan(this._scanCallback);\r\n }\r\n resolve();\r\n }, arg.seconds * 1000);\r\n } else {\r\n resolve();\r\n }\r\n } catch (ex) {\r\n console.log(\"Error in Bluetooth.startScanning: \" + ex);\r\n reject(ex);\r\n }\r\n });\r\n };\r\n\r\n stopScanning() {\r\n return new Promise(function (resolve, reject) {\r\n try {\r\n if (!this._isEnabled()) {\r\n reject(\"Bluetooth is not enabled\");\r\n return;\r\n }\r\n if (android.os.Build.VERSION.SDK_INT < 21 /* android.os.Build.VERSION_CODES.LOLLIPOP */) {\r\n adapter.stopLeScan(this._scanCallback);\r\n } else {\r\n adapter.getBluetoothLeScanner().stopScan(this._scanCallback);\r\n }\r\n resolve();\r\n } catch (ex) {\r\n console.log(\"Error in Bluetooth.stopScanning: \" + ex);\r\n reject(ex);\r\n }\r\n });\r\n };\r\n\r\n _disconnect(gatt) {\r\n if (gatt !== null) {\r\n var device = gatt.getDevice();\r\n var stateObject = this._connections[device.getAddress()];\r\n console.log(\"----- invoking disc cb\");\r\n if (stateObject && stateObject.onDisconnected) {\r\n stateObject.onDisconnected({\r\n UUID: device.getAddress(),\r\n name: device.getName()\r\n });\r\n } else {\r\n console.log(\"----- !!! no disconnect callback found\");\r\n }\r\n this._connections[device.getAddress()] = null;\r\n gatt.close();\r\n }\r\n };\r\n\r\n // note that this doesn't make much sense without scanning first\r\n connect(arg) {\r\n return new Promise(function (resolve, reject) {\r\n try {\r\n // or macaddress..\r\n if (!arg.UUID) {\r\n reject(\"No UUID was passed\");\r\n return;\r\n }\r\n var bluetoothDevice = adapter.getRemoteDevice(arg.UUID);\r\n if (bluetoothDevice === null) {\r\n reject(\"Could not find peripheral with UUID \" + arg.UUID);\r\n } else {\r\n console.log(\"Connecting to peripheral with UUID: \" + arg.UUID);\r\n\r\n var bluetoothGatt;\r\n if (android.os.Build.VERSION.SDK_INT < 23 /*android.os.Build.VERSION_CODES.M */) {\r\n bluetoothGatt = bluetoothDevice.connectGatt(\r\n utils.ad.getApplicationContext(), // context\r\n false, // autoconnect\r\n new this._MyGattCallback(/* TODO pass in onWhatever function */)\r\n );\r\n } else {\r\n bluetoothGatt = bluetoothDevice.connectGatt(\r\n utils.ad.getApplicationContext(), // context\r\n false, // autoconnect\r\n new this._MyGattCallback(/* TODO pass in onWhatever function */),\r\n android.bluetooth.BluetoothDevice.TRANSPORT_LE // 2\r\n );\r\n }\r\n\r\n this._connections[arg.UUID] = {\r\n state: 'connecting',\r\n onConnected: arg.onConnected,\r\n onDisconnected: arg.onDisconnected,\r\n device: bluetoothGatt // TODO rename device to gatt?\r\n };\r\n }\r\n } catch (ex) {\r\n console.log(\"Error in Bluetooth.connect: \" + ex);\r\n reject(ex);\r\n }\r\n });\r\n };\r\n\r\n disconnect(arg) {\r\n return new Promise(function (resolve, reject) {\r\n try {\r\n if (!arg.UUID) {\r\n reject(\"No UUID was passed\");\r\n return;\r\n }\r\n var connection = this._connections[arg.UUID];\r\n if (!connection) {\r\n reject(\"Peripheral wasn't connected\");\r\n return;\r\n }\r\n\r\n this._disconnect(connection.device);\r\n resolve();\r\n } catch (ex) {\r\n console.log(\"Error in Bluetooth.disconnect: \" + ex);\r\n reject(ex);\r\n }\r\n });\r\n };\r\n\r\n // This guards against peripherals reusing char UUID's. We prefer notify.\r\n _findNotifyCharacteristic(bluetoothGattService, characteristicUUID) {\r\n // Check for Notify first\r\n var characteristics = bluetoothGattService.getCharacteristics();\r\n for (var i = 0; i < characteristics.size(); i++) {\r\n var c = characteristics.get(i);\r\n if ((c.getProperties() & android.bluetooth.BluetoothGattCharacteristic.PROPERTY_NOTIFY) !== 0 && characteristicUUID.equals(c.getUuid())) {\r\n return c;\r\n }\r\n }\r\n\r\n // If there wasn't a Notify Characteristic, check for Indicate\r\n for (i = 0; i < characteristics.size(); i++) {\r\n var ch = characteristics.get(i);\r\n if ((ch.getProperties() & android.bluetooth.BluetoothGattCharacteristic.PROPERTY_INDICATE) !== 0 && characteristicUUID.equals(ch.getUuid())) {\r\n return ch;\r\n }\r\n }\r\n\r\n // As a last resort, try and find ANY characteristic with this UUID, even if it doesn't have the correct properties\r\n return bluetoothGattService.getCharacteristic(characteristicUUID);\r\n };\r\n\r\n // This guards against peripherals reusing char UUID's.\r\n _findCharacteristicOfType(bluetoothGattService, characteristicUUID, charType) {\r\n var characteristics = bluetoothGattService.getCharacteristics();\r\n for (var i = 0; i < characteristics.size(); i++) {\r\n var c = characteristics.get(i);\r\n if ((c.getProperties() & charType) !== 0 && characteristicUUID.equals(c.getUuid())) {\r\n return c;\r\n }\r\n }\r\n // As a last resort, try and find ANY characteristic with this UUID, even if it doesn't have the correct properties\r\n return bluetoothGattService.getCharacteristic(characteristicUUID);\r\n };\r\n\r\n _getWrapper(arg, reject) {\r\n if (!this._isEnabled(arg)) { //Is that edit correct?\r\n reject(\"Bluetooth is not enabled\");\r\n return;\r\n }\r\n if (!arg.peripheralUUID) {\r\n reject(\"No peripheralUUID was passed\");\r\n return;\r\n }\r\n if (!arg.serviceUUID) {\r\n reject(\"No serviceUUID was passed\");\r\n return;\r\n }\r\n if (!arg.characteristicUUID) {\r\n reject(\"No characteristicUUID was passed\");\r\n return;\r\n }\r\n\r\n var serviceUUID = this._stringToUuid(arg.serviceUUID);\r\n\r\n var stateObject = this._connections[arg.peripheralUUID];\r\n if (!stateObject) {\r\n reject(\"The peripheral is disconnected\");\r\n return;\r\n }\r\n\r\n var gatt = stateObject.device;\r\n var bluetoothGattService = gatt.getService(serviceUUID);\r\n\r\n if (!bluetoothGattService) {\r\n reject(\"Could not find service with UUID \" + arg.serviceUUID + \" on peripheral with UUID \" + arg.peripheralUUID);\r\n return;\r\n }\r\n\r\n // with that all being checked, let's return a wrapper object containing all the stuff we found here\r\n return {\r\n gatt: gatt,\r\n bluetoothGattService: bluetoothGattService\r\n };\r\n };\r\n\r\n read(arg) {\r\n return new Promise(function (resolve, reject) {\r\n try {\r\n var wrapper = this._getWrapper(arg, reject);\r\n if (wrapper === null) {\r\n // no need to reject, this has already been done\r\n return;\r\n }\r\n\r\n var gatt = wrapper.gatt;\r\n var bluetoothGattService = wrapper.bluetoothGattService;\r\n var characteristicUUID = this._stringToUuid(arg.characteristicUUID);\r\n\r\n var bluetoothGattCharacteristic = this._findCharacteristicOfType(bluetoothGattService, characteristicUUID, android.bluetooth.BluetoothGattCharacteristic.PROPERTY_READ);\r\n if (!bluetoothGattCharacteristic) {\r\n reject(\"Could not find characteristic with UUID \" + arg.characteristicUUID + \" on service with UUID \" + arg.serviceUUID + \" on peripheral with UUID \" + arg.peripheralUUID);\r\n return;\r\n }\r\n\r\n var stateObject = this._connections[arg.peripheralUUID];\r\n stateObject.onReadPromise = resolve;\r\n if (!gatt.readCharacteristic(bluetoothGattCharacteristic)) {\r\n reject(\"Failed to set client characteristic read for \" + characteristicUUID);\r\n }\r\n } catch (ex) {\r\n console.log(\"Error in Bluetooth.read: \" + ex);\r\n reject(ex);\r\n }\r\n });\r\n };\r\n\r\n // val must be a Uint8Array or Uint16Array or a string like '0x01' or '0x007F' or '0x01,0x02', or '0x007F,'0x006F''\r\n _encodeValue(val) {\r\n // if it's not a string assume it's a byte array already\r\n if (typeof val != 'string') {\r\n return val;\r\n }\r\n var parts = val.split(',');\r\n if (parts[0].indexOf('x') == -1) {\r\n return null;\r\n }\r\n var result = Array.create(\"byte\", parts.length);\r\n\r\n for (var i = 0; i < parts.length; i++) {\r\n result[i] = parts[i];\r\n }\r\n return result;\r\n };\r\n\r\n write(arg) {\r\n return new Promise(function (resolve, reject) {\r\n try {\r\n if (!arg.value) {\r\n reject(\"You need to provide some data to write in the 'value' property\");\r\n return;\r\n }\r\n var wrapper = this._getWrapper(arg, reject);\r\n if (wrapper === null) {\r\n // no need to reject, this has already been done\r\n return;\r\n }\r\n\r\n var bluetoothGattCharacteristic = this._findCharacteristicOfType(wrapper.bluetoothGattService, this._stringToUuid(arg.characteristicUUID), android.bluetooth.BluetoothGattCharacteristic.PROPERTY_WRITE);\r\n if (!bluetoothGattCharacteristic) {\r\n reject(\"Could not find characteristic with UUID \" + arg.characteristicUUID + \" on service with UUID \" + arg.serviceUUID + \" on peripheral with UUID \" + arg.peripheralUUID);\r\n return;\r\n }\r\n\r\n var val = this._encodeValue(arg.value);\r\n if (val === null) {\r\n reject(\"Invalid value: \" + arg.value);\r\n return;\r\n }\r\n\r\n bluetoothGattCharacteristic.setValue(val);\r\n bluetoothGattCharacteristic.setWriteType(android.bluetooth.BluetoothGattCharacteristic.WRITE_TYPE_DEFAULT);\r\n\r\n this._connections[arg.peripheralUUID].onWritePromise = resolve;\r\n if (!wrapper.gatt.writeCharacteristic(bluetoothGattCharacteristic)) {\r\n reject(\"Failed to write to characteristic \" + arg.characteristicUUID);\r\n }\r\n } catch (ex) {\r\n console.log(\"Error in Bluetooth.write: \" + ex);\r\n reject(ex);\r\n }\r\n });\r\n };\r\n\r\n writeWithoutResponse(arg) {\r\n return new Promise(function (resolve, reject) {\r\n try {\r\n if (!arg.value) {\r\n reject(\"You need to provide some data to write in the 'value' property\");\r\n return;\r\n }\r\n var wrapper = this._getWrapper(arg, reject);\r\n if (wrapper === null) {\r\n // no need to reject, this has already been done\r\n return;\r\n }\r\n\r\n var bluetoothGattCharacteristic = this._findCharacteristicOfType(wrapper.bluetoothGattService, this._stringToUuid(arg.characteristicUUID), android.bluetooth.BluetoothGattCharacteristic.PROPERTY_WRITE);\r\n if (!bluetoothGattCharacteristic) {\r\n reject(\"Could not find characteristic with UUID \" + arg.characteristicUUID + \" on service with UUID \" + arg.serviceUUID + \" on peripheral with UUID \" + arg.peripheralUUID);\r\n return;\r\n }\r\n\r\n var val = this._encodeValue(arg.value);\r\n if (val === null) {\r\n reject(\"Invalid value: \" + arg.value);\r\n return;\r\n }\r\n\r\n bluetoothGattCharacteristic.setValue(val);\r\n bluetoothGattCharacteristic.setWriteType(android.bluetooth.BluetoothGattCharacteristic.WRITE_TYPE_NO_RESPONSE);\r\n\r\n if (wrapper.gatt.writeCharacteristic(bluetoothGattCharacteristic)) {\r\n resolve();\r\n } else {\r\n reject(\"Failed to write to characteristic \" + arg.characteristicUUID);\r\n }\r\n } catch (ex) {\r\n console.log(\"Error in Bluetooth.writeWithoutResponse: \" + ex);\r\n reject(ex);\r\n }\r\n });\r\n };\r\n\r\n startNotifying(arg) {\r\n return new Promise(function (resolve, reject) {\r\n try {\r\n var wrapper = this._getWrapper(arg, reject);\r\n if (wrapper === null) {\r\n // no need to reject, this has already been done\r\n return;\r\n }\r\n\r\n var gatt = wrapper.gatt;\r\n var bluetoothGattService = wrapper.bluetoothGattService;\r\n var characteristicUUID = this._stringToUuid(arg.characteristicUUID);\r\n\r\n var bluetoothGattCharacteristic = this._findNotifyCharacteristic(bluetoothGattService, characteristicUUID);\r\n if (!bluetoothGattCharacteristic) {\r\n reject(\"Could not find characteristic with UUID \" + arg.characteristicUUID + \" on service with UUID \" + arg.serviceUUID + \" on peripheral with UUID \" + arg.peripheralUUID);\r\n return;\r\n }\r\n\r\n if (!gatt.setCharacteristicNotification(bluetoothGattCharacteristic, true)) {\r\n reject(\"Failed to register notification for characteristic \" + arg.characteristicUUID);\r\n return;\r\n }\r\n\r\n var clientCharacteristicConfigId = this._stringToUuid(\"2902\");\r\n var bluetoothGattDescriptor = bluetoothGattCharacteristic.getDescriptor(clientCharacteristicConfigId);\r\n if (!bluetoothGattDescriptor) {\r\n reject(\"Set notification failed for \" + characteristicUUID);\r\n return;\r\n }\r\n\r\n // prefer notify over indicate\r\n if ((bluetoothGattCharacteristic.getProperties() & android.bluetooth.BluetoothGattCharacteristic.PROPERTY_NOTIFY) !== 0) {\r\n bluetoothGattDescriptor.setValue(android.bluetooth.BluetoothGattDescriptor.ENABLE_NOTIFICATION_VALUE);\r\n } else if ((bluetoothGattCharacteristic.getProperties() & android.bluetooth.BluetoothGattCharacteristic.PROPERTY_INDICATE) !== 0) {\r\n bluetoothGattDescriptor.setValue(android.bluetooth.BluetoothGattDescriptor.ENABLE_INDICATION_VALUE);\r\n } else {\r\n console.log(\"Characteristic \" + characteristicUUID + \" does not have NOTIFY or INDICATE property set\");\r\n }\r\n\r\n if (gatt.writeDescriptor(bluetoothGattDescriptor)) {\r\n var cb = arg.onNotify || function (result) { console.log(\"No 'onNotify' callback function specified for 'startNotifying'\"); };\r\n var stateObject = this._connections[arg.peripheralUUID];\r\n stateObject.onNotifyCallback = cb;\r\n console.log(\"--- notifying\");\r\n resolve();\r\n } else {\r\n reject(\"Failed to set client characteristic notification for \" + characteristicUUID);\r\n }\r\n } catch (ex) {\r\n console.log(\"Error in Bluetooth.startNotifying: \" + ex);\r\n reject(ex);\r\n }\r\n });\r\n };\r\n\r\n // TODO lot of reuse between this and .startNotifying\r\n stopNotifying(arg) {\r\n return new Promise(function (resolve, reject) {\r\n try {\r\n var wrapper = this._getWrapper(arg, reject);\r\n if (wrapper === null) {\r\n // no need to reject, this has already been done\r\n return;\r\n }\r\n\r\n var gatt = wrapper.gatt;\r\n var bluetoothGattService = wrapper.bluetoothGattService;\r\n var characteristicUUID = this._stringToUuid(arg.characteristicUUID);\r\n\r\n var bluetoothGattCharacteristic = this._findNotifyCharacteristic(bluetoothGattService, characteristicUUID);\r\n console.log(\"---- got gatt service char: \" + bluetoothGattCharacteristic);\r\n\r\n if (!bluetoothGattCharacteristic) {\r\n reject(\"Could not find characteristic with UUID \" + arg.characteristicUUID + \" on service with UUID \" + arg.serviceUUID + \" on peripheral with UUID \" + arg.peripheralUUID);\r\n return;\r\n }\r\n\r\n var stateObject = this._connections[arg.peripheralUUID];\r\n stateObject.onNotifyCallback = null;\r\n\r\n if (gatt.setCharacteristicNotification(bluetoothGattCharacteristic, false)) {\r\n resolve();\r\n } else {\r\n reject(\"Failed to remove client characteristic notification for \" + characteristicUUID);\r\n }\r\n\r\n } catch (ex) {\r\n console.log(\"Error in Bluetooth.stopNotifying: \" + ex);\r\n reject(ex);\r\n }\r\n });\r\n };\r\n\r\n}\r\n"],"sourceRoot":"/source/"}