Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

location GetRaw return nil #10

Open
lmahmutov opened this issue Dec 27, 2024 · 18 comments
Open

location GetRaw return nil #10

lmahmutov opened this issue Dec 27, 2024 · 18 comments

Comments

@lmahmutov
Copy link

Cannot get Gpsraw location data on modemmanager 1.22

START Location

ThreeGppLacCi: Mcc: 250, Mnc: 01, Lac: 0, Ci: 5324821, Tac: 2D7B, GpsNmea: NmeaSentences: [$GPGSA,A,2,05,13,18,20,27,30,,,,,,,1.4,1.0,0.934 $GPRMC,075236.0,A,5545.261656,N,05200.831352,E,0.0,329.7,271224,11.9,E,A3E $GPGSV,3,1,11,05,28,284,48,09,15,150,21,13,28,303,46,15,00,319,417C $GPGSV,3,2,11,18,05,344,36,20,17,250,34,27,22,043,32,30,74,261,297B $GPGSV,3,3,11,07,63,097,,08,35,080,,14,34,210,42 $GPVTG,329.7,T,317.9,M,0.0,N,0.0,K,A20 $GPGGA,075236.0,5545.261656,N,05200.831352,E,1,06,1.0,166.0,M,-1.0,M,,*4B]
[3gppLacCi GpsRaw GpsNmea]

@maltegrosse
Copy link
Owner

please provide abit more information

@lmahmutov
Copy link
Author

lmahmutov commented Dec 27, 2024

	for _, modem := range modems {
		location, err := modem.GetLocation()
		if err != nil {
			panic(err)
		}
		gpsraw, err := location.GetCurrentLocation()
		if err != nil {
			panic(err)
		}
		fmt.Println("GPS Raw Data:", gpsraw)
	}

return every time only location based on CID
but mmcli show GpsRaw location

@maltegrosse
Copy link
Owner

sometimes it takes some time until a location is received/populated via dbus. have you tried to make a loop and wait certain time? Have you tried location.GetLocation() ?

To be honest, I havent tested it deeply with modem manager, as I always used geoclue2 (I also made a go wrapper: https://github.com/maltegrosse/go-geoclue2 )

@lmahmutov
Copy link
Author

location.GetLocation() --- get empty response.

But if i request location via DBUS i recieve normal and full answer

@maltegrosse
Copy link
Owner

Then there is probably an issue with my wrapper, have you tried to add some breakpoints there?
https://github.com/maltegrosse/go-modemmanager/blob/master/ModemLocation.go#L316

@lmahmutov
Copy link
Author

Code entered here
https://github.com/maltegrosse/go-modemmanager/blob/master/ModemLocation.go#L342
but ok false and tmpMap empty

@maltegrosse
Copy link
Owner

have you tried do wrap it in some loop and query it every 30 sec for 2-5 min? the dbus path are correct in my implementation? (I currently dont have a device around to test it on my side, sorry)

@lmahmutov
Copy link
Author

Where i can see DBUS PATCH?
location

@maltegrosse
Copy link
Owner

@lmahmutov
Copy link
Author

it's true

@maltegrosse
Copy link
Owner

can you check the output of res?
https://github.com/maltegrosse/go-modemmanager/blob/master/ModemLocation.go#L257
perhaps some issue with parsing

@lmahmutov
Copy link
Author

Issue here.
https://github.com/maltegrosse/go-modemmanager/blob/master/ModemLocation.go#L342
i added

fmt.Println(" GPSRAW_CHECK ", element.String())

for view dbus.element
and recieved

GPSRAW_CHECK  {"altitude": <@d 169>, "latitude": <@d 35.75443335>, "longitude": <@d 32.01379205>, "utc-time": <"094509.0">}

@maltegrosse
Copy link
Owner

maltegrosse commented Dec 27, 2024

weird, as it should convert map[string]interface{}
can you try to cast it to map[string]float64?

@lmahmutov
Copy link
Author

lmahmutov commented Dec 27, 2024

element.Value return

map[altitude:@d 151.3 latitude:@d 35.75437328333334 longitude:@d 32.01384675 utc-t
ime:"095457.0"]

@maltegrosse
Copy link
Owner

but you mentioned the tmpmap is empty: https://github.com/maltegrosse/go-modemmanager/blob/master/ModemLocation.go#L342

that means it something wrong with the casting.

@lmahmutov
Copy link
Author

Value is not a map[string]interface{}

@lmahmutov
Copy link
Author

i realy dont now why it's not cast to map. I realised it without map...

				re := regexp.MustCompile(`<@d (-?\d+\.?\d*)>`)
				processedInput := re.ReplaceAllString(element.String(), "$1")
				processedInput = strings.ReplaceAll(processedInput, "<\"", "\"")
				processedInput = strings.ReplaceAll(processedInput, "\">", "\"")

				var location Location
				err := json.Unmarshal([]byte(processedInput), &location)
				if err != nil {
					return locs, err
				}

				var gpsRaw GpsRawLocation
				// Parse timestamp ("06": Year, "01": Zero Month, "02": Zero Day, "15": Hour, "04": Zero Minute, "05": Zero Second)
				t, err := time.Parse("150405", location.UtcTime)
				if err != nil {
					return locs, err
				}
				now := time.Now().UTC()
				// workaround as date is missing
				t = t.AddDate(now.Year(), int(now.Month()), now.Day())
				gpsRaw.UtcTime = t
				gpsRaw.Altitude = location.Altitude
				gpsRaw.Latitude = location.Latitude
				gpsRaw.Longitude = location.Longitude
				locs.GpsRaw = gpsRaw
				```

@maltegrosse
Copy link
Owner

if you its working for you, you can provide a PR - thank you

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants