]> git.tdb.fi Git - ext/subsurface.git/commitdiff
More libdivecomputer boilerplate stuff
authorLinus Torvalds <torvalds@linux-foundation.org>
Mon, 12 Sep 2011 17:37:54 +0000 (10:37 -0700)
committerLinus Torvalds <torvalds@linux-foundation.org>
Mon, 12 Sep 2011 17:37:54 +0000 (10:37 -0700)
.. 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>
libdivecomputer.c

index c95e02ac442131767d9a91b6dbfe90d03d845006..c08b1175fe42654e1aa4b2c128b41c39e7b885d7 100644 (file)
@@ -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