Fix.
This commit is contained in:
parent
620c98cbf1
commit
dbb4fc5939
@ -127,20 +127,20 @@ func (p *atPort) Request(cmdType CmdType, cmd string) (outStr string, outErr err
|
||||
if len(rawResp) == 0 {
|
||||
return "", fmt.Errorf("read nothing")
|
||||
}
|
||||
resp := strings.Split(rawResp, "\n")
|
||||
resp := rawResp[2 : len(rawResp)-2] // Cut \r\n
|
||||
switch cmdType {
|
||||
case CmdTest, CmdCheck:
|
||||
// Check and test cmds do not suppose anything but OK
|
||||
if len(resp[1]) >= 2 && resp[1][:2] == "OK" {
|
||||
if len(resp) >= 2 && resp[:2] == "OK" {
|
||||
return "", nil
|
||||
}
|
||||
return "", fmt.Errorf("connection lost")
|
||||
case CmdGet, CmdQuestion:
|
||||
checkL := len(cmd) + 1
|
||||
if len(resp[1]) >= checkL && resp[1][:checkL] != "+"+cmd {
|
||||
if len(resp) >= checkL && resp[:checkL] != "+"+cmd {
|
||||
return "", fmt.Errorf("connetion lost")
|
||||
}
|
||||
return strings.Split(resp[1], ":")[1], nil
|
||||
return strings.Split(resp, ":")[1], nil
|
||||
}
|
||||
return "", fmt.Errorf("undefined command type")
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user