Added local compilation. Cleaning.
This commit is contained in:
@ -18,8 +18,10 @@ type gps struct {
|
||||
type Gps interface {
|
||||
Init() error
|
||||
Update() error
|
||||
|
||||
GetData() Data
|
||||
CheckStatus() (Status, error)
|
||||
GetStatus() (Status, error)
|
||||
|
||||
io.Closer
|
||||
}
|
||||
|
||||
@ -56,6 +58,14 @@ func (g *gps) Update() error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (g *gps) GetData() Data {
|
||||
return g.data
|
||||
}
|
||||
|
||||
func (g *gps) Close() error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (g *gps) switchGpsMode(on bool) error {
|
||||
onStr := "0"
|
||||
if on {
|
||||
@ -94,11 +104,3 @@ func (g *gps) switchGpsMode(on bool) error {
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (g *gps) GetData() Data {
|
||||
return g.data
|
||||
}
|
||||
|
||||
func (g *gps) Close() error {
|
||||
return nil
|
||||
}
|
||||
|
@ -85,6 +85,9 @@ func (g *gps) rawCollect(flags nmeaFlags) (string, error) {
|
||||
if _, err := s.Write([]byte("AT+CGPSINFOCFG=0,31\r\n")); err != nil {
|
||||
return "", fmt.Errorf("serial port write 2: %w", err)
|
||||
}
|
||||
if _, err := s.Write([]byte("AT+CGPSFTM=0\r\n")); err != nil { // For sure because sometimes it cannot stop...
|
||||
return "", fmt.Errorf("serial port write 2: %w", err)
|
||||
}
|
||||
|
||||
time.Sleep(100 * time.Millisecond) // To enshure
|
||||
|
||||
@ -115,7 +118,7 @@ func (g *gps) collectNmeaReports(flags nmeaFlags) ([]string, error) {
|
||||
}
|
||||
|
||||
// DEBUG
|
||||
g.logger.Println("NMEA raw collect:", resp)
|
||||
// g.logger.Println("NMEA raw collect:", resp)
|
||||
|
||||
// Right responce struct:
|
||||
// \r\n
|
||||
|
@ -12,24 +12,13 @@ type Status struct {
|
||||
ActiveSatelitesCounte int `json:"activeSatelitesCount"`
|
||||
}
|
||||
|
||||
func (st Status) String() string {
|
||||
got := "false"
|
||||
if st.GotResponses {
|
||||
got = "true"
|
||||
}
|
||||
return "" +
|
||||
"GotResponses: " + got + "\n" +
|
||||
"FoundSatelitesCount: " + string(st.FoundSatelitesCount) + "\n" +
|
||||
"ActiveSatelitesCounte: " + string(st.ActiveSatelitesCounte) + "\n"
|
||||
}
|
||||
|
||||
var StatusNil = Status{
|
||||
GotResponses: false,
|
||||
FoundSatelitesCount: 0,
|
||||
ActiveSatelitesCounte: 0,
|
||||
}
|
||||
|
||||
func (g *gps) CheckStatus() (Status, error) {
|
||||
func (g *gps) GetStatus() (Status, error) {
|
||||
// Provides more information about signal and possible problems using NMEA reports
|
||||
|
||||
// Collect reports
|
Reference in New Issue
Block a user