Compare commits
No commits in common. "development" and "1.2.1" have entirely different histories.
developmen
...
1.2.1
@ -279,9 +279,7 @@ 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)
|
||||||
}
|
}
|
||||||
|
|
||||||
defer func() {
|
logStatus(status)
|
||||||
logStatus(status)
|
|
||||||
}()
|
|
||||||
stockStatus = stockTake(status)
|
stockStatus = stockTake(status)
|
||||||
c.setStock(status)
|
c.setStock(status)
|
||||||
|
|
||||||
@ -296,75 +294,48 @@ 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)
|
time.Sleep(delay)
|
||||||
|
status, err = c.CheckStatus(ctx)
|
||||||
for {
|
if err != nil {
|
||||||
time.Sleep(delay * 2)
|
return stockStatus, fmt.Errorf("[%s] re-check status: %w", funcName, err)
|
||||||
if 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
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
logStatus(status)
|
||||||
|
stockStatus = stockTake(status)
|
||||||
|
c.setStock(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.do(ctx, cmdStatus)
|
status, err := c.CheckStatus(ctx)
|
||||||
if err == nil && len(status) >= 4 {
|
if err != nil {
|
||||||
c.setStock(status)
|
return stockStatus, fmt.Errorf("[%s] check status: %w", funcName, err)
|
||||||
}
|
}
|
||||||
|
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)
|
||||||
}
|
}
|
||||||
|
|
||||||
defer func() {
|
time.Sleep(delay)
|
||||||
logStatus(status)
|
status, err = c.CheckStatus(ctx)
|
||||||
}()
|
if err != nil {
|
||||||
|
return stockStatus, fmt.Errorf("[%s] re-check status: %w", funcName, err)
|
||||||
deadline := time.Now().Add(6 * time.Second)
|
|
||||||
|
|
||||||
for {
|
|
||||||
time.Sleep(delay * 2)
|
|
||||||
if 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
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
logStatus(status)
|
||||||
|
stockStatus = stockTake(status)
|
||||||
|
c.setStock(status)
|
||||||
|
|
||||||
|
return stockStatus, nil
|
||||||
}
|
}
|
||||||
|
|||||||
@ -191,7 +191,6 @@ 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 {
|
||||||
|
|||||||
@ -192,13 +192,8 @@ func (app *App) onChipDNAError(w http.ResponseWriter, r *http.Request) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (app *App) handleAvailabilityDebounced(isAvailable bool) {
|
func (app *App) handleAvailabilityDebounced(isAvailable bool) {
|
||||||
const (
|
title := "ChipDNA Error"
|
||||||
debounceDay = 30
|
key := fmt.Sprintf("%s-%d", app.cfg.Hotel, app.cfg.Kiosk)
|
||||||
debounceNight = 600
|
|
||||||
title = "ChipDNA Error"
|
|
||||||
)
|
|
||||||
|
|
||||||
key := app.availabilityKey()
|
|
||||||
|
|
||||||
app.availabilityMu.Lock()
|
app.availabilityMu.Lock()
|
||||||
defer app.availabilityMu.Unlock()
|
defer app.availabilityMu.Unlock()
|
||||||
@ -218,21 +213,14 @@ func (app *App) handleAvailabilityDebounced(isAvailable bool) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
debounce := debounceDay
|
log.Println("PDQ reported unavailable - starting 10s debounce timer")
|
||||||
|
|
||||||
hour := time.Now().Hour()
|
timer := time.AfterFunc(60*time.Second, func() {
|
||||||
if hour < 6 {
|
|
||||||
debounce = debounceNight
|
|
||||||
}
|
|
||||||
|
|
||||||
log.Printf("PDQ reported unavailable - starting %ds debounce timer", debounce)
|
|
||||||
|
|
||||||
timer := time.AfterFunc(time.Duration(debounce)*time.Second, func() {
|
|
||||||
mail.SendEmailOnError(
|
mail.SendEmailOnError(
|
||||||
app.cfg.Hotel,
|
app.cfg.Hotel,
|
||||||
app.cfg.Kiosk,
|
app.cfg.Kiosk,
|
||||||
title,
|
title,
|
||||||
fmt.Sprintf("ChipDNA PDQ unavailable for more than %d seconds", debounce),
|
"ChipDNA PDQ unavailable for more than 60 seconds",
|
||||||
)
|
)
|
||||||
|
|
||||||
app.availabilityMu.Lock()
|
app.availabilityMu.Lock()
|
||||||
@ -242,11 +230,3 @@ func (app *App) handleAvailabilityDebounced(isAvailable bool) {
|
|||||||
|
|
||||||
app.availabilityTimers[key] = timer
|
app.availabilityTimers[key] = timer
|
||||||
}
|
}
|
||||||
|
|
||||||
func (app *App) availabilityKey() string {
|
|
||||||
return fmt.Sprintf("hotel=%s|kiosk=%d|app=%p",
|
|
||||||
strings.TrimSpace(app.cfg.Hotel),
|
|
||||||
app.cfg.Kiosk,
|
|
||||||
app,
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|||||||
4
main.go
4
main.go
@ -29,7 +29,7 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
buildVersion = "1.2.5"
|
buildVersion = "1.2.1"
|
||||||
serviceName = "hardlink"
|
serviceName = "hardlink"
|
||||||
pollingFrequency = 8 * time.Second
|
pollingFrequency = 8 * time.Second
|
||||||
)
|
)
|
||||||
@ -127,7 +127,7 @@ func main() {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
mail.SendEmailOnError(cfg.Hotel, cfg.Kiosk, "PDQ Status Read Error", err.Error())
|
mail.SendEmailOnError(cfg.Hotel, cfg.Kiosk, "PDQ Status Read Error", err.Error())
|
||||||
} else {
|
} else {
|
||||||
fmt.Printf("\nPDQ availabile: %v\n", pdqstatus.IsAvailable)
|
fmt.Printf("PDQ availabile: %v\n", pdqstatus.IsAvailable)
|
||||||
log.Infof("PDQ availabile: %v", pdqstatus.IsAvailable)
|
log.Infof("PDQ availabile: %v", pdqstatus.IsAvailable)
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
|
|||||||
@ -2,19 +2,6 @@
|
|||||||
|
|
||||||
builtVersion is a const in main.go
|
builtVersion is a const in main.go
|
||||||
|
|
||||||
#### 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
|
|
||||||
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
|
|
||||||
|
|
||||||
#### 1.2.1 - 09 February 2026
|
#### 1.2.1 - 09 February 2026
|
||||||
increased waiting time befor sending email on PDQ unavailability to 60 seconds
|
increased waiting time befor sending email on PDQ unavailability to 60 seconds
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user