summaryrefslogtreecommitdiffstats
path: root/core
diff options
context:
space:
mode:
authorGravatar Jan Mulder <jlmulder@xs4all.nl>2017-07-11 13:29:41 +0200
committerGravatar Jan Mulder <jlmulder@xs4all.nl>2017-07-11 13:29:41 +0200
commitb409e9fc91d87bbd5f88c53cf937cf73a66821f4 (patch)
tree7c0b9b85166b11e8b34772a99ce9d291d3e91c4e /core
parentb7057c414fc43bb81fc0d01bc07f32d18bce8ab0 (diff)
downloadsubsurface-b409e9fc91d87bbd5f88c53cf937cf73a66821f4.tar.gz
BLE read: remove aggressive read
Commit 709c1df2af4b87 introduced a hard blocking read for BLE devices. This did break BLE reads from multiple DCs, and (in hindsight) was not a correct implementation. It would require, for example, dynamic read buffers as especially profile data grows with dive time, and in addition, and more importantly, also the OSTC libdc parser cannot process the entire profile of a dive at once (but likes to receive it in 1K blocks). So, basically, it introduced issues, and did not solve the OSTC read. This commit reverts this hard blocking read (and as such will break OSTC BLE reads). But it enables removal of the special cases for the EON Steel and G2. A next commit will solve OSTC BLE reads. Signed-off-by: Jan Mulder <jlmulder@xs4all.nl>
Diffstat (limited to 'core')
-rw-r--r--core/qt-ble.cpp37
1 files changed, 7 insertions, 30 deletions
diff --git a/core/qt-ble.cpp b/core/qt-ble.cpp
index 7afdf484b..a8002b49b 100644
--- a/core/qt-ble.cpp
+++ b/core/qt-ble.cpp
@@ -27,8 +27,6 @@ static int debugCounter;
#define IS_HW(_d) same_string((_d)->vendor, "Heinrichs Weikamp")
#define IS_SHEARWATER(_d) same_string((_d)->vendor, "Shearwater")
-#define IS_EON_STEEL(_d) same_string((_d)->product, "EON Steel")
-#define IS_G2(_d) same_string((_d)->product, "G2")
#define MAXIMAL_HW_CREDIT 255
#define MINIMAL_HW_CREDIT 32
@@ -189,38 +187,17 @@ dc_status_t BLEObject::read(void *data, size_t size, size_t *actual)
if (receivedPackets.isEmpty())
return DC_STATUS_IO;
- int offset = 0;
- while (!receivedPackets.isEmpty()) {
- /*
- * Yes, two while loops with same condition seems strange. The inner one
- * does the real work, but it prevents the QtEventloop to do its thing.
- * As the incoming packets arrive based on signals and slots, that
- * stuff is not handeled during the inner loop. So, add a short waitFor
- * between the inner and outer while loop.
- */
- while (!receivedPackets.isEmpty()) {
- QByteArray packet = receivedPackets.takeFirst();
+ QByteArray packet = receivedPackets.takeFirst();
- if (IS_SHEARWATER(device))
- packet.remove(0,2);
+ if (IS_SHEARWATER(device))
+ packet.remove(0,2);
- //qDebug() << ".. read (packet.length, contents, size)" << packet.size() << packet.toHex() << size;
+ if (packet.size() > size)
+ return DC_STATUS_NOMEMORY;
- if ((offset + packet.size()) > size) {
- qDebug() << "BLE read trouble, receive buffer too small";
- return DC_STATUS_NOMEMORY;
- }
+ memcpy((char *)data, packet.data(), packet.size());
+ *actual += packet.size();
- memcpy((char *)data + offset, packet.data(), packet.size());
- offset += packet.size();
- *actual += packet.size();
- // EON Steel wants to read only one packet at a time
- if (IS_EON_STEEL(device) || IS_G2(device))
- goto we_are_done;
- }
- waitFor(50); // and process some Qt events to see if there is more data coming in.
- }
-we_are_done:
return DC_STATUS_SUCCESS;
}