I used the ESP Configurator to get me started with communicating with my ESP-12E.
When I then tried using the B4A client example to communicate with it, it ended up screwing up the WiFi settings on the ESP. I quickly realized why after looking at the code.
So now I intend to add a "header" so to speak when communicating from a B4J or B4A app. In other words, I intend to first send a description of what the app is doing, such as "CONFIG" when sending WiFi configuration stuff or "DATA" when sending other config type things, such as setting the status of a relay.
I have worked out a way to take the incoming bytes and break it down into objects, then re-convert the objects back into bytes and send that on to where it saves the network details. This is working, so I think I am on the right path. But if I send a "header" part, I want to be able to remove that before handling it in the proper way.
Any suggestions or examples on how to do this? I can either remove the first object or create an all-new array of objects but leave out the first (the "header").
When I then tried using the B4A client example to communicate with it, it ended up screwing up the WiFi settings on the ESP. I quickly realized why after looking at the code.
So now I intend to add a "header" so to speak when communicating from a B4J or B4A app. In other words, I intend to first send a description of what the app is doing, such as "CONFIG" when sending WiFi configuration stuff or "DATA" when sending other config type things, such as setting the status of a relay.
I have worked out a way to take the incoming bytes and break it down into objects, then re-convert the objects back into bytes and send that on to where it saves the network details. This is working, so I think I am on the right path. But if I send a "header" part, I want to be able to remove that before handling it in the proper way.
Any suggestions or examples on how to do this? I can either remove the first object or create an all-new array of objects but leave out the first (the "header").
B4X:
Private Sub Astream_NewData (Buffer() As Byte)
Log("New data arrived...")
Log("Data length: ", Buffer.Length)
Dim Objects() As Object = serializator.ConvertBytesToArray(Buffer,ObjectsBuffer)
Log("Reading data: ")
For Each o As Object In Objects
Log("Incoming Object: ", o)
Next
' How to remove the first object above and pass on the rest below?
Dim FinalData() As Byte = serializator.ConvertArrayToBytes(Objects)
Main.SaveNetworkDetails(FinalData) ' Originally Main.SaveNetworkDetails(Buffer)
End Sub