Page 1 of 1

Help with ESP8266 TCP server and HTML

Posted: Sun Aug 25, 2019 10:03 am
by gonzogonzo
Hello,
I'm trying to use ESP8266 as a TCP AP server and everything works but I have a problem with assigning the value of a textbox to a required parameter (use of GetInValue(x)) in html (I'm not an expert in this) in Flowcode; does anyone have a small example?
Thanks in advance

Re: Help with ESP8266 TCP server and HTML

Posted: Sun Aug 25, 2019 3:10 pm
by gonzogonzo
I managed to make it work but only if I use the zero parameter with the others not; I attach html because it probably causes the malfunction; if anyone can help me ...
Cattura.PNG
(7.76 KiB) Downloaded 1204 times
<html>
<head>
<title>ESP8266 - DHT22: impostazioni</title>
<style>
body {
background-color: black;
text-align: center;
color: white;
font-family: Arial, Helvetica, sans-serif;
}
</style>
</head>
<body>


<form action="page2.htm?0">
<textarea name="myTextBox" cols="10" rows="1">
Enter
</textarea>
<br />
<input type="submit" />
</form>

</body>
</html>

Re: Help with ESP8266 TCP server and HTML

Posted: Sun Aug 25, 2019 11:22 pm
by viktor_au
Hello gonzogonzo

I am not sure, but looks like your HTML page1 asks for HTML page2.
The form on HTML page1 has code: <form action="page2.htm?0">

Re: Help with ESP8266 TCP server and HTML

Posted: Mon Aug 26, 2019 10:21 am
by gonzogonzo
Hello viktor_au,

I have to apologize because I didn't post html of all the pages; I do it now.
Summing up, everything works except the textbox part if I try to use parameters other than parameter 0; the strange thing is that the lines above the textbox part work and this makes me think of something I don't understand about HTML (I'm not an expert I've only tried to reuse parts of code).

I tested it on real circuit with PIC18F45K22, ESP8266-01 and AM2302 (DHT22) with success (if i use 0 parameter for textbox); page2.htm,in my intentions, would be used to set some parameter of circuit and index.htm used to display value.

Some idea?

Thank you
<!-- index.htm -->

<html><head><title>ESP8266-DHT22</title>
<script type="text/javascript">
function reFresh()
{
location.reload(true)
}
window.setInterval("reFresh()",5000);
</script>
<style>
.On {background-color: black;text-align: center;color: white;font-family: Arial, Helvetica, sans-serif;}
.Off{background-color: black;text-align: center;color: white;font-family: Arial, Helvetica, sans-serif;}
</style></head>
<body class=On> <h1>Temperatura = %1 <h1> Umidita' = %2 <br>
<a href="page2.htm">Impostazioni</a></body></html>


<!-- page2.htm -->

<html>
<head>
<title>ESP8266 - DHT22: impostazioni</title>
<style>
body {
background-color: black;
text-align: center;
color: white;
font-family: Arial, Helvetica, sans-serif;
}
</style>
</head>
<body>

<!-- Under work ok -->

<h1><a href="index.htm">Pagina principale</a><br></h1>
<p><a href="page2.htm?1=1?2=5">Invia 1</a><br></p>
<p><a href="page2.htm?1=2?2=6">Invia 2</a><br></p>

<!-- Under work ok ONLY for 0 parameter not for 1 or 2 parameter -->

<form action="page2.htm?0">
<textarea name="myTextBox" cols="10" rows="1">
Enter
</textarea>
<br />
<input type="submit" />
</form>

</body>
</html>

Re: Help with ESP8266 TCP server and HTML

Posted: Mon Aug 26, 2019 12:30 pm
by viktor_au
Hello again
----
Can you post your program?
---

Re: Help with ESP8266 TCP server and HTML

Posted: Mon Aug 26, 2019 2:13 pm
by gonzogonzo
Hi, I also am not sure I have understood what you are saying (as I have already told you I am not an expert in terms of networks and protocols: I just wanted to try to create a circuit to access with WIFI and PC); however I attach the program (I made some visual improvements in index.htm but it doesn't change anything) and I guarantee you that as it is it works on real devices.
[img]
Cattura.PNG
(11.7 KiB) Downloaded 1164 times
[/img]

Re: Help with ESP8266 TCP server and HTML

Posted: Tue Aug 27, 2019 2:18 am
by viktor_au
Hello gonzogonzo

Looks like we need help from advanced in web communication people.
I hope Matrix team will direct us.

Re: Help with ESP8266 TCP server and HTML

Posted: Tue Aug 27, 2019 8:52 am
by LeighM
Hi,
I am not sure exactly what you are trying to do, but hope this helps:

This will send a request to page2 with two text strings as parameters

Code: Select all

<form action="page2.htm">
Item 0: <input type="text" name="0" value="Contents 0"><br>
Item 1: <input type="text" name="1" value="Contents 1"><br>
<input type="submit" value="Submit">
</form>
So after a call to CheckForPageRequests(), check that ret has the value 2 (to indicate that it was a request for page 2)
Then GetInValue(0) will return "Contents 0" and GetInValue(1) will return "Contents 1"

Re: Help with ESP8266 TCP server and HTML

Posted: Tue Aug 27, 2019 11:26 am
by gonzogonzo
Hello LeighM,
yes this is the suggestion that served my purpose; now I understand how to use html together into Flowcode. A proper thanks to you and also to viktor_au goes for help me.