From e52e48af0c8ea8b70291806266b64024211f1ff3 Mon Sep 17 00:00:00 2001 From: Francisco Sales Date: Thu, 2 Mar 2017 16:12:44 +0000 Subject: [PATCH 1/4] added missing permissions for discovery on android api level 23+ --- README.md | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index eea75d0..0761dce 100644 --- a/README.md +++ b/README.md @@ -13,6 +13,8 @@ Officialy this library supports React Native >= 0.25, it may run on older versio ``` + + ``` ## Manual installation @@ -109,12 +111,3 @@ You can use `BluetoothSerial.removeListener(eventName, callback)` to stop listen ## TODO - Make services configurable on ios - - - - - - - - - From 4d926e16193777393be0430cede0d9739967865a Mon Sep 17 00:00:00 2001 From: Francisco Sales Date: Tue, 7 Mar 2017 15:10:49 +0000 Subject: [PATCH 2/4] exposing read --- index.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/index.js b/index.js index 1a151dd..91ace49 100644 --- a/index.js +++ b/index.js @@ -34,4 +34,8 @@ BluetoothSerial.write = (data) => { return BluetoothSerial.writeToDevice(data.toString('base64')) } +BluetoothSerial.read = () => { + return BluetoothSerial.readFromDevice() +} + module.exports = BluetoothSerial From ba8719b6c7d872a3049fe197b771695783d6073a Mon Sep 17 00:00:00 2001 From: Francisco Sales Date: Tue, 7 Mar 2017 15:43:33 +0000 Subject: [PATCH 3/4] available data to read --- index.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/index.js b/index.js index 91ace49..434e238 100644 --- a/index.js +++ b/index.js @@ -38,4 +38,8 @@ BluetoothSerial.read = () => { return BluetoothSerial.readFromDevice() } +BluetoothSerial.availableToRead = () =. { + return BluetoothSerial.available() +} + module.exports = BluetoothSerial From 796d1f39206e703b15f93cf111069bd3d88bf55c Mon Sep 17 00:00:00 2001 From: Francisco Sales Date: Tue, 7 Mar 2017 17:00:33 +0000 Subject: [PATCH 4/4] delimiter oiptions --- .../RCTBluetoothSerial/RCTBluetoothSerialModule.java | 1 + .../RCTBluetoothSerial/RCTBluetoothSerialService.java | 2 +- index.js | 8 ++++---- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/android/src/main/java/com/rusel/RCTBluetoothSerial/RCTBluetoothSerialModule.java b/android/src/main/java/com/rusel/RCTBluetoothSerial/RCTBluetoothSerialModule.java index be90cf3..4e48985 100644 --- a/android/src/main/java/com/rusel/RCTBluetoothSerial/RCTBluetoothSerialModule.java +++ b/android/src/main/java/com/rusel/RCTBluetoothSerial/RCTBluetoothSerialModule.java @@ -476,6 +476,7 @@ void onError (Exception e) { * @param data Message */ void onData (String data) { + Log.d(TAG, "ON read data"); mBuffer.append(data); String completeData = readUntil(this.delimiter); if (completeData != null && completeData.length() > 0) { diff --git a/android/src/main/java/com/rusel/RCTBluetoothSerial/RCTBluetoothSerialService.java b/android/src/main/java/com/rusel/RCTBluetoothSerial/RCTBluetoothSerialService.java index c818bc5..1f0faa3 100644 --- a/android/src/main/java/com/rusel/RCTBluetoothSerial/RCTBluetoothSerialService.java +++ b/android/src/main/java/com/rusel/RCTBluetoothSerial/RCTBluetoothSerialService.java @@ -304,7 +304,7 @@ public void run() { try { bytes = mmInStream.read(buffer); // Read from the InputStream String data = new String(buffer, 0, bytes, "ISO-8859-1"); - + Log.i(TAG, "Reading data"); mModule.onData(data); // Send the new data String to the UI Activity } catch (Exception e) { Log.e(TAG, "disconnected", e); diff --git a/index.js b/index.js index 434e238..1b1213e 100644 --- a/index.js +++ b/index.js @@ -34,12 +34,12 @@ BluetoothSerial.write = (data) => { return BluetoothSerial.writeToDevice(data.toString('base64')) } -BluetoothSerial.read = () => { - return BluetoothSerial.readFromDevice() -} -BluetoothSerial.availableToRead = () =. { +BluetoothSerial.availableToRead = () => { return BluetoothSerial.available() } +BluetoothSerial.setReadDelimiter = (delimiter) => { + return BluetoothSerial.withDelimiter(delimiter); +} module.exports = BluetoothSerial