Note that there are some explanatory texts on larger screens.

plurals
  1. POAndroid: Switch between SPP Bluetooth Devices
    primarykey
    data
    text
    <p>I have two different Bluetooth Printers. Bixolon SPP-R200 and Fujitsu FTP-628WSL110. I can connect to each of them separately (using a Samsung Galaxy SII) print, disconnect and reconnect just fine. However, if I switch off the Bixolon and try to pair with the Fujitsu (previously unpaired, Bixolon is still paired), then it fails when trying to connect to the created socket. Same the other way around.</p> <p>Here is the error message:</p> <pre><code>07-02 13:00:11.040: E/MyApp.BluetoothConnection(9380): Failed to connect to rfcomm socket. 07-02 13:00:11.040: E/MyApp.BluetoothConnection(9380): java.io.IOException: Service discovery failed 07-02 13:00:11.040: E/MyApp.BluetoothConnection(9380): at android.bluetooth.BluetoothSocket$SdpHelper.doSdp(BluetoothSocket.java:406) 07-02 13:00:11.040: E/MyApp.BluetoothConnection(9380): at android.bluetooth.BluetoothSocket.connect(BluetoothSocket.java:217) 07-02 13:00:11.040: E/MyApp.BluetoothConnection(9380): at MyApp.BluetoothConnection.connect(BluetoothConnection.java:171) 07-02 13:00:11.040: E/MyApp.BluetoothConnection(9380): at MyApp.AbstractBluetoothPrinter.connect(AbstractBluetoothPrinter.java:34) </code></pre> <p>Here is the code, which makes the connection attempt, the line that fails under the explained circumstances is btSocket.connect(); - exception see above:</p> <pre><code>/** Is set in connect() */ private BluetoothSocket btSocket = null; /** Is set prior to connect() */ private BluetoothSocket btDevice; public boolean connect(){ try { btSocket = btDevice.createRfcommSocketToServiceRecord("00001101-0000-1000-8000-00805F9B34FB"); if (btDevice.getName().startsWith("FTP")) { //Special treatment for the fujitsu printer SystemClock.sleep(1000); } } catch (Throwable e) { LogCat.e(TAG, "Failed to create rfcomm socket.", e); return false; } try { // Stop Bluetooth discovery if it's going on BluetoothHandler.cancelDiscovery(); // This fails under the described circumstances btSocket.connect(); } catch (Throwable e) { LogCat.e(TAG, "Failed to connect to rfcomm socket.", e); return false; } // Obtain streams etc... } </code></pre> <p>I am using the <strong>same</strong> UUID to connect to <strong>both</strong> devices (but only one device is switched on at a time, they're never switched on at the same time), the well known SPP UUID from the SDK API:</p> <pre><code>00001101-0000-1000-8000-00805F9B34FB </code></pre> <p>Which makes me wonder: Could it be, that I need a different UUID for each device? If yes any idea which?</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload