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

Add isConnected to BLEPrinter (Android) #131

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

hkerkhoff
Copy link

@hkerkhoff hkerkhoff commented Oct 10, 2024

this adds a isConnected-Function to the Android implementation for BLEPrinter.

It seems as if the connection-Status is not updated when the device looses the connection (so the bluetooth socket still claims its connected).

What I do:

await BLEPrinter.init();
await BLEPrinter.closeConn(); 
if (!(await BLEPrinter.isConnected())) {
      await BLEPrinter.connectPrinter(macAddress);
}

const connected = await BLEPrinter.isConnected();
if (connected) {
      // print stuff
} else {
      // show dialog / handle not connected
}

Feel free to merge, modify or use the my fork https://github.com/hkerkhoff/react-native-thermal-receipt-printer-image-qr with no warranty :)

@thiendangit
Copy link
Owner

how about ios @hkerkhoff ?

@hkerkhoff
Copy link
Author

how about ios @hkerkhoff ?

@thiendangit i'm not an objective-c guy - I added the implementation with help of chatgpt, looks ok for me, but would be great if you can check it :)

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

Successfully merging this pull request may close these issues.

2 participants