The image stream will continuosly stream to another device.
So if I add text to one, would it just go into a queue?
You can also use the first byte to mark the message type.
If you change the first byte of, will it change anything on the picture itself?
and on the B4A bridge, where exactly is the code that does it? and how does it work?
So it adds 1 unique identifier (byte) at the end of the stream (or at the beginning)?
Sub AddCommandToBytes(Command As Byte, Buffer() As Byte, Length As Int) As Byte()
Dim b(Length + 1) As Byte
b(0) = Command
BC.ArrayCopy(Buffer, 0, b, 1, Length)
Return b
End Sub
and does it also remove it?
Why do you convert the image to string??? Why not send the raw bytes.
Yeah, I already figured it out. I didn't need to do that, Only to check if I actually did receive something.
xverhelstx
EDIT: I think I understand it.
So here:
Sub AddCommandToBytes(Command As Byte, Buffer() As Byte, Length As Int) As Byte()
Dim b(Length + 1) As Byte
b(0) = Command
BC.ArrayCopy(Buffer, 0, b, 1, Length)
Return b
End Sub
It grabs the data from your buffer, and 1 to the length and as first number you give it the command byte.
Then you return a copy of it. and sends B then with AsyncStream. Nice ;D
So when this is done, You have to start reading from the first byte then right?
Dim command As Byte
command = Buffer(0)
Select command
Case TEXT_BYTE
Dim msg As String
msg = BytesToString(Buffer, 1 <-- first byte, Buffer.Length -1, "UTF8")
Msgbox(msg, "")
Case IMAGE_BYTE
Dim msg As String
msg = BytesToString(Buffer, 1, Buffer.Length -1, "UTF8")
Msgbox(msg, "")
End Select
OMG, These just works
![Big Grin :D :D](data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7)
![Big Grin :D :D](data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7)
Thanks A lot Erel
![Big Grin :D :D](data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7)
Although, Sometimes, I won't sent my message. Dunno why, but it happens only when I send my CurrentJPEG over??
Mostly, It sends the first time but then it doesn't anymore.
Like if I first send the CurrentJPEG, it works, but that both doesn't work anymore.
Dim TEXT_BYTE, IMAGE_BYTE As Byte
TEXT_BYTE = 1
IMAGE_BYTE = 2
Sub mnuSend_Click
If connected Then
If AStreams.IsInitialized = False Then Return
Astreams.Write(AddCommandToBytes(IMAGE_BYTE, CurrentJPEG, CurrentJPEG.Length))
Log("Sending: Image ")
Else
Msgbox("You are not connected to your crew." & CRLF & "Select 'Start' to assign one.","Connection")
End If
End Sub
' R button: Ask to come live.
If Keycode = 103 Then
If connected Then
If AStreams.IsInitialized = False Then Return
strWriteText = "Permission: Record"
Dim bfrWriteText() As Byte
bfrWriteText = strWriteText.GetBytes("UTF8")
AStreams.Write(AddCommandToBytes(TEXT_BYTE, bfrWriteText, bfrWriteText.Length))
Log("Sending: Permission Record")
Else
Msgbox("You are not connected to your crew." & CRLF & "Select 'Start' to assign one.","Connection")
End If
End If