"open": DoorCmdHandler{ checkCmdDoorControl, "o"},
"close": DoorCmdHandler{ checkCmdDoorControl, "c"},
"toggle": DoorCmdHandler{ checkCmdDoorControl, "t"},
- "status": DoorCmdHandler{ checkCmdDoorControl, "s"},
+ "status": DoorCmdHandler{ checkCmdNoArgs, "s"},
}
// ---------- Command Handling Code -------------
func checkCmdDoorControl(tokens [][]byte) (error) {
doorctrl_usage := "syntax: <open|close|toggle> <method> <nickname>"
- if len(tokens) != 3 {
+ if len(tokens) < 2 || len(tokens) > 3 {
return errors.New(doorctrl_usage)
}
cmd := string(tokens[0])
if ! (method == "Button" || method == "ssh" || method == "SSH" || method == "Phone") {
return errors.New("method must be one either Button, SSH or Phone")
}
- if len(tokens[2]) == 0 && method != "Button" {
+ if (len(tokens) == 2 || len(tokens[2]) == 0) && method != "Button" {
return errors.New("Operator nickname must be given")
}
return nil
}
-func checkCmdStatus(tokens [][]byte) (error) {
+func checkCmdNoArgs(tokens [][]byte) (error) {
if len(tokens) != 1 {
- return errors.New("status command does not accept arguments")
+ return errors.New("command does not accept arguments")
}
return nil
}
}
if err := dch.Checker(tokens); err != nil {
- //return error to sender
- return nil
+ return err
}
serial_wr <- dch.FirmwareChar