Closed nvdnvd00 closed 9 months ago
@nvdnvd00 Hello! Have you tried to run an example app? Could you please try to look at a logcat during "discovery"?
@tr3v3r Yes, my app working perfectly on my tablet. But it discover forever on kiosk device
I'll put logcat file (of kiosk device) here if you need it https://www.dropbox.com/sh/q6310jkd50wecim/AADwrS7nuhw6JoEYh6jMJX6xa?dl=0&preview=2022.11.17_logcat.txt
The packageName is app.<XXX>.kiosk
@nvdnvd00 Could you tell me a bit more info about your kiosk device? Android version And processor architecture? processor architecture
@nvdnvd00 Btw how did you achieve such a layout? I mean text on the left and right?
asking because working right now on the way to do it
@tr3v3r I repeat "space" between left side and right side. It still works for long line with wrap.
I'm waiting for kiosk information and will send it to you soon.
Everything I know is meridian kiosk
and it run on android 11
const printLeftRight = (
printing: Printing,
left: string,
right: string,
maxChar: number,
size: TScalingFactors = 1,
) => {
const totaLeft: number = left.length * size;
const totaRight: number = right.length * size;
const totalChar: number = totaLeft + totaRight;
let centerSpaceLength: number = 0;
let numberOfLines = 1;
while (numberOfLines * maxChar < totalChar) {
numberOfLines++;
}
centerSpaceLength = numberOfLines * maxChar - totalChar;
printing
.size(size)
.text(left)
.size(1)
.text(' '.repeat(centerSpaceLength))
.size(size)
.text(right)
.newline();
};
@nvdnvd00 and for maxChar you're using this method, right?
@tr3v3r Correct!
@tr3v3r Here's kiosk device specs (highlight part)
@nvdnvd00 sorry but I need also processor architecture.
@tr3v3r Does it help? My printer is EU-m30
ip-192-168-1-98:platform-tools kentk$ ./adb -s 192.168.100.2:46005 shell cat /proc/cpu/info
cat: /proc/cpu/info: No such file or directory
ip-192-168-1-98:platform-tools kentk$ ./adb -s 192.168.100.2:46005 shell getprop ro.product.cpu.abi
arm64-v8a
ip-192-168-1-98:platform-tools kentk$ ./adb -s 192.168.100.2:46005 shell getprop | grep abi
[ro.odm.product.cpu.abilist]: [arm64-v8a,armeabi-v7a,armeabi]
[ro.odm.product.cpu.abilist32]: [armeabi-v7a,armeabi]
[ro.odm.product.cpu.abilist64]: [arm64-v8a]
[ro.product.cpu.abi]: [arm64-v8a]
[ro.product.cpu.abilist]: [arm64-v8a,armeabi-v7a,armeabi]
[ro.product.cpu.abilist32]: [armeabi-v7a,armeabi]
[ro.product.cpu.abilist64]: [arm64-v8a]
[ro.vendor.product.cpu.abilist]: [arm64-v8a,armeabi-v7a,armeabi]
[ro.vendor.product.cpu.abilist32]: [armeabi-v7a,armeabi]
[ro.vendor.product.cpu.abilist64]: [arm64-v8a]
ip-192-168-1-98:platform-tools kentk$ ./adb -s 192.168.100.2:46005 shell getprop ro.product.cpu.abilist
arm64-v8a,armeabi-v7a,armeabi
ip-192-168-1-98:platform-tools kentk$ ./adb -s 192.168.100.2:46005 shell getprop | grep ro.product.cpu.abi
[ro.product.cpu.abi]: [arm64-v8a]
[ro.product.cpu.abilist]: [arm64-v8a,armeabi-v7a,armeabi]
[ro.product.cpu.abilist32]: [armeabi-v7a,armeabi]
[ro.product.cpu.abilist64]: [arm64-v8a]
ip-192-168-1-98:platform-tools kentk$
@nvdnvd00 Ok! Since your application works on tablets I suppose this is not a problem with the library for USB connections. What I can do: I'll add support for x86_64 arch for Android (which is missed right now) in an upcoming release ( I'll try to do it today ).
From your side: Please try to find what exactly happens when you try to discover on the Android side. Any errors/logs why you can not see the device. Also, double-check if all permissions are added according to the docs.
Also if its possible try to connect the printer with another connection type (Bluetooth, LAN )
Hello, I can also not discover serial printer with "discover" on kiosk. I get empty array back as a response. Do you have any tips for those?
@jankoJelic just released 2.3.0. Add support of x86_64 arch please try if it helps.
Nah, still an empty array Code:
useEffect(() => {
const test = async () => {
const printers = await EscPosPrinter.discover();
console.log(printers);
};
test();
}, []);
Logs: LOG requestAndroidPermissions true LOG enableLocationSetting true LOG []
I may have solved mine and maybe someone else's problem. I could find and print with this library in this case: https://github.com/melihyarikkaya/react-native-serialport/
It might help you with improving your project.
I will try using serialport's port opening and your API for printing (which is great btw, nice job!) and let you know how it works
Nah, still an empty array Code:
useEffect(() => { const test = async () => { const printers = await EscPosPrinter.discover(); console.log(printers); }; test(); }, []);
Logs: LOG requestAndroidPermissions true LOG enableLocationSetting true LOG []
Can I ask you to send me a logs from Android Studio logcat when you run discover method?
@tr3v3r after executing the following code , try { const printers = await EscPosPrinter.discover(); console.log("printers", printers); } catch (error) { console.log("Error:", error); }
getting the following console errors
requestAndroidPermissions false Error: No permissions granted
I am using Expo React Native in Dev Client. and added these "permissions": [ "android.permission.BLUETOOTH", "android.permission.BLUETOOTH_ADMIN", "android.permission.BLUETOOTH_CONNECT", "android.permission.BLUETOOTH_SCAN", "android.permission.INTERNET", "android.permission.WRITE_EXTERNAL_STORAGE", "android.permission.READ_EXTERNAL_STORAGE", "android.permission.ACCESS_COARSE_LOCATION" ],
in app.json file.
Even if I request BLUETOOTH_CONNECT and BLUETOOTH_SCAN permissions using PermissionsAndroid from react native it is giving this response {"android.permission.BLUETOOTH_CONNECT": "never_ask_again", "android.permission.BLUETOOTH_SCAN": "never_ask_again"}.
can you please check what is the issue ?
@tr3v3r I got the same issue where discover method does not resolve ever, on a special Android device, which has CPU:
Quad-core Coretex-A53 1.8Ghz
and ABI: armeabi-v7a
Apparently that CPU implements the Armv8-A architecture. How can we add support for it?
According to official docs of the Android SDK:
You can also try to take a look at this manual https://github.com/tr3v3r/react-native-esc-pos-printer/blob/main/docs/android_v2.27.0.pdf
Probably we missed something
@tr3v3r What should I look for in adb logcat? Shall I share it with you?
@tolypash you can try at least
Here it is, any help is much appreciated. I also tried your new version, with the class based approach but it seems like it it’s the same, it just gets stuck and doesn’t resolve the promise at all of discovering
@tolypash I can't see any info related to printer SDK in these logs.
Have you checked if the app has all the necessary permissions?
What type of connection you're using ? Bluetooth, WiFi, Lan Usb ?
btw with new discovery API there is no more promise. Instead you have event listener that will be listen for discovery updates during 5 sec (default). You can try to search it longer if needed by increasing timeout or desabling autoStop propery.
We’re trying to get Bluetooth working.
Yes, I realised that about the new discovery API, but then again it still awaits on it and it doesn’t fire the event listener (meanwhile it does on iOS)
For Android I have Bluetooth permission on, we pair the printer in settings and then turn on the app. Also access location we have. Anything else I might be missing?
Also, this issue is specific on a special Android device for payments which doesn’t have Google play on it. Could this be an issue with location services? 🤔
@tolypash it could be the reason yes Have you tried to log what this function returns for your case? https://github.com/tr3v3r/react-native-esc-pos-printer/blob/main/src/core/utils/permissions.ts
They both should give -> true
as I can see the second one (enableLocationAccessAndroid10) uses google services.
try manually to get rid of it in the node_modules/react-native-esc-pos-printer. ( just remove enableLocationAccessAndroid10 from the start discovery function on JS side )
Okay thank you I will try those and get back to you 🙏
@tr3v3r Thank you so much!! 🙏 That was the issue, the google services! I assume @nvdnvd00 had the same issue :)
@tolypash happy to hear that!
If you're using version 3.0.1 I can create a fix for you, to make this permission check optional
@tr3v3r Currently I have it patched for now, but if that will be possible will great, so I can also change it for devices that won't have Google services on them, by parameter 🙏
ok anyway... I added a code to the Android side to skip enabling location settings if Google services are unavailable.
Here it is: https://github.com/tr3v3r/react-native-esc-pos-printer/releases/tag/vv3.0.2
Hi, I'm intergrating the library for a kiosk device with printer connected via USB port My app working okay with my tablet but It couldn't find any printer on kiosk
Didn't return any error, it's just discover forever.
I tried again with other app: TM Assistant and it can detect my printer normally My printer is EU-m30
Do you know why? May I missed some configuration from android native ?
Kiosk found new USB device in android logcat: