Hello, I would like to know how can I divide a binary file in little bytes packet (divide to send to a device). And if possible with an adjustable packet size =)
Hello, I would like to know how can I divide a binary file in little bytes packet (divide to send to a device). And if possible with an adjustable packet size =)
You probably do not need to do that, most network file transfer protocols will do that (split the file in packets of the right size for the protocol you are using) for you.
What protocol do you intend to use?
Sub ReadFile(Dir As String, FileName As String) As Byte()
Dim out As OutputStream
out.InitializeToBytesArray(100) 'size not really important
File.Copy2(File.OpenInput(Dir, FileName), out)
Return out.ToBytesArray
End Sub
With that
B4X:
byte_arr = ReadFile(shared, "file_name.dat")
This file_name contain my data. But I think the data which are return are not the same. I use NotePad++ to open my file and I think I have more data in :/
Question: How to use BytesBuilder ? It's not like a Library so where do I need to "include" it ? Because it's a class and I don't know how to use that in B4A :/
It's work perfectly !
Now I have a problem with the communication between my device and B4A : Normally the device send some informations about his size, offset and CRC-32. But in the console log I can't catch this message, I only receive informations with this
B4X:
Public Sub DataAvailable(Services As String, Characteristics As Map)
log(Characteristics)
end sub
The fisrt part is my characteristic who send notification (Key if you prefer) and the last part is strange :/
Maybe I can modify the log to see more thing ?
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.