updated
This commit is contained in:
@@ -2,11 +2,15 @@ package models
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
"net"
|
||||
"net/http"
|
||||
"time"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
"github.com/tatsushid/go-fastping"
|
||||
json_data "github.com/tecamino/tecamino-json_data"
|
||||
"github.com/tecamino/tecamino-logger/logging"
|
||||
)
|
||||
|
||||
@@ -135,6 +139,11 @@ func (b *Bus) Stop() {
|
||||
}
|
||||
}
|
||||
|
||||
// status bus
|
||||
func (b *Bus) Status() bool {
|
||||
return b.Watchdog != nil
|
||||
}
|
||||
|
||||
// send dmx data
|
||||
func (b *Bus) SendData() error {
|
||||
if !b.Reachable {
|
||||
@@ -156,6 +165,24 @@ func (b *Bus) SendData() error {
|
||||
return err
|
||||
}
|
||||
|
||||
func (b *Bus) ParsePayload(c *gin.Context) error {
|
||||
|
||||
if err := c.BindJSON(b); err != nil {
|
||||
r := json_data.NewResponse()
|
||||
r.SendError("json: " + err.Error())
|
||||
c.JSON(http.StatusBadRequest, r)
|
||||
return err
|
||||
}
|
||||
|
||||
if b.Name == "" {
|
||||
r := json_data.NewResponse()
|
||||
r.SendError("bus name missing")
|
||||
c.JSON(http.StatusBadRequest, r)
|
||||
return errors.New("bus name missing")
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func isUDPReachable(ip string) (recieved bool, err error) {
|
||||
p := fastping.NewPinger()
|
||||
ra, err := net.ResolveIPAddr("ip4:icmp", ip)
|
||||
|
Reference in New Issue
Block a user