Android Tutorial Android Bluetooth / BluetoothAdmin Tutorial

Status
Not open for further replies.

Rusty

Well-Known Member
Licensed User
Longtime User
Erel,
Do you have an example of an Astreams implementation of receiving/sending a file over bluetooth?
The chat program works great but I need to send/receive files of 1mb (or so) in size.
Thanks,
Rusty
 

Rusty

Well-Known Member
Licensed User
Longtime User
Thanks Erel.
I anxiously await such an example.
As usual, you, Anywhere Software and the members of your group are great!
With appreciation.
Rusty
 

Rusty

Well-Known Member
Licensed User
Longtime User
Erel,
Your example works great, thank you.
Have you ever connected via Bluetooth to a Bluetooth RS-232 device.
For example, there are devices out there such as Bluetooth heart monitoring devices and others that I need to be able to stream their data to a file via Bluetooth. If so, can you recommend a code example or reference?
Thanks,
Rusty
 

Madf

New Member
Licensed User
Longtime User
Hello.

Tried this example. There is a problem, "txtInput.Text" returns for some reason is not only a text string, but another 4 bytes data length.
How can I get rid of them?
The function "left" does not help. How to cut these unnecessary data? How to transfer a text-only?


ps: in general, this is not BASIC - is a little of BASIC, and the rest is - Java! In BASIC there is no problem with the variables (usually automatically converted) and immediately access all the functions without any ads (then the compiler will optimize the code). (((
 

dschafer77

New Member
Licensed User
Longtime User
Hi Erel, great program.
I am running your bluetooth example, it works when i send text from phone to a bluetooth serial module, but sending any text to the phone forces closed the program.
Do you have any idea what would cause this?
Regards
Doug
 

Jayjay

New Member
Licensed User
Longtime User
Hi Erel,
I have now read through the forum to find a answer to my problem. Its related to the Bluetooth app found in the tutorial.
I noticed that you showed someone else away saying that its not a problem for this tread.
I have B4A working well as well and the bridge program using Bluetooth. However after compiling the example on Bluetooth and deploying it to the phone and tablet i get the same error message. Both devices are Samsung the phone being the S3. the error in question is this
java.io.ioException: Service Discovery Failed.
However there is another app on the net which does nearly the same as your example and works well. unfortnatunely its source is not available and i presume not written in B4A. (BTinterface Free trial version)
I am new to B4A and Bluetooth comms.
 

Jayjay

New Member
Licensed User
Longtime User
spend the day looking at your code on the example and found the source of the java.io.ioException: Service Discovery Failed.
Its in the serial1 Sub. and reports this when unable to connect.Its possible that the BTinterface Free trial version has been written in b4a. it connects to my laptop terminal first time. The example does not always do that i need to manually go online. But i will search the code for answers and in this way learn more.My two devices however once detected connect.Thanks.
 

sanduro

Member
Licensed User
Longtime User
This application works just fine between android devices, but how can I have a client in VB, C# ,processing or whatever, which can be used as another client, e.g. android > pc chat ?

San
 

GMan

Well-Known Member
Licensed User
Longtime User
how can i SEND (i.e. the number "1") via established BT-Connection when tapping on a button ?
 

KitCarlson

Active Member
Licensed User
Longtime User
B4X:
Sub btnOne_Click
    AStream.Write(Array As Byte(49))  ' "1"
End Sub

Make btnOne in designer.
 
Last edited:

GMan

Well-Known Member
Licensed User
Longtime User
I got the AsyncStreamsObject class and use it as
B4X:
Dim AStream As AsyncStreams

But i am using the BT-Example from Erel? and there is no AStream-x needed so far.
Its using a Serial1.xxxx

B4X:
If FirstTime Then
        admin.Initialize("admin")
        serial1.Initialize("serial1")
        txtLog.Initialize ("txtLog")
        txtInput.Initialize ("txtInput")
        BTConXXPicture.Initialize ("BTConXXPicture")
    End If
 
Last edited:

GMan

Well-Known Member
Licensed User
Longtime User
If i try
B4X:
 AStream.Write(Array As Byte(49))  ' "1"
nothing will be send (the indicator led does nothing)

If i use
B4X:
 txtInput.Text = "a"
AStream.Write(txtInput.Text.GetBytes("UTF8"))
the indocator led flashed, but nothing was sent (the monitoring keeps empty).

B4X:
Sub ToggleButton1_Click
If ToggleButton1.Checked Then
'  AStream.Write(Array As Byte(49))  ' "1"
 
  txtInput.Text = ""
  txtInput.Text = "1"
  AStream.Write(txtInput.Text.GetBytes("UTF8"))
  Else
'  AStream.Write(Array As Byte(48))  ' "0"

  txtInput.Text = "" 
  txtInput.Text = "0"
  AStream.Write(txtInput.Text.GetBytes("UTF8"))
End If
 
Last edited:
Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…