Skip to content

Commit

Permalink
clean up resopnse
Browse files Browse the repository at this point in the history
  • Loading branch information
joshspicer committed Mar 25, 2023
1 parent 1fb751e commit 5026286
Showing 1 changed file with 5 additions and 9 deletions.
14 changes: 5 additions & 9 deletions server/nodeRouter.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package main

import (
"fmt"
"io"
"log"
"net/http"
Expand Down Expand Up @@ -39,25 +40,20 @@ func getNodeInfo(c *gin.Context) {
var mio io.ReadWriter = m

modem := at.New(mio, at.WithTimeout(2*time.Second))

info, err := modem.Command("I")
if err != nil {
c.JSON(http.StatusInternalServerError, gin.H{
"message": "Error getting node info",
"error": err.Error(),
})
c.String(http.StatusInternalServerError, fmt.Sprintf("Error getting modem info, %s", err.Error()))
return
}
signalStrength, err := modem.Command("+CSQ")
if err != nil {
c.JSON(http.StatusInternalServerError, gin.H{
"message": "Error getting signal strength",
"error": err.Error(),
})
c.String(http.StatusInternalServerError, fmt.Sprintf("Error getting signal strength, %s", err.Error()))
return
}

c.JSON(http.StatusOK, gin.H{
"modemInfo": strings.Join(info, " "),
"modemInfo": info[0],
"signal": strings.Join(signalStrength, " "),
"accessoriesBattery": -1, // Mock
"gpsLatitude": 12.517572, // Mock
Expand Down

0 comments on commit 5026286

Please sign in to comment.