RemoteRig: Core infrastructure — MQTT subscriber, Pi deployment, ESP32 firmware, hardware design #5

Merged
overseer merged 33 commits from dev into main 2026-05-21 20:04:36 -04:00
5 changed files with 107 additions and 0 deletions
Showing only changes of commit ad55e94c9c - Show all commits
+76
View File
@@ -0,0 +1,76 @@
// Package main is the entry point for the RemoteRig central hub.
package main
import (
"fmt"
"log"
"os"
"time"
"gopkg.in/yaml.v3"
)
// Config holds the application configuration.
type Config struct {
DBPath string `yaml:"db_path"`
APIKey string `yaml:"api_key"`
Port string `yaml:"port"`
ReadTimeout time.Duration `yaml:"read_timeout"`
WriteTimeout time.Duration `yaml:"write_timeout"`
IdleTimeout time.Duration `yaml:"idle_timeout"`
MQTT struct {
Broker string `yaml:"broker"`
ClientID string `yaml:"client_id"`
} `yaml:"mqtt"`
Platform struct {
Type string `yaml:"type"`
MaxCameras int `yaml:"max_cameras"`
} `yaml:"platform"`
}
func main() {
log.Println("RemoteRig hub starting...")
// Load config
cfg, err := loadConfig("config.yaml")
if err != nil {
log.Fatalf("Failed to load config: %v", err)
}
// Print config values
log.Printf("Database: %s", cfg.DBPath)
log.Printf("API key set: %t", cfg.APIKey != "")
log.Printf("Server port: %s", cfg.Port)
log.Printf("MQTT broker: %s", cfg.MQTT.Broker)
log.Printf("Platform: %s (max %d cameras)", cfg.Platform.Type, cfg.Platform.MaxCameras)
log.Println("RemoteRig hub ready")
}
func loadConfig(path string) (*Config, error) {
data, err := os.ReadFile(path)
if err != nil {
return nil, fmt.Errorf("read config file: %w", err)
}
var cfg Config
if err := yaml.Unmarshal(data, &cfg); err != nil {
return nil, fmt.Errorf("parse config: %w", err)
}
// Defaults
if cfg.Port == "" {
cfg.Port = "8080"
}
if cfg.DBPath == "" {
cfg.DBPath = "remoterig.db"
}
if cfg.MQTT.Broker == "" {
cfg.MQTT.Broker = "localhost:1883"
}
if cfg.MQTT.ClientID == "" {
cfg.MQTT.ClientID = "remoterig-hub"
}
return &cfg, nil
}
+24
View File
@@ -0,0 +1,24 @@
# RemoteRig Central Hub Configuration
# Target platform: Raspberry Pi Zero 2 W
# Database
db_path: "remoterig.db"
# API Key for endpoint authentication
api_key: "changeme"
# Server settings
port: 8080
read_timeout: 5s
write_timeout: 10s
idle_timeout: 120s
# MQTT Broker
mqtt:
broker: "localhost:1883"
client_id: "remoterig-hub"
# Platform
platform:
type: "pi-zero-2w"
max_cameras: 16
+3
View File
@@ -0,0 +1,3 @@
module github.com/cubecraft/remoterig
go 1.24
+2
View File
@@ -0,0 +1,2 @@
// Package api handles HTTP request routing and handlers.
package api
+2
View File
@@ -0,0 +1,2 @@
// Package db provides SQLite database initialization and schema management.
package db