aboutsummaryrefslogtreecommitdiff
path: root/inform/tx_messages.go
diff options
context:
space:
mode:
authorMike Crute <mcrute@gmail.com>2016-09-24 19:35:35 -0700
committerMike Crute <mike@crute.us>2017-07-18 03:48:44 +0000
commit8fcbc57005d7a7195ee71d2ddc0b1ab70427ec3d (patch)
tree6cba2091448fe85d5650829f04f6239cdef80b6f /inform/tx_messages.go
parent409dcc5e2a0a603bf34a8066ca8f5451464e1e13 (diff)
downloadgo-inform-8fcbc57005d7a7195ee71d2ddc0b1ab70427ec3d.tar.bz2
go-inform-8fcbc57005d7a7195ee71d2ddc0b1ab70427ec3d.tar.xz
go-inform-8fcbc57005d7a7195ee71d2ddc0b1ab70427ec3d.zip
WIP
Diffstat (limited to 'inform/tx_messages.go')
-rw-r--r--inform/tx_messages.go20
1 files changed, 17 insertions, 3 deletions
diff --git a/inform/tx_messages.go b/inform/tx_messages.go
index 0021ef3..8962cad 100644
--- a/inform/tx_messages.go
+++ b/inform/tx_messages.go
@@ -25,8 +25,15 @@ type CommandMessage struct {
25 Voltage int `json:"volt,omitempty"` 25 Voltage int `json:"volt,omitempty"`
26} 26}
27 27
28func NewOutputCommand(port, val, timer int) *CommandMessage { 28// Freshen timestamps
29 return &CommandMessage{ 29func (m *CommandMessage) Freshen() {
30 m.DateTime = time.Now().Format(time.RFC3339)
31 m.ServerTime = unixMicroPSTString()
32 m.Time = unixMicroPST()
33}
34
35func NewOutputCommand(port int, val bool, timer int) *CommandMessage {
36 m := &CommandMessage{
30 Type: "cmd", 37 Type: "cmd",
31 Command: "mfi-output", 38 Command: "mfi-output",
32 DateTime: time.Now().Format(time.RFC3339), 39 DateTime: time.Now().Format(time.RFC3339),
@@ -34,8 +41,15 @@ func NewOutputCommand(port, val, timer int) *CommandMessage {
34 ServerTime: unixMicroPSTString(), 41 ServerTime: unixMicroPSTString(),
35 Time: unixMicroPST(), 42 Time: unixMicroPST(),
36 Timer: timer, 43 Timer: timer,
37 Value: val,
38 } 44 }
45
46 if val {
47 m.Value = 1
48 } else {
49 m.Value = 0
50 }
51
52 return m
39} 53}
40 54
41type NoopMessage struct { 55type NoopMessage struct {