location GetRaw return nil
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]
please provide abit more information
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
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 )
location.GetLocation() --- get empty response.
But if i request location via DBUS i recieve normal and full answer
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
Code entered here https://github.com/maltegrosse/go-modemmanager/blob/master/ModemLocation.go#L342 but ok false and tmpMap empty
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)
Where i can see DBUS PATCH?
https://github.com/maltegrosse/go-modemmanager/blob/master/ModemLocation.go#L17
this one defines the path
it's true
can you check the output of res? https://github.com/maltegrosse/go-modemmanager/blob/master/ModemLocation.go#L257 perhaps some issue with parsing
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">}
weird, as it should convert map[string]interface{} can you try to cast it to map[string]float64?
element.Value return
map[altitude:@d 151.3 latitude:@d 35.75437328333334 longitude:@d 32.01384675 utc-t
ime:"095457.0"]
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.
Value is not a map[string]interface{}
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
```
if you its working for you, you can provide a PR - thank you