hi
i try to extract data from html interface after a get, but my loop is not working
at end of inputs extract, , i want to convert inputs to byte with sr.convertarraytobytes to store after in eeprom but,
- if i store inputs in an array as string (init(14) as string), extraction is correct but sr.convertarraytobytes is not possible
- if i use init(14) as object, extraction of inputs is not correct but sr.convertarraytobytes seems possible.
i am not able to find correct way to make this extract and to send it to eeprom, your help will be welcome
i create this small code to test my issue:
i try to extract data from html interface after a get, but my loop is not working
at end of inputs extract, , i want to convert inputs to byte with sr.convertarraytobytes to store after in eeprom but,
- if i store inputs in an array as string (init(14) as string), extraction is correct but sr.convertarraytobytes is not possible
- if i use init(14) as object, extraction of inputs is not correct but sr.convertarraytobytes seems possible.
i am not able to find correct way to make this extract and to send it to eeprom, your help will be welcome
i create this small code to test my issue:
B4X:
sub Process_Globals
Public Serial1 As Serial
Private bc As ByteConverter
Private sr As B4RSerializator
Private htmlinput() As Byte ="GET /save?_nwk=Livebox-toto&_key=123456123456123456&_mth=my.cloudmqtt.com&_mtp=10753&_mtc=rfgate_070255&_mtu=uver750&_mtk=azertytyu&_ms1=tele%2Frfbridge%2FRESULT&_ms2=cmnd%2Frfgate&_ms3=stat%2Frfbridge%2FRESULT&_mt1=cmnd%2Frfbridge%2Fbacklog&_mt2=tele%2Frfgate%2FRESULT&_ss1=4DDDDD&_ss2=CEEEEE&_save= HTTP/1.1"
End Sub
Private Sub AppStart
Serial1.Initialize(115200)
Log("AppStart")
Astream_NewData(htmlinput)
End Sub
Private Sub Astream_NewData (Buffer() As Byte)
Log("startB=",Buffer,"=endB")
If bc.IndexOf(Buffer, "save?_nwk=") <> -1 Then
Dim init(14) As String 'object NOK
Dim pt1,pt2 As Int
pt1 = bc.IndexOf(Buffer, "save?_nwk=")+10
Dim nb As Int = 0
Dim nkay() As String = Array As String("&_key=","&_mth=","&_mtp=","&_mtc=","&_mtu=","&_mtk=","&_ms1=","&_ms2=","&_ms3=","&_mt1=","&_mt2","&_ss1","&_ss2","&_save=")
For Each n As String In nkay
pt2 = bc.IndexOf(Buffer, n)
Log("pt2=",pt2)
init(nb) =bc.StringFromBytes(bc.substring2(Buffer,pt1,pt2))
pt1 = pt2+6
nb = nb +1
Next
Log("inputs from html !")
For Each o As Object In init
Log("html=",o)
Next
' Log("htmldata:",sr.convertarraytobytes(init)) 'with init() as string NOK
' Main.SaveNetworkDetails(sr.ConvertArrayToBytes(init))
Log("memory=", AvailableRAM)
Log("stack :",StackBufferUsage)
End If
End Sub