Skip to content

Driver design API

Ayke edited this page Jan 28, 2019 · 7 revisions

Proposal for driver design

Drivers vary greatly in their complexity. Here is a WIP proposal for an API.

Simple sensors

type TemperatureSensor interface {
    // ReadTemperature returns the current temperature in milli-degrees
    // Celsius. For example, 25°C is returned as 25000.
    ReadTemperature() (int32, error)
}

type RelativeHumiditySensor interface {
    // ReadRelativeHumidity returns the current humidity (0%-100%) in
    // promilles.
    // Rationale: even very precise humidity sensors rarely go below 1%
    // accuracy so providing more accuracy isn't very useful.
    ReadRelativeHumidity() (int16, error)
}

More complex sensors

Clone this wiki locally