Documentation
¶
Index ¶
- Constants
- func DeviceName(id uint16) string
- type BrickData
- type BrickdCollector
- func (b *BrickdCollector) CloseEthernetState(_ uint64)
- func (b *BrickdCollector) Collect(ch chan<- prometheus.Metric)
- func (b *BrickdCollector) Describe(ch chan<- *prometheus.Desc)
- func (b *BrickdCollector) OnConnect(reason ipconnection.DisconnectReason)
- func (b *BrickdCollector) OnDisconnect(reason ipconnection.DisconnectReason)
- func (b *BrickdCollector) OnEnumerate(uid string, connectedUid string, position rune, hardwareVersion [3]uint8, ...)
- func (b *BrickdCollector) PollEthernetState(m master_brick.MasterBrick, uid string)
- func (b *BrickdCollector) RegisterAirQualityBricklet(uid string) ([]Register, error)
- func (b *BrickdCollector) RegisterBarometerBricklet(uid string) ([]Register, error)
- func (b *BrickdCollector) RegisterBarometerV2Bricklet(uid string) ([]Register, error)
- func (b *BrickdCollector) RegisterHumidityBricklet(uid string) ([]Register, error)
- func (b *BrickdCollector) RegisterHumidityV2Bricklet(uid string) ([]Register, error)
- func (b *BrickdCollector) RegisterMasterBrick(uid string) ([]Register, error)
- func (b *BrickdCollector) RegisterOutdoorWeatherBricklet(uid string) ([]Register, error)
- func (b *BrickdCollector) RegisterZeroHatBrick(uid string) ([]Register, error)
- func (b *BrickdCollector) Update()
- type Device
- type Register
- type RegisterFunc
- type Value
Constants ¶
const (
EthernetCallbackID uint64 = math.MaxUint64
)
Variables ¶
This section is empty.
Functions ¶
func DeviceName ¶
Types ¶
type BrickdCollector ¶
type BrickdCollector struct { sync.RWMutex Address string Password string Data *BrickData Registry map[string][]Register Connection ipconnection.IPConnection Values chan Value Devices map[uint16]RegisterFunc CallbackPeriod uint32 IgnoredUIDs []string Labels map[string]string SensorLabels map[string]map[string]map[string]string EthernetState chan interface{} }
BrickdCollector does all the work
func NewCollector ¶
func NewCollector(addr, password string, cbPeriod time.Duration, ignoredUIDs []string, labels map[string]string, sensorLabels map[string]map[string]map[string]string) *BrickdCollector
NewCollector creates a new collector for the given address (and authenticates with the password)
func (*BrickdCollector) CloseEthernetState ¶
func (b *BrickdCollector) CloseEthernetState(_ uint64)
func (*BrickdCollector) Collect ¶
func (b *BrickdCollector) Collect(ch chan<- prometheus.Metric)
Collect is part of the prometheus.Collector interface
func (*BrickdCollector) Describe ¶
func (b *BrickdCollector) Describe(ch chan<- *prometheus.Desc)
Describe is part of the prometheus.Collector interface
func (*BrickdCollector) OnConnect ¶
func (b *BrickdCollector) OnConnect(reason ipconnection.DisconnectReason)
OnConnect is called when the brickd collector (re-)connects to the brickd
func (*BrickdCollector) OnDisconnect ¶
func (b *BrickdCollector) OnDisconnect(reason ipconnection.DisconnectReason)
OnDisconnect is called when the brickd collector disconnects from the brickd
func (*BrickdCollector) OnEnumerate ¶
func (b *BrickdCollector) OnEnumerate( uid string, connectedUid string, position rune, hardwareVersion [3]uint8, firmwareVersion [3]uint8, deviceIdentifier uint16, enumerationType ipconnection.EnumerationType)
OnEnumerate receives the callbacks from the Enumerate() call
func (*BrickdCollector) PollEthernetState ¶
func (b *BrickdCollector) PollEthernetState(m master_brick.MasterBrick, uid string)
func (*BrickdCollector) RegisterAirQualityBricklet ¶
func (b *BrickdCollector) RegisterAirQualityBricklet(uid string) ([]Register, error)
func (*BrickdCollector) RegisterBarometerBricklet ¶
func (b *BrickdCollector) RegisterBarometerBricklet(uid string) ([]Register, error)
func (*BrickdCollector) RegisterBarometerV2Bricklet ¶
func (b *BrickdCollector) RegisterBarometerV2Bricklet(uid string) ([]Register, error)
func (*BrickdCollector) RegisterHumidityBricklet ¶
func (b *BrickdCollector) RegisterHumidityBricklet(uid string) ([]Register, error)
func (*BrickdCollector) RegisterHumidityV2Bricklet ¶
func (b *BrickdCollector) RegisterHumidityV2Bricklet(uid string) ([]Register, error)
func (*BrickdCollector) RegisterMasterBrick ¶
func (b *BrickdCollector) RegisterMasterBrick(uid string) ([]Register, error)
func (*BrickdCollector) RegisterOutdoorWeatherBricklet ¶
func (b *BrickdCollector) RegisterOutdoorWeatherBricklet(uid string) ([]Register, error)
func (*BrickdCollector) RegisterZeroHatBrick ¶
func (b *BrickdCollector) RegisterZeroHatBrick(uid string) ([]Register, error)
func (*BrickdCollector) Update ¶
func (b *BrickdCollector) Update()
Update runs in the background and discovers devices and collects the Values
type Device ¶
type Device struct { UID string ConnectedUID string Position rune HardwareVersion string FirmwareVersion string DeviceID uint16 Available bool }
Device is a discovered device
type Register ¶
Register is a callback register, the Deregister func will be called as reg.Deregister(reg.ID)
type RegisterFunc ¶
RegisterFunc is the funcion of BrickdCollector to register callbacks
type Value ¶
type Value struct { Index int // index in BrickData.Values, needs to be assigned by the callback DeviceID uint16 // https://www.tinkerforge.com/en/doc/Software/Device_Identifier.html UID string // UID as given from brickd SensorID int // sensor id in outdoor_weather_bricklet Type prometheus.ValueType // probably just prometheus.GaugeValue Help string // help for users, i.e. prometheus' "# HELP brickd_humidity_value ..." line, (just the help text) Name string // value name, such as "usb_voltage" or "humidity" Value float64 // the measurement value }
Value is returned from the callbacks