Unable to print on TD-2125NWB using Bluetooth
Hello,
I'm trying to print labels from an iPad using Bluetooth on the TD-2125NWB but consistently get a ERROR_COMMUNICATION_ERROR message. Everything works perfectly when using the same printer over WIFI.
I have also tested the Brother Print SDK demo app which works both with WIFI and Bluetooth.
Here is the code I use to connect to the printer and print a file :
List<BluetoothPrinter> printers = await Printer().getBluetoothPrinters([
Model.TD_2120N.getName(),
Model.TD_2125N.getName(),
Model.TD_2125NWB.getName(),
Model.TD_2130N.getName(),
]);
Printer printer = Printer();
PrinterInfo printInfo = PrinterInfo();
printInfo.printerModel = printers.first.model;
printInfo.printMode = PrintMode.FIT_TO_PAGE;
printInfo.isAutoCut = false;
printInfo.port = Port.BLUETOOTH;
printInfo.macAddress = printers.first.macAddress;
printInfo.binCustomPaper = _customPaperFromModel();
printInfo.printQuality = PrintQuality.HIGH_RESOLUTION;
printInfo.rjDensity = 8;
printer.setPrinterInfo(printInfo);
PrinterStatus status = await printer.printFile(testFile.path);
Output :
flutter: Received Result: {labelType: -1, maxOfBatteryResidualQuantityLevel: -1, labelId: -1, isACConnected: {id: -1, name: Unknown}, batteryResidualQuantityLevel: -1, isBatteryMounted: {id: -1, name: Unknown}, batteryLevel: -1, errorCode: {name: ERROR_COMMUNICATION_ERROR, id: -1}}
flutter: ERROR_COMMUNICATION_ERROR
Any idea how to fix this?
Hi @PrimaelQuemerais ,
Thanks for reaching out about this. Unfortunately I don't have any of those printers to be able to test, so could I bother you try a few things for me and let me know the result?
- When searching for the printer just include the TD-2125NWB and see if you still get the same error.
- Before printing over BT ensure that under settings in the device the printer appears as "Connected" in the Bluetooth list, if not tap it to connect.
Thanks in advance,
Hi @CodeMinion,
I'm now getting a new error :
I/BluetoothAdapter(14631): cancelDiscovery
I/BluetoothSocket(14631): connect() for device XX:XX:XX:XX:C0:B8 called by pid: 14631
I/gralloc4(14631): register: id=4340000012c, handle:0xb40000797d060700, vaddr=0x7979752000
D/BluetoothSocket(14631): close() this: XX:XX:XX:XX:C0:B8, channel: 1, mSocketIS: android.net.LocalSocketImpl$SocketInputStream@81764ed, mSocketOS: android.net.LocalSocketImpl$SocketOutputStream@f045f22, mSocket: android.net.LocalSocket@250db3 impl:android.net.LocalSocketImpl@5658f70 fd:java.io.FileDescriptor@e9262e9, mSocketState: CONNECTED
D/BluetoothSocket(14631): close() this: XX:XX:XX:XX:C0:B8, channel: 1, mSocketIS: android.net.LocalSocketImpl$SocketInputStream@81764ed, mSocketOS: android.net.LocalSocketImpl$SocketOutputStream@f045f22, mSocket: null, mSocketState: CLOSED
D/BluetoothSocket(14631): close() this: XX:XX:XX:XX:C0:B8, channel: 1, mSocketIS: android.net.LocalSocketImpl$SocketInputStream@81764ed, mSocketOS: android.net.LocalSocketImpl$SocketOutputStream@f045f22, mSocket: null, mSocketState: CLOSED
I/flutter (14631): Received Result: {isBatteryMounted: {name: Unknown, id: -1}, labelId: 65535, maxOfBatteryResidualQuantityLevel: -1, labelType: 65535, errorCode: {name: ERROR_NOT_SAME_MODEL, id: -1}, isACConnected: {name: Unknown, id: -1}, batteryLevel: -1, batteryResidualQuantityLevel: -1}
I/flutter (14631): ERROR_NOT_SAME_MODEL
In the Android settings I paired the printer but it is unable to connect, clicking the connect button doesn't do anything, no error message either. I reckon the first time I paired the device it told me "This device requires an app to function"
Let me know if I can run more tests to help
Okay I got it to work.
What confused me is the modelName returned by the Bluetooth search function is not the same as for Wifi, and since I used this to determine which model I'm dealing with it didn't work.
Wifi returns Brother TD-2125NWB whereas Bluetooth returns TD-2125NWB_5452
Glad you to it to work @PrimaelQuemerais. That's correct, for some printers the Bluetooth name includes the first octect of the Bluetooth MAC of the printer.
Apologies for the confusion, the connected step was meant for iOS devices.
Ah right I switched devices in the middle of my test, I will test again with the iPad by perhaps the issue also came from me passing the wrong model to the printer