fix(pkg/sensor): reduce interface functions for better error handling
This commit is contained in:
@ -5,6 +5,7 @@ import (
|
||||
"fmt"
|
||||
"log"
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
"github.com/d2r2/go-bsbmp"
|
||||
"github.com/d2r2/go-i2c"
|
||||
@ -19,9 +20,8 @@ type BME280 struct {
|
||||
*types.Sensor
|
||||
}
|
||||
|
||||
// GetSensorModel returns the sensor model
|
||||
func (s *BME280) GetSensorModel() types.SensorModel {
|
||||
return s.Sensor.SensorModel
|
||||
func (s *BME280) ID() string {
|
||||
return s.SensorID
|
||||
}
|
||||
|
||||
// Read measured values
|
||||
@ -124,3 +124,12 @@ func (s *BME280) ReadContinously(ctx context.Context, measuredValueChannel chan<
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Ticker returns a new ticker, which tick every when the sensor should be read
|
||||
func (s *BME280) Ticker() *time.Ticker {
|
||||
duration, err := time.ParseDuration(s.TickDuration)
|
||||
if err != nil {
|
||||
duration = time.Minute
|
||||
}
|
||||
return time.NewTicker(duration)
|
||||
}
|
||||
|
Reference in New Issue
Block a user