×

Discussion Board

Results 1 to 3 of 3
  1. #1
    Registered User
    Join Date
    Mar 2003
    Posts
    5

    Cannot upload via urllib and read from bluetooth

    I am trying to extend the basic GPS logger from http://gagravarr.org/code/show_nmea_location.py so that it also uploads NMEA sentences via HTTP. This is so that I can track the phone's location from a website.

    However, I have found strange problems when I try to add this ability: the phone prompts for an internet connection as expected, and uploads the first sentence without any problem. However, it then 'hangs' after a seemingly random number of uploads, and furthermore, seems to do this in the part of the code that is due doing the reading from the GPS, not in the bit that is doing the upload.

    The code I have added is as follows:

    postdata = urllib.urlencode({'line' : data})
    fh = urllib.urlopen(URL, postdata)
    fh.close()

    where data is the NMEA sentence, and URL is a remote URL.

    If I remove this code, the script logs without any problems.

    Equally, I have tested the urllib part of it by reading from a logfile previously generated by the GPS, and it will upload everything without complaint - it just seems to be the combination of reading from the GPS via Bluetooth and doing the uploads via urllib that seems to cause this unpredictable behaviour.

    So... does anybody have any idea what could be wrong?

    Failing that (or even as well as ), does anybody know of another script which will read from a GPS via bluetooth and periodically upload results to the internet?

    Many thanks.

    -Tristan.

  2. #2
    Nokia Developer Champion
    Join Date
    Feb 2008
    Location
    Ahmedabad, Gujarat, India
    Posts
    3,852

    Re: Cannot upload via urllib and read from bluetooth

    hi tristanr
    plz look at here and it can explain how to upload the data to a webserver in detail hope it helps you.
    feel free to feedback
    Last edited by gaba88; 2008-04-25 at 16:28.

  3. #3
    Super Contributor
    Join Date
    Mar 2003
    Location
    Espoo, Finland
    Posts
    976

    Re: Cannot upload via urllib and read from bluetooth

    Quote Originally Posted by tristanr View Post
    phone prompts for an internet connection as expected, and uploads the first sentence without any problem. However, it then 'hangs' after a seemingly random number of uploads
    ...
    tested the urllib part of it by reading from a logfile previously generated by the GPS, and it will upload everything without complaint
    Don't know a thing about GPS or bluetooth, not yet

    Access point have an internal time-out, which is a few minutes. How often do you sent data to server? Your test with pre-recorded data most likely ignores all the waiting times and just sends everything as fast as possible?

    HTTP sessions can time-out, too. The latter can be solved by using keep-alive, which by default is supposed to be 2 hours at server-side, but I recall we had to send it a lot more frequently.

    Solution proposal: make sure there is some data traffic about once a minute. That should prevent both time-outs.

    Cheers,

    --jouni

Similar Threads

  1. Replies: 3
    Last Post: 2006-05-02, 20:12

Posting Permissions

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