github.com/simpleiot/simpleiot@v0.18.3/cmd/serial-encode/main.go (about) 1 // serial encode test 2 package main 3 4 import ( 5 "fmt" 6 "log" 7 8 "github.com/simpleiot/simpleiot/client" 9 "github.com/simpleiot/simpleiot/data" 10 "github.com/simpleiot/simpleiot/test" 11 ) 12 13 func main() { 14 seq := byte(23) 15 16 subject := "" 17 18 points := data.Points{ 19 {Type: "temp", Value: 23}, 20 {Type: "description", Text: "temp sensor"}, 21 } 22 23 data, err := client.SerialEncode(seq, subject, points) 24 25 if err != nil { 26 log.Fatal("Encode error: ", err) 27 } 28 29 fmt.Println("Encoded data: ", test.HexDump(data)) 30 31 }