giorgiofellipe / cordova-plugin-datecs-printer

Cordova plugin to print on Mobile Bluetooth ESC/POS Printers - Tested on Datecs DPP-250 Printer
MIT License
73 stars 60 forks source link

Can't print text #137

Open cloudeweb opened 5 years ago

cloudeweb commented 5 years ago

Hello I'm trying to use your plugin. This you example code after run onDeviceReady.

window.DatecsPrinter.listBluetoothDevices(
  function (devices) {
    window.DatecsPrinter.connect(devices[0].address,
      function() {
        alert("connected!");
        printSomeTestText();
      },
      function() {
        alert(JSON.stringify(error));
      }
    );
  },
  function (error) {
    alert(JSON.stringify(error));
  }
);

function printSomeTestText() {
  window.DatecsPrinter.printText("Print Test!", 'ISO-8859-1',
    function() {
      alert("finished!");
    }
  );
}

I no understand this step: connect(address): this will establish the bluetooth connection with the selected printer (you need pass the address attribute of the selected device)

how can I connect my print address? (MTP-II)

thanks

luca-itro commented 5 years ago

window.DatecsPrinter.connect(devices[0].address) simply connect with the first found device. You need to manage all (paired) devices found listBluetoothDevices() and search for your printer.