added Dormakaba lock server integration
This commit is contained in:
@@ -7,12 +7,12 @@ import (
|
||||
"os"
|
||||
"strconv"
|
||||
"strings"
|
||||
"time"
|
||||
"time"
|
||||
|
||||
log "github.com/sirupsen/logrus"
|
||||
)
|
||||
|
||||
// Build key encoding request command for the Omnitec lock server.
|
||||
// BuildCommand builds key encoding request command for the Omnitec lock server.
|
||||
func (lock *OmniLockServer) BuildCommand(doorReq DoorCardRequest, checkIn, checkOut time.Time) error {
|
||||
const funcName = "OmniLockServer.BuildCommand"
|
||||
hostname, err := os.Hostname()
|
||||
@@ -25,7 +25,7 @@ func (lock *OmniLockServer) BuildCommand(doorReq DoorCardRequest, checkIn, check
|
||||
if err != nil {
|
||||
return fmt.Errorf("[%s] failed to convert lockId to integer: %v", funcName, err)
|
||||
}
|
||||
formattedLockId := fmt.Sprintf("%04d", idInt)
|
||||
formattedLockID := fmt.Sprintf("%04d", idInt)
|
||||
|
||||
// Format date/time parts
|
||||
dt := checkOut.Format("15:04") // DT = HH:mm
|
||||
@@ -37,7 +37,7 @@ func (lock *OmniLockServer) BuildCommand(doorReq DoorCardRequest, checkIn, check
|
||||
payload := fmt.Sprintf(
|
||||
"KR|KC%s|KTD|RN%s|%s|DT%s|G#75|GA%s|GD%s|KO0000|DA%s|TI%s|",
|
||||
lock.encoderAddr,
|
||||
formattedLockId,
|
||||
formattedLockID,
|
||||
hostname,
|
||||
dt,
|
||||
ga,
|
||||
@@ -52,7 +52,7 @@ func (lock *OmniLockServer) BuildCommand(doorReq DoorCardRequest, checkIn, check
|
||||
return nil
|
||||
}
|
||||
|
||||
// Starts link to the Omnitec lock server and perform key encoding
|
||||
// LockSequence starts link to the Omnitec lock server and perform key encoding
|
||||
func (lock *OmniLockServer) LockSequence() error {
|
||||
const funcName = "OmniLockServer.LockSequence"
|
||||
|
||||
@@ -136,4 +136,4 @@ func parseOmniResponse(raw string) (string, error) {
|
||||
return "", fmt.Errorf("negative response code: %s", clean)
|
||||
}
|
||||
return "Success: " + clean, nil
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user