From 7d8fed4eee77ed8e011762bde6f5691f0fa81f39 Mon Sep 17 00:00:00 2001 From: Linus Torvalds Date: Mon, 12 Sep 2011 10:37:54 -0700 Subject: [PATCH] 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 --- libdivecomputer.c | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/libdivecomputer.c b/libdivecomputer.c index c95e02a..c08b117 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 -- 2.45.2