mirror of
https://github.com/bettercap/bettercap
synced 2025-08-20 21:43:18 -07:00
new: parsing gps GPGGA messages other than just GNGGA (fixes #473)
This commit is contained in:
parent
4e860c73fe
commit
963840915b
2 changed files with 24 additions and 8 deletions
|
@ -106,12 +106,21 @@ func (mod *GPS) readLine() (line string, err error) {
|
|||
}
|
||||
|
||||
func (mod *GPS) Show() error {
|
||||
fmt.Printf("latitude:%f longitude:%f quality:%s satellites:%d altitude:%f\n",
|
||||
mod.Session.GPS.Latitude,
|
||||
mod.Session.GPS.Longitude,
|
||||
mod.Session.GPS.FixQuality,
|
||||
mod.Session.GPS.NumSatellites,
|
||||
mod.Session.GPS.Altitude)
|
||||
if mod.Session.GPS.GNGGA.Time.Valid {
|
||||
fmt.Printf("latitude:%f longitude:%f quality:%s satellites:%d altitude:%f\n",
|
||||
mod.Session.GPS.GNGGA.Latitude,
|
||||
mod.Session.GPS.GNGGA.Longitude,
|
||||
mod.Session.GPS.GNGGA.FixQuality,
|
||||
mod.Session.GPS.GNGGA.NumSatellites,
|
||||
mod.Session.GPS.GNGGA.Altitude)
|
||||
} else {
|
||||
fmt.Printf("latitude:%f longitude:%f quality:%s satellites:%d altitude:%f\n",
|
||||
mod.Session.GPS.GPGGA.Latitude,
|
||||
mod.Session.GPS.GPGGA.Longitude,
|
||||
mod.Session.GPS.GPGGA.FixQuality,
|
||||
mod.Session.GPS.GPGGA.NumSatellites,
|
||||
mod.Session.GPS.GPGGA.Altitude)
|
||||
}
|
||||
|
||||
mod.Session.Refresh()
|
||||
|
||||
|
@ -132,7 +141,9 @@ func (mod *GPS) Start() error {
|
|||
if s, err := nmea.Parse(line); err == nil {
|
||||
// http://aprs.gids.nl/nmea/#gga
|
||||
if m, ok := s.(nmea.GNGGA); ok {
|
||||
mod.Session.GPS = m
|
||||
mod.Session.GPS.GNGGA = m
|
||||
} else if m, ok := s.(nmea.GPGGA); ok {
|
||||
mod.Session.GPS.GPGGA = m
|
||||
}
|
||||
} else {
|
||||
mod.Debug("error parsing line '%s': %s", line, err)
|
||||
|
|
|
@ -73,6 +73,11 @@ func (mm ModuleList) MarshalJSON() ([]byte, error) {
|
|||
return json.Marshal(mods)
|
||||
}
|
||||
|
||||
type GPS struct {
|
||||
GNGGA nmea.GNGGA
|
||||
GPGGA nmea.GPGGA
|
||||
}
|
||||
|
||||
type Session struct {
|
||||
Options core.Options `json:"options"`
|
||||
Interface *network.Endpoint `json:"interface"`
|
||||
|
@ -85,7 +90,7 @@ type Session struct {
|
|||
Queue *packets.Queue `json:"packets"`
|
||||
StartedAt time.Time `json:"started_at"`
|
||||
Active bool `json:"active"`
|
||||
GPS nmea.GNGGA `json:"gps"`
|
||||
GPS GPS `json:"gps"`
|
||||
Modules ModuleList `json:"modules"`
|
||||
|
||||
Input *readline.Instance `json:"-"`
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue