Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot print on Embedded printer #6

Closed
weyotech opened this issue Oct 5, 2021 · 2 comments
Closed

Cannot print on Embedded printer #6

weyotech opened this issue Oct 5, 2021 · 2 comments

Comments

@weyotech
Copy link

weyotech commented Oct 5, 2021

I am testing this library on JP-Q2i POS Terminal PDA (Embedded printer is configured as Bluetooth device)
but I cannot print a text.

Printama.with(this).connect(new Printama.OnConnected() {
                    @Override
                    public void onConnected(Printama printama) {
                        printama.printText("TEST");
                    }
                });

Library connect with MPT-II but not start a print

@weyotech
Copy link
Author

weyotech commented Oct 5, 2021

@anggastudio

I have found the bug in PrinterUtil.java
The problem is when receive uuids = null so to solve this problemi you should change code with this

        @Override
        protected BluetoothSocket doInBackground(BluetoothDevice... bluetoothDevices) {
            BluetoothDevice device = bluetoothDevices[0];
            UUID uuid;
            if (device != null) {
//                uuid = device.getUuids()[0].getUuid();
                ParcelUuid[] uuids = device.getUuids();
                uuid = (uuids != null && uuids.length > 0) ? uuids[0].getUuid() : UUID.randomUUID();
            } else {
                return null;
            }
            BluetoothSocket socket = null;
            boolean connected = true;
            try {
                socket = device.createRfcommSocketToServiceRecord(uuid);
                socket.connect();
            } catch (IOException e) {
                e.printStackTrace();
            } catch (Exception e2) {
                connected = false;
            }
            return connected ? socket : null;
        }

anggastudio added a commit that referenced this issue Oct 29, 2021
@anggastudio
Copy link
Owner

Thank you for reporting this,
and I apologize for the late response.
Actually, you can do a Pull Request, so that you can be a contributor.

Fixed and released an update on 0.9.7

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants