Quality of life improvements

This commit is contained in:
Arti Zirk 2023-08-03 11:03:43 +03:00
parent 41725fdc4a
commit a9e008b7f2
2 changed files with 14 additions and 7 deletions

View File

@ -115,7 +115,14 @@ func setup() {
go func() {
for {
waitEvents()
err := waitEvents()
if err != nil {
log.Printf("LongPoll for events failed: %v", err)
log.Println("Will try to LongPoll again in 120 seconds")
time.Sleep(120 * time.Second)
go reloadTokens()
}
time.Sleep(1 * time.Second)
}
}()
@ -299,8 +306,6 @@ func waitEvents() error {
log.Println("There was an error opening and closing the Door")
}
}
go reloadTokens()
}
}
@ -319,7 +324,9 @@ func reloadTokens() error {
if err != nil {
return err
}
log.Printf("%v\n", resp)
if resp.StatusCode != 200 {
log.Printf("%v\n", resp)
}
var cl cardList
@ -338,7 +345,7 @@ func reloadTokens() error {
validUids = make(ValidUids)
var totalCardCount int = 0
for i, val := range cl.AllowedUids {
log.Printf("%d: %+v\n", i, val.Token.UidHash)
//log.Printf("%d: %+v\n", i, val.Token.UidHash)
validUids[val.Token.UidHash] = true
totalCardCount = i
}

View File

@ -90,14 +90,14 @@ func (w *WiegandHW) GetCardUid() (uint64, error) {
func (w *WiegandHW) wiegandAEvent(evt gpiod.LineEvent) {
w.bitTimeoutTimer.Reset(w.bitTimeout)
w.bits[w.bitNr] = true
fmt.Printf("1")
//fmt.Printf("1")
w.bitNr += 1
}
func (w *WiegandHW) wiegandBEvent(evt gpiod.LineEvent) {
w.bitTimeoutTimer.Reset(w.bitTimeout)
w.bits[w.bitNr] = false
fmt.Printf("0")
//fmt.Printf("0")
w.bitNr += 1
}