summaryrefslogtreecommitdiffstats
path: root/libdivecomputer.c
diff options
context:
space:
mode:
authorGravatar Linus Torvalds <torvalds@linux-foundation.org>2011-09-12 10:37:54 -0700
committerGravatar Linus Torvalds <torvalds@linux-foundation.org>2011-09-12 10:37:54 -0700
commit7d8fed4eee77ed8e011762bde6f5691f0fa81f39 (patch)
tree584eab53bb7d984feb3db61154b5f7abb5dbd3bf /libdivecomputer.c
parent6b0bb87f5b1f6495f0d4853f5f71c5774682cc32 (diff)
downloadsubsurface-7d8fed4eee77ed8e011762bde6f5691f0fa81f39.tar.gz
More libdivecomputer boilerplate stuff
.. fill in the event parsing. This doesn't generate the fingerprint like the example does, I just don't care about that yet. Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'libdivecomputer.c')
-rw-r--r--libdivecomputer.c29
1 files changed, 29 insertions, 0 deletions
diff --git a/libdivecomputer.c b/libdivecomputer.c
index c95e02ac4..c08b1175f 100644
--- a/libdivecomputer.c
+++ b/libdivecomputer.c
@@ -222,6 +222,35 @@ static device_status_t device_open(const char *devname,
static void
event_cb (device_t *device, device_event_t event, const void *data, void *userdata)
{
+ const device_progress_t *progress = (device_progress_t *) data;
+ const device_devinfo_t *devinfo = (device_devinfo_t *) data;
+ const device_clock_t *clock = (device_clock_t *) data;
+ device_data_t *devdata = (device_data_t *) userdata;
+
+ switch (event) {
+ case DEVICE_EVENT_WAITING:
+ printf("Event: waiting for user action\n");
+ break;
+ case DEVICE_EVENT_PROGRESS:
+ printf("Event: progress %3.2f%% (%u/%u)\n",
+ 100.0 * (double) progress->current / (double) progress->maximum,
+ progress->current, progress->maximum);
+ break;
+ case DEVICE_EVENT_DEVINFO:
+ devdata->devinfo = *devinfo;
+ printf("Event: model=%u (0x%08x), firmware=%u (0x%08x), serial=%u (0x%08x)\n",
+ devinfo->model, devinfo->model,
+ devinfo->firmware, devinfo->firmware,
+ devinfo->serial, devinfo->serial);
+ break;
+ case DEVICE_EVENT_CLOCK:
+ devdata->clock = *clock;
+ printf("Event: systime=%lld, devtime=%u\n",
+ clock->systime, clock->devtime);
+ break;
+ default:
+ break;
+ }
}
static int