From dbb4fc5939199b674921bf6e28e0e4bca6484432 Mon Sep 17 00:00:00 2001 From: Andrey Egorov Date: Mon, 22 Jul 2024 20:57:36 +0300 Subject: [PATCH] Fix. --- api/modem/at/at.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) 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") }