Fixed error logging. Added more logging of SIM info.
This commit is contained in:
@ -23,7 +23,11 @@ func (st Status) String() string {
|
||||
"ActiveSatelitesCounte: " + string(st.ActiveSatelitesCounte) + "\n"
|
||||
}
|
||||
|
||||
var StatusNil = Status{}
|
||||
var StatusNil = Status{
|
||||
GotResponses: false,
|
||||
FoundSatelitesCount: 0,
|
||||
ActiveSatelitesCounte: 0,
|
||||
}
|
||||
|
||||
func (g *gps) CheckStatus() (Status, error) {
|
||||
// Provides more information about signal and possible problems using NMEA reports
|
||||
|
@ -48,7 +48,7 @@ func (g *gps) Update() error {
|
||||
return fmt.Errorf("receive GPS data: %w", err)
|
||||
}
|
||||
if !resp.Check() {
|
||||
return fmt.Errorf("error response")
|
||||
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 {
|
||||
return fmt.Errorf("decode: %w", err)
|
||||
@ -77,7 +77,7 @@ func (g *gps) switchGpsMode(on bool) error {
|
||||
return fmt.Errorf("make at ask: %w", err)
|
||||
}
|
||||
if !resp.Check() {
|
||||
return fmt.Errorf("error response")
|
||||
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)
|
||||
if ans == onStr {
|
||||
@ -87,10 +87,10 @@ func (g *gps) switchGpsMode(on bool) error {
|
||||
// Modem is not in GPS mode
|
||||
resp, err = g.port.Send("AT+CGPS=" + onStr)
|
||||
if err != nil {
|
||||
return fmt.Errorf("try to switch to gps: %w", err)
|
||||
return fmt.Errorf("set GPS mode: %w", err)
|
||||
}
|
||||
if !resp.Check() {
|
||||
return fmt.Errorf("switch tp GPS failed")
|
||||
return fmt.Errorf("set GPS mode: error response: %s", resp)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
@ -54,28 +54,12 @@ func (g *gps) rawCollect(flags nmeaFlags) (string, error) {
|
||||
|
||||
// Setup gps
|
||||
|
||||
// Receive data from all contries' satelites, enable DPO(Dynamic Power Optimization) mode
|
||||
// if resp, err := g.port.Send("AT+CGNSSMODE=15,1"); err != nil {
|
||||
// return "", fmt.Errorf("AT+CGNSSMODE= request: %w", err)
|
||||
// } else {
|
||||
// if !resp.Check() {
|
||||
// return "", fmt.Errorf("AT+CGNSSMODE= error response: %s", resp)
|
||||
// }
|
||||
// }
|
||||
// Receive all types of data
|
||||
// if resp, err := g.port.Send("AT+CGPSNMEA=200191"); err != nil {
|
||||
// return "", fmt.Errorf("AT+CGPSNMEA= request: %w", err)
|
||||
// } else {
|
||||
// if !resp.Check() {
|
||||
// return "", fmt.Errorf("AT+CGPSNMEA= error response: %s", resp)
|
||||
// }
|
||||
// }
|
||||
// Set output rate to 10Hz
|
||||
if resp, err := g.port.Send("AT+CGPSNMEARATE=1"); err != nil {
|
||||
return "", fmt.Errorf("AT+CGPSNMEARATE= request: %w", err)
|
||||
} else {
|
||||
if !resp.Check() {
|
||||
return "", fmt.Errorf("AT+CGPSNMEARATE= error response: %s", resp)
|
||||
return "", fmt.Errorf("set output rate: error response: %s", resp)
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user