From 4c51fd0f4c90d9bb61d441d80dbd48bc50153711 Mon Sep 17 00:00:00 2001 From: Luccas Robert Date: Fri, 20 Apr 2018 15:54:57 -0300 Subject: [PATCH 1/6] Start service on subscribe --- src/android/com/megster/cordova/BluetoothSerial.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/android/com/megster/cordova/BluetoothSerial.java b/src/android/com/megster/cordova/BluetoothSerial.java index 8be5575f..8b465e5e 100644 --- a/src/android/com/megster/cordova/BluetoothSerial.java +++ b/src/android/com/megster/cordova/BluetoothSerial.java @@ -149,6 +149,8 @@ public boolean execute(String action, CordovaArgs args, CallbackContext callback delimiter = args.getString(0); dataAvailableCallback = callbackContext; + bluetoothSerialService.start(); + PluginResult result = new PluginResult(PluginResult.Status.NO_RESULT); result.setKeepCallback(true); callbackContext.sendPluginResult(result); From 7166a78fcf714d258a6428bcdeb660ecef27e836 Mon Sep 17 00:00:00 2001 From: Luccas Robert Date: Fri, 20 Apr 2018 15:58:25 -0300 Subject: [PATCH 2/6] Start service on subscribe --- src/android/com/megster/cordova/BluetoothSerial.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/android/com/megster/cordova/BluetoothSerial.java b/src/android/com/megster/cordova/BluetoothSerial.java index 8b465e5e..e9f36859 100644 --- a/src/android/com/megster/cordova/BluetoothSerial.java +++ b/src/android/com/megster/cordova/BluetoothSerial.java @@ -148,7 +148,7 @@ public boolean execute(String action, CordovaArgs args, CallbackContext callback delimiter = args.getString(0); dataAvailableCallback = callbackContext; - + //Start the Bluetooth service on the subscribe command to accept incoming connections. bluetoothSerialService.start(); PluginResult result = new PluginResult(PluginResult.Status.NO_RESULT); From 0170dfa5b169d866274ed4ed4550349394a0c2bd Mon Sep 17 00:00:00 2001 From: Luccas Robert Date: Fri, 20 Apr 2018 15:59:32 -0300 Subject: [PATCH 3/6] Enabled listening state --- src/android/com/megster/cordova/BluetoothSerialService.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/android/com/megster/cordova/BluetoothSerialService.java b/src/android/com/megster/cordova/BluetoothSerialService.java index 63ce6c53..c1647c91 100644 --- a/src/android/com/megster/cordova/BluetoothSerialService.java +++ b/src/android/com/megster/cordova/BluetoothSerialService.java @@ -96,8 +96,9 @@ public synchronized void start() { // Cancel any thread currently running a connection if (mConnectedThread != null) {mConnectedThread.cancel(); mConnectedThread = null;} - setState(STATE_NONE); - + //setState(STATE_NONE); + //Enabled listening state for accepting incoming connections. + setState(STATE_LISTEN); // Listen isn't working with Arduino. Ignore since assuming the phone will initiate the connection. // setState(STATE_LISTEN); // From 0210bcb5905d50766441416512512378f2f9df19 Mon Sep 17 00:00:00 2001 From: Luccas Robert Date: Fri, 20 Apr 2018 16:04:01 -0300 Subject: [PATCH 4/6] Use correct UUIDs when connecting --- .../com/megster/cordova/BluetoothSerialService.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/android/com/megster/cordova/BluetoothSerialService.java b/src/android/com/megster/cordova/BluetoothSerialService.java index c1647c91..4158c0f5 100644 --- a/src/android/com/megster/cordova/BluetoothSerialService.java +++ b/src/android/com/megster/cordova/BluetoothSerialService.java @@ -348,11 +348,11 @@ public ConnectThread(BluetoothDevice device, boolean secure) { // Get a BluetoothSocket for a connection with the given BluetoothDevice try { if (secure) { - // tmp = device.createRfcommSocketToServiceRecord(MY_UUID_SECURE); - tmp = device.createRfcommSocketToServiceRecord(UUID_SPP); + tmp = device.createRfcommSocketToServiceRecord(MY_UUID_SECURE); + //tmp = device.createRfcommSocketToServiceRecord(UUID_SPP); } else { - //tmp = device.createInsecureRfcommSocketToServiceRecord(MY_UUID_INSECURE); - tmp = device.createInsecureRfcommSocketToServiceRecord(UUID_SPP); + tmp = device.createInsecureRfcommSocketToServiceRecord(MY_UUID_INSECURE); + //tmp = device.createInsecureRfcommSocketToServiceRecord(UUID_SPP); } } catch (IOException e) { Log.e(TAG, "Socket Type: " + mSocketType + "create() failed", e); From 8fa87f12d3966c7373dd33f1fdeb7e667760921f Mon Sep 17 00:00:00 2001 From: Luccas Robert Date: Fri, 20 Apr 2018 16:12:09 -0300 Subject: [PATCH 5/6] Update README --- README.md | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index c30d9dad..b1964df6 100644 --- a/README.md +++ b/README.md @@ -1,9 +1,11 @@ # Bluetooth Serial Plugin for PhoneGap -This plugin enables serial communication over Bluetooth. It was written for communicating between Android or iOS and an Arduino. +This plugin enables serial communication over Bluetooth. It was written for communicating between Android(android to android and android to another device) or iOS and an Arduino. Android and Windows Phone use Classic Bluetooth. iOS uses Bluetooth Low Energy. +*This is a fork of the original Project with modifications that allow the connection between two android devices and tests using this [bluetooth printer emulator](https://play.google.com/store/apps/details?id=co.com.BluetoothPrinterEmulator) + ## Supported Platforms * Android @@ -17,7 +19,6 @@ Android and Windows Phone use Classic Bluetooth. iOS uses Bluetooth Low Energy. * The phone must initiate the Bluetooth connection * iOS Bluetooth Low Energy requires iPhone 4S, iPhone5, iPod 5, or iPad3+ - * Will *not* connect Android to Android[*](https://github.com/don/BluetoothSerial/issues/50#issuecomment-66405396) * Will *not* connect iOS to iOS[*](https://github.com/don/BluetoothSerial/issues/75#issuecomment-52591397) # Installing From 13b56fcafb8fe5d25eccea8361b2aa90096f2f3e Mon Sep 17 00:00:00 2001 From: Luccas Robert Date: Fri, 20 Apr 2018 17:07:57 -0300 Subject: [PATCH 6/6] Update README --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index b1964df6..18380deb 100644 --- a/README.md +++ b/README.md @@ -4,7 +4,7 @@ This plugin enables serial communication over Bluetooth. It was written for comm Android and Windows Phone use Classic Bluetooth. iOS uses Bluetooth Low Energy. -*This is a fork of the original Project with modifications that allow the connection between two android devices and tests using this [bluetooth printer emulator](https://play.google.com/store/apps/details?id=co.com.BluetoothPrinterEmulator) +*This is a fork of the original Project with modifications(based on [tomvanenckevort fork](https://github.com/tomvanenckevort/BluetoothSerial)) that allow the connection between two android devices and tests using this [bluetooth printer emulator](https://play.google.com/store/apps/details?id=co.com.BluetoothPrinterEmulator) ## Supported Platforms