×

Discussion Board

Results 1 to 2 of 2
  1. #1
    Registered User
    Join Date
    Oct 2006
    Location
    Bergen, Norway
    Posts
    2

    GPS data via bluetooth

    Hei.
    Jeg har en Nokia N73 telefon og en bluetooth GPS-modul (GlobalSat Bluetooth pocket GPS, BT-328) som jeg ønsker å bruke sammen.

    Den følgende kodesnutten tar i mot GPS data via bluetooth, og lagrer disse til lokal fil på telefonen, men programmet stopper etter en stund (før (time.time() - startTime) < 1000).

    Hva er riktig måte å lese ut data fra en slik seriell forbindelse? Tegn for tegn, linje for linje, eller mer?

    Dag Magne



    Code:
    #!/usr/bin/env python
    
    import socket
    import time
    import sys
    
    # Default bluetooth address to connect to
    # If blank, will prompt you to pick one
    def_gps_addr='00:0d:b5:33:6a:fb'
    gps_addr = ''
    
    bt_sock=socket.socket(socket.AF_BT, socket.SOCK_STREAM)
    
    if not def_gps_addr == '':
      gps_addr = def_gps_addr
      target=(gps_addr,1) 
      print "Will connect to the GPS" + str(gps_addr)
    else:
      # Prompt them to select a bluetooth GPS
      gps_addr,services=socket.bt_discover()
      target=(gps_addr,services.values()[0])
    
    # Connect to the bluetooth GPS using the serial service
    bt_sock.connect(target)
    print "Connected to the GPS"
    
    tempfilename = 'c:/Data/Python/gpslogg.txt'
    filehandle = open ( tempfilename, 'a' ) 
    
    startTime = time.time()
    try:
      while (time.time() - startTime) < 1000:
        data = bt_sock.recv(200)
        print len(data)
        filehandle.write(data)
    
    except Exception, e:
      print e
    
    filehandle.close()  
    bt_sock.close()

  2. #2
    Registered User
    Join Date
    Oct 2006
    Location
    Bergen, Norway
    Posts
    2

    Re: GPS data via bluetooth

    Sorry for posting in Norwegian.

    I have a Nokia N73 and a bluetooth GPS device, and a small python script for reading GPS info from the device and store to a local file on the phone.
    But this script sometimes stops, (before (time.time() - startTime) > 1000), and I wonder if I am reading data correctly.

    What is the best/correct way of reading data from such a bluetooth (serial?) connection? Character by character? Line by line? Or more like I do trying to read 200 characters at a time?

    I guess the GPS is writing data continously into the serial connection from its side...

Similar Threads

  1. J2ME -> Bluetooth GPS
    By dav_coleman in forum Bluetooth Technology
    Replies: 10
    Last Post: 2007-11-25, 11:30
  2. How to translate binary data form pc to mobile via bluetooth
    By mjsteed in forum Bluetooth Technology
    Replies: 0
    Last Post: 2006-03-17, 17:34
  3. Bluetooth - transfering data to different devices
    By melas21 in forum Mobile Java Networking & Messaging & Security
    Replies: 0
    Last Post: 2005-09-06, 15:04
  4. GPS - Bluetooth connection problem
    By can_bal99 in forum Symbian Networking & Messaging (Closed)
    Replies: 2
    Last Post: 2005-08-22, 13:11
  5. How to connect to Bluetooth GPS receiver from Nokia 3650
    By spider_net in forum Bluetooth Technology
    Replies: 0
    Last Post: 2003-08-14, 18:59

Posting Permissions

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