don / BluetoothSerial

Cordova (PhoneGap) Plugin for Serial Communication over Bluetooth
Other
1.07k stars 666 forks source link

Error in Success callbackId: BluetoothSerial1953436156 : TypeError: callback.success.apply is not a function #424

Open sunilk44 opened 3 years ago

sunilk44 commented 3 years ago

bluetoothSerial.write(txt.toString() + '\n', success,failure); Error in Success callbackId: BluetoothSerial1953436156 : TypeError: callback.success.apply is not a function cordova.js:294 Uncaught (in promise) TypeError: callback.success.apply is not a function at Object.callbackFromNative (cordova.js:294) at processMessage (cordova.js:1120) at processMessages (cordova.js:1143) I am running this fucnction in loop and sometime it gives above error and i did't get the issue behind it. And after that error hangs up on the screen please suggest me something to resolve above Error

MaikStar commented 3 years ago

You can't use bluetoothSerial.write in a loop. Like for (var cnt=0;cnt<=10;cnt++) bluetoothSerial.write

Because it's a async call So you have to use success method

  1. Fill a list
  2. loop through this list with onSuccess methods

Hope this helps