Cesar_Morisco
Active Member
Talk about weight
All good
I have a question about NewSocket.Stream
Doesn't work, locks app data
I can't receive the data from my application, can anyone give me some guidance?
If I add the second line it works with 50%
Abrir no Google Tradutor•
Feedback
All good
I have a question about NewSocket.Stream
Doesn't work, locks app data
I can't receive the data from my application, can anyone give me some guidance?
If I add the second line it works with 50%
B4R:
Private Sub Server_NewConnection (NewSocket As WiFiSocket)
Astream.Initialize(NewSocket.Stream, "astream_NewData","astream_Error") <<<<<<<<<<< ERROR
Astream.Initialize(NewSocket.Stream, "astream1_NewData","astream2_Error") <<<<<<<<<<<< OK + -
Astream.Write("<html lang=""en"" class="" "">")
Astream.Write( "<head>")
Astream.Write(" <meta charset='utf-8'><meta name=""viewport"" content=""width=device-width,initial-scale=1,user-scalable=no""/>")
Astream.Write(" <style>div,fieldset,input,select{padding:5px;font-size:1em;}fieldset{background:#4f4f4f;}p{margin:0.5em 0;}input{width:100%;box-sizing:border-box;-webkit-box-sizing:border-box;-moz-box-sizing:border-box;background:#dddddd;color:#000000;}input[type=checkbox],input[type=radio]{width:1em;margin-right:6px;vertical-align:-1px;}input[type=range]{width:99%;}select{width:100%;background:#dddddd;color:#000000;}textarea{resize:none;width:98%;height:318px;padding:5px;overflow:auto;background:#1f1f1f;color:#65c115;}body{text-align:center;font-family:verdana,sans-serif;background:#252525;}td{padding:0px;}button{border:0;border-radius:0.3rem;background:#1fa3ec;color:#faffff;line-height:2.4rem;font-size:1.2rem;width:100%;-webkit-transition-duration:0.4s;transition-duration:0.4s;cursor:pointer;}button:hover{background:#0e70a4;}.bred{background:#d43535;}.bred:hover{background:#931f1f;}.bgrn{background:#47c266;}.bgrn:hover{background:#5aaf6f;}a{color:#1fa3ec;text-decoration:none;}.p{float:left;text-align:left;}.q{float:right;text-align:right;}.r{border-radius:0.3em;padding:2px;margin:6px 2px;}</style>")
Astream.Write(" </head>")
Astream.Write(" <body>")
Astream.Write(" <div style='text-align:left;display:inline-block;color:#eaeaea;min-width:340px;'>")
Astream.Write(" <div style='text-align:center;color:#eaeaea;'>")
Dim numberofnetwork As Byte = WiFi.Scan
For i = 0 To numberofnetwork - 1
Astream.Write(" <div style='text-align:left;color:#0000FF;'>")
Astream.Write("Rede: ").Write(Main.wifi.ScannedSSID(i)).Write("")
Astream.Write("</div>")
Next
Astream.Write(" <h3>ESP8266 ESP-12F Modulo</h3>")
Astream.Write(" </div>")
Astream.Write(" <fieldset>")
Astream.Write(" <form action='save' method='get'>")
Astream.Write(" <div><label For='_nwk'>SSID:</label><br><input name='_nwk' id='_nwk' value='").write(bc.StringFromBytes(GStore1.slot0)).write("'></div>")
Astream.Write(" <div><label For='_key'>SSID Key:</label><br><input name='_key' id='_key' value='").write(bc.StringFromBytes(GStore1.slot1)).write("'></div>")
Astream.Write(" <div><label For='_mth'>MQTT Urlm:</label><br><input name='_mth' id='_mth' value='").write(bc.StringFromBytes(GStore1.slot2)).write("'></div>")
Astream.Write(" <div><label For='_mtp'>MQTT Porta:</label><br><input name='_mtp' id='_mtp' value='").write(bc.StringFromBytes(GStore1.slot3)).write("'></div>")
Astream.Write(" <div><label For='_mtc'>MQTT ClientID:</label><br><input name='_mtc' id='_mtc' value='").write(bc.StringFromBytes(GStore1.slot4)).write("'></div>")
Astream.Write(" <div><label For='_mtu'>MQTT Nome:</label><br><input name='_mtu' id='_mtu' value='").write(bc.StringFromBytes(GStore1.slot5)).write("'></div>")
Astream.Write(" <div><label For='_mtk'>MQTT Senha:</label><br><input name='_mtk' id='_mtk' value='").write(bc.StringFromBytes(GStore1.slot6)).write("'></div>")
Astream.Write(" <div><br><button name='_save'>Salvar</button></div>")
Astream.Write(" </form>")
Astream.Write(" <form action='_abort' method='get'>")
Astream.Write(" <div><button onclick=""location.href='/';"" name='_clear'>Apagar</button></div>")
Astream.Write(" </fieldset>")
Astream.Write(" </body>")
Astream.Write(" </html>")
End Sub
Private Sub Astream_NewData (Buffer() As Byte)
If bc.IndexOf(Buffer, "save?_nwk=") <> -1 Then
Dim init(8) As Object
Dim Pt1,Pt2 As Int
Dim nb As Int = 0
Dim nkay() As String = Array As String("&_key=","&_mth=","&_mtp=","&_mtc=","&_mtu=","&_mtk=","&_save=")
Pt1 = bc.IndexOf(Buffer, "save?_nwk=")+10
For Each n As String In nkay
Pt2 = bc.IndexOf(Buffer, n)
Dim temp1() As Byte =bc.substring2(Buffer,Pt1,Pt2)
temp1 = ReplaceString(temp1,"+".getbytes,"%20".getbytes) 'recovery of Space
temp1 = convertunicode(temp1)
bc.ObjectSet(temp1,init(nb))
Log("Valor Nb= ",init(nb))
Pt1 = Pt2+6
nb = nb+1
Next
CloseConnection(0)
For Each o As Object In init
Log("Html= ",o)
Next
Log("Htmldata:",sr.ConvertArrayToBytes(init))
Main.SaveNetworkDetails(sr.ConvertArrayToBytes(init))
CloseConnection(0)
Else
If bc.IndexOf(Buffer, "/_abort?_abort=") <> -1 Then
Log("====> abort input")
CloseConnection(0)
Else
If bc.IndexOf(Buffer, "/_abort?_clear=") <> -1 Then
Log("====> clear eeprow")
Main.ClearStoredDataLength
End If
CloseConnection(9)
End If
End If
End Sub
Private Sub Astream1_NewData (Buffer() As Byte)
'Dim value As String = bc.StringFromBytes(Buffer)
Log(Buffer)
End Sub
Private Sub CloseConnection(u As Byte)
If server.Socket.Connected Then
server.Socket.Stream.Flush
server.Socket.Close
End If
End Sub
Private Sub AStream_Error
server.Socket.Close
server.Listen
End Sub
Private Sub AStream2_Error
server.Socket.Close
server.Listen
End Sub
Abrir no Google Tradutor•
Feedback