import (
"regexp"
- "strconv"
+ //~ "strconv"
"time"
//~ "./brain"
pubsub "github.com/tuxychandru/pubsub"
zmq "github.com/vaughan0/go-zmq"
- "log"
"./r3events"
)
var (
- re_presence_ *regexp.Regexp = regexp.MustCompile("Presence: (yes|no)(?:, (opened|closed), (.+))?")
- re_state_ *regexp.Regexp = regexp.MustCompile("State: (closed|opened|manual movement|error|reset|timeout after open|timeout after close|opening|closing).*")
- re_status_ *regexp.Regexp = regexp.MustCompile("Status: (closed|opened), (closed|opened|manual movement|error|reset|timeout after open|timeout after close|opening|closing), (ajar|shut).*")
- re_infocard_ *regexp.Regexp = regexp.MustCompile("Info\\(card\\): card\\(([a-fA-F0-9]+)\\) (found|not found).*")
+ //~ re_presence_ *regexp.Regexp = regexp.MustCompile("Presence: (yes|no)(?:, (opened|closed), (.+))?")
+ //~ re_state_ *regexp.Regexp = regexp.MustCompile("State: (closed|opened|manual movement|error|reset|timeout after open|timeout after close|opening|closing).*")
+ //~ re_status_ *regexp.Regexp = regexp.MustCompile("Status: (closed|opened), (closed|opened|manual movement|error|reset|timeout after open|timeout after close|opening|closing), (ajar|shut).*")
+ //~ re_infocard_ *regexp.Regexp = regexp.MustCompile("Info\\(card\\): card\\(([a-fA-F0-9]+)\\) (found|not found).*")
re_cardid_ *regexp.Regexp = regexp.MustCompile("card\\(([a-fA-F0-9]+)\\)")
- re_infoajar_ *regexp.Regexp = regexp.MustCompile("Info\\(ajar\\): door is now (ajar|shut)")
- re_command_ *regexp.Regexp = regexp.MustCompile("(open|close|toggle|reset)(?: +(Card|Phone|SSH|ssh))?(?: +(.+))?")
- re_button_ *regexp.Regexp = regexp.MustCompile("PanicButton|button\\d?")
- re_temp_ *regexp.Regexp = regexp.MustCompile("temp0: (\\d+\\.\\d+)")
- re_photo_ *regexp.Regexp = regexp.MustCompile("photo0: (\\d+)")
+ //~ re_infoajar_ *regexp.Regexp = regexp.MustCompile("Info\\(ajar\\): door is now (ajar|shut)")
+ //~ re_command_ *regexp.Regexp = regexp.MustCompile("(open|close|toggle|reset)(?: +(Card|Phone|SSH|ssh))?(?: +(.+))?")
+ //~ re_button_ *regexp.Regexp = regexp.MustCompile("PanicButton|button\\d?")
+ //~ re_temp_ *regexp.Regexp = regexp.MustCompile("temp0: (\\d+\\.\\d+)")
+ //~ re_photo_ *regexp.Regexp = regexp.MustCompile("photo0: (\\d+)")
)
case "opening":
case "closing":
default:
- if Syslog_ != nil {Syslog_.Print("parseSocketInputLine_State: Unexpected State:", lines)}
+ Syslog_.Print("parseSocketInputLine_State: Unexpected State:", lines)
}
}
func ParseSocketInputLine(lines [][]byte, ps *pubsub.PubSub, keylookup_socket *zmq.Socket) { //, brn *brain.Brain) {
ts := time.Now().Unix()
if len(lines) < 1 { return }
- log.Printf("ParseSocketInputLine: %s %s",string(lines[0]), lines[1:])
+ Debug_.Printf("ParseSocketInputLine: %s %s",string(lines[0]), lines[1:])
switch string(lines[0]) {
case "State:":
if len(lines) < 2 { return }
ps.Pub(r3events.DoorAjarUpdate{string(lines[4]) == "shut", ts}, "door")
case "open", "close", "toggle", "reset":
ps.Pub(r3events.DoorCommandEvent{string(lines[0]), string(lines[1]), string(lines[2]), ts},"doorcmd")
- case "photo0":
- newphoto, err := strconv.ParseInt(string(lines[1]), 10, 32)
- if err == nil {
- // brn.Oboite("photo0", newphoto)
- ps.Pub(r3events.IlluminationSensorUpdate{0, newphoto, ts}, "sensors")
- }
+ //~ case "photo0:":
+ //~ newphoto, err := strconv.ParseInt(string(lines[1]), 10, 32)
+ //~ if err == nil {
+ //~ ps.Pub(r3events.IlluminationSensorUpdate{0, newphoto, ts}, "sensors")
+ //~ }
case "IlluminationSensorUpdate","TempSensorUpdate":
//try decode r3event
evnt, err := r3events.UnmarshalByteByte2Event(lines)