Android Question Weird issue with SPP on L+

Discussion in 'Android Questions' started by techknight, Jun 12, 2015.

  1. techknight

    techknight Active Member Licensed User

    My apps which use bluetooth SPP to communicate with devices, all work fine with samsung tab 3, and before.

    But I noticed the latest version of tab3 lites, and tab4s, and my s6 edge which all have Android L, have issues.

    I will get random errors such as:
    java.io.IOException: read failed, socket might closed or timeout, read ret: -1

    and then sometimes it will connect fine, and then it sends 3 random bytes through the BT connection instead of the real packet, and sometimes it works fine. its very erratic/random. Then when I hit the back arrow to get out of the app, it will close unexpectedly sometimes. And, the logcat in the IDE through USB debugging isnt catching the exception so I dont see what happened.

    Go back to my older devices which are running kitkat, problems gone. So... I dunno what to do. My S6 edge does very similar things as the Tab 3 Lite that I have. I have a gut feeling it has something to do with the dalvik/art switchover.

    I am compiling with API21, in the process of downloading API22 to see if it makes any difference.

    any ideas?
     
  2. Erel

    Erel Administrator Staff Member Licensed User

    It will not change the Bluetooth behavior.

    Are you using Listen or Listen2? Maybe there is another app that is already listening to the default SPP UUID.
     
  3. techknight

    techknight Active Member Licensed User

    No, I am not running a bluetooth server.

    I actually do a scan for devices, then a connect. Basically duplicating the tutorial. Once the serial1.connect is successful, it opens the astream, and sends a packet.

    I did notice every once in awhile, the bluetooth name will come up empty, but the MAC is there. But its always done that.

    Oh, and I forgot to mention. The device in question with issues, will list 6 or 7 copies of the same bluetooth dongle in the spinner after scanning for devices. it sees my computer 3 or 4 times.

    Its the only device that does this.
     
  4. Erel

    Erel Administrator Staff Member Licensed User

    Bluetooth is not stable on many Android devices.

    However it is worth trying to use a custom UUID instead of the default one. It is possible that another process is already using the default UUID.
     
  5. techknight

    techknight Active Member Licensed User

    And how do you do that? Also, how do I make it stable? My product relies on it.
     
  6. Erel

    Erel Administrator Staff Member Licensed User

    There is nothing that you can do about it. It depends on the Android device. I think that Android 4.x+ devices are more stable than the older devices.

    About the UUID, you should use Serial.Listen2 and Connect2 and set the UUID. The default value is: 00001101-0000-1000-8000-00805F9B34FB
     
  7. techknight

    techknight Active Member Licensed User

    Well, I am always making an outgoing connection to a device, Never the other way around, so I wont use Listen. Just Connect.

    But I noticed the Tab3 Lite running Android L has serious issues with bluetooth and my app, Same thing when using the example discovery mode, the spinner is full of duplicates or missing text tags. etc... The older tab 3 lite running kitkat had no issues.

    The tab 4 running kitkat, no problems at all.
     
  8. techknight

    techknight Active Member Licensed User

    How do I know what UUID to use? I tried making one up by changing the B to a C, and I get timeout.
     
  9. Erel

    Erel Administrator Staff Member Licensed User

    What are you connecting to? Are you connecting to your app or to a different app?
     
  10. techknight

    techknight Active Member Licensed User

    Connecting to an out-board bluetooth serial dongle from my app.

    My application actually controls LED hardware via a bluetooth link to an LM048/LM058 bluetooth dongle. Which works fine. On certain tablets/hardware.
     
  11. Erel

    Erel Administrator Staff Member Licensed User

    In that case you cannot change the uuid.
     
Loading...