Android Question Bluetooth big file transfer

peacemaker

Expert
Licensed User
Longtime User
There is a ready BT device that has protocol like
TEXT COMMAND & BINARY DATA.
No PREFIX mode is applicable, need to follow to the ready protocol.

Short commands are debugged well using Bluetooth Chat sample.
But now it needs to send big binary files, 30-130 KBytes. Write command includes ADDRESS, LENGTH, CHECKSUM bytes, and this big binary file array after them.
Device replay is the same command block as confirmation, when the command is finished OK.

Transferring speed is limited by device's FLASH memory, need 4-7 second at least.
Sending via a PC COM-port terminal is OK now.

How to tranfer using Sub AStreams_NewData (Buffer() As Byte) sub (AsyncStreams object RAF v.1.32)? Impossible for 5 second before FC offer ?
Now Android is hunging and restarts when to AStream.Write(FileDump)
 
Last edited:

peacemaker

Expert
Licensed User
Longtime User
Erel, if possible, a sample, please. Where to open an OutputStream ?
 
Upvote 0

peacemaker

Expert
Licensed User
Longtime User
Yes, main is to send. Receiving may be needed to check that correctly sent.
 
Last edited:
Upvote 0

peacemaker

Expert
Licensed User
Longtime User
Thanks !
Now tried to use
B4X:
    Dim len, rest As Int
    len = FileDump.Length/20
    For i= 0 To FileDump.Length - 1 Step len
        rest = FileDump.Length - i
        If rest >= len Then
            If AStream.Write2(FileDump, i, len) = False Then
                'pause for transferring buffer
                DoEvents:DoEvents
                i = i - len
            Else
                Log(i)
            End If
        Else
            AStream.Write2(FileDump, i, rest)
        End If
    Next

Sending is OK. But strange that only files up to 20 kB, 100 kB file is out to buffer, but remote device does not reply that received.
But if to send as the file from PC by Terminal software - sent OK any variant :-(
 
Upvote 0

peacemaker

Expert
Licensed User
Longtime User
Wooohoo ! Seems, it's the buggy BT device, not my app :)
Another device receives big files well !
Thanks, Erel !
 
Upvote 0
Top