Added local compilation. Cleaning.

This commit is contained in:
2024-08-06 20:37:20 +03:00
parent 026c1aa3bb
commit 6a96656434
10 changed files with 100 additions and 123 deletions

View File

@ -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
}

View File

@ -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

View File

@ -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