forked from nativescript-community/ble
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbluetooth.ios.js.map
1 lines (1 loc) · 44.9 KB
/
bluetooth.ios.js.map
1
{"version":3,"sources":["bluetooth.ios.ts"],"names":[],"mappings":";AAAA,yCAAyC;AACzC,iCAAwB,oBAAoB,CAAC,CAAA;AAG7C;IAAwB,6BAAS;IAU/B;QACE,iBAAO,CAAC;QAVV,WAAM,GAAG;YACP,OAAO,EAAE,IAAI;YACb,eAAe,EAAE,IAAI;YACrB,eAAe,EAAE,IAAI;YACrB,gBAAgB,EAAE,EAAE;YACpB,mBAAmB,EAAE,EAAE;YACvB,YAAY,EAAE,IAAI;SACnB,CAAC;QA0UF,uBAAkB,GAAG,UAAU,GAAG;YAChC,MAAM,CAAC,IAAI,OAAO,CAAC,UAAU,OAAO,EAAE,MAAM;gBAC1C,IAAI,CAAC;oBACH,OAAO,CAAC,IAAI,CAAC,UAAU,EAAE,CAAC,CAAC;gBAC7B,CAAE;gBAAA,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;oBACZ,OAAO,CAAC,GAAG,CAAC,yCAAyC,GAAG,EAAE,CAAC,CAAC;oBAC5D,MAAM,CAAC,EAAE,CAAC,CAAC;gBACb,CAAC;YACH,CAAC,CAAC,CAAC;QACL,CAAC,CAAC;QAEF,kBAAa,GAAG,UAAU,GAAG;YAC3B,MAAM,CAAC,IAAI,OAAO,CAAC,UAAU,OAAO,EAAE,MAAM;gBAC1C,IAAI,CAAC;oBACH,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,UAAU,EAAE,CAAC,CAAC,CAAC;wBACvB,MAAM,CAAC,0BAA0B,CAAC,CAAC;wBACnC,MAAM,CAAC;oBACT,CAAC;oBACD,IAAI,CAAC,MAAM,CAAC,eAAe,GAAG,cAAc,CAAC,GAAG,EAAE,CAAC;oBAEnD,6HAA6H;oBAC7H,IAAI,CAAC,MAAM,CAAC,YAAY,GAAG,GAAG,CAAC,YAAY,CAAC;oB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YACb,CAAC;QACH,CAAC,CAAC,CAAC;IACL,CAAC;;IAED,wCAAoB,GAApB,UAAqB,GAAG;QACtB,MAAM,CAAC,IAAI,OAAO,CAAC,UAAU,OAAO,EAAE,MAAM;YAC1C,IAAI,CAAC;gBACH,EAAE,CAAC,CAAC,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC;oBACf,MAAM,CAAC,gEAAgE,CAAC,CAAC;oBACzE,MAAM,CAAC;gBACT,CAAC;gBACD,IAAI,OAAO,GAAG,IAAI,CAAC,WAAW,CAAC,GAAG,EAAE,0BAA0B,CAAC,4CAA4C,EAAE,MAAM,CAAC,CAAC;gBACrH,EAAE,CAAC,CAAC,OAAO,KAAK,IAAI,CAAC,CAAC,CAAC;oBACrB,gDAAgD;oBAChD,MAAM,CAAC;gBACT,CAAC;gBAED,IAAI,YAAY,GAAG,IAAI,CAAC,YAAY,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;gBAChD,OAAO,CAAC,GAAG,CAAC,iCAAiC,GAAG,YAAY,CAAC,CAAC;gBAE9D,OAAO,CAAC,UAAU,CAAC,+BAA+B,CAChD,YAAY,EACZ,OAAO,CAAC,cAAc,EACtB,yBAAyB,CAAC,oCAAoC,CAAC,CAAC;gBAElE,OAAO,EAAE,CAAC;YACZ,CAAE;YAAA,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;gBACZ,OAAO,CAAC,GAAG,CAAC,2CAA2C,GAAG,EAAE,CAAC,CAAC;gBAC9D,MAAM,CAAC,EAAE,CAAC,CAAC;YACb,CAAC;QACH,CAAC,CAAC,CAAC;IACL,CAAC;;IACH,gBAAC;AAAD,CAxuBA,AAwuBC,CAxuBuB,4BAAS,GAwuBhC","file":"bluetooth.ios.js","sourcesContent":["/// <reference path=\"_references.d.ts\" />\r\nimport {bluetooth} from \"./bluetooth-common\";\r\n\r\n\r\nclass Bluetooth extends bluetooth {\r\n _state = {\r\n manager: null,\r\n centralDelegate: null,\r\n peripheralArray: null,\r\n connectCallbacks: {},\r\n disconnectCallbacks: {},\r\n onDiscovered: null\r\n };\r\n\r\n constructor(){\r\n super();\r\n //impliment the commented out functionality below\r\n } \r\n\r\n /*\r\n var CBPeripheralDelegateImpl = (function (_super) {\r\n __extends(CBPeripheralDelegateImpl, _super);\r\n function CBPeripheralDelegateImpl() {\r\n _super.apply(this, arguments);\r\n }\r\n CBPeripheralDelegateImpl.new = function () {\r\n return _super.new.call(this);\r\n };\r\n CBPeripheralDelegateImpl.prototype.initWithCallback = function (callback) {\r\n this._callback = callback;\r\n // this._services = [];\r\n this._servicesWithCharacteristics = [];\r\n return this;\r\n };\r\n CBPeripheralDelegateImpl.prototype.peripheralDidDiscoverServices = function(peripheral, error) {\r\n console.log(\"----- delegate peripheralDidDiscoverServices\");\r\n \r\n // map native services to a JS object\r\n this._services = [];\r\n for (var i = 0; i < peripheral.services.count; i++) {\r\n var service = peripheral.services.objectAtIndex(i);\r\n this._services.push({\r\n UUID: service.UUID.UUIDString,\r\n name: service.UUID\r\n });\r\n // NOTE: discover all is slow\r\n peripheral.discoverCharacteristicsForService(null, service);\r\n }\r\n };\r\n CBPeripheralDelegateImpl.prototype.peripheralDidDiscoverIncludedServicesForServiceError = function(peripheral, service, error) {\r\n console.log(\"----- delegate peripheral:didDiscoverIncludedServicesForService:error\");\r\n };\r\n CBPeripheralDelegateImpl.prototype._getProperties = function(characteristic) {\r\n var props = characteristic.properties;\r\n return {\r\n broadcast: (props & CBCharacteristicPropertyBroadcast) == CBCharacteristicPropertyBroadcast,\r\n read: (props & CBCharacteristicPropertyRead) == CBCharacteristicPropertyRead,\r\n broadcast2: (props & CBCharacteristicPropertyBroadcast) == CBCharacteristicPropertyBroadcast,\r\n read2: (props & CBCharacteristicPropertyRead) == CBCharacteristicPropertyRead,\r\n write: (props & CBCharacteristicPropertyWrite) == CBCharacteristicPropertyWrite,\r\n writeWithoutResponse: (props & CBCharacteristicPropertyWriteWithoutResponse) == CBCharacteristicPropertyWriteWithoutResponse,\r\n notify: (props & CBCharacteristicPropertyNotify) == CBCharacteristicPropertyNotify,\r\n indicate: (props & CBCharacteristicPropertyIndicate) == CBCharacteristicPropertyIndicate,\r\n authenticatedSignedWrites: (props & CBCharacteristicPropertyAuthenticatedSignedWrites) == CBCharacteristicPropertyAuthenticatedSignedWrites,\r\n extendedProperties: (props & CBCharacteristicPropertyExtendedProperties) == CBCharacteristicPropertyExtendedProperties,\r\n notifyEncryptionRequired: (props & CBCharacteristicPropertyNotifyEncryptionRequired) == CBCharacteristicPropertyNotifyEncryptionRequired,\r\n indicateEncryptionRequired: (props & CBCharacteristicPropertyIndicateEncryptionRequired) == CBCharacteristicPropertyIndicateEncryptionRequired\r\n };\r\n };\r\n CBPeripheralDelegateImpl.prototype._getDescriptors = function(characteristic) {\r\n var descs = characteristic.descriptors;\r\n var descsJs = [];\r\n for (var i = 0; i < descs.count; i++) {\r\n var desc = descs.objectAtIndex(i);\r\n console.log(\"--------- descriptor value: \" + desc.value);\r\n descsJs.push({\r\n UUID: desc.UUID.UUIDString,\r\n value: desc.value\r\n });\r\n }\r\n return descsJs;\r\n };\r\n CBPeripheralDelegateImpl.prototype.peripheralDidDiscoverCharacteristicsForServiceError = function(peripheral, service, error) {\r\n if (error) {\r\n // TODO invoke reject and stop processing\r\n return;\r\n }\r\n var characteristics = [];\r\n for (var i = 0; i < service.characteristics.count; i++) {\r\n var characteristic = service.characteristics.objectAtIndex(i);\r\n var result = {\r\n UUID: characteristic.UUID.UUIDString,\r\n name: characteristic.UUID,\r\n // see serviceAndCharacteristicInfo in CBPer+Ext of Cordova plugin\r\n value: characteristic.value ? characteristic.value.base64EncodedStringWithOptions(0) : null,\r\n properties: this._getProperties(characteristic),\r\n // descriptors: this._getDescriptors(characteristic), // TODO we're not currently discovering these\r\n isNotifying: characteristic.isNotifying,\r\n permissions: characteristic.permissions // prolly not too useful\r\n };\r\n characteristics.push(result);\r\n \r\n for (var j=0; j<this._services.length; j++) {\r\n var s = this._services[j];\r\n if (s.UUID == service.UUID.UUIDString) {\r\n s.characteristics = characteristics;\r\n this._servicesWithCharacteristics.push(s);\r\n // the same service may be found multiple times, so make sure it's not added yet\r\n this._services.splice(j, 1);\r\n break;\r\n }\r\n }\r\n \r\n // Could add this one day: get details about the characteristic\r\n // peripheral.discoverDescriptorsForCharacteristic(characteristic);\r\n }\r\n \r\n if (this._services.length === 0) {\r\n if (this._callback) {\r\n this._callback({\r\n UUID: peripheral.identifier.UUIDString,\r\n name: peripheral.name,\r\n state: this._getState(peripheral.state),\r\n services: this._servicesWithCharacteristics\r\n });\r\n this._callback = null;\r\n }\r\n }\r\n };\r\n \r\n CBPeripheralDelegateImpl.prototype._toArrayBuffer = function(value) {\r\n if (value === null) {\r\n return null;\r\n }\r\n \r\n // value is of ObjC type: NSData\r\n var b = value.base64EncodedStringWithOptions(0);\r\n return this._base64ToArrayBuffer(b);\r\n };\r\n \r\n // this is called when a value is read from a peripheral\r\n CBPeripheralDelegateImpl.prototype.peripheralDidUpdateValueForCharacteristicError = function(peripheral, characteristic, error) {\r\n if (!characteristic) {\r\n console.log(\"^^^^^^^^ NO peripheralDidUpdateValueForCharacteristicError\");\r\n return;\r\n }\r\n \r\n if (error !== null) {\r\n // TODO handle.. pass in sep callback?\r\n console.log(\"------------ error @ peripheralDidUpdateValueForCharacteristicError!\");\r\n return;\r\n }\r\n \r\n var result = {\r\n type: characteristic.isNotifying ? \"notification\" : \"read\",\r\n characteristicUUID: characteristic.UUID.UUIDString,\r\n valueRaw: characteristic.value,\r\n value: this._toArrayBuffer(characteristic.value)\r\n };\r\n \r\n if (result.type === \"read\") {\r\n if (this._onReadPromise) {\r\n this._onReadPromise(result);\r\n } else {\r\n console.log(\"No _onReadPromise found!\");\r\n }\r\n } else {\r\n if (this._onNotifyCallback) {\r\n this._onNotifyCallback(result);\r\n } else {\r\n console.log(\"^^^^^^^^ CALLBACK IS GONE!\");\r\n }\r\n }\r\n };\r\n CBPeripheralDelegateImpl.prototype.peripheralDidWriteValueForCharacteristicError = function(peripheral, characteristic, error) {\r\n console.log(\"----- delegate peripheral:didWriteValueForCharacteristic:error\");\r\n if (this._onWritePromise) {\r\n this._onWritePromise({\r\n characteristicUUID: characteristic.UUID.UUIDString\r\n });\r\n } else {\r\n console.log(\"No _onWritePromise found!\");\r\n }\r\n };\r\n \r\n // The peripheral letting us know whether our subscribe/unsubscribe happened or not\r\n CBPeripheralDelegateImpl.prototype.peripheralDidUpdateNotificationStateForCharacteristicError = function(peripheral, characteristic, error) {\r\n console.log(\"----- delegate peripheral:didUpdateNotificationStateForCharacteristic:error, error: \" + error);\r\n // alert(\"peripheralDidUpdateNotificationStateForCharacteristicError\");\r\n if (error) {\r\n console.log(\"----- delegate peripheral:didUpdateNotificationStateForCharacteristic:error.localizedDescription, \" + error.localizedDescription); \r\n } else {\r\n if (characteristic.isNotifying) {\r\n console.log(\"------ Notification began on \" + characteristic);\r\n } else {\r\n console.log(\"------ Notification stopped on \" + characteristic + \", consider diconnecting\");\r\n // this._state.manager.cancelPeripheralConnection(peripheral);\r\n }\r\n }\r\n };\r\n CBPeripheralDelegateImpl.prototype.peripheralDidDiscoverDescriptorsForCharacteristicError = function(peripheral, characteristic, error) {\r\n \r\n // NOTE that this cb won't be invoked bc we curr don't discover descriptors\r\n \r\n console.log(\"----- delegate peripheral:didDiscoverDescriptorsForCharacteristic:error\");\r\n console.log(\"----- delegate peripheral:didDiscoverDescriptorsForCharacteristic:error characteristic.value: \" + characteristic.value);\r\n \r\n // TODO extract details, see https://github.com/randdusing/cordova-plugin-bluetoothle/blob/master/src/ios/BluetoothLePlugin.m#L1844\r\n console.log(characteristic.descriptors);\r\n for (var i = 0; i < characteristic.descriptors.count; i++) {\r\n var descriptor = characteristic.descriptors.objectAtIndex(i);\r\n console.log(\"char desc UUID: \" + descriptor.UUID.UUIDString);\r\n }\r\n \r\n // now let's see if we're ready to invoke the callback\r\n // TODO wait for the last one, THEN return\r\n if (this._services.length == this._servicesWithCharacteristics.length) {\r\n if (this._callback) {\r\n this._callback({\r\n UUID: peripheral.identifier.UUIDString,\r\n name: peripheral.name,\r\n state: this._getState(peripheral.state),\r\n services: this._services\r\n });\r\n this._callback = null;\r\n }\r\n }\r\n };\r\n CBPeripheralDelegateImpl.prototype.peripheralDidUpdateValueForDescriptorError = function(peripheral, descriptor, error) {\r\n console.log(\"----- delegate peripheral:didUpdateValueForDescriptor:error\");\r\n };\r\n CBPeripheralDelegateImpl.prototype.peripheralDidWriteValueForDescriptorError = function(peripheral, descriptor, error) {\r\n console.log(\"----- delegate peripheral:didWriteValueForDescriptor:error\");\r\n };\r\n CBPeripheralDelegateImpl.ObjCProtocols = [CBPeripheralDelegate];\r\n return CBPeripheralDelegateImpl;\r\n })(NSObject);\r\n \r\n \r\n var CBCentralManagerDelegateImpl = (function (_super) {\r\n __extends(CBCentralManagerDelegateImpl, _super);\r\n function CBCentralManagerDelegateImpl() {\r\n _super.apply(this, arguments);\r\n }\r\n CBCentralManagerDelegateImpl.new = function () {\r\n return _super.new.call(this);\r\n };\r\n CBCentralManagerDelegateImpl.prototype.initWithCallback = function (callback) {\r\n this._callback = callback;\r\n return this;\r\n };\r\n // fires when a peripheral is discovered after executing the 'scan' function\r\n CBCentralManagerDelegateImpl.prototype.centralManagerDidDiscoverPeripheralAdvertisementDataRSSI = function(central, peripheral, advData, RSSI) {\r\n console.log(\"----- delegate centralManager:didDiscoverPeripheral: \" + peripheral.name + \" @ \" + RSSI);\r\n var peri = this._findPeripheral(peripheral.identifier.UUIDString);\r\n if (!peri) {\r\n this._state.peripheralArray.addObject(peripheral);\r\n if (this._state.onDiscovered) {\r\n this._state.onDiscovered({\r\n UUID: peripheral.identifier.UUIDString,\r\n name: peripheral.name,\r\n RSSI: RSSI,\r\n state: this._getState(peripheral.state)\r\n });\r\n } else {\r\n console.log(\"----- !!! No onDiscovered callback specified\");\r\n }\r\n }\r\n };\r\n CBCentralManagerDelegateImpl.prototype.centralManagerDidUpdateState = function(central) {\r\n console.log(\"----- delegate centralManagerDidUpdateState: \" + central.state);\r\n if (central.state == CBCentralManagerStateUnsupported) {\r\n console.log(\"WARNING: This hardware does not support Bluetooth Low Energy.\");\r\n }\r\n };\r\n CBCentralManagerDelegateImpl.prototype.centralManagerWillRestoreState = function(central, dict) {\r\n console.log(\"----- delegate centralManager:willRestoreState\");\r\n };\r\n CBCentralManagerDelegateImpl.prototype.centralManagerDidConnectPeripheral = function(central, peripheral) {\r\n console.log(\"----- delegate centralManager:didConnectPeripheral: \" + peripheral);\r\n \r\n // find the peri in the array and attach the delegate to that\r\n var peri = this._findPeripheral(peripheral.identifier.UUIDString);\r\n console.log(\"----- delegate centralManager:didConnectPeripheral: cached perio: \" + peri);\r\n \r\n var cb = this._state.connectCallbacks[peripheral.identifier.UUIDString];\r\n var delegate = CBPeripheralDelegateImpl.new().initWithCallback(cb);\r\n CFRetain(delegate);\r\n peri.delegate = delegate;\r\n \r\n console.log(\"----- delegate centralManager:didConnectPeripheral, let's discover service\");\r\n peri.discoverServices(null);\r\n };\r\n CBCentralManagerDelegateImpl.prototype.centralManagerDidDisconnectPeripheralError = function(central, peripheral, error) {\r\n // this event needs to be honored by the client as any action afterwards crashes the app\r\n var cb = this._state.disconnectCallbacks[peripheral.identifier.UUIDString];\r\n if (cb) {\r\n cb({\r\n UUID: peripheral.identifier.UUIDString,\r\n name: peripheral.name\r\n });\r\n } else {\r\n console.log(\"----- !!! no disconnect callback found\"); \r\n }\r\n var foundAt = this._state.peripheralArray.indexOfObject(peripheral);\r\n this._state.peripheralArray.removeObject(foundAt);\r\n };\r\n CBCentralManagerDelegateImpl.prototype.centralManagerDidFailToConnectPeripheralError = function(central, peripheral, error) {\r\n // TODO send event to JS\r\n console.log(\"----- delegate centralManager:didFailToConnectPeripheral:error\");\r\n // this._callback(error);\r\n };\r\n CBCentralManagerDelegateImpl.ObjCProtocols = [CBCentralManagerDelegate];\r\n return CBCentralManagerDelegateImpl;\r\n })(NSObject);\r\n \r\n // check for bluetooth being enabled as soon as the app starts\r\n (function () {\r\n this._state.centralDelegate = CBCentralManagerDelegateImpl.new().initWithCallback(function (obj) {\r\n console.log(\"----- centralDelegate obj: \" + obj);\r\n });\r\n // TODO options? https://github.com/randdusing/cordova-plugin-bluetoothle/blob/master/src/ios/BluetoothLePlugin.m#L187\r\n this._state.manager = CBCentralManager.alloc().initWithDelegateQueue(this._state.centralDelegate, null);\r\n })();\r\n */\r\n _isEnabled(arg) {\r\n return this._state.manager.state == CBCentralManagerState.CBCentralManagerStatePoweredOn;\r\n };\r\n\r\n _getState(stateId) {\r\n if (stateId == CBPeripheralState.CBPeripheralStateConnecting) {\r\n return 'connecting';\r\n } else if (stateId == CBPeripheralState.CBPeripheralStateConnected) {\r\n return 'connected';\r\n } else if (stateId == CBPeripheralState.CBPeripheralStateDisconnected) {\r\n return 'disconnected';\r\n } else {\r\n console.log(\"Unexpected state, returning 'disconnected': \" + stateId);\r\n return 'disconnected';\r\n }\r\n };\r\n\r\n isBluetoothEnabled = function (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 startScanning = function (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 this._state.peripheralArray = NSMutableArray.new();\r\n\r\n // TODO actualy, should init the delegate here with this as the callback (see 'onConnected') --> but first test if that works\r\n this._state.onDiscovered = arg.onDiscovered;\r\n var serviceUUIDs = arg.serviceUUIDs || [];\r\n\r\n var services = [];\r\n for (var s in serviceUUIDs) {\r\n services.push(CBUUID.UUIDWithString(serviceUUIDs[s]));\r\n }\r\n this._state.manager.scanForPeripheralsWithServicesOptions(services, null);\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 this._state.manager.stopScan();\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 = function (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 this._state.manager.stopScan();\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 _findPeripheral = function (UUID) {\r\n for (var i = 0; i < this._state.peripheralArray.count; i++) {\r\n var peripheral = this._state.peripheralArray.objectAtIndex(i);\r\n if (UUID == peripheral.identifier.UUIDString) {\r\n return peripheral;\r\n }\r\n }\r\n return null;\r\n };\r\n\r\n // note that this doesn't make much sense without scanning first\r\n connect = function (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 if (!arg.UUID) {\r\n reject(\"No UUID was passed\");\r\n return;\r\n }\r\n var peripheral = this._findPeripheral(arg.UUID);\r\n if (peripheral === 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 this._state.connectCallbacks[arg.UUID] = arg.onConnected;\r\n this._state.disconnectCallbacks[arg.UUID] = arg.onDisconnected;\r\n this._state.manager.connectPeripheralOptions(peripheral, null);\r\n resolve();\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 = function (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 if (!arg.UUID) {\r\n reject(\"No UUID was passed\");\r\n return;\r\n }\r\n var peripheral = this._findPeripheral(arg.UUID);\r\n if (peripheral === null) {\r\n reject(\"Could not find peripheral with UUID \" + arg.UUID);\r\n } else {\r\n console.log(\"Disconnecting peripheral with UUID: \" + arg.UUID);\r\n // no need to send an error when already disconnected, but it's wise to check it\r\n if (peripheral.state != CBPeripheralState.CBPeripheralStateDisconnected) {\r\n this._state.manager.cancelPeripheralConnection(peripheral);\r\n peripheral.delegate = null;\r\n // TODO remove from the peripheralArray as well\r\n }\r\n resolve();\r\n }\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 isConnected = function (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 if (!arg.UUID) {\r\n reject(\"No UUID was passed\");\r\n return;\r\n }\r\n var peripheral = this._findPeripheral(arg.UUID);\r\n if (peripheral === null) {\r\n reject(\"Could not find peripheral with UUID \" + arg.UUID);\r\n } else {\r\n console.log(\"checking connection with peripheral UUID: \" + arg.UUID);\r\n resolve(peripheral.state == CBPeripheralState.CBPeripheralStateConnected);\r\n }\r\n } catch (ex) {\r\n console.log(\"Error in Bluetooth.isConnected: \" + ex);\r\n reject(ex);\r\n }\r\n });\r\n };\r\n\r\n _findService = function (UUID, peripheral) {\r\n for (var i = 0; i < peripheral.services.count; i++) {\r\n var service = peripheral.services.objectAtIndex(i);\r\n // console.log(\"--- service.UUID: \" + service.UUID);\r\n // TODO this may need a different compare, see Cordova plugin's findServiceFromUUID function\r\n if (UUID.UUIDString == service.UUID.UUIDString) {\r\n // console.log(\"--- found our service with UUID: \" + service.UUID);\r\n return service;\r\n }\r\n }\r\n // service not found on this peripheral\r\n return null;\r\n };\r\n\r\n _findCharacteristic = function (UUID, service, property) {\r\n // console.log(\"--- _findCharacteristic UUID: \" + UUID);\r\n // console.log(\"--- _findCharacteristic service: \" + service);\r\n console.log(\"--- _findCharacteristic characteristics: \" + service.characteristics);\r\n // console.log(\"--- _findCharacteristic characteristics.count: \" + service.characteristics.count);\r\n for (var i = 0; i < service.characteristics.count; i++) {\r\n var characteristic = service.characteristics.objectAtIndex(i);\r\n // console.log(\"--- characteristic.UUID: \" + characteristic.UUID);\r\n if (UUID.UUIDString == characteristic.UUID.UUIDString) {\r\n if (property) {\r\n if ((characteristic.properties & property) == property) {\r\n // console.log(\"--- characteristic.found: \" + characteristic.UUID);\r\n return characteristic;\r\n }\r\n } else {\r\n return characteristic;\r\n }\r\n }\r\n }\r\n // characteristic not found on this service\r\n console.log(\"--- characteristic.NOT.found!\");\r\n return null;\r\n };\r\n\r\n _getWrapper = function (arg, property, reject) {\r\n if (!this._isEnabled()) {\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 null;\r\n }\r\n if (!arg.serviceUUID) {\r\n reject(\"No serviceUUID was passed\");\r\n return null;\r\n }\r\n if (!arg.characteristicUUID) {\r\n reject(\"No characteristicUUID was passed\");\r\n return null;\r\n }\r\n\r\n var peripheral = this._findPeripheral(arg.peripheralUUID);\r\n if (!peripheral) {\r\n reject(\"Could not find peripheral with UUID \" + arg.peripheralUUID);\r\n return null;\r\n }\r\n\r\n if (peripheral.state != CBPeripheralState.CBPeripheralStateConnected) {\r\n reject(\"The peripheral is disconnected\");\r\n return null;\r\n }\r\n\r\n var serviceUUID = CBUUID.UUIDWithString(arg.serviceUUID);\r\n var service = this._findService(serviceUUID, peripheral);\r\n if (!service) {\r\n reject(\"Could not find service with UUID \" + arg.serviceUUID + \" on peripheral with UUID \" + arg.peripheralUUID);\r\n return null;\r\n }\r\n\r\n var characteristicUUID = CBUUID.UUIDWithString(arg.characteristicUUID);\r\n var characteristic = this._findCharacteristic(characteristicUUID, service, property);\r\n\r\n // Special handling for INDICATE. If charateristic with notify is not found, check for indicate.\r\n if (property == CBCharacteristicProperties.CBCharacteristicPropertyNotify && !characteristic) {\r\n characteristic = this._findCharacteristic(characteristicUUID, service, CBCharacteristicProperties.CBCharacteristicPropertyIndicate);\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 if (!characteristic) {\r\n characteristic = this._findCharacteristic(characteristicUUID, service);\r\n }\r\n\r\n if (!characteristic) {\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 null;\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 peripheral: peripheral,\r\n service: service,\r\n characteristic: characteristic\r\n };\r\n };\r\n\r\n read = function (arg) {\r\n return new Promise(function (resolve, reject) {\r\n try {\r\n var wrapper = this._getWrapper(arg, CBCharacteristicProperties.CBCharacteristicPropertyRead, 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 // TODO we could (should?) make this characteristic-specific\r\n wrapper.peripheral.delegate._onReadPromise = resolve;\r\n wrapper.peripheral.readValueForCharacteristic(wrapper.characteristic);\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 startNotifying = function (arg) {\r\n return new Promise(function (resolve, reject) {\r\n try {\r\n var wrapper = this._getWrapper(arg, CBCharacteristicProperties.CBCharacteristicPropertyNotify, reject);\r\n console.log(\"--------- startNotifying wrapper: \" + wrapper);\r\n\r\n if (wrapper === null) {\r\n // no need to reject, this has already been done\r\n return;\r\n }\r\n var cb = arg.onNotify || function (result) { console.log(\"No 'onNotify' callback function specified for 'startNotifying'\"); };\r\n\r\n // TODO we could (should?) make this characteristic-specific\r\n wrapper.peripheral.delegate._onNotifyCallback = cb;\r\n wrapper.peripheral.setNotifyValueForCharacteristic(true, wrapper.characteristic);\r\n resolve();\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 stopNotifying = function (arg) {\r\n return new Promise(function (resolve, reject) {\r\n try {\r\n var wrapper = this._getWrapper(arg, CBCharacteristicProperties.CBCharacteristicPropertyNotify, reject);\r\n console.log(\"--------- stopNotifying wrapper: \" + wrapper);\r\n\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 peripheral = this._findPeripheral(arg.peripheralUUID);\r\n // peripheral.delegate = null;\r\n peripheral.setNotifyValueForCharacteristic(false, wrapper.characteristic);\r\n resolve();\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 // val must be a Uint8Array or Uint16Array or a string like '0x01' or '0x007F' or '0x01,0x02', or '0x007F,'0x006F''\r\n _encodeValue = function (val) {\r\n // if it's not a string assume it's a UintXArray\r\n if (typeof val != 'string') {\r\n return val.buffer;\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;\r\n if (parts[0].length == 4) { // eg. 0x01\r\n result = new Uint8Array(parts.length);\r\n } else {\r\n // assuming eg. 0x007F\r\n result = new Uint16Array(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.buffer;\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, CBCharacteristicProperties.CBCharacteristicPropertyWrite, 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 valueEncoded = this._encodeValue(arg.value);\r\n if (valueEncoded === null) {\r\n reject(\"Invalid value: \" + arg.value);\r\n return;\r\n }\r\n\r\n // the promise will be resolved from 'didWriteValueForCharacteristic',\r\n // but we should make this characteristic-specific (see .read)\r\n wrapper.peripheral.delegate._onWritePromise = resolve;\r\n\r\n wrapper.peripheral.writeValueForCharacteristicType(\r\n valueEncoded,\r\n wrapper.characteristic,\r\n CBCharacteristicWriteType.CBCharacteristicWriteWithResponse);\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, CBCharacteristicProperties.CBCharacteristicPropertyWriteWithoutResponse, 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 valueEncoded = this._encodeValue(arg.value);\r\n console.log(\"Attempting to write (encoded): \" + valueEncoded);\r\n\r\n wrapper.peripheral.writeValueForCharacteristicType(\r\n valueEncoded,\r\n wrapper.characteristic,\r\n CBCharacteristicWriteType.CBCharacteristicWriteWithoutResponse);\r\n\r\n resolve();\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"],"sourceRoot":"/source/"}