Fix: latitude, longitude format

This commit is contained in:
Andrey Egorov 2024-09-30 20:43:37 +03:00
parent 509006fae1
commit 4f89f15146
4 changed files with 12 additions and 12 deletions

View File

@ -11,10 +11,10 @@ import (
) )
type Data struct { type Data struct {
Latitude float64 `json:"Latitude"` Latitude float64 `json:"Latitude"` // ddmm.mmmmmm
Longitude float64 `json:"Longitude"` Longitude float64 `json:"Longitude"` // dddmm.mmmmmm
LatitudeIndicator string `json:"Latitude_indicator"` // North/South LatitudeIndicator string `json:"Latitude_indicator"` // N/S - North/South
LongitudeIndicator string `json:"Longitude_indicator"` // West/East LongitudeIndicator string `json:"Longitude_indicator"` // W/E - West/East
Speed float64 `json:"Speed"` Speed float64 `json:"Speed"`
Course float64 `json:"-"` Course float64 `json:"-"`
Altitude float64 `json:"-"` Altitude float64 `json:"-"`
@ -59,8 +59,6 @@ func (gps *Data) decode(str string) error {
if err != nil { if err != nil {
logger.Println("ERROR parse longitude:", err.Error()) logger.Println("ERROR parse longitude:", err.Error())
} }
newGpsInfo.Latitude /= 100
newGpsInfo.Longitude /= 100
newGpsInfo.LatitudeIndicator = strs[1] newGpsInfo.LatitudeIndicator = strs[1]
newGpsInfo.LongitudeIndicator = strs[3] newGpsInfo.LongitudeIndicator = strs[3]
newGpsInfo.Date = strs[4] newGpsInfo.Date = strs[4]

View File

@ -34,6 +34,8 @@ const (
) )
func secondCountDownTimer(title string, logger *log.Logger, t time.Duration) { func secondCountDownTimer(title string, logger *log.Logger, t time.Duration) {
_ = title
_ = logger
counter := 0 counter := 0
for { for {
if counter > int(t.Seconds()) { if counter > int(t.Seconds()) {

View File

@ -25,7 +25,7 @@ func CheckSignal(port at.Port, logger *log.Logger) (bool, error) {
} }
func checkRssi(rssi int) error { func checkRssi(rssi int) error {
// rssi - Received signal strenght indicator // rssi - Received signal strength indicator
// 0 -113 dBm or less // 0 -113 dBm or less
// 1 -111 dBm // 1 -111 dBm
// 2...30 -109... - 53 dBm // 2...30 -109... - 53 dBm

10
main.go
View File

@ -53,7 +53,7 @@ setupRouteTableLoop:
} }
func Cmd(cmd string) { func Cmd(cmd string) {
resp, err := m.At().SendWithTimeout(cmd, 50*time.Millisecond) resp, err := m.At().SendWithTimeout(cmd, 10*time.Second) //50*time.Millisecond)
logger.Println(cmd, "===>", resp, err) logger.Println(cmd, "===>", resp, err)
} }
@ -96,9 +96,9 @@ initLoop:
}() }()
// Internet connect // Internet connect
if err := InetInit(); err != nil { // if err := InetInit(); err != nil {
return err // return err
} // }
logger.Println("||||||||||||||||| SMS |||||||||||||||||") logger.Println("||||||||||||||||| SMS |||||||||||||||||")
@ -109,7 +109,7 @@ initLoop:
// Cmd("AT+CREG?") // Cmd("AT+CREG?")
// Cmd("AT+CNMI?") // Cmd("AT+CNMI?")
// Cmd("AT+CSQ") Cmd("AT+CNETSCAN")
// Cmd("AT+CSCA?") // Cmd("AT+CSCA?")
// Cmd("AT+CPOL?") // Cmd("AT+CPOL?")
// Cmd("AT+COPS?") // Cmd("AT+COPS?")