Fixed RmFront panic.
This commit is contained in:
@ -49,9 +49,10 @@ func (g *gps) Update() error {
|
||||
if err != nil {
|
||||
return fmt.Errorf("receive GPS data: %w", err)
|
||||
}
|
||||
if !resp.Check() {
|
||||
if !resp.Check() || !resp.CheckFront("+CGPSINFO:") {
|
||||
return fmt.Errorf("get GPS info: error response: %s", resp)
|
||||
}
|
||||
|
||||
if err := g.data.decode(strings.Split(strings.Replace(resp.RmFront("+CGPSINFO:").String(), "\r", "", -1), "\n")[0]); err != nil {
|
||||
g.logger.Printf("error decode: %s\n", err.Error())
|
||||
}
|
||||
@ -86,7 +87,7 @@ func (g *gps) switchGpsMode(on bool) error {
|
||||
if err != nil {
|
||||
return fmt.Errorf("make at ask: %w", err)
|
||||
}
|
||||
if !resp.Check() {
|
||||
if !resp.Check() || !resp.CheckFront("+CGPS:") {
|
||||
return fmt.Errorf("get GPS mode: error response: %s", resp)
|
||||
}
|
||||
ans := strings.Replace(strings.Split(strings.Split(resp.RmFront("+CGPS:").String(), "\n")[0], ",")[0], " ", "", -1)
|
||||
|
Reference in New Issue
Block a user