Select to view content in your preferred language

AGSNMEALocationDataSource Bug?

641
5
09-15-2022 11:05 PM
ShiminCai
Occasional Contributor III

Hi There,

I'm using the AGSNMEALocationDataSource to get the location feed from external GPS unit:

mapView.locationDisplay.dataSource = AGSNMEALocationDataSource(eaAccessory: connectedAccessory!, protocol: protocalString) 

When the data source was started, the gps symbol appeared on map. When I started walking, the gps symbol moved with me.  So far so good, it had worked as expected. Then I stopped the data source to turn off the gps symbol and continued walking without the gps symbol on map. I stopped walking at the top end of the black dots as shown in below picture. Now the problem: I started the data source again and the gps symbol appeared on map again, but the gps symbol was not at my current location - the top end of the black dots. It did not catch up with my current location! It was stuck where the data source was stopped. Then when I moved, the gps symbol did not move at all and stuck there forever...      

Screen Shot 2022-09-16 at 2.58.13 pm.png

However, with the AGSCLLocationDataSource I did not have the above problem.

Any idea?

Thanks,

Shimin

 

0 Kudos
5 Replies
ShiminCai
Occasional Contributor III

Hi there,

Never mind! Figured it out based on the ESRI sample code "Display device location with NMEA data sources". Just need to recreate the AGSNMEALocationDataSource object and assign it to the mapView.locationDisplay.dataSource before call mapView.locationDisplay.dataSource.start(). I think the connectedAccessory need to be refreshed when the dataSource is turned back on after it is turned off. You don't have to do this with the default location datasource though. 

Cheers,

Shimin 

Ting
by Esri Contributor
Esri Contributor

Glad you figured it out! We had a discussion earlier but wasn't able to repro, thus delayed response.

0 Kudos
ShiminCai
Occasional Contributor III

Hi @Ting,

Thanks for looking into this for us. ESRI's support has been terrific. Really appreciated.

You could reproduce the issue in the sample code "Display device location with NMEA data sources" by making below code changes:

1. Commented out the line 186 in the @IBAction func reset() {...}

    

Screen Shot 2022-09-22 at 9.08.22 am.png

2. Added the 105 and 107 lines below in @IBAction func chooseDataSource(_ sender: UIBarButtonItem) {...}

    

Screen Shot 2022-09-22 at 9.07.51 am.png

 

The steps to reproduce:

1. Have a GPS unit blue tooth connected to your iPhone or iPad.

2. Run the sample and look for Maps/Display device location with NMEA data sources.

3. After ArcGIS Online Login, tap the Source/Device (not Mock Data). The map now zooms to your current location and the gps symbol appears. You can walk around and notice that the gps symbol moves along with you indicating your current location.

4. Tap the Reset to turn off the gps symbol.

5. Walk away say 20 meters.

6. Tap the Source/Device to turn on gps again. The gps symbol appears again but it is NOT at your current location. it is stuck where it is turn off. If you continue walking, the gps symbol does not move at all.

 

I noticed that this does not happen with AGSCLLocationDataSource and AGSLocationDataSource but only happens with AGSNMEALocationDataSource. 

 

Cheers,

Shimin

  

0 Kudos
Ting
by Esri Contributor
Esri Contributor

Thanks for the repro steps. We queried our internal users and they have also experienced similar issues in the past, so we created an issue to dig into it. It might be related to the location data source's caching mechanism, though there currently isn't a way to flush the cache.

In the meantime, a potential workaround is to recreate a new `NMEALocationDataSource` instance every time.

0 Kudos
ShiminCai
Occasional Contributor III

Thanks @Ting 

Hopefully it will be fixed in the SDK in the future. your suggested workaround is exactly what we've done.

Cheers,

Shimin