BluetoothSerial icon indicating copy to clipboard operation
BluetoothSerial copied to clipboard

bluetoothSerial.clearDeviceDiscoveredListener() does not work

Open lovemonkey opened this issue 6 years ago • 0 comments

var tempArr=[], index=0; bluetoothSerial.setDeviceDiscoveredListener(function(device) { console.log(index++); if(tempArr.length===0){ me.comp("undispairedDevs").newData({defaultValues:dataformat([device])}); tempArr.push(device); console.log("第一个:"+JSON.stringify(tempArr)); }else{ for(var i=0,len=tempArr.length;i<len;i++){ if(device.address==tempArr[i].address){ return; } } me.comp("undispairedDevs").newData({defaultValues:dataformat([device])}); tempArr.push(device); console.log(JSON.stringify(tempArr)); } }); bluetoothSerial.discoverUnpaired(function(devices){ console.log(JSON.stringify(devices)); bluetoothSerial.clearDeviceDiscoveredListener(); }, errCallBack); and I have a 'cancel' button which is used to stop discoverUnpaired or clearDeviceDiscoveredListener : Model.prototype.cancelbtnClick = function(event){ bluetoothSerial.clearDeviceDiscoveredListener(); this.close(); }; but it doesn't work. click the button, the console doesn't stop console.log the 'index' and 'device' , untill discoverUnpaired over. why?

lovemonkey avatar Mar 15 '19 01:03 lovemonkey