Android Tutorial FileTransfer - Send and receive files with AsyncStreams

Status
Not open for further replies.

Kwame Twum

Active Member
Licensed User
Longtime User
I keep getting an error when I try to connect to another device through BT... Please help
 

Attachments

  • screenshot_2013-11-15_2232.png
    55 KB · Views: 877

Kwame Twum

Active Member
Licensed User
Longtime User
This error usually means that the other device isn't listening for connections.
The other device was in listening mode though... even tried my computer's Bluetooth but didn't work (but I guess that was because of the bridge connection)
 

grifoDev

Member
Licensed User
Longtime User
Hello, Erel
I connect to wifi my phone,
installed filetransfert and Ok,
on the pc run shell dos IPCONFIG and find the ip of PC for connection
but on phone "Wifi Status = Disconnected" (

thanks
grifoDev
 

grifoDev

Member
Licensed User
Longtime User
oops sorry ..
can you sugest me what I can use for connect PC -> device and Device -> PC ?
thanks
grifoDev
 

grifoDev

Member
Licensed User
Longtime User
Hello tuhatinvn
No, I use Delphi , with vcl INDY I can connect to TCPIP or UDP...
thanks
 

Robert Valentino

Well-Known Member
Licensed User
Longtime User
I tried this an keep getting Service Discovery Failed.

BUT if I go into "my files" select a file and then select share and select Bluetooth it sends the file to my PC with no problem.

How can I get this fail transfer program to work?

Using it with a Samsung Galaxy Tab-3 7" and HP Pavilion DM1 (running Windows 8.1)

Thanks

BobVal
 

pgargom

Member
Licensed User
Longtime User
Hi Erel,
i have a doubt about use of Bluetooth.
i'm using the example of file Transfer but implement only 1 side of the conection.
I use "serial1.Connect3(Address,11)" to connect with my device and i get the conection but when i try to send a photo, my device dont receive nothing.
AsynscStreams are initialited like "astream.Initialize(Null,out, "astream")" and i initialited it in serial_conected like in the example

Note: the file in "Dir,Filename" exists

my sendFile method is the next

B4X:
Dim out As OutputStream
      out.InitializeToBytesArray(100)
      File.Copy2(File.OpenInput(Dir, FileName), out)
    astream.Write(out.ToBytesArray) 'write the file name
    lblFile = "Sending: " & currentFile
    SendingFile = True
    UpdateProgress

Thanks
 

Mbc

Member
Licensed User
Longtime User
FileTransfer example demonstrates how AsyncStreams can be used to send and receive files of any size. This example allows you to connect two devices over Bluetooth or Wifi (assuming that both are connected to the same local network).
Hi Erel,
The FileTransfer app gives consistent and identical errors on both my Android phone and my Android tablet.
On trying to connect to an existing WiFi device it produces the error:
Error: (ErmoException) libcore.io ErnoException: isConnecte failed: EHOSTUNREACH (No route to....
On trying to connect to a paired BT device it produces the error:
Error: java.io.IOException: read failed, socket might be closed timeout, read ret: -1

Any idea?
Thanks.
 
Last edited by a moderator:

Mbc

Member
Licensed User
Longtime User
Are the two devices connected to the same local network?

Yes they are.
Some more info:
Communicating using WiFi or BT with other devices on this network but using different apps, runs flawlessly.
Another BT app from Basic4Android (Package=anywheresoftware.b4a.samples.bluetooth) also gives problems. It crashes after a string is sent. After the code:
Sub btnSend_Click
AStream.Write(txtInput.Text.GetBytes("UTF8"))
txtInput.SelectAll
txtInput.RequestFocus
LogMessage("Me", txtInput.Text)
End Sub
 

lemonisdead

Well-Known Member
Licensed User
Longtime User
Erel,
Are you refering to a log FileTransfer produces? Where can I find that?
You will find the log in the right part of your B4A's IDE (look at the tabs). When you are in Debug mode and connected with B4A Bridge, you will see the error messages.
 

GMan

Well-Known Member
Licensed User
Longtime User
you will see the error messages.
But NOT on x64-Systems
For my behavior this is a VERY BIG negative point when developing
 

Mbc

Member
Licensed User
Longtime User
You will find the log in the right part of your B4A's IDE (look at the tabs). When you are in Debug mode and connected with B4A Bridge, you will see the error messages.

Yes of course. Thanks for pointing that out.
Log does not seem to give any error but I found out some interesting behaviour in the meantime:
Errors with FileTransfer do not occur when connecting FileTransfer with WiFi or with Bluetooth to Android phone (also used as device to test Basic4Android, might have someting to do with it). Trying to connect with Windows PC or Arduino BT device does produce the error.
 
Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…