)
type SpaceState struct {
- present bool
- buttonpress_until int64
+ present bool
+ buttonpress_until int64
door_locked bool
door_shut bool
}
var (
presence_socket_path_ string
- xmpp_presence_events_chan_ chan interface{}
+ xmpp_presence_events_chan_ chan interface{}
xmpp_login_ struct {jid string; pass string}
xmpp_bot_authstring_ string
xmpp_state_save_dir_ string
//-------
func init() {
- flag.StringVar(&xmpp_login_.jid, "xjid", "realrauminfo@realraum.at/Tuer", "XMPP Bot Login JID")
- flag.StringVar(&xmpp_login_.pass, "xpass", "", "XMPP Bot Login Password")
- flag.StringVar(&xmpp_bot_authstring_, "xbotauth", "", "String that user use to authenticate themselves to the bot")
- flag.StringVar(&presence_socket_path_,"presencesocket", "/var/run/tuer/presence.socket", "Path to presence socket")
- flag.StringVar(&xmpp_state_save_dir_,"xstatedir","/flash/var/lib/r3netstatus/", "Directory to save XMPP bot state in")
+ flag.StringVar(&xmpp_login_.jid, "xjid", "realrauminfo@realraum.at/Tuer", "XMPP Bot Login JID")
+ flag.StringVar(&xmpp_login_.pass, "xpass", "", "XMPP Bot Login Password")
+ flag.StringVar(&xmpp_bot_authstring_, "xbotauth", "", "String that user use to authenticate themselves to the bot")
+ flag.StringVar(&presence_socket_path_,"presencesocket", "/var/run/tuer/presence.socket", "Path to presence socket")
+ flag.StringVar(&xmpp_state_save_dir_,"xstatedir","/flash/var/lib/r3netstatus/", "Directory to save XMPP bot state in")
flag.Parse()
}
xmpp_presence_events_chan_ <- r3xmppbot.XMPPPresenceEvent{Present: present, Who: who, DoorLock: locked, DoorShut: shut, Button: false}
case DoorCommandEvent:
who = event.Who
- xmpp_presence_events_chan_ <- fmt.Sprintln("DoorCommandEvent",event)
+ xmpp_presence_events_chan_ <- fmt.Sprintln("DoorCommand: ",event.Command, "using", event.Using, "by", event.Who, event.Ts)
case DoorStatusUpdate:
locked = event.Locked
shut = event.Shut
- xmpp_presence_events_chan_ <- fmt.Sprintln("DoorStatusUpdate",event)
+ xmpp_presence_events_chan_ <- fmt.Sprintln("DoorStatus locked:",event.Locked, "shut:", event.Shut, event.Ts)
case ButtonPressUpdate:
xmpp_presence_events_chan_ <- r3xmppbot.XMPPPresenceEvent{Present: present, Who: who, DoorLock: locked, DoorShut: shut, Button: true}
}
#!/bin/zsh
+export GO386=387
go-linux-386 clean
#go-linux-386 build
#strip ${PWD:t}
go-linux-386 build -ldflags "-s"
-rsync -v ${PWD:t} wuzzler.realraum.at:/flash/tuer/
\ No newline at end of file
+rsync -v ${PWD:t} wuzzler.realraum.at:/flash/tuer/
var (
re_presence_ *regexp.Regexp = regexp.MustCompile("Presence: (yes|no)(?:, (opened|closed), (.+))?")
re_status_ *regexp.Regexp = regexp.MustCompile("Status: (closed|opened), (opening|waiting|closing|idle), (ajar|shut).*")
- re_command_ *regexp.Regexp = regexp.MustCompile("(open|close|toggle) (Card |Phone )?([^ ]+) *")
+ re_command_ *regexp.Regexp = regexp.MustCompile("(open|close|toggle) (?:(Card|Phone) )?(.+)")
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+)")
Ts int64
}
+type MovementSensorUpdate struct {
+ Sensorindex int
+ Ts int64
+}
func ParseSocketInputLine(line string, ps *pubsub.PubSub) { //, brn *brain.Brain) {
- match_presence := re_presence_.FindStringSubmatch(line)
- match_status := re_status_.FindStringSubmatch(line)
- match_command := re_command_.FindStringSubmatch(line)
- match_button := re_button_.FindStringSubmatch(line)
- match_temp := re_temp_.FindStringSubmatch(line)
- match_photo := re_photo_.FindStringSubmatch(line)
+ match_presence := re_presence_.FindStringSubmatch(line)
+ match_status := re_status_.FindStringSubmatch(line)
+ match_command := re_command_.FindStringSubmatch(line)
+ match_button := re_button_.FindStringSubmatch(line)
+ match_temp := re_temp_.FindStringSubmatch(line)
+ match_photo := re_photo_.FindStringSubmatch(line)
+ //~ log.Println("ParseSocketInputLine",line)
var tidbit interface{}
ts := time.Now().Unix()
- if match_presence != nil {
+ if match_presence != nil {
tidbit = PresenceUpdate{match_presence[1] == "yes", ts}
//~ brn.Oboite("presence", tidbit)
ps.Pub(tidbit, "presence")
//~ brn.Oboite("door", tidbit)
ps.Pub(tidbit, "door")
} else if match_command != nil {
- tidbit = DoorCommandEvent{match_status[1], match_status[2], match_status[3], ts}
+ tidbit = DoorCommandEvent{match_command[1], match_command[2], match_command[3], ts}
//~ brn.Oboite("doorcmd", tidbit)
ps.Pub(tidbit, "door")
} else if match_button != nil {
//~ brn.Oboite("photo0", newphoto)
ps.Pub(IlluminationSensorUpdate{0, newphoto, ts}, "sensors")
}
+ } else if line == "movement" {
+ //~ brn.Oboite("movement", ts)
+ ps.Pub(MovementSensorUpdate{0, ts}, "movements")
}
}