Skip to content

Commit

Permalink
traccar working all 3 protocols
Browse files Browse the repository at this point in the history
  • Loading branch information
talkkonnect committed Jan 5, 2022
1 parent 9667a03 commit bf89be6
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 8 deletions.
4 changes: 2 additions & 2 deletions client.go
Original file line number Diff line number Diff line change
Expand Up @@ -500,12 +500,12 @@ func (b *Talkkonnect) ClientStart() {
go consoleScreenLogging()
}

if Config.Global.Hardware.TargetBoard != "rpi" && Config.Global.Hardware.Traccar.DeviceScreenEnabled {
if Config.Global.Hardware.TargetBoard == "rpi" && Config.Global.Hardware.Traccar.DeviceScreenEnabled {
go localScreenLogging()
}

if Config.Global.Hardware.Traccar.Enabled && Config.Global.Hardware.Traccar.Track && Config.Global.Hardware.Traccar.Protocol.Name == "osmand" {
go httpSendTraccarOsman()
go httpSendTraccarOsmand()
}

if Config.Global.Hardware.Traccar.Enabled && Config.Global.Hardware.Traccar.Track && Config.Global.Hardware.Traccar.Protocol.Name == "opengts" {
Expand Down
14 changes: 9 additions & 5 deletions gps.go
Original file line number Diff line number Diff line change
Expand Up @@ -234,17 +234,18 @@ func getGpsPosition(verbosity int) (bool, error) {
return false, errors.New("gnss not enabled")
}

func httpSendTraccarOsman() {
func httpSendTraccarOsmand() {

Receivers++
for {
GNSSDataTraccar := <-GNSSDataPublic

TraccarDateTime := GNSSDataTraccar.DateTime.Format("2006-02-01") + "%20" + GNSSDataTraccar.DateTime.Format("15:04:05")
TraccarDateTime := GNSSDataTraccar.DateTime.Format("2006-01-02") + "%20" + GNSSDataTraccar.DateTime.Format("15:04:05")

TraccarServerFullURLOsman := (fmt.Sprint(Config.Global.Hardware.Traccar.Protocol.Osmand.ServerURL) + ":" + fmt.Sprint(Config.Global.Hardware.Traccar.Protocol.Osmand.Port) + "/?" + "id=" + Config.Global.Hardware.Traccar.ClientId + "&" +
"timestamp=" + TraccarDateTime + "&" + "lat=" + fmt.Sprintf("%f", GNSSDataTraccar.Lattitude) +
"&" + "lon=" + fmt.Sprintf("%f", GNSSDataTraccar.Longitude) + "&" + "speed=" + fmt.Sprintf("%f", GNSSDataTraccar.Speed) + "&" + "course=" +
fmt.Sprintf("%f", GNSSDataTraccar.Course) + "&" + "variation=" + fmt.Sprintf("%f", GNSSDataTraccar.Variation))
fmt.Sprintf("%f", GNSSDataTraccar.Course) + "&" + "variation=" + fmt.Sprintf("%f", GNSSDataTraccar.Variation) + "&" + "hdop=" + fmt.Sprintf("%f", GNSSData.HDOP) + "&" + "altitude=" + fmt.Sprintf("%f", GNSSData.Altitude))

response, err := http.Get(TraccarServerFullURLOsman)

Expand Down Expand Up @@ -272,10 +273,13 @@ func httpSendTraccarOsman() {
}

}

}

func tcpSendT55Traccar() {

Receivers++

for {
GNSSDataTraccar := <-GNSSDataPublic

Expand Down Expand Up @@ -308,7 +312,7 @@ func tcpSendT55Traccar() {
log.Println("debug: Traccar Client:", CONN.LocalAddr().String(), "Connected to Server:", CONN.RemoteAddr().String())

fmt.Fprint(CONN, PGID) // Send ID
time.Sleep(1 * time.Second)
time.Sleep(5 * time.Second)
fmt.Fprint(CONN, GPRMC) // send $GPRMC
log.Println("debug: Sending position message to Traccar over Protocol: " + strings.Title(strings.ToLower(Config.Global.Hardware.Traccar.Protocol.Name)))

Expand Down Expand Up @@ -353,7 +357,7 @@ func httpSendTraccarOpenGTS() {
for {
GNSSDataTraccar := <-GNSSDataPublic

TraccarServerFullURLOpenGTS := (fmt.Sprint(Config.Global.Hardware.Traccar.Protocol.Opengts.ServerURL) + ":" + fmt.Sprint(Config.Global.Hardware.Traccar.Protocol.Opengts.Port) + "/?id=" + Config.Global.Hardware.Traccar.ClientId + "&grmpc=" + GNSSDataTraccar.RMCRaw)
TraccarServerFullURLOpenGTS := (fmt.Sprint(Config.Global.Hardware.Traccar.Protocol.Opengts.ServerURL) + ":" + fmt.Sprint(Config.Global.Hardware.Traccar.Protocol.Opengts.Port) + "/?id=" + Config.Global.Hardware.Traccar.ClientId + "&gprmc=" + GNSSDataTraccar.RMCRaw)

log.Println("alert:", TraccarServerFullURLOpenGTS)

Expand Down
7 changes: 6 additions & 1 deletion version.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,11 @@
package talkkonnect

const (
talkkonnectVersion string = "2.07.14"
talkkonnectVersion string = "2.07.15"
talkkonnectReleased string = "Jan 05 2022"
)

/* Release Notes
1. Used Zoran's Patch to make traccar working with all 3 protocols
2. Fixed wrong logic for Config.Global.Hardware.TargetBoard == "rpi" && Config.Global.Hardware.Traccar.DeviceScreenEnabled causing the screen not to work
*/

0 comments on commit bf89be6

Please sign in to comment.