aboutsummaryrefslogtreecommitdiffstats
path: root/core/uemis-downloader.c
AgeCommit message (Collapse)Author
2018-01-31uemis: code refactoringGravatar Oliver Schwaneberg
- Variable max_deleted_seen had no effect and is removed. - Results of read/write operations are evaluated to assert success and to prevent compiler warnings. Signed-off-by: Oliver Schwaneberg <oliver.schwaneberg@gmail.com>
2018-01-31uemis: Fix mapping of object_ids to dive numbersGravatar Oliver Schwaneberg
When performing a factory reset to an uemis, the object_ids within the divelog will not be reset. Nevertheless, the dive numbers are reset to 1. So, the first log will have a positive offset n to the first dive number. The uemis-downloader used the object_id from the logs as a start point for getDive, if dives were already synced before. This causes the sync to stall. I prevent this by subtracting the lowest object_id from the requested before using it as dive number. Signed-off-by: Oliver Schwaneberg <oliver.schwaneberg@gmail.com>
2018-01-27uemis: speed up synchronisation of same divesitesGravatar Oliver Schwaneberg
uemis-downloader downloads the dive spot for each dive, even if the same location was already downloaded before within the ongoing synchronization run. I modified the function "get_uemis_divespot" to remember all requested divespot_ids and their mapping to uuids. New helper functions: - static void erase_divespot_mapping() - static void add_to_divespot_mapping(int divespot_id, uint32_t dive_site_uuid) - static bool is_divespot_mappable(int divespot_id) - static uint32_t get_dive_site_uuid_by_divespot_id(int divespot_id) The memory leak is removed through the call of erade_divespot_mapping(). Signed-off-by: Oliver Schwaneberg <oliver.schwaneberg@gmail.com>
2018-01-19Checking for ACK for getDive.Gravatar Oliver Schwaneberg
get_matching_dive does not check if the DC wrote an acknowledgement for the requested dive. As result, the sync stalls if dive number 0 is not available. Signed-off-by: Oliver Schwaneberg <oliver.schwaneberg@gmail.com>
2018-01-11Use helper function empty_string() instead of manual checksGravatar Berthold Stoeger
For code consistency, substitute boolean expressions: s && *s -> !empty_string(s) s && s[0] -> !empty_string(s) !s || !*s -> empty_string(s) !s || !s[0] -> empty_string(s) Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-01-06Trivial: remove redundant declarations of downloadTableGravatar Berthold Stoeger
downloadTable was declared twice in "dive.h". Remove one occurence. Moreover, "uemis-downloader.c" also declared downloadTable. This can likewise be removed, because "uemis-downloader.c" indirectly includes "dive.h". Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2017-12-30Cleanup: consistently handle file open failuresGravatar Dirk Hohndel
In part based on Coverity CID 45129 Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2017-12-30Cleanup: fix memory leakGravatar Dirk Hohndel
Oops, I previously fixed only one of two instances. Coverity CID 45078 Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2017-12-27Cleanup: avoid memory leakGravatar Dirk Hohndel
Coverity CID 45078 Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2017-12-26Cleanup: avoid out of bounds accessGravatar Dirk Hohndel
sizeof() is clearly the wrong way to get to the size of that array... Coverity CID 208294 Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2017-07-17Resolve type confusionGravatar Dirk Hohndel
No idea why this now shows up as an error in the iOS build. We need to refer to the typedef, not the underlying struct. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2017-06-27Switch over to SSRF_CUSTOM_IO v2Gravatar Linus Torvalds
I hate changing the IO interfaces this often, but when I converted the custom serial interface to the more generic custom IO interface, I intentionally left the legacy serial operations alone, because I didn't want to change something I didn't care about. But it turns out that leaving them with the old calling convention caused extra problems when converting the bluetooth serial code to have the BLE GATT packet fall-back, which requires mixing two kinds of operations. Also, the packet_open() routine was passed a copy of the 'dc_context_t', which makes it possible to update the 'dc_custom_io_t' field on the fly at open time. That makes a lot of chaining operations much simpler, since now you can chain the 'custom_io_t' at open time and then libdivecomputer will automatically call the new routines instead of the old ones. That dc_context_t availability gets rid of all the if (device && device->ops) return device->ops->serial_xyz(..); hackery inside the rfcomm routines - now we can just at open time do a simple dc_context_set_custom_io(context, &ble_serial_ops); to switch things over to the BLE version of the serial code instead. Finally, SSRF_CUSTOM_IO v2 added an opaque "dc_user_device_t" pointer argument to the custom_io descriptor, which gets filled in as the custom_io is registered with the download context. Note that unlike most opaque pointers, this one is opaque to *libdivecomputer*, and the type is supposed to be supplied by the user. We define the "dc_user_device_t" as our old "struct device_data_t", making it "struct user_device_t" instead. That means that the IO routines now get passed the device info showing what device they are supposed to download for. That, in turn, means that now our BLE GATT open code can take the device type it opens for into account if it wants to. And it will want to, since the rules for Shearwater are different from the rules for Suunto, for example. NOTE! Because of the interface change with libdivecomputer, this will need a flag-day again where libdivecomputer and subsurface are updated together. It may not be the last time, either. Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2017-05-27Separate the download thread from the widget logicGravatar Tomaz Canabrava
This is important to not duplicate code for the Qml view. Now the DownloadFromDiveComputer widget is mostly free from important code (that has been upgraded to the core folder), and I can start coding the QML interface. There are still a few functions on the desktop widget that will die so I can call them via the QML code later. I also touched the location of a few globals (please, let's stop using those) - because it was declared on the desktop code and being used in the core. Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2017-04-29Add SPDX header to core C filesGravatar Dirk Hohndel
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2017-03-11Merge branch 'master' of https://github.com/dje29/subsurfaceGravatar Dirk Hohndel
2017-03-11divespot > dive spotGravatar Martin Měřinský
2017-03-11divelog > dive logGravatar Martin Měřinský
2017-03-09Fix potential double/float to int rounding errorsGravatar Jeremie Guichard
Not using lrint(f) when converting double/float to int creates rounding errors. This error was detected by TestParse::testParseDM4 failure on Windows. It was creating rounding inconsistencies on Linux too, see change in TestDiveDM4.xml. Enable -Wfloat-conversion for gcc version greater than 4.9.0 Signed-off-by: Jeremie Guichard <djebrest@gmail.com>
2017-03-08Change calls to rint into lrint avoiding conversion warningsGravatar Jeremie Guichard
Using gcc option "-Wfloat-conversion" is useful to catch potential conversion errors (where lrint should be used). rint returns double and still raises the same warning, this is why this change updates all rint calls to lrint. In few places, where input type is a float, corresponding lrinf is used. Signed-off-by: Jeremie Guichard <djebrest@gmail.com>
2016-04-29Extend time parsing to before 1970Gravatar Linus Torvalds
It turns out that we are starting to have users that have logs that go back that far. It won't be common, but let's get it right anyway. NOTE! With us now supporting dates earlier in 1900, this also makes "utc_mktime()" always add the "1900" to the year field. That way we avoid ever using the fairly ambiguous two-digit shorthand. It didn't use to be all that ambiguous when we knew that any two-digit number less than 70 had to be 2000+. Now that we support going back to earlier in the last centiry, that certainty is eroding. Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-04-04Move subsurface-core to core and qt-mobile to mobile-widgetsGravatar Dirk Hohndel
Having subsurface-core as a directory name really messes with autocomplete and is obviously redundant. Simmilarly, qt-mobile caused an autocomplete conflict and also was inconsistent with the desktop-widget name for the directory containing the "other" UI. And while cleaning up the resulting change in the path name for include files, I decided to clean up those even more to make them consistent overall. This could have been handled in more commits, but since this requires a make clean before the build, it seemed more sensible to do it all in one. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>