2 * This file is Copyright (c) 2010 by the GPSD project
3 * BSD terms apply: see the file COPYING in the distribution root for details.
7 #include "gpsd_config.h"
11 static DBusConnection *connection = NULL;
14 * Does what is required to initialize the dbus connection
15 * This is pretty basic at this point, as we don't receive commands via dbus.
16 * Returns 0 when everything is OK.
18 int initialize_dbus_connection(void)
22 dbus_error_init(&error);
23 connection = dbus_bus_get(DBUS_BUS_SYSTEM, &error);
24 if (connection == NULL) {
31 void send_dbus_fix(struct gps_device_t *channel)
33 /* sends the current fix data for this channel via dbus */
34 struct gps_data_t *gpsdata;
35 struct gps_fix_t *gpsfix;
37 /*DBusMessageIter iter; */
38 dbus_uint32_t serial; /* collected, but not used */
40 /* this packet format was designed before we split eph */
43 /* if the connection is non existent, return without doing anything */
44 if (connection == NULL)
47 gpsdata = &(channel->gpsdata);
48 gpsfix = &(gpsdata->fix);
49 /* this packet format was designed before we split eph */
50 eph = EMIX(gpsfix->epx, gpsfix->epy);
51 gpsd_devname = gpsdata->dev.path;
53 /* Send the named signel. */
54 message = dbus_message_new_signal("/org/gpsd", "org.gpsd", "fix");
55 dbus_message_append_args(message,
56 DBUS_TYPE_DOUBLE, &(gpsfix->time),
57 DBUS_TYPE_INT32, &(gpsfix->mode),
58 DBUS_TYPE_DOUBLE, &(gpsfix->ept),
59 DBUS_TYPE_DOUBLE, &(gpsfix->latitude),
60 DBUS_TYPE_DOUBLE, &(gpsfix->longitude),
61 DBUS_TYPE_DOUBLE, &(eph),
62 DBUS_TYPE_DOUBLE, &(gpsfix->altitude),
63 DBUS_TYPE_DOUBLE, &(gpsfix->epv),
64 DBUS_TYPE_DOUBLE, &(gpsfix->track),
65 DBUS_TYPE_DOUBLE, &(gpsfix->epd),
66 DBUS_TYPE_DOUBLE, &(gpsfix->speed),
67 DBUS_TYPE_DOUBLE, &(gpsfix->eps),
68 DBUS_TYPE_DOUBLE, &(gpsfix->climb),
69 DBUS_TYPE_DOUBLE, &(gpsfix->epc),
70 DBUS_TYPE_STRING, &gpsd_devname,
72 dbus_message_set_no_reply(message, TRUE);
73 dbus_connection_send(connection, message, &serial);
74 dbus_message_unref(message);
77 #endif /* DBUS_ENABLE */