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