From 348387c6f68c6299facd97aa6d76fe6b6a749e4a Mon Sep 17 00:00:00 2001 From: Dirk Hohndel Date: Tue, 11 Sep 2018 21:30:45 -0700 Subject: [PATCH] Shearwater PNF support: fall back to default logbook style On Android we appear to mis-interpret the response to the RDBI command. Instead of failing, fall back to the default value (PNF for Teric, Predator-like for everything else). With this I can successfully download dive data from my Teric on Android. Signed-off-by: Dirk Hohndel --- src/shearwater_petrel.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/shearwater_petrel.c b/src/shearwater_petrel.c index 67a3bbc..f71a89f 100644 --- a/src/shearwater_petrel.c +++ b/src/shearwater_petrel.c @@ -263,25 +263,27 @@ shearwater_petrel_device_foreach (dc_device_t *abstract, dc_dive_callback_t call return rc; } unsigned int base_addr = array_uint_be (dc_buffer_get_data (buffer), dc_buffer_get_size (buffer)); + INFO(abstract->context, "RDBI command completed with %d bytes, evaluated as %08x", dc_buffer_get_size (buffer), base_addr); base_addr &= 0xFF000000u; switch (base_addr) { case 0xDD000000: // Predator or Predator-Like Format // on a Predator, use the old format, otherwise use the Predator-Like Format (what we called Petrel so far) if (model != PREDATOR) - base_addr = 0xC0000000; + base_addr = 0xC0000000u; break; case 0x90000000: // some firmware versions supported an earlier version of PNF without final record // use the Predator-Like Format instead - base_addr = 0xC0000000; + base_addr = 0xC0000000u; break; case 0x80000000: // new Petrel Native Format with final record // that's the correct address break; default: // unknown format - ERROR (abstract->context, "Unknown logbook format %08x", base_addr); - dc_buffer_free (buffer); - dc_buffer_free (manifests); - return DC_STATUS_UNSUPPORTED; + // use the defaults for the models + if (model >= TERIC) + base_addr = 0x80000000u; + else + base_addr = 0xC0000000u; } // Read the manifest pages