added the second attempt to send the card to the encoder after 6 seconds

This commit is contained in:
yurii 2026-04-20 11:17:27 +01:00
parent c6c2b40f37
commit 20fcbe5499
4 changed files with 24 additions and 9 deletions

View File

@ -296,11 +296,17 @@ func (c *Client) DispenserStart(ctx context.Context) (string, error) {
return stockStatus, fmt.Errorf("[%s] to encoder: %w", funcName, err) return stockStatus, fmt.Errorf("[%s] to encoder: %w", funcName, err)
} }
deadline := time.Now().Add(6 * time.Second) halfway := time.Now().Add(6 * time.Second)
deadline := time.Now().Add(12 * time.Second)
for { for {
time.Sleep(delay * 2) time.Sleep(delay * 2)
if time.Now().After(deadline) { switch {
case time.Now().After(halfway):
if err := c.ToEncoder(ctx); err != nil {
return stockStatus, fmt.Errorf("[%s] to encoder: %w", funcName, err)
}
case time.Now().After(deadline):
return stockStatus, nil return stockStatus, nil
} }
@ -345,11 +351,17 @@ func (c *Client) DispenserFinal(ctx context.Context) (string, error) {
logStatus(status) logStatus(status)
}() }()
deadline := time.Now().Add(6 * time.Second) halfway := time.Now().Add(6 * time.Second)
deadline := time.Now().Add(12 * time.Second)
for { for {
time.Sleep(delay * 2) time.Sleep(delay * 2)
if time.Now().After(deadline) { switch {
case time.Now().After(halfway):
if err := c.ToEncoder(ctx); err != nil {
return stockStatus, fmt.Errorf("[%s] to encoder: %w", funcName, err)
}
case time.Now().After(deadline):
return stockStatus, nil return stockStatus, nil
} }

View File

@ -1,15 +1,16 @@
// Package lockserver provides functionality for interacting with Assa Abloy lock servers.
package lockserver package lockserver
import ( import (
"fmt" "fmt"
"net" "net"
"time"
"strings" "strings"
"time"
log "github.com/sirupsen/logrus" log "github.com/sirupsen/logrus"
) )
// Build key encoding request command for the Assa Abloy lock server. // BuildCommand builds a key encoding request command for the Assa Abloy lock server.
func (lock *AssaLockServer) BuildCommand(doorReq DoorCardRequest, checkIn, checkOut time.Time) error { func (lock *AssaLockServer) BuildCommand(doorReq DoorCardRequest, checkIn, checkOut time.Time) error {
ci := checkIn.Format("200601021504") ci := checkIn.Format("200601021504")
co := checkOut.Format("200601021504") co := checkOut.Format("200601021504")
@ -71,4 +72,3 @@ func parseAssaResponse(raw string) (string, error) {
} }
return "Success: " + clean, nil return "Success: " + clean, nil
} }

View File

@ -29,7 +29,7 @@ import (
) )
const ( const (
buildVersion = "1.2.5" buildVersion = "1.2.6"
serviceName = "hardlink" serviceName = "hardlink"
pollingFrequency = 8 * time.Second pollingFrequency = 8 * time.Second
) )

View File

@ -2,6 +2,9 @@
builtVersion is a const in main.go builtVersion is a const in main.go
#### 1.2.6 - 20 April 2026
added the second attempt to send the card to the encoder after 6 seconds
#### 1.2.5 - 20 March 2026 #### 1.2.5 - 20 March 2026
removed early return on error when checking dispenser status in the start and final loops. removed early return on error when checking dispenser status in the start and final loops.