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

write() function not working with thermal printer #461

Open
emilkitua opened this issue May 12, 2023 · 2 comments
Open

write() function not working with thermal printer #461

emilkitua opened this issue May 12, 2023 · 2 comments

Comments

@emilkitua
Copy link

emilkitua commented May 12, 2023

Hello,

I am using the plugin to connect and print using a thermal printer. but the write() function is not working giving error: Device connection was lost.

my code:

`

import { BluetoothSerial } from '@awesome-cordova-plugins/bluetooth-serial/ngx';

....

async printStuff() {
    // this.alertMessage2(this.selectedPrinter);
    this.bluetooth.connect(this.selectedPrinter)
    .subscribe(async() => {
      //2. Connected successfully
      // this.alertMessage2('392: ' + success)

      await this.bluetooth.write(this.espEncode())
         .then(success => {
            //3. Print successful
            //If you want to tell user print is successful,
            //handle it here
            //4. IMPORTANT! Disconnect bluetooth after printing
            // console.log('sucess')
            this.alertMessage2('401: ' + success)
            this.bluetooth.disconnect()
         }, err => {
            //If there is an error printing to bluetooth printer
            //handle it here
            console.error('43:' + err)
            this.alertMessage2('error 43: ' + err)

         })
    }, err => {

      //If there is an error connecting to bluetooth printer
      //handle it here
      this.alertMessage('error 416: ' + err, '')
      
      this.bluetooth.disconnect();

      console.error(err)
    })

    // await this.print.sendToBluetoothPrinter(this.selectedPrinter, this.espEncode());
  }`
@sadalsuud
Copy link

In my case no it does not shows any message, supposedly print, but It does not print

@bobolat
Copy link

bobolat commented Jan 19, 2024

i have the same problem..got Write successfully OK but printer no action

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

3 participants