n9m/devemm.go
2023-11-30 20:05:11 +03:00

37 lines
948 B
Go

package n9m
import "fmt"
// main server util
func (e *Package) RequestGeolocation(serial int, Sid string) {
e.Payload = map[string]any{
"MODULE": "DEVEMM",
"OPERATION": "GETPOS",
"PARAMETER": map[string]any{
"SERIAL": serial,
},
"SESSION": Sid,
}
}
func (e *Package) ResponseGeolocation(errorCode int, errorCause string, serial int, longitude float32, latitude float32, altitude float32, speed int, course int, time string) {
e.Payload = map[string]any{
"MODULE": "DEVEMM",
"OPERATION": "GETPOS",
"RESPONSE": map[string]any{
"ERRORCODE": errorCode,
"ERRORCAUSE": errorCause,
"SERIAL": serial,
"P": map[string]any{
"V": errorCode == 0,
"J": fmt.Sprintf("%4.6v", longitude),
"W": fmt.Sprintf("%4.6v", latitude),
"H": fmt.Sprintf("%4.6v", altitude),
"S": speed, // unit - 0.01 km/h
"C": course, // direction (angle from north)
"T": time, // yyyymmddhhmmss
},
},
}
}