ive set ever thing up but i don’t know why i am not receiving anything.
home.ts
import { Component } from '@angular/core';
import { BluetoothSerial } from 'ionic-native';
import { NavController } from 'ionic-angular';
import { AlertController } from 'ionic-angular';
import { BLE } from '@ionic-native/ble';
@Component({
selector: 'page-home',
templateUrl: 'home.html'
})
export class HomePage {
infomation: string;
constructor(private ble: BLE, public alertCtrl: AlertController, public navCtrl: NavController){}
ionViewDidLoad(){
this.ble.isEnabled().then(() => {
console.log('hurray it bluetooth is on');
}, (error) => {
console.log(error);
this.ble.enable().then(resp => {
console.log("bluetooth is enabled now");
}, (error) => {
console.log('bluetooth was not enabled');
});
});
}
search(){
this.ble.startScan([]).subscribe(data => {
this.infomation = JSON.stringify(data.name) + ' '+ JSON.stringify(data.id);
}, (error) => {
let alert = this.alertCtrl.create({
title: 'devices not found',
message: error,
buttons: ['ok']
});
alert.present();
})
}
home.html
<ion-header>
<ion-navbar>
<ion-title>
Bluetooth Light control
</ion-title>
</ion-navbar>
</ion-header>
<ion-content padding>
<button ion-button (click) = "search()">list of paired devices</button>
<button ion-button (click) = "discover()">list of unpaired devices</button>
<p>
here is a list of id's...
</p>
<ion-list>
<ion-item>
{{infomation}}
</ion-item>
</ion-list>
iv imported correctly. ive read the documents. ive ran it on ionic view on my phone. but i still cant understand why i am not receiving anything