react-native-ble-manager 10.0.0 → 10.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (30) hide show
  1. package/README.md +2 -2
  2. package/android/src/main/java/it/innove/NotifyBufferContainer.java +19 -15
  3. package/android/src/main/java/it/innove/Peripheral.java +286 -272
  4. package/package.json +1 -1
  5. package/android/.gradle/7.4/checksums/checksums.lock +0 -0
  6. package/android/.gradle/7.4/dependencies-accessors/dependencies-accessors.lock +0 -0
  7. package/android/.gradle/7.4/dependencies-accessors/gc.properties +0 -0
  8. package/android/.gradle/7.4/executionHistory/executionHistory.bin +0 -0
  9. package/android/.gradle/7.4/executionHistory/executionHistory.lock +0 -0
  10. package/android/.gradle/7.4/fileChanges/last-build.bin +0 -0
  11. package/android/.gradle/7.4/fileHashes/fileHashes.bin +0 -0
  12. package/android/.gradle/7.4/fileHashes/fileHashes.lock +0 -0
  13. package/android/.gradle/7.4/fileHashes/resourceHashesCache.bin +0 -0
  14. package/android/.gradle/7.4/gc.properties +0 -0
  15. package/android/.gradle/buildOutputCleanup/buildOutputCleanup.lock +0 -0
  16. package/android/.gradle/buildOutputCleanup/cache.properties +0 -2
  17. package/android/.gradle/buildOutputCleanup/outputFiles.bin +0 -0
  18. package/android/.gradle/file-system.probe +0 -0
  19. package/android/.gradle/vcs-1/gc.properties +0 -0
  20. package/android/.idea/.name +0 -1
  21. package/android/.idea/compiler.xml +0 -6
  22. package/android/.idea/gradle.xml +0 -18
  23. package/android/.idea/jarRepositories.xml +0 -40
  24. package/android/.idea/misc.xml +0 -10
  25. package/android/.idea/vcs.xml +0 -6
  26. package/android/gradle/wrapper/gradle-wrapper.jar +0 -0
  27. package/android/gradle/wrapper/gradle-wrapper.properties +0 -5
  28. package/android/gradlew +0 -234
  29. package/android/gradlew.bat +0 -89
  30. package/android/local.properties +0 -8
package/README.md CHANGED
@@ -301,7 +301,7 @@ BleManager.startNotification(
301
301
 
302
302
  ### startNotificationUseBuffer(peripheralId, serviceUUID, characteristicUUID, buffer) [Android only]
303
303
 
304
- Start the notification on the specified characteristic, you need to call `retrieveServices` method before. The buffer will collect a number or messages from the server and then emit once the buffer count it reached. Helpful to reducing the number or js bridge crossings when a characteristic is sending a lot of messages.
304
+ Start the notification on the specified characteristic, you need to call `retrieveServices` method before. The buffer collect messages until the buffer of messages bytes reaches the limit defined with the `buffer` argument and then emit all the collected data. Helpful to reducing the number or js bridge crossings when a characteristic is sending a lot of messages.
305
305
  Returns a `Promise` object.
306
306
 
307
307
  **Arguments**
@@ -309,7 +309,7 @@ Returns a `Promise` object.
309
309
  - `peripheralId` - `String` - the id/mac address of the peripheral.
310
310
  - `serviceUUID` - `String` - the UUID of the service.
311
311
  - `characteristicUUID` - `String` - the UUID of the characteristic.
312
- - `buffer` - `Integer` - a number of message to buffer prior to emit for the characteristic.
312
+ - `buffer` - `Integer` - the capacity of the buffer (bytes) stored before emitting the data for the characteristic.
313
313
 
314
314
  **Examples**
315
315
 
@@ -3,30 +3,34 @@ package it.innove;
3
3
  import java.nio.ByteBuffer;
4
4
 
5
5
  public class NotifyBufferContainer {
6
- public final Integer maxBufferSize;
7
- private Integer bufferCount;
8
6
  public ByteBuffer items;
9
7
 
10
- public NotifyBufferContainer(Integer size) {
11
- this.maxBufferSize = size;
12
- this.resetBuffer();
8
+ public NotifyBufferContainer(int size) {
9
+ this.items = ByteBuffer.allocate(size);
13
10
  }
14
11
  public void resetBuffer(){
15
- this.bufferCount = 0;
16
- this.items = ByteBuffer.allocate(this.maxBufferSize);
12
+ this.items.clear();
17
13
  }
18
- public void put(byte[] value){
19
- this.bufferCount += value.length;
20
- if (this.items.remaining() < value.length) {
21
- return;
14
+ public byte[] put(byte[] value){
15
+ int restLength = value.length - this.items.remaining();
16
+ byte[] toInsert = null;
17
+ byte[] rest = null;
18
+ if (restLength < 0) {
19
+ rest = new byte[restLength];
20
+ toInsert = new byte[value.length - restLength];
21
+ System.arraycopy(value, 0, toInsert, 0, toInsert.length);
22
+ System.arraycopy(value, toInsert.length, rest, restLength, rest.length);
23
+ } else {
24
+ toInsert = value;
22
25
  }
23
- this.items.put(value);
26
+ this.items.put(toInsert);
27
+ return rest;
24
28
  }
25
29
  public boolean isBufferFull(){
26
- return this.bufferCount >= this.maxBufferSize;
30
+ return this.items.remaining() == 0;
27
31
  }
28
- public Integer size() {
29
- return this.bufferCount;
32
+ public int size() {
33
+ return this.items.limit();
30
34
  }
31
35
  @Override
32
36
  protected void finalize() throws Throwable {