Add configuration system and ARP-based device discovery

Implement comprehensive configuration management with CLI flags for WiFi interface, device discovery method, and file paths. Add ARP table parsing as an alternative to DHCP leases for more reliable device detection. Improve WiFi scanning to handle concurrent scan requests gracefully.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
This commit is contained in:
nemunaire 2025-12-28 18:51:15 +07:00
commit 2b3a5b89f8
8 changed files with 156 additions and 28 deletions

View file

@ -7,6 +7,7 @@ import (
"time"
"github.com/nemunaire/repeater/internal/api"
"github.com/nemunaire/repeater/internal/config"
"github.com/nemunaire/repeater/internal/device"
"github.com/nemunaire/repeater/internal/logging"
"github.com/nemunaire/repeater/internal/models"
@ -19,6 +20,7 @@ type App struct {
StatusMutex sync.RWMutex
StartTime time.Time
Assets embed.FS
Config *config.Config
}
// New creates a new application instance
@ -38,9 +40,12 @@ func New(assets embed.FS) *App {
}
// Initialize initializes the application
func (a *App) Initialize() error {
func (a *App) Initialize(cfg *config.Config) error {
// Store config reference
a.Config = cfg
// Initialize WiFi D-Bus connection
if err := wifi.Initialize(); err != nil {
if err := wifi.Initialize(cfg.WifiInterface); err != nil {
return err
}
@ -54,7 +59,7 @@ func (a *App) Initialize() error {
// Run starts the HTTP server
func (a *App) Run(addr string) error {
router := api.SetupRouter(&a.Status, a.Assets)
router := api.SetupRouter(&a.Status, a.Config, a.Assets)
logging.AddLog("Système", "Serveur API démarré sur "+addr)
return router.Run(addr)
@ -88,7 +93,7 @@ func (a *App) periodicDeviceUpdate() {
defer ticker.Stop()
for range ticker.C {
devices, err := device.GetConnectedDevices()
devices, err := device.GetConnectedDevices(a.Config)
if err != nil {
log.Printf("Error getting connected devices: %v", err)
continue