Quantcast
Channel: Ionic Framework - Ionic Forum
Viewing all articles
Browse latest Browse all 48983

Problem with BLE read and notify HELP!

$
0
0

I have a BLE setup with Arduino and Ionic Cordova, and using the cordova-ble-central-plugin.

it will read good when I use read, but when I put notify command it will not show anymore.
please help me!
here is my sample code:

this.ble.startNotification(this.peripheral.id, BLE_SERVICE, BLE_CHARACTERISTIC)
.subscribe(
data => {
// this.ngZone.run(() => {
//console.log(data);
this.onTemperatureChange(data);
// });
}

);

this.ble.read(this.peripheral.id, BLE_SERVICE, BLE_CHARACTERISTIC)
// .then(
.then(
data => {
console.log(data);
this.onTemperatureChange(data);
},
() =>
this.showAlert(“Unexpected Error”,“Failed to subscribe for changes, please try to re-connect.”)
);

}

onTemperatureChange(buffer:ArrayBuffer) {

var data = new Uint8Array(buffer);
console.log(data[0]);

this.ngZone.run(() => {
this.temperature = data[0];
});

}

1 post - 1 participant

Read full topic


Viewing all articles
Browse latest Browse all 48983

Trending Articles