Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
20fcbe5499 | ||
|
|
c6c2b40f37 | ||
|
|
8f093159cd | ||
|
|
e1549dda2f |
@@ -279,7 +279,9 @@ func (c *Client) DispenserStart(ctx context.Context) (string, error) {
|
|||||||
return stockStatus, fmt.Errorf("[%s] check status: %w", funcName, err)
|
return stockStatus, fmt.Errorf("[%s] check status: %w", funcName, err)
|
||||||
}
|
}
|
||||||
|
|
||||||
logStatus(status)
|
defer func() {
|
||||||
|
logStatus(status)
|
||||||
|
}()
|
||||||
stockStatus = stockTake(status)
|
stockStatus = stockTake(status)
|
||||||
c.setStock(status)
|
c.setStock(status)
|
||||||
|
|
||||||
@@ -294,48 +296,87 @@ 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)
|
||||||
}
|
}
|
||||||
|
|
||||||
time.Sleep(delay)
|
halfway := time.Now().Add(6 * time.Second)
|
||||||
status, err = c.CheckStatus(ctx)
|
deadline := time.Now().Add(12 * time.Second)
|
||||||
if err != nil {
|
|
||||||
return stockStatus, fmt.Errorf("[%s] re-check status: %w", funcName, err)
|
|
||||||
}
|
|
||||||
logStatus(status)
|
|
||||||
stockStatus = stockTake(status)
|
|
||||||
c.setStock(status)
|
|
||||||
|
|
||||||
return stockStatus, nil
|
for {
|
||||||
|
time.Sleep(delay * 2)
|
||||||
|
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
|
||||||
|
}
|
||||||
|
|
||||||
|
status, _ = c.do(ctx, cmdStatus)
|
||||||
|
|
||||||
|
stockStatus = stockTake(status)
|
||||||
|
c.setStock(status)
|
||||||
|
logStatus(status)
|
||||||
|
|
||||||
|
// error states first
|
||||||
|
if isCardWellEmpty(status) {
|
||||||
|
return stockStatus, fmt.Errorf(stockStatus)
|
||||||
|
}
|
||||||
|
|
||||||
|
if isAtEncoderPosition(status) {
|
||||||
|
return stockStatus, nil
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *Client) DispenserFinal(ctx context.Context) (string, error) {
|
func (c *Client) DispenserFinal(ctx context.Context) (string, error) {
|
||||||
const funcName = "DispenserFinal"
|
const funcName = "DispenserFinal"
|
||||||
stockStatus := ""
|
stockStatus := ""
|
||||||
|
var status []byte
|
||||||
|
|
||||||
if err := c.OutOfMouth(ctx); err != nil {
|
if err := c.OutOfMouth(ctx); err != nil {
|
||||||
return stockStatus, fmt.Errorf("[%s] out of mouth: %w", funcName, err)
|
return stockStatus, fmt.Errorf("[%s] out of mouth: %w", funcName, err)
|
||||||
}
|
}
|
||||||
|
|
||||||
time.Sleep(delay)
|
time.Sleep(delay)
|
||||||
status, err := c.CheckStatus(ctx)
|
status, err := c.do(ctx, cmdStatus)
|
||||||
if err != nil {
|
if err == nil && len(status) >= 4 {
|
||||||
return stockStatus, fmt.Errorf("[%s] check status: %w", funcName, err)
|
c.setStock(status)
|
||||||
}
|
}
|
||||||
logStatus(status)
|
|
||||||
stockStatus = stockTake(status)
|
|
||||||
c.setStock(status)
|
|
||||||
|
|
||||||
time.Sleep(delay)
|
time.Sleep(delay)
|
||||||
if err := c.ToEncoder(ctx); err != nil {
|
if err := c.ToEncoder(ctx); err != nil {
|
||||||
return stockStatus, fmt.Errorf("[%s] to encoder: %w", funcName, err)
|
return stockStatus, fmt.Errorf("[%s] to encoder: %w", funcName, err)
|
||||||
}
|
}
|
||||||
|
|
||||||
time.Sleep(delay)
|
defer func() {
|
||||||
status, err = c.CheckStatus(ctx)
|
logStatus(status)
|
||||||
if err != nil {
|
}()
|
||||||
return stockStatus, fmt.Errorf("[%s] re-check status: %w", funcName, err)
|
|
||||||
}
|
|
||||||
logStatus(status)
|
|
||||||
stockStatus = stockTake(status)
|
|
||||||
c.setStock(status)
|
|
||||||
|
|
||||||
return stockStatus, nil
|
halfway := time.Now().Add(6 * time.Second)
|
||||||
|
deadline := time.Now().Add(12 * time.Second)
|
||||||
|
|
||||||
|
for {
|
||||||
|
time.Sleep(delay * 2)
|
||||||
|
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
|
||||||
|
}
|
||||||
|
|
||||||
|
status, _ = c.do(ctx, cmdStatus)
|
||||||
|
|
||||||
|
stockStatus = stockTake(status)
|
||||||
|
c.setStock(status)
|
||||||
|
logStatus(status)
|
||||||
|
|
||||||
|
if isCardWellEmpty(status) {
|
||||||
|
return stockStatus, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
if isAtEncoderPosition(status) {
|
||||||
|
return stockStatus, nil
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -191,6 +191,7 @@ func (app *App) takePayment(w http.ResponseWriter, r *http.Request) {
|
|||||||
writeTransactionResult(w, http.StatusServiceUnavailable, theResponse)
|
writeTransactionResult(w, http.StatusServiceUnavailable, theResponse)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if r.Method == http.MethodOptions {
|
if r.Method == http.MethodOptions {
|
||||||
|
|||||||
@@ -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
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -29,7 +29,7 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
buildVersion = "1.2.2"
|
buildVersion = "1.2.6"
|
||||||
serviceName = "hardlink"
|
serviceName = "hardlink"
|
||||||
pollingFrequency = 8 * time.Second
|
pollingFrequency = 8 * time.Second
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -2,6 +2,18 @@
|
|||||||
|
|
||||||
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
|
||||||
|
removed early return on error when checking dispenser status in the start and final loops.
|
||||||
|
|
||||||
|
#### 1.2.4 - 18 March 2026
|
||||||
|
added check if keycard at the encoder position before trying to encode key
|
||||||
|
|
||||||
|
#### 1.2.3 - 17 March 2026
|
||||||
|
added check if keycard at the encoder position before trying to encode key
|
||||||
|
|
||||||
#### 1.2.2 - 11 February 2026
|
#### 1.2.2 - 11 February 2026
|
||||||
increased waiting time befor sending email on PDQ unavailability to 30 seconds day time and 10 minutes night time
|
increased waiting time befor sending email on PDQ unavailability to 30 seconds day time and 10 minutes night time
|
||||||
to give it a chance to become available again
|
to give it a chance to become available again
|
||||||
|
|||||||
Reference in New Issue
Block a user