View Single Post
tz1's Avatar
Posts: 716 | Thanked: 236 times | Joined on Dec 2007
#7
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.
 

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