)
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).*")
)
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_cardid_ *regexp.Regexp = regexp.MustCompile("card\(([a-fA-F0-9]+)\)")
- re_infoajar_ *regexp.Regexp = regexp.MustCompile("Info\(ajar\): door is now (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_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+)")
switch string(lines[0]) {
case "closed":
ps.Pub(DoorLockUpdate{0, true, ts}, "door")
switch string(lines[0]) {
case "closed":
ps.Pub(DoorLockUpdate{0, true, ts}, "door")
-func ParseSocketInputLine(lines [][]byte, ps *pubsub.PubSub) { //, brn *brain.Brain) {
+func ParseSocketInputLine(lines [][]byte, ps *pubsub.PubSub, keylookup_socket *zmq.Socket) { //, brn *brain.Brain) {
- if len(lines) < 3 { continue }
- tidbit = DoorLockUpdate{0, lines[1] == []byte("closed"), ts}
+ if len(lines) < 3 { return }
+ tidbit = DoorLockUpdate{0, string(lines[1]) == "closed", ts}
match_cardid := re_cardid_.FindSubmatch(lines[1])
if len(match_cardid) > 1 {
// PreCondition: same thread/goroutinge as created keylookup_socket !!!!
match_cardid := re_cardid_.FindSubmatch(lines[1])
if len(match_cardid) > 1 {
// PreCondition: same thread/goroutinge as created keylookup_socket !!!!
}
// new event: toggle by user nick using card
ps.Pub(DoorCommandEvent{"toggle", "Card", nick, ts},"doorcmd")
}
case "Info(ajar):":
}
// new event: toggle by user nick using card
ps.Pub(DoorCommandEvent{"toggle", "Card", nick, ts},"doorcmd")
}
case "Info(ajar):":
- if len(lines) < 5 { continue }
- DoorAjarUpdate{0, match_status[4] == []byte("shut"), ts}
+ if len(lines) < 5 { return }
+ tidbit = DoorAjarUpdate{0, string(lines[4]) == "shut", ts}
//~ brn.Oboite("door", tidbit)
ps.Pub(tidbit, "door")
case "open", "close", "toggle", "reset":
ps.Pub(DoorCommandEvent{string(lines[0]), string(lines[1]), string(lines[2]), ts},"doorcmd")
//~ brn.Oboite("door", tidbit)
ps.Pub(tidbit, "door")
case "open", "close", "toggle", "reset":
ps.Pub(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(IlluminationSensorUpdate{0, newphoto, ts}, "sensors")
+ }
+func FormatEventForSocket(event_interface interface{}) (data [][]byte, err error) {
+ msg, err := json.Marshal(data)
+ if err != nil {
+ return
+ }
+ return [][]byte{msg}, nil
+}
//~ match_presence := re_presence_.FindStringSubmatch(line)
//~ match_status := re_status_.FindStringSubmatch(line)
//~ match_presence := re_presence_.FindStringSubmatch(line)
//~ match_status := re_status_.FindStringSubmatch(line)
//~ // brn.Oboite("movement", ts)
//~ ps.Pub(MovementSensorUpdate{0, ts}, "movements")
//~ }
//~ // brn.Oboite("movement", ts)
//~ ps.Pub(MovementSensorUpdate{0, ts}, "movements")
//~ }