Skip to content

Commit

Permalink
no mock gps
Browse files Browse the repository at this point in the history
  • Loading branch information
joshspicer committed Mar 27, 2023
1 parent fa2a75d commit e540a4d
Showing 1 changed file with 7 additions and 9 deletions.
16 changes: 7 additions & 9 deletions server/nodeRouter.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@ func getNodeInfo(c *gin.Context) {

//var info string = "ERR"
var signalStrength string = "ERR"
var gpsLatitude float32 = 12.517572
var gpsLongitude float32 = -69.9649462
var gpsLatitude float32 = -1
var gpsLongitude float32 = -1

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

if tmpLatitude != -1 && tmpLongitude != -1 {
gpsLatitude = tmpLatitude
gpsLongitude = tmpLongitude
}
// Convert AT latitude and longitude response
gpsLatitude = convertGpsLocation(gpsLocationArr[1])
gpsLongitude = convertGpsLocation(gpsLocationArr[2])
}

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

0 comments on commit e540a4d

Please sign in to comment.