diff --git a/api/modem/gps/check.go b/api/modem/gps/check.go index b1fa3cb..1200b62 100644 --- a/api/modem/gps/check.go +++ b/api/modem/gps/check.go @@ -22,9 +22,14 @@ func (g *gps) CheckStatus() error { // asc := 0 // Active satelites' counter checkLoop: for _, s := range reports { + // Check for NMEA format + if len(s) < 1 || s[0] != '$' { + continue checkLoop + } + g.logger.Println("NMEA check:", s) values := strings.Split(s, ",") - if len(values) < 1 || len(values[0]) != 6 || values[0][0] != '$' { + if len(values[0]) != 6 { return fmt.Errorf("nmea invalid sentence: %s", s) } switch values[0][3:] { // Switch by content diff --git a/api/modem/gps/nmea.go b/api/modem/gps/nmea.go index 554adf0..f701323 100644 --- a/api/modem/gps/nmea.go +++ b/api/modem/gps/nmea.go @@ -51,7 +51,7 @@ var nmeaFlagsAll = gga | rmc | gpgsv | gpgsa | vtg | xfi | glgsa | gns | gagsv | func (g *gps) rawCollect(flags nmeaFlags) (string, error) { // Need to omplement low level write/read here because collect must be atomic operation // If other command is executed(write/read) it will read a part of nmea report and cause an error - + // Setup gps // Receive data from all contries' satelites, enable DPO(Dynamic Power Optimization) mode @@ -146,11 +146,15 @@ func (g *gps) collectNmeaReports(flags nmeaFlags) ([]string, error) { // OK // (NMEA sentence)... // OK - if len(strs) < 2 { - return nil, fmt.Errorf("responce too few rows: %d", len(strs)) - } - if !(strs[0] == "OK" && strs[len(strs)-1] == "OK") { - return nil, fmt.Errorf("not OK responce: [% s]", strs) - } - return strs[1 : len(strs)-1], nil + // if len(strs) < 2 { + // return nil, fmt.Errorf("responce too few rows: %d", len(strs)) + // } + // if !(strs[0] == "OK" && strs[len(strs)-1] == "OK") { + // return nil, fmt.Errorf("not OK responce: [% s]", strs) + // } + + // This... response is not stable + // Every time it gives one or two OK and in ramdom order + // So I will not check gor it + return strs, nil } diff --git a/api/modem/internet/ic.go b/api/modem/internet/ic.go index d197394..9612478 100644 --- a/api/modem/internet/ic.go +++ b/api/modem/internet/ic.go @@ -132,7 +132,7 @@ func (c *conn) ConfigurePPP() error { config := fmt.Sprintf(pppConfig, apn, c.port.GetName(), c.port.GetBaudrate()) // Write to file - f, err := os.OpenFile("/etc/ppp/peers/"+pppConfigName, os.O_CREATE | os.O_WRONLY, 0666) + f, err := os.OpenFile("/etc/ppp/peers/"+pppConfigName, os.O_CREATE|os.O_WRONLY, 0666) if err != nil { return fmt.Errorf("open ppp config file %w", err) } @@ -230,8 +230,7 @@ func (c *conn) Ping() bool { } c.logger.Println("Ping 2 resp:", string(resp)) - - return !strings.Contains(string(resp), "Destination Host Unreachable") // tmp solution + return !(strings.Contains(string(resp), "Destination Host Unreachable") || strings.Contains(string(resp), "Destination Net Unreachable")) // tmp solution } func (c *conn) Close() error {