Eddayy / flutter_star_prnt

Flutter plugin for star printer
GNU General Public License v3.0
15 stars 60 forks source link

getBluetoothService() called with no BluetoothManagerCallback #16

Open viktordineout opened 3 years ago

viktordineout commented 3 years ago

Hi there :)

I'm calling checkStatus on a mPOP Bluetooth printer (POP10-OF). The tablet is able to connect to it but when ever I check the status I get this message and after a few seconds it times out and crashes.

getBluetoothService() called with no BluetoothManagerCallback

The call looks like this:

await StarPrnt.checkStatus(portName: "BT:xxx", emulation: "StarPrnt");

Checking status on a LAN connected mC-Print3 works great though.

Any idea what could be causing this? Could it because the Android OS has already established a connection with this device and StarPrnt is trying to establish another one? This also happens when calling print on the Bluetooth printer.

P.s. I've also tested other emulation types such as StarPRNT, StarPRNTL & StarLine.

Thank you!

viktordineout commented 3 years ago

This is very strange. It does not happen when I put a breakpoint into checkStatus in the StarPrnt package 🤔 Then everything returns normally.

viktordineout commented 3 years ago

I think the culprit could be a loop which I use to call checkStatus periodically. According to these docs, calling checkStatus while already connected could produce unexpected results: https://github.com/auctifera-josed/starprnt#check-status

The checkStatus(port, emulation, success, error) returns the current status of the printer, as well as model number and firmware information. Checking status of a printer while connected to that printer can produce unexpected results.

Perhaps checkStatus could be implemented so that it gracefully returns results when already connected? @Eddayy

Eddayy commented 3 years ago

Its probably due to the native implementation where it tries to establish a connection each time to check the status. I'll look into implementing the connect and disconnect function from that repo. Should provide a persistent connection instance to better check status.

viktordineout commented 3 years ago

Maybe this could be of some help. I'm also looking into this but have no experience with Kotlin.