maemo.org - Talk

maemo.org - Talk (https://talk.maemo.org/index.php)
-   Nokia N810 (https://talk.maemo.org/forumdisplay.php?f=28)
-   -   Using N810 as a bluetooth GPS module (https://talk.maemo.org/showthread.php?t=20907)

ledimies 2008-06-12 13:42

Using N810 as a bluetooth GPS module
 
Hello,

I was wondering if it is possible to use the n810 as a bluetooth gps module. I just bought Nokia E51 phone and it has some interesting apllications that would benefit from gps connection (such as sports tracker). I would like to use n810's gps so I wouldn't have to buy a separate bluetooth gps module. Does anyone know if this is possible and, if it is, how?

jakubd 2008-06-12 15:49

Re: Using N810 as a bluetooth GPS module
 
It is definitely doable, but probably not out of the box - you need to make n810 to open service over SPP profile on BT and feed there internal GPS data. Probably it can be done in a simple bash script, but you have two problems:
1. n810 GPS device is just... not the best (especially taking into account time-to-fix)
2. n810 battery might die quite fast
I really think, that buying ANY bluetooth GPS receiver (they are really cheap now) might be just better choice.

ledimies 2008-06-13 05:29

Re: Using N810 as a bluetooth GPS module
 
Great! I don't care about the long time-to-fix, once the fix is aquired it is reliable. I also don't care about the possible battery life problems.

I am sure someone has already done this so I am sure that that someone could shed some details about how this was done.

Thanks!

speculatrix 2008-06-14 23:32

Re: Using N810 as a bluetooth GPS module
 
I would guess that you need to do the following (I don't have an n810 or anything similar)

basically, make a script that "listens" to rfcomm on the tablet and then reads from /dev/gps writing to the bluetooth virtual serial device.. something like this

rfcomm listen 0 "cat /dev/gps > /dev/rfcomm0"


you might need to put the "cat" command into a shell script, e.g.
Code:

$ cat > gps_to_rfcomm
#!/bin/bash
cat /dev/gps > /dev/rfcomm0
^D
$ chmod ugo+x gps_to_rfcomm
$ rfcomm listen 0 gps_to_rfcomm


MOC 2008-06-16 19:44

Re: Using N810 as a bluetooth GPS module
 
I would absolutly love to have this ability too.

So, my fingers are crossed that someone skillful will come up with a solution.

Cheers!

locusf 2008-06-16 20:03

Re: Using N810 as a bluetooth GPS module
 
Quote:

Originally Posted by speculatrix (Post 192158)
I would guess that you need to do the following (I don't have an n810 or anything similar)

basically, make a script that "listens" to rfcomm on the tablet and then reads from /dev/gps writing to the bluetooth virtual serial device.. something like this

rfcomm listen 0 "cat /dev/gps > /dev/rfcomm0"


you might need to put the "cat" command into a shell script, e.g.
Code:

$ cat > gps_to_rfcomm
#!/bin/bash
cat /dev/gps > /dev/rfcomm0
^D
$ chmod ugo+x gps_to_rfcomm
$ rfcomm listen 0 gps_to_rfcomm


Device /dev/gps doesn't exist but /dev/pgps does, I changed it and tried Nokia Maps 2.0 on my E51 but no avail :(.

It seems that the channel needs to be specified as well, does anyone know what is the common channel for this service?

Better yet if someone would post the SDP record for the GPS service on some device so that the UUID of this service could be registered on a certain port and a phone or whatever would find it :).

So theoretically its possible.

tz1 2008-06-18 15:54

Re: Using N810 as a bluetooth GPS module
 
The internal GPS is off by default. You need to send a "P 3" to the control socket to power it up.

The following code (sending "P 3\n") turns it on, P 0 turns it off

Code:

static void sendnokgps(char *cmd)
{
    int n, len;
    struct sockaddr_un igps;
    n = socket(AF_UNIX, SOCK_STREAM, 0);
    if (n >= 0) {
        igps.sun_family = AF_UNIX;
        strcpy(igps.sun_path, "/var/lib/gps/gps_driver_ctrl");
        len = strlen(igps.sun_path) + sizeof(igps.sun_family);
        if (connect(n, (struct sockaddr *) &igps, len) != -1) {
            char buf[4];
            if (!fork()) {      // this can take a while
                write(n, cmd, strlen(cmd));
                read(n, buf, 4);
                close(n);
                exit(0);
            }
            close(n);
        }
    }
}

That will turn the GPS on. You can do it manually with echo "P 3" | socat unix:/var/lib... stdio ## if you have socat.

The next problem is the far endpoint probably doesn't have a serial port, so the "rfcomm connect rfcomm0 11:22:33:44:55:66" will fail, and I don't know how to make the Nokia use an inbound rfcomm off the top of my head (time for google).

If the second obstacle is overcome, "cat /dev/pgps >/dev/rfcomm0" will work.

tz1 2008-06-18 17:10

Re: Using N810 as a bluetooth GPS module
 
Note: I tried a few things, mainly rfcomm from another linux box and they seemed to require a /etc/bluetooth/pin, but it still would not open a serial port across bluetooth. If someone can get rfcomm going so I can do ls >/dev/rfcomm0 on one computer (or the windows/mac equivalent) and cat /dev/rfcomm0 on the tablet (or vice versa) it would help greatly.

I suspect there is no serial port profile (SPP) at one or both ends.

tz1 2008-06-18 17:47

Re: Using N810 as a bluetooth GPS module
 
progress of a sort, on the Nokia:

rfcomm -i hci0 listen 0 "cat /dev/pgps >/dev/rfcomm0"

It listens and connects (and I've paired the devices), but I think I need to change the "cat..." into a shell script. I also need to do a pgps control program.

tz1 2008-06-18 19:22

Re: Using N810 as a bluetooth GPS module
 
Success!

First, create a script to launch the navicore gps control program (make sure it is set to the internal and not a BT gps via the control panel). and make it executable (I call it gpson):

Code:

#!/bin/sh
exec /usr/libexec/navicore-gpsd-helper >$1

Then, make sure you've paired with the other device (in the BT devices list).

(UPDATE!) Advertise a serial port service

Code:

sdptool add SP
Then run:

Code:

rfcomm -i hci0 listen 2 1 ./gpson {}
and then connect from a remote device. You might want to put it into an infinite loop, and or background. Also you might want to try "rfcomm -r -i hci0..." to put it in raw mode.

The navicore-gpsd-helper turns the internal GPS on (if it is selected) and emits NMEA to stdout.

Note: my linux laptop works with rfcomm connect... & cat /dev/rfcommX. I had to tweak my Mac (control panel, bluetooth, edit serial port). I will try Windows later, but adding the service above should make things work.


All times are GMT. The time now is 07:11.

vBulletin® Version 3.8.8