From cee3d7515c38cf0121ae71f5b69fc3bc13b5b622 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sylwester=20Zieli=C5=84ski?= Date: Fri, 8 Apr 2022 12:41:58 +0200 Subject: [PATCH 1/2] Increase Gradle to 7.1.3 --- ble-common/build.gradle | 2 ++ ble-common/src/main/AndroidManifest.xml | 2 +- ble-ktx/build.gradle | 2 ++ ble-ktx/src/main/AndroidManifest.xml | 2 +- ble-livedata/build.gradle | 2 ++ ble-livedata/src/main/AndroidManifest.xml | 2 +- ble/build.gradle | 2 ++ ble/src/main/AndroidManifest.xml | 3 +-- build.gradle | 2 +- 9 files changed, 13 insertions(+), 6 deletions(-) diff --git a/ble-common/build.gradle b/ble-common/build.gradle index 19539f1e..e4c814c2 100644 --- a/ble-common/build.gradle +++ b/ble-common/build.gradle @@ -1,6 +1,8 @@ apply plugin: 'com.android.library' android { + namespace 'no.nordicsemi.android.ble.common' + compileSdkVersion 30 defaultConfig { diff --git a/ble-common/src/main/AndroidManifest.xml b/ble-common/src/main/AndroidManifest.xml index 6edc7fe5..8072ee00 100644 --- a/ble-common/src/main/AndroidManifest.xml +++ b/ble-common/src/main/AndroidManifest.xml @@ -1,2 +1,2 @@ - + diff --git a/ble-ktx/build.gradle b/ble-ktx/build.gradle index ea1c2e57..11c7c46b 100644 --- a/ble-ktx/build.gradle +++ b/ble-ktx/build.gradle @@ -4,6 +4,8 @@ plugins { } android { + namespace 'no.nordicsemi.android.ble.ktx' + compileSdkVersion 30 defaultConfig { diff --git a/ble-ktx/src/main/AndroidManifest.xml b/ble-ktx/src/main/AndroidManifest.xml index a91b9983..568741e5 100644 --- a/ble-ktx/src/main/AndroidManifest.xml +++ b/ble-ktx/src/main/AndroidManifest.xml @@ -1,2 +1,2 @@ - \ No newline at end of file + \ No newline at end of file diff --git a/ble-livedata/build.gradle b/ble-livedata/build.gradle index 4747c172..b921b114 100644 --- a/ble-livedata/build.gradle +++ b/ble-livedata/build.gradle @@ -3,6 +3,8 @@ plugins { } android { + namespace 'no.nordicsemi.android.ble.livedata' + compileSdkVersion 30 defaultConfig { diff --git a/ble-livedata/src/main/AndroidManifest.xml b/ble-livedata/src/main/AndroidManifest.xml index b14acee5..8072ee00 100644 --- a/ble-livedata/src/main/AndroidManifest.xml +++ b/ble-livedata/src/main/AndroidManifest.xml @@ -1,2 +1,2 @@ - + diff --git a/ble/build.gradle b/ble/build.gradle index 93ab0e93..28ff751f 100644 --- a/ble/build.gradle +++ b/ble/build.gradle @@ -1,6 +1,8 @@ apply plugin: 'com.android.library' android { + namespace 'no.nordicsemi.android.ble' + compileSdkVersion 30 defaultConfig { diff --git a/ble/src/main/AndroidManifest.xml b/ble/src/main/AndroidManifest.xml index 9610a3a8..bf1982e4 100644 --- a/ble/src/main/AndroidManifest.xml +++ b/ble/src/main/AndroidManifest.xml @@ -1,6 +1,5 @@ - + diff --git a/build.gradle b/build.gradle index 304b82ed..06e909e5 100644 --- a/build.gradle +++ b/build.gradle @@ -10,7 +10,7 @@ buildscript { maven { url "https://plugins.gradle.org/m2/" } } dependencies { - classpath 'com.android.tools.build:gradle:7.1.2' + classpath 'com.android.tools.build:gradle:7.1.3' classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" classpath "io.github.gradle-nexus:publish-plugin:$gradle_nexus_publish_plugin" } From b52979f5af2357adad1d5d61c94bf598d923c9a4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sylwester=20Zieli=C5=84ski?= Date: Tue, 10 May 2022 13:39:02 +0200 Subject: [PATCH 2/2] Allow sending empty string using WriteRequest --- .../java/no/nordicsemi/android/ble/WaitForReadRequest.java | 5 +++-- .../main/java/no/nordicsemi/android/ble/WriteRequest.java | 7 +++++-- .../java/no/nordicsemi/android/ble/data/DataSplitter.java | 3 ++- 3 files changed, 10 insertions(+), 5 deletions(-) diff --git a/ble/src/main/java/no/nordicsemi/android/ble/WaitForReadRequest.java b/ble/src/main/java/no/nordicsemi/android/ble/WaitForReadRequest.java index f4021ae1..7f96036b 100644 --- a/ble/src/main/java/no/nordicsemi/android/ble/WaitForReadRequest.java +++ b/ble/src/main/java/no/nordicsemi/android/ble/WaitForReadRequest.java @@ -198,10 +198,11 @@ public WaitForReadRequest split(@NonNull final WriteProgressCallback callback) { * @param mtu the current MTU. * @return The next bytes to be sent. */ + @NonNull byte[] getData(@IntRange(from = 23, to = 517) final int mtu) { if (dataSplitter == null || data == null) { complete = true; - return data; + return data != null ? data : new byte[] {}; } // Read [procedure requires 3 bytes for handler and op code. @@ -220,7 +221,7 @@ byte[] getData(@IntRange(from = 23, to = 517) final int mtu) { if (nextChunk == null) { complete = true; } - return chunk; + return chunk != null ? chunk : new byte[] {}; } /** diff --git a/ble/src/main/java/no/nordicsemi/android/ble/WriteRequest.java b/ble/src/main/java/no/nordicsemi/android/ble/WriteRequest.java index c96031e4..5c426b5b 100644 --- a/ble/src/main/java/no/nordicsemi/android/ble/WriteRequest.java +++ b/ble/src/main/java/no/nordicsemi/android/ble/WriteRequest.java @@ -232,10 +232,12 @@ void forceSplit() { * @param mtu the current MTU. * @return The next bytes to be sent. */ + @NonNull byte[] getData(@IntRange(from = 23, to = 517) final int mtu) { if (dataSplitter == null || data == null) { complete = true; - return currentChunk = data; + currentChunk = data; + return data != null ? data : new byte[] {}; } // Write Request and Write Command require 3 bytes for handler and op code. @@ -256,7 +258,8 @@ byte[] getData(@IntRange(from = 23, to = 517) final int mtu) { if (nextChunk == null) { complete = true; } - return currentChunk = chunk; + currentChunk = chunk; + return chunk != null ? chunk : new byte[] {}; } /** diff --git a/ble/src/main/java/no/nordicsemi/android/ble/data/DataSplitter.java b/ble/src/main/java/no/nordicsemi/android/ble/data/DataSplitter.java index 1cb1e9de..03ef956e 100644 --- a/ble/src/main/java/no/nordicsemi/android/ble/data/DataSplitter.java +++ b/ble/src/main/java/no/nordicsemi/android/ble/data/DataSplitter.java @@ -42,5 +42,6 @@ public interface DataSplitter { */ @Nullable byte[] chunk(@NonNull final byte[] message, - @IntRange(from = 0) final int index, @IntRange(from = 20) final int maxLength); + @IntRange(from = 0) final int index, + @IntRange(from = 20) final int maxLength); }