mirror of
https://github.com/nikdoof/hapz2m.git
synced 2026-01-30 12:48:21 +00:00
Don't start HAP server without any devices
This ensures that when iOS reconnects, it doesn't find an empty server and thinks all the devices have been removed, and removes them all locally.
This commit is contained in:
@@ -212,6 +212,11 @@ func (br *Bridge) WaitConfigured() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Return number of devices added to the bridge.
|
||||||
|
func (br *Bridge) NumDevices() int {
|
||||||
|
return len(br.devices)
|
||||||
|
}
|
||||||
|
|
||||||
// Connects to the MQTT server.
|
// Connects to the MQTT server.
|
||||||
// Blocks until the connection is established, then auto-reconnect logic takes over
|
// Blocks until the connection is established, then auto-reconnect logic takes over
|
||||||
func (br *Bridge) ConnectMQTT() error {
|
func (br *Bridge) ConnectMQTT() error {
|
||||||
|
|||||||
@@ -123,6 +123,10 @@ func main() {
|
|||||||
}()
|
}()
|
||||||
|
|
||||||
br.WaitConfigured()
|
br.WaitConfigured()
|
||||||
|
if br.NumDevices() == 0 {
|
||||||
|
log.Println("No devices added to bridge. Refusing to start.")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
log.Println("hapz2m configured. starting HAP server...")
|
log.Println("hapz2m configured. starting HAP server...")
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user