diff --git a/api/modem/at/at.go b/api/modem/at/at.go index 9c1c5a3..bb3dbad 100644 --- a/api/modem/at/at.go +++ b/api/modem/at/at.go @@ -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") }