feat: add smart fan unit support (#29)

* feat: add smart fanunit (serial) protocol

Signed-off-by: Matthias Riegler <matthias.riegler@ankorstore.com>

* feat: add rudimentary eventbus to ease implementation

Signed-off-by: Matthias Riegler <matthias.riegler@ankorstore.com>

* feat: smart fanunit client

Signed-off-by: Matthias Riegler <matthias.riegler@ankorstore.com>

* feat: initial smart fan unit implementation

Signed-off-by: Matthias Riegler <matthias.riegler@ankorstore.com>

* feat: improve logging, double btn press

Signed-off-by: Matthias Riegler <matthias.riegler@ankorstore.com>

* fix: testcases

Signed-off-by: Matthias Riegler <matthias.riegler@ankorstore.com>

* fix: context closure handling, RPM reporting

Signed-off-by: Matthias Riegler <matthias.riegler@ankorstore.com>

* fix: address linting issues

Signed-off-by: Matthias Riegler <matthias.riegler@ankorstore.com>

* fix: edge line closure

Signed-off-by: Matthias Riegler <matthias.riegler@ankorstore.com>

* fix: reset CPU after i2c lockup

Signed-off-by: Matthias Riegler <matthias.riegler@ankorstore.com>

* feat: add uf2 to release

Signed-off-by: Matthias Riegler <matthias.riegler@ankorstore.com>

---------

Signed-off-by: Matthias Riegler <matthias.riegler@ankorstore.com>
This commit is contained in:
Matthias Riegler
2023-11-25 11:07:50 +01:00
committed by GitHub
parent c6bba1339b
commit 99920370fb
33 changed files with 1975 additions and 257 deletions

View File

@@ -10,13 +10,12 @@ listen:
# Hardware abstraction layer configuration
hal:
bcm2711:
# For the default fan unit, fanspeed measurement is causing a tiny bit of CPU laod.
# Sometimes it might not be desired
disable_fanspeed_measurement: false
# For the default fan unit, fanspeed measurement is causing a tiny bit of CPU laod.
# Sometimes it might not be desired
rpm_reporting_standard_fan_unit: true
# Idle LED color, values range from 0-255
idle_led_color:
idle_led_color:
red: 0
green: 16
blue: 0

View File

@@ -36,7 +36,7 @@ func main() {
// Setup configuration
viper.SetConfigType("yaml")
// auto-bind environment variables
viper.SetEnvPrefix("AGENT")
viper.SetEnvPrefix("BLADE")
viper.SetEnvKeyReplacer(strings.NewReplacer(".", "_"))
viper.AutomaticEnv()
// Load potential file configs
@@ -56,7 +56,9 @@ func main() {
}
zapLogger := baseLogger.With(zap.String("app", "computeblade-agent"))
defer zapLogger.Sync()
defer func() {
_ = zapLogger.Sync()
}()
_ = zap.ReplaceGlobals(zapLogger.With(zap.String("scope", "global")))
baseCtx := log.IntoContext(context.Background(), zapLogger)
@@ -70,12 +72,6 @@ func main() {
cancelCtx(err)
}
computebladeAgent, err := agent.NewComputeBladeAgent(cbAgentConfig)
if err != nil {
log.FromContext(ctx).Error("Failed to create agent", zap.Error(err))
cancelCtx(err)
}
// setup stop signal handlers
sigs := make(chan os.Signal, 1)
signal.Notify(sigs, syscall.SIGINT, syscall.SIGTERM)
@@ -91,10 +87,19 @@ func main() {
}
}()
log.FromContext(ctx).Info("Bootstrapping computeblade-agent", zap.String("version", viper.GetString("version")))
computebladeAgent, err := agent.NewComputeBladeAgent(ctx, cbAgentConfig)
if err != nil {
log.FromContext(ctx).Error("Failed to create agent", zap.Error(err))
cancelCtx(err)
os.Exit(1)
}
// Run agent
wg.Add(1)
go func() {
defer wg.Done()
log.FromContext(ctx).Info("Starting agent")
err := computebladeAgent.Run(ctx)
if err != nil && err != context.Canceled {
log.FromContext(ctx).Error("Failed to run agent", zap.Error(err))