CodeMinion / another_brother

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

Consistently seeing 'W/BluetoothAdapter(29032): getBluetoothService() called with no BluetoothManagerCallback' #84

Closed lukesalter closed 3 months ago

lukesalter commented 3 months ago

For some reason Android on a real device (version 2.1.4) is persistently giving me the following error: W/BluetoothAdapter(29032): getBluetoothService() called with no BluetoothManagerCallback when trying to connect to the printer resulting in an ERROR_CONNECT_SOCKET_FAILED error.

I've tried multiple Android devices and I've tried stripping out all kinds of things from the repository to try and get it to work. All permissions are showing as granted and the label and printer model match perfectly.

The output from the debugger (including my own log) is as follows:

W/BluetoothAdapter(29032): getBluetoothService() called with no BluetoothManagerCallback [log] ✅ Setting up printer: [QL-820NWB | W62 | CC:78:AB:99:0D:EC] E/Brother Print SDK(29032): IOException is caught in connect method. E/Brother Print SDK(29032): read failed, socket might closed or timeout, read ret: -1 W/BluetoothAdapter(29032): getBluetoothService() called with no BluetoothManagerCallback E/Brother Print SDK(29032): IOException is caught in connect method. E/Brother Print SDK(29032): read failed, socket might closed or timeout, read ret: -1

It tries twice and fails. It's perfect on iOS and completes without issue. It's also great when connecting to the same printer via wifi with the same label setting.

The PrintInfo class has the following values:

printerModel: {id: 53, name: QL_820NWB} port: {id: 2, name: BLUETOOTH} ipAddress: macAddress: CC:78:AB:99:0D:EC localName: lastConnectedAddress: paperSize: {id: 1, name: A4} orientation: {id: 1, name: PORTRAIT} numberOfCopies: 1 halftone: {id: 2, name: PATTERNDITHER} printMode: {id: 2, name: FIT_TO_PAGE} align: {id: 1, name: LEFT} valign: {id: 1, name: TOP} margin: {top: 0, left: 0} pjCarbon: false pjDensity: 5 pjFeedMode: {id: 2, name: PJ_FEED_MODE_FIXEDPAGE} customPaperWidth: 0 customPaperLength: 0 customFeed: 0 rjDensity: 8 rotate180: true peelMode: false mirrorPrint: false paperPosition: {id: 2, name: CENTER} isAutoCut: true isCutAtEnd: true mode9: true skipStatusCheck: false checkPrintEnd: {id: 3, name: CPE_CHECK} rollPrinterCase: {id: 1, name: PJ_ROLLCASE_OFF} pjSpeed: 2 thresholdingValue: 127 timeout: {processTimeoutSec: -1, sendTimeoutSec: 90, receiveTimeoutSec: 180, closeWaitMSec: 500, connectionWaitMSec: 500, closeWaitDisusingStatusCheckSec: 3} dashLine: false savePrnPath: overwrite: true isHalfCut: false isSpecialTape: false labelNameIndex: 15 customPaper: binCustomPaper: null customPaperInfo: null isLabelEndCut: false printQuality: {id: 2, name: NORMAL} labelMargin: 0 scaleValue: 1.0 isCutMark: false softFocusing: false trimTapeAfterData: false enabledTethering: false rawMode: false workPath: pjPaperKind: {id: 2, name: PJ_CUT_PAPER} useLegacyHalftoneEngine: false banishMargin: false useCopyCommandInTemplatePrint: false labelName: {id: 16, name: W62, model: QL700}

Any wisdom or thoughts on things I could try would be great. All my googling around the logged issue state that it happens when multiple bluetooth connections are happening at the same time but that could be a red herring?!

lukesalter commented 3 months ago

Nevermind! Cracked it with help from this issue: https://github.com/CodeMinion/another_brother/issues/76

Turns out if multiple devices are connected to the printer then only one of them will work on it. Looks like the 'getBluetoothService() called with no BluetoothManagerCallback' error isn't a problem and shows anyway (perhaps that needs looking into?).

I'll add something into my app which states about making sure multiple devices aren't connected via Bluetooth to the printer if ERROR_CONNECT_SOCKET_FAILED is seen.

Closing off!