Active Topics

 


Reply
Thread Tools
tz1's Avatar
Posts: 716 | Thanked: 236 times | Joined on Dec 2007
#11
This works. It can be launched from one of the statusbar launchers.

Save to /usr/local/bin/nokasgps or whatever, as perm 755 (probably owned by root). Then just run it (without parameters) to sit and listen for a connection. Pair your Nokia with your device and set up the serial port. It will take a second or two for the NMEA stream to appear. You can kill it when you don't need it, but it will just sit there and wait (maybe with BT on draining the battery a bit faster?).

Code:
#!/bin/sh
if [ $# == 0 ]; then
        sdptool add SP
        while true; do
                rfcomm -r -i hci0 listen 2 1 $0 {}
        done
fi
exec /usr/libexec/navicore-gpsd-helper >$1
Note you will want to use the control panel to insure the location is set to the "Internal GPS" - though it probably would echo a BT GPS unit.

Last edited by tz1; 2008-06-19 at 12:09. Reason: Oops, perm 755
 

The Following 4 Users Say Thank You to tz1 For This Useful Post:
tz1's Avatar
Posts: 716 | Thanked: 236 times | Joined on Dec 2007
#12
It works with Windows XP too. I did have to delete and repair my tablet for it to see the serial port service, but it came up with the serial ports when it was paired. I also did the same thing with my MacBook.

Now to try my n810...
 
Posts: 6 | Thanked: 2 times | Joined on Jun 2008
#13
Thanks tz1!

Your script works just fine. It would seem that the rfcomm program is not installed to OS2008 automatically. All I had to do to fix that issue was to install bluez-utils-test (apt-get install bluez-utils-test).

Now I need to figure out how can I run the script from somewhere else except from the console...
 
tz1's Avatar
Posts: 716 | Thanked: 236 times | Joined on Dec 2007
#14
I use:

http://maemo-hackers.org/wiki/OssoStatusbarCpu

I'd create one command for (path)nokasgps, and maybe another for "killall nokasgps" if you need it.

There is probably a way to start it backgrounded from /etc/init.d/ somewhere.

So far, it doesn't seem to use much power. The tablet looks like it would run about as long as my stand-alone devices.
 
Posts: 7 | Thanked: 1 time | Joined on Jul 2008
#15
The script works when I connect using a serial program.
However, it doesn't work when I connect using a GPS program. on my phone.
Any suggestions?
 

The Following User Says Thank You to Alexl For This Useful Post:
tz1's Avatar
Posts: 716 | Thanked: 236 times | Joined on Dec 2007
#16
Make sure the phone expects "NMEA" streams and isn't looking for a BT garmin or other device. The Nokia also takes time to enable GPS and lock, and your phone's software might not wait long enough or display that the GPS is still searching.

Or your phone isn't properly paired with the n810. You may need to redo the pairing after this is running so it sees the SDP service used by the GPS and not just obex and audio stuff.
 
Posts: 4 | Thanked: 0 times | Joined on Oct 2008
#17
Tz1, I really would like to implement your code to enable the N810 to be used as a GPS module (by my Treo 680 running TomTom nav software).

However, I am a newbie and don't know much about Linux or developing for the 810. Can you please point me to a good intro to get me started? I don't even know where to place the code, if it needs to be compiled or linked or if any additional package is necessary.

I don't want to get into anything fancy, just to be able to set up nice solutions like the one you posted.

Thanks for any help you can provide.
-Mark
 
tz1's Avatar
Posts: 716 | Thanked: 236 times | Joined on Dec 2007
#18
PM me if this doesn't answer.

Any introduction to Linux that includes information on how to use the "command line interface" or "shell" or "shell scripting" would explain what that bit of code I posted does in general terms and how to get it on your system.

Also I was thinking of including this functionality as part of minigpsd (which is smaller, faster, but has lots more features than the stock gpsd). This could be made an installable debian file and run at bootup time, but I want to be a little more careful in not stepping on anything else.
 
Posts: 4 | Thanked: 0 times | Joined on Oct 2008
#19
Thanks for the answer! I'll give it a try. I, for one, would vote for including this functionality in minigpsd, especially if it is an installable debian file.
Regards,
-Mark
 
tz1's Avatar
Posts: 716 | Thanked: 236 times | Joined on Dec 2007
#20
Annotated:

#!/bin/sh The pound sign is treated as a comment. The pair #! tells the system that it is a runnable shell script, and should be passed to the program which follows, in this case "/bin/sh". You can find similar things for python, e.g. /usr/bin/python or /usr/bin/gawk.

if [ $# == 0 ]; then The if/then are basic programming constructs in the shell. The "[" is actually the "test" command (see manpage for test) which processes everything to the closing bracket and returns a value. $# is the number of parameters on the command line. So the statement says do the following section (up to an else or "fi" - fi ends if, esac ends case, they like spelling backwards...


sdptool add SP This is a bluetooth command (from the package bluez-utils-test - search the fora for links) which turns on the SerialProfile, so it can look like it has a serial port.

while true; do
rfcomm -r -i hci0 listen 2 1 $0 {}
done


The while-true just creates an infinite loop. The rfcomm command is another bluetooth utility which listens for a connection then executes a program. In this case $0 which ends up being this same script (with a parameter this time, and the parameter will be the port the bluetooth wants to talk over). It will repeatedly run after disconnecting each session, and a disconnect will kill the script it runs.

fi
exec /usr/libexec/navicore-gpsd-helper >$1


fi ends the if section, and we only come here if there is a parameter, in this case it will be in "$1" which will expand to something like "/dev/rfcomm2". So this will run the navicore-gpsd-helper and the output will go out over the bluetooth serial port.

The "exec" says to overlay the shell process with the command, so instead of having a shell calling an executable with parameters, the shell process becomes the executable with parameters saving resources.
 

The Following 2 Users Say Thank You to tz1 For This Useful Post:
Reply


 
Forum Jump


All times are GMT. The time now is 18:15.