On 30-06-17 00:31, Anton Lundin wrote:
I tested this to, against a OSTC4, and I actually got some data back.
It looks scrambled, and haven't had the time to decipher what might
be wrong.
Checked your btle_ostc4.txt and see that you are connecting to the wrong
service. You need to connect to
the service starting with 0000fefb (which is the Stollmann Terminal IO thingy).
And yes, the
current master selects the wrong service, so you have to adapt the code for
that. In addition, you need
to select the proper characteristic to receive notifications. I have added a
patch from Linus (from yesterday)
the takes care of selecting the proper characteristic, and one of mine to
select the proper service (and
mine contains also a lot of debug crap, so be careful if you want to apply
this).
And the bad news is .... with all this I still cannot get downloaded data from
my OSTC3 (but it
selects download mode correctly).
--jan
diff --git a/core/qt-ble.cpp b/core/qt-ble.cpp
index d6a71665..b03783a5 100644
--- a/core/qt-ble.cpp
+++ b/core/qt-ble.cpp
@@ -251,10 +251,17 @@ dc_status_t qt_ble_open(dc_custom_io_t *io, dc_context_t *context, const char *d
/* Enable notifications */
QList<QLowEnergyCharacteristic> list = ble->preferredService()->characteristics();
+ const QLowEnergyCharacteristic *notifyC = NULL, *writeC = NULL;
- if (!list.isEmpty()) {
- const QLowEnergyCharacteristic &c = list.constLast();
- QList<QLowEnergyDescriptor> l = c.descriptors();
+ foreach(const QLowEnergyCharacteristic &c, list) {
+ if (!notifyC && (c.properties() & QLowEnergyCharacteristic::Notify))
+ notifyC = &c;
+ if (!writeC && (c.properties() & (QLowEnergyCharacteristic::WriteNoResponse | QLowEnergyCharacteristic::Write)))
+ writeC = &c;
+ }
+
+ if (notifyC) {
+ QList<QLowEnergyDescriptor> l = notifyC->descriptors();
qDebug() << "Descriptor list with" << l.length() << "elements";
diff --git a/core/qt-ble.cpp b/core/qt-ble.cpp
index b03783a5..67643a6b 100644
--- a/core/qt-ble.cpp
+++ b/core/qt-ble.cpp
@@ -54,6 +54,7 @@ void BLEObject::characteristcStateChanged(const QLowEnergyCharacteristic &c, con
{
Q_UNUSED(c)
+ qDebug() << "characteristcStateChanged";
receivedPackets.append(value);
waitForPacket.exit();
}
@@ -68,12 +69,17 @@ void BLEObject::writeCompleted(const QLowEnergyDescriptor &d, const QByteArray &
void BLEObject::addService(const QBluetoothUuid &newService)
{
+ if (services.length() >= 1) return;
qDebug() << "Found service" << newService;
bool isStandardUuid = false;
newService.toUInt16(&isStandardUuid);
if (isStandardUuid) {
qDebug () << " .. ignoring standard service";
- return;
+ if (newService == QUuid("{0000fefb-0000-1000-8000-00805f9b34fb}")) {
+ qDebug () << " .. or not .. this is my terminal IO";
+ } else {
+ return;
+ }
}
auto service = controller->createServiceObject(newService, this);
@@ -111,6 +117,8 @@ dc_status_t BLEObject::write(const void *data, size_t size, size_t *actual)
QList<QLowEnergyCharacteristic> list = preferredService()->characteristics();
QByteArray bytes((const char *)data, (int) size);
+ //preferredService()->writeCharacteristic(list[2], QByteArray::fromHex("FF"));
+
if (!list.isEmpty()) {
const QLowEnergyCharacteristic &c = list.constFirst();
QLowEnergyService::WriteMode mode;
@@ -295,12 +303,14 @@ dc_status_t qt_ble_close(dc_custom_io_t *io)
dc_status_t qt_ble_read(dc_custom_io_t *io, void* data, size_t size, size_t *actual)
{
+ qDebug() << ".. qt_ble_read" << size;
BLEObject *ble = (BLEObject *) io->userdata;
return ble->read(data, size, actual);
}
dc_status_t qt_ble_write(dc_custom_io_t *io, const void* data, size_t size, size_t *actual)
{
+ qDebug() << ".. qt_ble_write" << size;
BLEObject *ble = (BLEObject *) io->userdata;
return ble->write(data, size, actual);
}
_______________________________________________
subsurface mailing list
[email protected]
http://lists.subsurface-divelog.org/cgi-bin/mailman/listinfo/subsurface