Compare commits

...
2 Commits
3 changed files with 16 additions and 10 deletions
+9 -9
View File
@@ -31,8 +31,8 @@ func calculateLRC(data []byte) byte {
func (lock *SaltoLockServer) BuildCommand(req DoorCardRequest, checkIn, checkOut time.Time) error {
// helper: hh[mm]DDMMYY
fmtStamp := func(t time.Time) string {
return fmt.Sprintf("%02d%02d%02d%02d%02d",
t.Hour(), t.Minute(), t.Day(), int(t.Month()), t.Year()%100)
return fmt.Sprintf("%02d%02d%02d%02d",
t.Hour(), t.Day(), int(t.Month()), t.Year()%100)
}
start := fmtStamp(checkIn)
expiry := fmtStamp(checkOut)
@@ -140,7 +140,7 @@ func (lock *SaltoLockServer) waitForAck(conn net.Conn, reader *bufio.Reader, tim
// LockSequence performs the full ENQ/ACK handshake and command exchange
func (lock *SaltoLockServer) LockSequence() error {
const timeout = 10 * time.Second
const timeout = 20 * time.Second
var (
resp []byte
drained = 0 // count of stale frames consumed across waits
@@ -151,8 +151,8 @@ func (lock *SaltoLockServer) LockSequence() error {
return err
}
defer conn.Close()
reader := bufio.NewReader(conn)
reader := bufio.NewReader(conn)
// 1. Send ENQ
log.Infof("Sending ENQ")
@@ -178,7 +178,7 @@ func (lock *SaltoLockServer) LockSequence() error {
// 5. Now read the *next* STX frame which should be the response to our command.
for {
conn.SetReadDeadline(time.Now().Add(20 * time.Second))
conn.SetReadDeadline(time.Now().Add(40 * time.Second))
b, e := reader.ReadByte()
if e != nil {
return fmt.Errorf("error reading response start: %w", e)
@@ -210,11 +210,11 @@ func (lock *SaltoLockServer) LockSequence() error {
case b1 == 'C' && b2 == 'C':
log.Infof("LockSequence: command response is CC (follow-up)")
case b1 == 'T' && b2 == 'D':
log.Warnf("LockSequence: command response is TD (room does not exist)")
return fmt.Errorf("lock response indicates room does not exist")
log.Warnf("LockSequence: command response is TD (room does not exist): %q", string(resp))
return fmt.Errorf("lock response indicates room does not exist: %q", string(resp))
default:
log.Warnf("LockSequence: unexpected command response %q", string(resp))
return fmt.Errorf("error encoding keycard, unexpected response")
return fmt.Errorf("error encoding keycard, unexpected response: %q", string(resp))
}
} else {
log.Warnf("LockSequence: response too short: %q", string(resp))
+1 -1
View File
@@ -29,7 +29,7 @@ import (
)
const (
buildVersion = "1.0.19"
buildVersion = "1.0.21"
serviceName = "hardlink"
customLayout = "2006-01-02 15:04:05 -0700"
transactionUrl = "http://127.0.0.1:18181/start-transaction/"
+6
View File
@@ -2,6 +2,12 @@
builtVersion is a const in main.go
#### 1.0.21 - 20 October 2025
increased timeout for Salto lock server connection to 40 seconds
#### 1.0.20 - 06 October 2025
removed minutes from the start and expiry time in Salto lock command
#### 1.0.19 - 10 September 2025
allowed to continue if the connection to the lock server fails at startup