summaryrefslogtreecommitdiffstats
path: root/src/bluetooth/android/lowenergynotificationhub.cpp
diff options
context:
space:
mode:
authorAlex Blasche <alexander.blasche@qt.io>2017-01-17 15:17:10 +0100
committerAlex Blasche <alexander.blasche@qt.io>2017-01-24 14:49:13 +0000
commit6b0595b64ea46554a8a63f026c15ab07ea804285 (patch)
tree97a469bd455cbe32ee7dfc23a79c05cb9b7e41dd /src/bluetooth/android/lowenergynotificationhub.cpp
parenta8604157818e21d7b70e2853258fc4569db770be (diff)
Android: Implement QLEService::characteristicChanged() for peripheral mode
Emits the above signal when the remote client successfully updates a characteristic. Change-Id: I236b1f92b682028bc10be798192f46bffc981101 Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io> Reviewed-by: Alex Blasche <alexander.blasche@qt.io>
Diffstat (limited to 'src/bluetooth/android/lowenergynotificationhub.cpp')
-rw-r--r--src/bluetooth/android/lowenergynotificationhub.cpp22
1 files changed, 22 insertions, 0 deletions
diff --git a/src/bluetooth/android/lowenergynotificationhub.cpp b/src/bluetooth/android/lowenergynotificationhub.cpp
index d6e0a4f1..b0d8b0a2 100644
--- a/src/bluetooth/android/lowenergynotificationhub.cpp
+++ b/src/bluetooth/android/lowenergynotificationhub.cpp
@@ -294,6 +294,28 @@ void LowEnergyNotificationHub::lowEnergy_characteristicChanged(
Q_ARG(int, charHandle), Q_ARG(QByteArray, payload));
}
+void LowEnergyNotificationHub::lowEnergy_serverCharacteristicChanged(
+ JNIEnv *env, jobject, jlong qtObject, jobject characteristic, jbyteArray newValue)
+{
+ lock.lockForRead();
+ LowEnergyNotificationHub *hub = hubMap()->value(qtObject);
+ lock.unlock();
+ if (!hub)
+ return;
+
+ QByteArray payload;
+ if (newValue) { //empty Java byte array is 0x0
+ jsize length = env->GetArrayLength(newValue);
+ payload.resize(length);
+ env->GetByteArrayRegion(newValue, 0, length,
+ reinterpret_cast<signed char*>(payload.data()));
+ }
+
+ QMetaObject::invokeMethod(hub, "serverCharacteristicChanged", Qt::QueuedConnection,
+ Q_ARG(QAndroidJniObject, characteristic),
+ Q_ARG(QByteArray, payload));
+}
+
void LowEnergyNotificationHub::lowEnergy_serviceError(
JNIEnv *, jobject, jlong qtObject, jint attributeHandle, int errorCode)
{