mirror of
https://github.com/subsurface/subsurface.git
synced 2025-01-19 14:25:27 +00:00
BLE read: remove aggressive read
Commit 709c1df2af
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>
This commit is contained in:
parent
b7057c414f
commit
b409e9fc91
1 changed files with 7 additions and 30 deletions
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue