Skip to content

Commit e540a4d

Browse files
authored
no mock gps
1 parent fa2a75d commit e540a4d

File tree

1 file changed

+7
-9
lines changed

1 file changed

+7
-9
lines changed

server/nodeRouter.go

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,8 @@ func getNodeInfo(c *gin.Context) {
4141

4242
//var info string = "ERR"
4343
var signalStrength string = "ERR"
44-
var gpsLatitude float32 = 12.517572
45-
var gpsLongitude float32 = -69.9649462
44+
var gpsLatitude float32 = -1
45+
var gpsLongitude float32 = -1
4646

4747
//infoArr, err := modem.Command("I")
4848
//if err == nil {
@@ -58,14 +58,11 @@ func getNodeInfo(c *gin.Context) {
5858
// +QGPSLOC: 174111.0,4736.8397N,12218.8860W,1.5,98.7,3,224.01,0.0,0.0,260323,05
5959
gpsLocationArr, err := modem.Command("+QGPSLOC?")
6060
if err == nil {
61-
// Convert AT latitude and longitude response
62-
var tmpLatitude = convertGpsLocation(gpsLocationArr[1])
63-
var tmpLongitude = convertGpsLocation(gpsLocationArr[2])
61+
log.Printf("Raw GPS Location: %s", gpsLocationArr)
6462

65-
if tmpLatitude != -1 && tmpLongitude != -1 {
66-
gpsLatitude = tmpLatitude
67-
gpsLongitude = tmpLongitude
68-
}
63+
// Convert AT latitude and longitude response
64+
gpsLatitude = convertGpsLocation(gpsLocationArr[1])
65+
gpsLongitude = convertGpsLocation(gpsLocationArr[2])
6966
}
7067

7168
c.JSON(http.StatusOK, gin.H{
@@ -100,5 +97,6 @@ func convertGpsLocation(gpsLocation string) float32 {
10097
log.Println(err)
10198
return -1
10299
}
100+
log.Printf("Parsed into float: %f", gpsLocationFloat)
103101
return float32(gpsLocationFloat)
104102
}

0 commit comments

Comments
 (0)