Closed pdlm95 closed 4 years ago
I feel so dumb, found the problem. It is not a problem of the library itself, It's the printer buffer.
I had to separate the code into multiple writeCharacteristicWithResponseForService with limited characters and now it works like a charm.
@pdlm95 hello brother..i have also a bluetooth printer i need to print Image how its works.i can print text or letters successfully.please help me and waiting your response
@FazilMuhammed I can't really tell how, never printed an image. You should check your printer requirements for images, maybe all you have to do its print a base64
@pdlm95 i converted the images into base64 while printing something wrong letters coming..
@pdlm95 if i may ask, how did you get your printers UUID? I'm trying to connect to a bluetooth label printer but I only have its BT Mac. Thanks.
@devnullpointer you should first try looking for information in the manufacturer's manual. If there's nothing, you could try installing an app that tells you the characteristics of the device. You could check nRF connect
@pdlm95 can u provide the example for print text? how u convert printer command to base64?
@mayniii This is how I made it. I provide the text that I want to print in an array, where each line I wish to print its an array item.
import { Buffer } from 'buffer';
const SERVICE_UUID = '000018f0-0000-1000-8000-00805f9b34fb'; //primary service (printers)
const CHAR_UUID = '00002af1-0000-1000-8000-00805f9b34fb'; //characteristic (write)
async print(text: array){
await this.scanAndConnect().then(async (res: any) => {
for (let item of text) {
let encryptedCredentials = new Buffer(item).toString("base64");
promises.push(res.Device.writeCharacteristicWithResponseForService(
SERVICE_UUID, CHAR_UUID, encryptedCredentials));
}
await Promise.all(promises).then(() => {
this.manager.destroy()
})
}).catch(err => {return});
}
@pdlm95 can you guide me about receipt printing?
Prerequisites
Expected Behavior
Print each time the button is pressed
Current Behavior
The first time app sends print command, it prints. The second time (without any change), doesn't do anything. The next time, it prints duplicates (from the second and third time).
Steps to Reproduce
Context
As you can see, after scanning and connecting to the device, the print command is sent. After printing, I cancel the connection and then destroy the manager object in order to restart the object and be able to print again.
But this doesn't happen until the third time, when it prints duplicates. It does not show errors.
Maybe I got something wrong and I can't see it. Some help will be appreciated.