×

Discussion Board

Results 1 to 12 of 12
  1. #1
    Registered User
    Join Date
    Sep 2010
    Posts
    13

    WRT and location API - issues

    I'm seeing the following various issues when writing WRT widgets that use the location API (1.0) on my 5800 (firmware V31.0.101), I was wondering if any of these are known bugs (couldn't find any with a search) or if there's anything odd I'm likely to be doing (though I can reproduce these with very basic tests). Has anyone seen any of them before?

    - when using GetLocation() and requesting generic rather than basic data, I receive values for the satellite data (in-view and used) when the GPS has reception, but when using Trace() I never receive them (for my purposes I need to use only GPS data, not cell-derived location, and I can't find any other way of distinguishing the two)
    - when using either function, again requesting generic data, I never receive any speed/heading/etc information
    - when using Trace(), I often receive timeout error 1016, even in good coverage, after which I have to exit the widget before the GPS will work again
    - when using GetLocation() called via setTimeout(), the widget will periodically exit outright with no errors displayed

    That said, I have a widget which polls via setTimeout()/GetLocation() and runs ok - and that's using basic data. However, I need the satellite info...

    Any thoughts?

  2. #2
    Registered User
    Join Date
    Sep 2010
    Posts
    13

    Re: WRT and location API - issues

    Well, I thought maybe I'd try the 2.0 location API. Results here are at least more consistent. Calling each of the four available methods I get no error, no error callback and no success callback. Silence. The widget is still alive and well, but the API behaves like a black hole. I'm baffled.

  3. #3
    Regular Contributor
    Join Date
    May 2009
    Location
    sydney
    Posts
    117

    Re: WRT and location API - issues

    reference your PlatformServies 2 js file in your project, location api also very depends on your carriers' signal as it will influence the performance as well, and it is very resource consuming.

  4. #4
    Registered User
    Join Date
    Sep 2010
    Posts
    13

    Re: WRT and location API - issues

    Quote Originally Posted by wenz View Post
    reference your PlatformServies 2 js file in your project
    Ah - thanks for that pointer. It wasn't mentioned in the area of the documentation I was looking at so I'd assumed it was globally available as with v1.0. I've now found the relevant page so I'll try again...

  5. #5
    Registered User
    Join Date
    Sep 2010
    Posts
    13

    Re: WRT and location API - issues

    So I'm more than a little curious now.

    I downloaded the package here and used the platformservices.js file.

    Now I get error 0 (unknown) when calling getCurrentPosition() and watchPosition() - which is a little odd because on modifying the platformservices.js so it outputs the underlying error code, it's 1016, my old friend the timeout error. Fine, although it's unclear why it doesn't return the timeout error code (which it returns for code -33, a value which isn't anything like the listed v1.0 error codes that appear to be coming through). Strangely, though not entirely relevant, nothing in the code ever throws 'POSITION_UNAVAILABLE'.

    Equally bizarre is the fact that getPositionByMethodName() isn't defined in the js file, which explains why calling that in my code fails outright ('the result of expression so.getPositionByMethodName() is not an object').

    I'm sure I must be missing something but no matter how hard I stare at it, it appears the code simply doesn't implement the documented API. (And it seems to be simply a layer that calls the 1.0 API anyway so I doubt it's going to solve my problem.)

  6. #6
    Regular Contributor
    Join Date
    May 2009
    Location
    sydney
    Posts
    117

    Re: WRT and location API - issues

    hi Massive-pebkac,
    umm my recommendation is try nokia's official WRT lng lat app first (somewhere in wiki or sample codes), make sure you can get the right lng lat data on your handset first,
    for debuging, you can try to use an excellent signal sim card and turn your phone to online mode, and if there is a time-out occures you could try to extend the timeout by adjusting the position object.
    hope it helps.
    if it's not, you can post your code here

    Chrs,
    Wenz

  7. #7
    Registered User
    Join Date
    Sep 2010
    Posts
    13

    Re: WRT and location API - issues

    Ok, here's the code. With this exact code I can reproduce two of the above issues:

    - clicking the 'poll' button can cause the application to simply terminate (this occurs on about 50% of presses)
    - using the 'start' button will cause satellite details to never be returned

    Note re the second point that I am fairly certain it is actually using satellite data since (a) I can test this in a position where I've already obtained a good satellite lock by other means, eg Ovi Maps or by using the poll button, and (b) the co-ordinates it returns are non-constant and have small variations, characteristic of standard GPS error (when there is no satellite lock, I get a constant - and by now recognisable - pair of co-ordinates derived from network data).

    So far I've not observed the issue of halting on a timeout error with this exact code, but I'll check this later today and post again if I see it.

    Note also that you'll need Prototype (or to change the $ calls to standard Javascript DOM calls).

    index.xhtml:

    Code:
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
      <head>
        <title>H1</title>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
        <script language="javascript" type="text/javascript" src="prototype.js"></script>
        <script language="javascript" type="text/javascript" src="index.js"></script>
        <style>
            body {
                font-size: 30px;
            }
            button {
                display: block;
                width: 320px;
                height: 50px;
                margin-bottom: 10px;
            }
        </style>
      </head>
      <body onload="init();">
          <button id="start-button" onclick="start();">Start</button>
          <button id="stop-button" onclick="stop();">Stop</button>
          <button id="poll-button" onclick="poll();">Poll</button>
        <p id="call-status"></p>
        <p id="gps-status"></p>
      </body>
    </html>
    index.js:

    Code:
    var so;
    
    function init() {
        try {
            so = device.getServiceObject("Service.Location", "ILocation");
            $('call-status').update(so ? 'service obtained ok' : 'no service');
        }
        catch (e) {
            alert(e);
        }
    }
    
    function start() {
        try {
            var criteria = {
                LocationInformationClass : 'GenericLocationInfo',
                Updateoptions : {
                    PartialUpdates : false
                }
            };
            $('call-status').update('started trace');
            so.ILocation.Trace(criteria, gpsCallback);
        }
        catch (e) {
            $('call-status').update('start trace error: ' + e);
        }
    }
    
    function stop() {
        try {
            var criteria = {
                CancelRequestType : 'TraceCancel'
            };
            $('call-status').update('stopping trace');
            so.ILocation.CancelNotification(criteria);
            $('call-status').update('trace stopped');
        }
        catch (e) {
            $('call-status').update('stop trace error: ' + e);
        }
    }
    
    function poll() {
        try {
            var criteria = {
                LocationInformationClass : 'GenericLocationInfo',
                Updateoptions : {
                    PartialUpdates : false
                }
            };
            $('call-status').update('polling...');
            so.ILocation.GetLocation(criteria, gpsCallback);
        }
        catch (e) {
            $('call-status').update('poll error: ' + e);
        }
    }
    
    function gpsCallback(transId, eventCode, result) {
        try {
            $('call-status').update('returned code ' + eventCode + ' at ' + new Date().getTime());
            $('gps-status').update('');
            if (result.ErrorCode) {
                $('gps-status').update('err: ' + result.ErrorCode);
            }
            if (eventCode != 4) {
                $('gps-status').update('pos: ' + result.ReturnValue.Longitude.toFixed(6) + ', ' + result.ReturnValue.Latitude.toFixed(6) + '<br/>sats: ' + result.ReturnValue.SatelliteNumViewUsed);
            }
        }
        catch (e) {
            $('gps-status').update('gpsCallback error: ' + e);
        }
    }
    info.plist:

    Code:
    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE plist PUBLIC "-//Nokia//DTD PLIST 1.0//EN" "http://www.nokia.com/DTDs/plist-1.0.dtd">
    <plist version="1.0">
        <dict>
    
            <key>DisplayName</key>
            <string>H1</string>
    
            <key>Identifier</key>
            <string>com.stewartpratt.wrt.h1</string>
    
            <key>Version</key>
            <string>0.1</string>
    
            <key>MainHTML</key>
            <string>index.xhtml</string>
    
            <key>MiniViewEnabled</key>
            <false/>
    
            <key>AllowNetworkAccess</key>
            <true/>
    
        </dict>
    </plist>
    Last edited by massive-pebkac; 2010-09-21 at 09:12.

  8. #8
    Registered User
    Join Date
    Sep 2010
    Posts
    13

    Re: WRT and location API - issues

    Ok, I tested the widget again this morning. I appear to be unable to reduce the "timeout prevents further readings" issue.

    However, I did observe a new one. At one point the lon/lat values started coming back as NaN, and once this occurred they did not recover. I haven't been able to reproduce this so I can't confirm any indication of possible cause or whether it would recover after an extensive wait, etc. I've no idea if this is expected behaviour - I don't recall any mention of it in the documentation, let alone what circumstances might cause it.

  9. #9
    Registered User
    Join Date
    Sep 2010
    Posts
    13

    Re: WRT and location API - issues

    FWIW I have now installed firmware version 40.0.005 and am still seeing the same issues.

    Can anyone else reproduce them? At the moment I have two applications I want to write and these issues prevent me from doing so (one needs the satellite information, the other needs to be able to make single calls to get the location).

  10. #10
    Registered User
    Join Date
    Sep 2010
    Posts
    13

    Re: WRT and location API - issues

    And still failing in 50.0.005.

  11. #11
    Regular Contributor
    Join Date
    May 2009
    Location
    sydney
    Posts
    117

    Cool Re: WRT and location API - issues

    Try this to get the gps lng lat data..
    Code:
    	try {
    			var serviceObj = nokia.device.load("geolocation");
    			SetUserLocation();
    		} 
    		catch (e) 
    		{
    			var error = e.toString();
    			alert(error);
    		}
    
    function SetUserLocation() {
        try {	
    		positionOpts = {
                timeout: 20000,
                maximumAge: 1000
            };
    		
    		serviceObj.getCurrentPosition(showCurrentUserLocation, error_callback, positionOpts);    
    	}
        catch (e) {
            DEBUG(e);
        }
    }
    /*location callbacks*/
    function error_callback(p) {
         //error msg
    	}
    }
    
    function showCurrentUserLocation(p) {
        try {
    			alert(p.coords.latitude + " :" +p.coords.longitude);
                }
     catch (e) {
            alert(e);
        }
    chrs,
    Wen
    Last edited by wenz; 2010-10-01 at 00:56.

  12. #12
    Registered User
    Join Date
    Sep 2010
    Posts
    13

    Re: WRT and location API - issues

    Quote Originally Posted by wenz View Post
    Try this to get the gps lng lat data..
    Thanks - although that's a chunk of something larger so I can't run it verbatim. I do already have some code which makes the same 2.0 call, though, and I do get the occasional crashing issue.

    I've given up with the 2.0 API. It only calls the 1.0 API anyway, and since the actual implementation obfuscates the error codes and doesn't implement its published API, it's just layering more problems on top of the existing ones.

    It the 1.0 API holds up fine if I request basic data via Trace(), so I shall stick to that for now and work around not having any additional data.

Similar Threads

  1. Location API Issues on Nokia5800 Xpress Music
    By KevinBoyd in forum Mobile Java General
    Replies: 9
    Last Post: 2011-01-09, 20:19
  2. Replies: 1
    Last Post: 2010-05-30, 13:03
  3. Issues with Location API on 5800Xpress Music
    By KevinBoyd in forum Mobile Java General
    Replies: 0
    Last Post: 2009-09-20, 10:54
  4. ContentPanel issues wrt Toolkit
    By subbiswas in forum Symbian
    Replies: 3
    Last Post: 2009-05-25, 12:51
  5. Several issues developing on WRT 1.0
    By alexheyd in forum Symbian
    Replies: 0
    Last Post: 2009-01-23, 22:00

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
×