离子蓝牙扫描不会返回任何东西

时间:2017-06-18 15:05:38

标签: cordova bluetooth ionic2

我尝试通过蓝牙串行插件连接蓝牙,所以我写这些代码:

import { Component } from '@angular/core';
import { NavController } from 'ionic-angular';
import { BluetoothSerial } from '@ionic-native/bluetooth-serial';


 @Component({
  selector: 'page-home',
  templateUrl: 'home.html'
 })
  export class HomePage {
    device: Array<any>;
     isconnected: string;
   scanning:string;
     constructor(public navCtrl: NavController,public bls:BluetoothSerial) {
    this.device = [];
     this.scanning = "no scan";
    }
   scan(){ this.scanning = "scan";
   let that = this;
   this.bls.list().then(function(d){

    that.device = d;
    that.scanning ="success";
  },function(e){
    that.scanning = "error";
  });
 }
 checkConnect() {
let that = this;
this.bls.isEnabled().then(function(){
  that.isconnected = "Enable";
},function(){
  that.isconnected = "Disable"
})
 }

  }

如果我在真实设备或使用api level 17和android 4.2.2的genymotion模拟器中运行这些代码,我会收到以下错误: enter image description here

如果我在api 25和android 7的设备上运行此代码我可以看到我的应用程序,但它有权扫描蓝牙设备?任何人都知道问题是什么

这是我的离子信息:

` 离子信息

全球套餐:

@ionic/cli-utils : 1.4.0
Cordova CLI      : 7.0.1
Ionic CLI        : 3.4.0

本地包裹:

@ionic/app-scripts              : 1.3.7
@ionic/cli-plugin-cordova       : 1.4.0
@ionic/cli-plugin-ionic-angular : 1.3.1
Cordova Platforms               : android 6.2.3
Ionic Framework                 : ionic-angular 3.4.0

系统:

Node       : v6.11.0
OS         : Windows 10
Xcode      : not installed
ios-deploy : not installed
ios-sim    : not installed
npm        : 4.6.1 

`

0 个答案:

没有答案