Skip to content

Add isConnected to BLEPrinter (Android)#131

Open
hkerkhoff wants to merge 2 commits into
thiendangit:mainfrom
hkerkhoff:main
Open

Add isConnected to BLEPrinter (Android)#131
hkerkhoff wants to merge 2 commits into
thiendangit:mainfrom
hkerkhoff:main

Conversation

@hkerkhoff

@hkerkhoff hkerkhoff commented Oct 10, 2024

Copy link
Copy Markdown

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
Copy Markdown
Owner

how about ios @hkerkhoff ?

@hkerkhoff

Copy link
Copy Markdown
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