【发布时间】:2017-07-20 15:52:38
【问题描述】:
我正在尝试构建一个简单的蓝牙串行应用程序来连接到我的 arduino。我正在使用 ionic2 制作 android app。现在,我要做的就是列出所有可用的蓝牙设备。以下是我的代码:
import { Component } from '@angular/core';
import { BluetoothSerial } from 'ionic-native';
import { NavController } from 'ionic-angular';
@Component({
selector: 'page-home',
templateUrl: 'home.html'
})
export class HomePage {
public working:string;
public var2: string ;
bluetoothSerial.isEnabled(
function() {
this.working= "Bluetooth is enabled";
},
function() {
this.working="Bluetooth is *not* enabled";
}
);
public lists = [];
bluetoothSerial.discoverUnpaired(function(devices) {
this.lists.push(devices);
}, function(){ this.var2 = 'could not find any bluetooth device';});
constructor() { }
}
每当我执行离子服务时,我都会犯很多错误,主要是因为无法识别蓝牙(缺少功能实现)。它也不允许我构建应用程序。
请帮忙。
非常感谢
【问题讨论】:
标签: ionic-framework bluetooth ionic2 android-bluetooth