Report hotspot config

This commit is contained in:
nemunaire 2026-01-01 17:32:46 +07:00
commit c443fce24f
8 changed files with 244 additions and 160 deletions

View file

@ -82,11 +82,11 @@ func ConfigureHotspot(c *gin.Context) {
// ToggleHotspot handles hotspot enable/disable
func ToggleHotspot(c *gin.Context, status *models.SystemStatus) {
status.HotspotEnabled = !status.HotspotEnabled
enabled := status.HotspotEnabled
// Determine current state
isEnabled := status.HotspotStatus != nil && status.HotspotStatus.State == "ENABLED"
var err error
if enabled {
if !isEnabled {
err = hotspot.Start()
logging.AddLog("Hotspot", "Hotspot activé")
} else {
@ -100,7 +100,10 @@ func ToggleHotspot(c *gin.Context, status *models.SystemStatus) {
return
}
c.JSON(http.StatusOK, gin.H{"enabled": enabled})
// Update status immediately
status.HotspotStatus = hotspot.GetDetailedStatus()
c.JSON(http.StatusOK, gin.H{"enabled": !isEnabled})
}
// GetDevices returns connected devices