CesarBalzer / Cordova-Plugin-BTPrinter

A cordova plugin for bluetooth printer for android platform
Apache License 2.0
81 stars 64 forks source link

How the BTPrinter.connected() method work? #67

Open wencywww opened 1 year ago

wencywww commented 1 year ago

I wonder how exactly the BTPrinter.connected() method determines if the printer is still connected?

Looking at the Java code, the method is:

// Check if printer is already connected
    boolean connected(CallbackContext callbackContext) {
        try {
            if (mmSocket == null) {
                callbackContext.success("false");
                return false;
            } else if (mmSocket.isConnected()) {
                callbackContext.success("true");
                return true;
            } else {
                callbackContext.success("false");
                return false;
            }
        } catch (Exception e) {
            String errMsg = e.getMessage();
            Log.e(LOG_TAG, errMsg);
            e.printStackTrace();
            callbackContext.error(errMsg);
        }
        return false;
    }

However, in my case this method always return True after initial successful connection - even after the printer is turned OFF? Any ideas about this?

Vacalexis commented 3 months ago

I have the same issue. Did you manage to fix ?

wencywww commented 3 months ago

I have the same issue. Did you manage to fix ?

Unfortunately - not :(