ble.write()回叫“ OK”,但是蓝牙打印机不工作(离子式的科尔多瓦android)

时间:2019-12-06 08:21:44

标签: android cordova ionic-framework bluetooth ionic-native

我使用ionic cordova和打字稿来开发我的应用程序,并按照官方文档“ ionic cordova plugin add cordova-plugin-ble-central”“ npm install @ ionic-native / ble”的要求导入了相应的插件,可以发现并连接蓝牙打印机,并使用ble.write()打印数据,此函数成功回调“确定”,但是打印机不起作用,以下是我的代码:

const data = new Uint8Array([0x80, 0xbe, 0xf5, 0xac, 0xff]);
    const characteristics = this.deviceinfo.characteristics;
    for (let i = 0; i < characteristics.length; i++) {
      const item = characteristics[i];
      if (item.properties.includes('Write')) {
        this.ble.write(this.deviceinfo.id, item.service, item.characteristic, data.buffer).then(res => {
          console.log('write()success:  ' + JSON.stringify(res));  //write()success:  "OK"
        }, err => {
          console.log('write()fail:  ' + JSON.stringify(err));
        });
        break;
      }

任何建议将不胜感激!

0 个答案:

没有答案