Gypsy Reference Manual | ||||
---|---|---|---|---|
GypsyDevice; #define GYPSY_DEVICE_DBUS_SERVICE #define GYPSY_DEVICE_DBUS_INTERFACE enum GypsyDeviceFixStatus; GypsyDevice* gypsy_device_new (const char *object_path); gboolean gypsy_device_get_connection_status (GypsyDevice *device, GError **error); GypsyDeviceFixStatus gypsy_device_get_fix_status (GypsyDevice *device, GError **error); gboolean gypsy_device_start (GypsyDevice *device, GError **error); gboolean gypsy_device_stop (GypsyDevice *device, GError **error);
"connection-changed" : Run First / No Recursion "fix-status-changed" : Run First / No Recursion
GypsyDevice is used whenever the client program wishes to know about changes in the device's status. It has signals for connection status and fix status. It can also be used to tell gypsy-daemon to start or stop parsing sentences from the GPS device.
A GypsyDevice object is created using gypsy_device_new()
using the D-Bus path of
the GPS device. This path is returned from the gypsy_control_create()
function. The client can start the GPS data stream with gypsy_device_start()
,
stop it with gypsy_device_stop()
, or find out about the status with
gypsy_device_get_fix_status()
and gypsy_device_get_connection_status()
.
As the fix status and connection status change, GypsyDevice will emit the fix-status-changed and connection-changed signals respectively.
GypsyDevice *device; GError *error = NULL; . . . / * path comes from the gypsy_control_create() function * / device = gypsy_device_new (path); g_signal_connect (device, "connection-changed", G_CALLBACK (connection_changed), NULL); gypsy_device_start (device, &error); if (error != NULL) { g_warning ("Error starting GPS: %s", error->message); g_error_free (error); } . . . static void connection_changed (GypsyDevice *device, gboolean connected, gpointer data) { g_print ("Connection status: %s\n", connected ? "Connected" : "Disconnected"); }
#define GYPSY_DEVICE_DBUS_SERVICE "org.freedesktop.Gypsy"
A define containing the address of the Device service
#define GYPSY_DEVICE_DBUS_INTERFACE "org.freedesktop.Gypsy.Device"
A define containing the name of the Device interface
typedef enum { GYPSY_DEVICE_FIX_STATUS_INVALID = 0, GYPSY_DEVICE_FIX_STATUS_NONE, GYPSY_DEVICE_FIX_STATUS_2D, GYPSY_DEVICE_FIX_STATUS_3D } GypsyDeviceFixStatus;
An enum representing the various fix states that a GPS device can be in.
GypsyDevice* gypsy_device_new (const char *object_path);
Creates a new GypsyDevice that points to object_path
object_path : |
Object path to the device |
Returns : | A pointer to a GypsyDevice |
gboolean gypsy_device_get_connection_status (GypsyDevice *device, GError **error);
Obtains the connection status of device
.
device : |
A GypsyDevice |
error : |
A pointer to a GError to return an error in. |
Returns : | TRUE if the device is connected, FALSE otherwise. |
GypsyDeviceFixStatus gypsy_device_get_fix_status (GypsyDevice *device, GError **error);
Obtains the current fix status of device
.
device : |
A GypsyDevice |
error : |
A pointer to a GError to return a error in. |
Returns : | A GypsyDeviceFixStatus |
gboolean gypsy_device_start (GypsyDevice *device, GError **error);
Starts the connection to the physical device pointed to by device
, and
listens for incoming messages.
device : |
A GypsyDevice |
error : |
A pointer to a GError to return the error in |
Returns : | TRUE on success, FALSE otherwise. |
gboolean gypsy_device_stop (GypsyDevice *device, GError **error);
Stops the physical device pointed to by device
.
device : |
A GypsyDevice |
error : |
A pointer to a GError to return the error in |
Returns : | TRUE on success, FALSE otherwise. |
void user_function (GypsyDevice *connected, gboolean arg1, gpointer user_data) : Run First / No Recursion
The ::connection-changed signal is emitted whenever the device connection changes.
connected : |
Whether or not the device is connected |
user_data : |
user data set when the signal handler was connected. |
void user_function (GypsyDevice *fix_status, gint arg1, gpointer user_data) : Run First / No Recursion
The ::fix-status-changed signal is emitted whenever the GPS device
reports that its fix status has changed. fix_status
is a
GypsyDeviceFixStatus
fix_status : |
The new fix status |
user_data : |
user data set when the signal handler was connected. |