0

以下のプラグインを使用して Bluetooth プリンターに接続できません

$ ionic cordova plugin add de.appplant.cordova.plugin.printer
$ npm install --save @ionic-native/printer

ionic 3を使用してBluetoothプリンターを接続する方法はありますか?

4

2 に答える 2

1

次の 3 つの手順に従ってください: 1-Bluetooth デバイスを検索、2-デバイスを ID に接続、3-印刷

devices = [];
btnFindDevices() {
   this.bluetoothSerial.isEnabled().then(() => {
   this.bluetoothSerial.discoverUnpaired().then((allDevices) => {
   this.devices = allDevices;
   console.log(allDevices);
});
});
}

btnBlueToothConnect() {
   if (this.devices.length > 0) {
   //this code connects device which’s position is 0. Change it whatever you 
   //want.
   this.bluetoothSerial.connect(this.devices[0].id).subscribe((data) => {
   console.log(“Connected”, data);
   }, (error) => {
   console.log(“not Connected”, error);
   });
    }
    else {
    console.log(“Device List did not genereted yet.”);
    }
    }

    btnBlueToothPrint() {
    //Attention… Bluetooth printer prints data when whole line filled. For 
    //example in my case printer is 32 colon,
    //“hello world” has 11 characters. so it prints after 3 times clicked 
    //the print button.
        this.bluetoothSerial.write(‘hello world’).then(() => { console.log(“s”); }, () => { console.log(“f”); });
    }
于 2018-03-30T13:46:55.713 に答える