Gypsy Reference Manual | ||||
---|---|---|---|---|
GypsyControl; #define GYPSY_CONTROL_DBUS_SERVICE #define GYPSY_CONTROL_DBUS_PATH #define GYPSY_CONTROL_DBUS_INTERFACE GypsyControl* gypsy_control_get_default (void); char* gypsy_control_create (GypsyControl *control, const char *device_name, GError **error);
GypsyControl is the object that controls the gypsy-daemon process.
It is a singleton object, meaning that there can only be one instance of it
per application. Once the object has been created (or referenced if it
had already been created for the application) with
gypsy_control_get_default()
, it can be used to tell gypsy-daemon what GPS
device to connect to with gypsy_control_create()
. This call returns the
D-Bus path to the GPS object in gypsy-daemon. This path is then used to
create other objects, such as GypsyPosition, or GypsyCourse.
As gypsy-daemon is able to connect to multiple GPS devices, the one
GypsyControl can be used to create them, returning a different path for
each GPS device. Gypsy-daemon can connect to both serial port devices which
have an entry in /dev and Bluetooth devices natively without the need to use
rfcomm to set up a /dev entry. To do this you pass either the device path or
the Bluetooth address of the device to gypsy_control_create()
.
Once the program has finished with the GPS, the GypsyControl object should
by unreferenced with g_object_unref()
.
. . . GypsyControl *control; char *path_bt, *path_dev; GError *error = NULL; . . . control = gypsy_control_get_default (); / * Use a Bluetooth device * / path_bt = gypsy_control_create (control, "aa:bb:cc:dd:ee", &error); if (path_bt == NULL) { g_warning ("There was an error creating aa:bb:cc:dd:ee - %s", error->message); g_error_free (error); error = NULL; } / * Use a serial port device * / path_dev = gypsy_control_create (control, "/dev/gps", &error); if (path_dev == NULL) { g_warning ("There was an error creating /dev/gps - %s", error->message); g_error_free (error); error = NULL; } . . . / * Use the paths here to create listener objects * / . . . g_free (path_bt); g_free (path_dev); . . . / * The program has finished with Gypsy now, unref the object. * / g_object_unref (G_OBJECT (control));
#define GYPSY_CONTROL_DBUS_SERVICE "org.freedesktop.Gypsy"
A define containing the address of the control service
#define GYPSY_CONTROL_DBUS_PATH "/org/freedesktop/Gypsy"
A define containing the path to the Gypsy object
#define GYPSY_CONTROL_DBUS_INTERFACE "org.freedesktop.Gypsy.Server"
A define containing the name of the Control interface
GypsyControl* gypsy_control_get_default (void);
Retrieves the default GypsyControl object
Returns : | A singleton GypsyControl |
char* gypsy_control_create (GypsyControl *control, const char *device_name, GError **error);
Creates a device on the server that refers to the gps device at device_name
.
When this object is finalized, the remote object on the server will be
shutdown after which any calls to the object at the returned path
are not guarenteed to work.
control : |
The GypsyControl device |
device_name : |
The path to the device file |
error : |
A GError to return errors in |
Returns : | The path to the created object. |