CodeMinion / another_brother

Another Brother Flutter SDK
BSD 3-Clause "New" or "Revised" License
21 stars 19 forks source link

Printing not working, even though permissions are set #49

Closed mikhael28 closed 1 year ago

mikhael28 commented 1 year ago

I'm getting basically this exact same issue in the another_brother prime, though I'm using 0.33 on pub.dev. As you can see, I'm inspect the picture to be printed (in the assets folder). I have given the permissions to access the files/storage APIs, however I end up getting a ' {name: ERROR_STORAGE_PERMISSION_NOT_GRANTED, id: 9999}' even though I've granted permission. You can also see at some point that I am in fact connected to the QL-1110NW, before it disconnects upon printing attempt (using the same logic as another-brother-prime's discovery of bluetooth.

Does anyone have any thoughts/quick suggestions as to what is blocking me here?

` E/A-Brother(13675): Printers: [Lcom.brother.ptouch.sdk.NetPrinter;@c2866d4 E/A-Brother(13675): Out Printers: []

_typedData: [137, 80, 78, 71, 13, 10, 26, 10, 0, 0, 0, 13, 73, 72, 68, 82, 0, 0, 5, 146, 0, 0, 5, 114, 8, 6, 0, 0, 0, 155, 80, 11, 233, 0, 0, 12, 105, 105, 67, 67, 80, 73, 67, 67, 32, 80, 114, 111, 102, 105, 108, 101, 0, 0, 72, 137, 149, 87, 7, 88, 83, 201, 22, 158, 91, 82, 73, 104, 129, 8, 72, 9, 189, 9, 34, 189, 72, 9, 161, 5, 16, 144, 42, 216, 8, 73, 32, 161, 196, 152, 16, 84, 236, 101, 81, 193, 181, 34, 162, 88, 209, 85, 17, 69, 215, 2, 200, 162, 34, 246, 178, 40, 246, 190, 88, 80, 81, 214, 197, 130, 162, 168, 188, 9, 9, 232, 186, 175, 124, 239, 124, 223, 220, 249, 239, 153, 51, 255, 41, 119, 230, 222, 59, 0, 104, 245, 240, 164, 210, 92, 84, 27, 128, 60, 73, 190, 44, 62, 60, 152, 53, 38, 53, 141, 69, 122, 10, 16, 64, 0, 100, 224, 5, 232, 60, 190, 92, 202, 142, 139, 139, 6, 80, 6, 250, 191, 203, 251, 27, 208, 26, 202, 85, 39, 37, 215, 63, 199, 255, 171, 232, 10, 132, 114, 62, 0, 200, 56, 136, 51, 4, 114, 126, 30, 196, 77, 0, 224, 235, 249, 82, 89, 62, 0, 68, 165, 222, 114, 74, 190, 84, 137, 231, 64, 172, 39, 131, 1, 6... buffer: _UnmodifiableByteBufferView elementSizeInBytes: 1 hashCode: 274679831 length: 170812 lengthInBytes: 170812 offsetInBytes: 0 runtimeType: Type (_UnmodifiableByteDataView) E/Brother (13675): Image Bytes: [B@2765235 - Size 120880 E/Brother (13675): PrintInfo: {binCustomPaper=null, isSpecialTape=false, rollPrinterCase={name=PJ_ROLLCASE_OFF, id=1}, customPaperLength=0, align={name=LEFT, id=1}, pjSpeed=2, isCutMark=false, printMode={name=FIT_TO_PAGE, id=2}, isCutAtEnd=true, savePrnPath=, isLabelEndCut=false, mirrorPrint=false, customFeed=0, overwrite=true, margin={top=0, left=0}, pjFeedMode={name=PJ_FEED_MODE_FIXEDPAGE, id=2}, isHalfCut=false, ipAddress=, rotate180=false, labelMargin=0, valign={name=TOP, id=1}, customPaper=, localName=, useLegacyHalftoneEngine=false, macAddress=60:E9:AA:EB:94:86, port={name=BLUETOOTH, id=2}, lastConnectedAddress=, printQuality={name=NORMAL, id=2}, pjCarbon=false, customPaperWidth=0, printerModel={name=QL_1110NWB, id=55}, labelNameIndex=20, skipStatusCheck=false, paperPosition={name=CENTER, id=2}, mode9=true, workPath=, timeout={connectionWaitMSec=500, receiveTimeoutSec=180, processTimeoutSec=-1, sendTimeoutSec=90, closeWaitMSec=500, closeWaitDisusingStatusCheckSec=3}, pjPaperKind={name=PJ_CUT_PAPER, id=2}, rawMode=false, useCopyCommandInTemplatePrint=false, peelMode=false, thresholdingValue=127, customPaperInfo=null, numberOfCopies=1, labelName={name=W103, model=QL1100, id=49}, orientation={name=PORTRAIT, id=1}, isAutoCut=true, dashLine=false, rjDensity=0, softFocusing=false, scaleValue=1.0, paperSize={name=A4, id=1}, halftone={name=PATTERNDITHER, id=2}, checkPrintEnd={name=CPE_CHECK, id=3}, enabledTethering=false, banishMargin=false, trimTapeAfterData=false, pjDensity=5} E/Brother (13675): Parsed Info: com.brother.ptouch.sdk.PrinterInfo@36b56ca W/BluetoothAdapter(13675): getBluetoothService() called with no BluetoothManagerCallback D/BluetoothSocket(13675): close() this: android.bluetooth.BluetoothSocket@aff2288, channel: 1, mSocketIS: android.net.LocalSocketImpl$SocketInputStream@8575421, mSocketOS: android.net.LocalSocketImpl$SocketOutputStream@b571046mSocket: android.net.LocalSocket@72b7207 impl:android.net.LocalSocketImpl@2a7df34 fd:java.io.FileDescriptor@db4115d, mSocketState: CONNECTED 2 D/BluetoothSocket(13675): close() this: android.bluetooth.BluetoothSocket@aff2288, channel: 1, mSocketIS: android.net.LocalSocketImpl$SocketInputStream@8575421, mSocketOS: android.net.LocalSocketImpl$SocketOutputStream@b571046mSocket: null, mSocketState: CLOSED I/flutter (13675): Print Result: {isBatteryMounted: {name: Unknown, id: -1}, labelId: 65535, maxOfBatteryResidualQuantityLevel: -1, labelType: 65535, errorCode: {name: ERROR_STORAGE_PERMISSION_NOT_GRANTED, id: 9999}, isACConnected: {name: Unknown, id: -1}, batteryLevel: -1, batteryResidualQuantityLevel: -1} D/BluetoothSocket(13675): close() this: android.bluetooth.BluetoothSocket@aff2288, channel: 1, mSocketIS: android.net.LocalSocketImpl$SocketInputStream@8575421, mSocketOS: android.net.LocalSocketImpl$SocketOutputStream@b571046mSocket: null, mSocketState: CLOSED `
mikhael28 commented 1 year ago

This is attempting to print through bluetooth - my device is connected, and is able to see the mac address but printing just doesn't work.

mikhael28 commented 1 year ago

So, I have printing working on Android now - it turns out the error was in fact, not related to permissions - but related to the label that I was setting. I was setting the label as W103, when I should have been setting W103H164. I really wish Brother provided some documentation as to what those labels even mean, I still don't know. I just started brute force checking and that one worked.

I was getting Error code 9999, as per line 281 in BrotherUtils.kt - it was, erroneously, override the ErrorCode from 'ERROR WRONG LABEL' to 'ERROR_STORAGE_PERMISSION_NOT_GRANTED'. Closing, as it is resolved - now to see if iOS can somehow work, it's not even picking up the bluetooth devices.

CodeMinion commented 1 year ago

Thanks for the report @mikhael28 .

In the case of the BrotherSDK if the permission is not granted on the device the library will notify ERROR WRONG LABEL. That intercept should only take place if we get ERROR WRONG LABEL and the permissions are not granted (https://github.com/CodeMinion/another_brother/blob/main/android/src/main/kotlin/com/rouninlabs/another_brother/method/BrotherUtils.kt#L278)

Could I trouble to share some details about what Android version you are running this on?

Thanks in advance,

mikhael28 commented 1 year ago

The permissions were definitely granted - the only difference was changing the label. compileSdkVersion 33, targetSdkVersion 32, kotlin 1.8.21, gradle android plugin 7.2.2 - FYI plugin 7.4 was breaking for me, so I downgraded to this version.

mikhael28 commented 1 year ago

Running this on Android 10 I believe, for the physical device.