mirror of
https://github.com/subsurface/subsurface.git
synced 2024-11-28 05:00:20 +00:00
OSTC over BLE: filter and track OSTC credit traffic
1) As the OSTC sends data to the BLE central role (the SSRF client) over 2 characteristics, we have to filter the administrative credit data from the actual dive data that it received. The characteristcStateChanged function is adapted for this. 2) We have to be sure that the Terminal Client I/O is fully defined during opening the connecton to the OSTC. From 6d505b24f0c15 we can see that the last step in setting up the terminal interface is the grant of credits. This is done by writing to the proper (the only one, with id = 0x2902) descriptor of the credits RX characteristic. The here added slot is triggered on the completion of write of credits marking the final stage of the setup. Signed-off-by: Jan Mulder <jlmulder@xs4all.nl>
This commit is contained in:
parent
6031692a39
commit
d6b17fef08
2 changed files with 24 additions and 3 deletions
|
@ -57,9 +57,28 @@ void BLEObject::serviceStateChanged(QLowEnergyService::ServiceState s)
|
|||
|
||||
void BLEObject::characteristcStateChanged(const QLowEnergyCharacteristic &c, const QByteArray &value)
|
||||
{
|
||||
Q_UNUSED(c)
|
||||
if (device_is_hw(device)) {
|
||||
if (c.uuid() == hwAllCharacteristics[HW_OSTC_BLE_DATA_TX]) {
|
||||
receivedPackets.append(value);
|
||||
} else {
|
||||
qDebug() << "ignore packet from" << c.uuid() << value.toHex();
|
||||
}
|
||||
} else {
|
||||
receivedPackets.append(value);
|
||||
}
|
||||
//qDebug() << ".. incoming packet count" << receivedPackets.length();
|
||||
}
|
||||
|
||||
receivedPackets.append(value);
|
||||
void BLEObject::characteristicWritten(const QLowEnergyCharacteristic &c, const QByteArray &value)
|
||||
{
|
||||
if (device_is_hw(device)) {
|
||||
if (c.uuid() == hwAllCharacteristics[HW_OSTC_BLE_CREDITS_RX]) {
|
||||
qDebug() << "HW_OSTC_BLE_CREDITS_RX confirmed" << c.uuid() << value.toHex();
|
||||
isCharacteristicWritten = true;
|
||||
}
|
||||
} else {
|
||||
qDebug() << "BLEObject::characteristicWritten not supposed to fire. Now HW only function";
|
||||
}
|
||||
}
|
||||
|
||||
void BLEObject::writeCompleted(const QLowEnergyDescriptor &d, const QByteArray &value)
|
||||
|
@ -67,7 +86,7 @@ void BLEObject::writeCompleted(const QLowEnergyDescriptor &d, const QByteArray &
|
|||
Q_UNUSED(d)
|
||||
Q_UNUSED(value)
|
||||
|
||||
qDebug() << "BLE write completed";
|
||||
qDebug() << "BLE write completed on" << d.name() << d.value();
|
||||
}
|
||||
|
||||
void BLEObject::addService(const QBluetoothUuid &newService)
|
||||
|
@ -95,6 +114,7 @@ void BLEObject::addService(const QBluetoothUuid &newService)
|
|||
services.append(service);
|
||||
connect(service, &QLowEnergyService::stateChanged, this, &BLEObject::serviceStateChanged);
|
||||
connect(service, &QLowEnergyService::characteristicChanged, this, &BLEObject::characteristcStateChanged);
|
||||
connect(service, &QLowEnergyService::characteristicWritten, this, &BLEObject::characteristicWritten);
|
||||
connect(service, &QLowEnergyService::descriptorWritten, this, &BLEObject::writeCompleted);
|
||||
service->discoverDetails();
|
||||
}
|
||||
|
|
|
@ -29,6 +29,7 @@ public slots:
|
|||
void addService(const QBluetoothUuid &newService);
|
||||
void serviceStateChanged(QLowEnergyService::ServiceState s);
|
||||
void characteristcStateChanged(const QLowEnergyCharacteristic &c, const QByteArray &value);
|
||||
void characteristicWritten(const QLowEnergyCharacteristic &c, const QByteArray &value);
|
||||
void writeCompleted(const QLowEnergyDescriptor &d, const QByteArray &value);
|
||||
int setupHwTerminalIo(QList<QLowEnergyCharacteristic>);
|
||||
private:
|
||||
|
|
Loading…
Reference in a new issue