Cordova-Plugin-BTPrinter icon indicating copy to clipboard operation
Cordova-Plugin-BTPrinter copied to clipboard

How the BTPrinter.connected() method work?

Open wencywww opened this issue 2 years ago • 2 comments

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?

wencywww avatar Jan 21 '23 16:01 wencywww

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

Vacalexis avatar Aug 08 '24 11:08 Vacalexis

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

Unfortunately - not :(

wencywww avatar Aug 08 '24 11:08 wencywww