cordova-brother-label-printer
cordova-brother-label-printer copied to clipboard
Android Bluetooth support, SDK updates (testers needed)
I wasn't quite happy with the state of the dev branch (lots of people have touched it, etc...) I shouldn't have accepted one of the merges for Bluetooth support because it's pulling classes from Brother's demo app, instead of relying on documentation from the SDK manual. I've taken the good bits from the dev branch, where Android is concerned, and have cleaned it up a bit.
- Brother SDK updated to latest (removed all PDF libraries as per the manual from Brother, as modern Android supports this natively, and I'm not looking to target older Android versions with this plugin)
- bluetooth support via findBluetoothPrinters()
- added generic findPrinters() to find network and bluetooth printers
- select a printer from the list of found printers via setPrinter()
- get printer status via printerStatus()
Unfortunately, I do not have a bluetooth label printer, so I cannot test this. @ykrasnokutskiy can you give this a shot and see if it works for you? It compiles fine, but there could be runtime errors.
If someone wants to send me the funds for a QL-820NWB, I'm happy to try to get it working (if it's not working already).
Hey @gordol,
I want to test the Bluetooth printer PT-P710BT on this branch with the SDK with version v3.0.13 (9/11/2018)
.
Listing the printers was super easy, printing an test image didn't work as expected. I've encountered the same exception as described here: https://github.com/gordol/cordova-brother-label-printer/issues/32 and been trying to fix this for hours.
You commented: "Looks to me like y'all don't have the Brother Android SDK installed properly, as that library is included with it. Otherwise, it doesn't match your architecture... Either way, it's not an issue with this Cordova extension."
Can you point me in a direction how to "add the libraries manually"?
@ykrasnokutskiy can you tell me how to "add the libraries manually"? Then you would be my hero.
@koktaildotcom
libs:
arm64-v8a armeabi armeabi-v7a BrotherPrintLibrary.aar BrotherPrintLibrary.jar x86 x86_64
libs/arm64-v8a:
libcreatedata.so
libs/armeabi:
libcreatedata.so
libs/armeabi-v7a:
libcreatedata.so
libs/x86:
libcreatedata.so
libs/x86_64:
libcreatedata.so
you should have a directory like that in your project. if you don't, you need to move these files from the SDK so they can be found by the linker.
Thank you very much, that helped! The printer that i used isn't compatible with the SDK however.
@koktaildotcom do you need a newer SDK for it to work? or is it just not compatible at all?
@koktaildotcom do you need a newer SDK for it to work? or is it just not compatible at all?
I've used the Brother PT-P710BT, and that printer not compatible with the SDK.
Hi @gordol ,
I tried using your branch to print on a QL-820NWB connected via Bluetooth (I'm still testing for wifi).
The first issue I ran into was the android system not being able to find libcreatedata.so
:
05-16 17:30:59.804 17913-18068/com.app E/AndroidRuntime: FATAL EXCEPTION: pool-2-thread-3
Process: com.app, PID: 17913
java.lang.UnsatisfiedLinkError: dalvik.system.PathClassLoader[DexPathList[[zip file "/data/app/com.app-1/base.apk"],nativeLibraryDirectories=[/data/app/com.app-1/lib/arm, /vendor/lib, /system/lib]]] couldn't find "libcreatedata.so"
at java.lang.Runtime.loadLibrary(Runtime.java:366)
at java.lang.System.loadLibrary(System.java:988)
at com.brother.ptouch.sdk.JNIWrapper.<clinit>(JNIWrapper.java:16)
at com.brother.ptouch.sdk.Printer.setPrinterInfo(Printer.java:1293)
at com.threescreens.cordova.plugin.brotherPrinter.BrotherPrinter$4.run(BrotherPrinter.java:433)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
at java.lang.Thread.run(Thread.java:818)
After some research, I came accross this stackoverflow which advises putting .so files in app/src/main/jniLibs. I did it in https://github.com/stevenremot/cordova-brother-label-printer/commit/088e14f72998fa3a0f7516bbcf796596ee4077c7. This solved the issue for me.
Then, when calling the printViaSdk
method, the SDK wasn't able to find the printer, even if it was detected with findPrinters
and set with setPrinters
. I had to ensure myPrinterInfo.macAddress
was set, as you already did with myPrinterInfo.ipAddress
on wifi in order for the SDK to find the printer.
Lastly, when the printer was found and the print order was sent, I got an error ERROR_WRONG_LABEL
. Apparently the labelNameId
must be set to a proper value for the QL-820-NWB.
I implemented a draft of API to set some label information before printing. This and the bluetooth fix were done in https://github.com/stevenremot/cordova-brother-label-printer/commit/6dd9d11eb4d8596322d99c3e7dd84431ac11ce9f
I succeeded in printing with the QL-820NWB in wifi infrastructure mode. I had to update the way the ip address was set though: https://github.com/stevenremot/cordova-brother-label-printer/commit/3585abc5fed56f8c68f027a71ba421a18c35bb58
@stevenremot thanks for the updates.
yeah, this SDK is a bit tedious, and there's not a simple solution for every printer, it takes a little tweaking between models apparently.
we might be able to build out some scaffolding with the various configurations for each model, but we need testers to do that. :)
thanks for your help.
@stevenremot pull requests are welcomed btw
@stevenremot pull requests are welcomed btw
I'm totally willing to open a PR with my changes. However, my branch is based on this PR, so I wasn't sure about what to do... Should I open a PR to replace yours ?
Hmm... can we merge into this one? Or are there conflicts... I haven't looked.
There ya go, I merged it all in.
https://github.com/gordol/cordova-brother-label-printer/pull/45
Yay thanks a lot!
What do you need for this PR to be merged ? More testers ?