Skip to content

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