Android Question Device unavailable in Android Bluetooth / BluetoothAdmin Tutorial

Discussion in 'Android Questions' started by howard bassen, Jan 2, 2018.

  1. howard bassen

    howard bassen Member Licensed User

    I am running the example for Bluetooth connectivity between two android devices:
    https://www.b4x.com/android/forum/threads/android-bluetooth-bluetoothadmin-tutorial.14768

    First I compiled program on my primary phone (ZTE Z981) and communicated with my PC (via its Bluetooth) . I can communicate both ways with a PC terminal emulator.

    When I try to connect my primary phone to a second (PAIRED) android device rather than the PC I get I see the GUI on the device but get the following errors when I try to send or receive:

    Logger connected to: ZTE Z981
    --------- beginning of main
    Nexus 7:08:60:6E:9D:87:70
    :17:8D:84:76:1D:02
    :08:66:98:B7:7B:D9
    :08:66:98:B7:7B:D9
    :08:66:98:B7:7B:D9
    connected: false
    java.io.IOException: read failed, socket might closed or timeout, read ret: -1
    ** Activity (main) Pause, UserClosed = false **

    Can anyone suggest a fix
     
  2. Erel

    Erel Administrator Staff Member Licensed User

    Is the other device listening for connections?
     
  3. howard bassen

    howard bassen Member Licensed User

    When I use a commercial BT terminal app on my phone it works well with my PC (running a terminal emulator).

    For the B4A app I can connect to my PC with the B4A example with difficulty. However the B4A app looses a connection when I try to send characters to the PC.
     
  4. Erel

    Erel Administrator Staff Member Licensed User

    Make sure that AsyncStreams is not initialized in prefix mode.
     
  5. howard bassen

    howard bassen Member Licensed User


    i see async streams only once in the code.
    "Dim AStream As AsyncStreamsocess_Globals"

    Please explain prefix mode. How would I initialize AsyncStreams?
     
  6. Erel

    Erel Administrator Staff Member Licensed User

  7. howard bassen

    howard bassen Member Licensed User

    Unfortunately I do not see how I can incorporate the various pieces of code into the B4A Bluetooth example to fix my problem. Which pieces of code from the Asysnc Streams need to be added to the Bluetooth example, and where?
     
  8. Erel

    Erel Administrator Staff Member Licensed User

    Search the code for InitializePrefix and change that line.
     
  9. howard bassen

    howard bassen Member Licensed User

    sorry but the example program has neither AsyncStreams, Astreams, or InitializePrefix. Should I add these subs from another example? if so, which and how?
     
  10. Erel

    Erel Administrator Staff Member Licensed User

  11. howard bassen

    howard bassen Member Licensed User

    thanks. sorry I was not more careful
     
Loading...
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice