Code:
#include <QCoreApplication>
#include <QDebug>
extern "C" {
#include <location/location-gps-device.h>
#include <location/location-gpsd-control.h>
}
static void changed(LocationGPSDevice *device, gpointer userdata)
{
Q_UNUSED(userdata);
qDebug() << QString("%1\t%2\t%3\t%4\t%5\t%6\t%7\t%8\t%9\t%10")
.arg(device->fix->time)
.arg(device->fix->ept)
.arg(device->fix->latitude)
.arg(device->fix->longitude)
.arg(device->fix->eph)
.arg(device->fix->speed)
.arg(device->fix->eps)
.arg(device->fix->track)
.arg(device->fix->epd)
.arg(device->satellites_in_use);
}
static void connected(LocationGPSDevice *device, gpointer userdata)
{
Q_UNUSED(device);
Q_UNUSED(userdata);
qDebug() << __PRETTY_FUNCTION__;
}
static void disconnected(LocationGPSDevice *device, gpointer userdata)
{
Q_UNUSED(device);
Q_UNUSED(userdata);
qDebug() << __PRETTY_FUNCTION__;
}
int main(int argc, char *argv[])
{
QCoreApplication app(argc, argv);
LocationGPSDevice *device;
LocationGPSDControl *control;
g_type_init ();
control = location_gpsd_control_get_default();
if (control)
location_gpsd_control_start(control);
device = (LocationGPSDevice*)g_object_new(LOCATION_TYPE_GPS_DEVICE, NULL);
if (device) {
g_signal_connect(device, "changed", G_CALLBACK(changed), 0);
g_signal_connect(device, "connected", G_CALLBACK(connected), 0);
g_signal_connect(device, "disconnected", G_CALLBACK(disconnected), 0);
}
int ret = app.exec();
if (device)
g_object_unref(device);
if (control)
location_gpsd_control_stop(control);
return ret;
}
What would be a log of this test app for you?