in src/sensors/barometer.ts [66:94]
async run() {
if (this.simulated) {
const intId = setInterval(
function (this: Barometer) {
this.emit(DATA_AVAILABLE_EVENT, this.id, getRandom());
}.bind(this),
this.interval,
);
this.currentRun = {
unsubscribe: () => {
clearInterval(intId);
},
};
} else {
this.currentRun = barometer.subscribe(
function (this: Barometer, {pressure}: {pressure: number}) {
if (pressure) {
this.emit(DATA_AVAILABLE_EVENT, this.id, pressure);
}
}.bind(this),
function (this: Barometer, error: any) {
if (error) {
this.enable(false);
this.emit(SENSOR_UNAVAILABLE_EVENT, this.id);
}
}.bind(this),
);
}
}