Changeset d6b17fe in subsurface


Ignore:
Timestamp:
Jul 4, 2017, 7:46:07 AM (2 weeks ago)
Author:
Dirk Hohndel <dirk@…>
Branches:
master
Children:
709c1df
Parents:
6031692
git-author:
Jan Mulder <jlmulder@…> (07/03/17 12:21:02)
git-committer:
Dirk Hohndel <dirk@…> (07/04/17 07:46:07)
Message:

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@…>

Location:
core
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • core/qt-ble.cpp

    r6031692 rd6b17fe  
    5858void BLEObject::characteristcStateChanged(const QLowEnergyCharacteristic &c, const QByteArray &value)
    5959{
    60         Q_UNUSED(c)
    61 
    62         receivedPackets.append(value);
     60        if (device_is_hw(device)) {
     61                if (c.uuid() == hwAllCharacteristics[HW_OSTC_BLE_DATA_TX]) {
     62                        receivedPackets.append(value);
     63                } else {
     64                        qDebug() << "ignore packet from" << c.uuid() << value.toHex();
     65                }
     66        } else {
     67            receivedPackets.append(value);
     68        }
     69        //qDebug() << ".. incoming packet count" << receivedPackets.length();
     70}
     71
     72void BLEObject::characteristicWritten(const QLowEnergyCharacteristic &c, const QByteArray &value)
     73{
     74        if (device_is_hw(device)) {
     75                if (c.uuid() == hwAllCharacteristics[HW_OSTC_BLE_CREDITS_RX]) {
     76                        qDebug() << "HW_OSTC_BLE_CREDITS_RX confirmed" << c.uuid() << value.toHex();
     77                        isCharacteristicWritten = true;
     78                }
     79        } else {
     80                qDebug() << "BLEObject::characteristicWritten not supposed to fire. Now HW only function";
     81        }
    6382}
    6483
     
    6887        Q_UNUSED(value)
    6988
    70         qDebug() << "BLE write completed";
     89        qDebug() << "BLE write completed on" << d.name() <<  d.value();
    7190}
    7291
     
    96115                connect(service, &QLowEnergyService::stateChanged, this, &BLEObject::serviceStateChanged);
    97116                connect(service, &QLowEnergyService::characteristicChanged, this, &BLEObject::characteristcStateChanged);
     117                connect(service, &QLowEnergyService::characteristicWritten, this, &BLEObject::characteristicWritten);
    98118                connect(service, &QLowEnergyService::descriptorWritten, this, &BLEObject::writeCompleted);
    99119                service->discoverDetails();
  • core/qt-ble.h

    r6031692 rd6b17fe  
    3030        void serviceStateChanged(QLowEnergyService::ServiceState s);
    3131        void characteristcStateChanged(const QLowEnergyCharacteristic &c, const QByteArray &value);
     32        void characteristicWritten(const QLowEnergyCharacteristic &c, const QByteArray &value);
    3233        void writeCompleted(const QLowEnergyDescriptor &d, const QByteArray &value);
    3334        int setupHwTerminalIo(QList<QLowEnergyCharacteristic>);
Note: See TracChangeset for help on using the changeset viewer.