mirror of
https://github.com/seriousm4x/UpSnap.git
synced 2026-03-31 06:24:09 -04:00
27 lines
521 B
Go
27 lines
521 B
Go
package networking
|
|
|
|
import (
|
|
"time"
|
|
|
|
"github.com/pocketbase/pocketbase/models"
|
|
"github.com/seriousm4x/upsnap/backend/logger"
|
|
)
|
|
|
|
func WakeDevice(device *models.Record) bool {
|
|
err := SendMagicPacket(device.GetString("mac"), device.GetString("netmask"))
|
|
if err != nil {
|
|
logger.Error.Println(err)
|
|
return false
|
|
}
|
|
|
|
// we wait 1 minute for the device to come up
|
|
// after that, we check the state
|
|
time.Sleep(1 * time.Minute)
|
|
isOnline := PingDevice(device)
|
|
if isOnline {
|
|
return true
|
|
} else {
|
|
return false
|
|
}
|
|
}
|