Help with ESP8266 TCP server and HTML

For Flowcode users to discuss projects, flowcharts, and any other issues related to Flowcode 8.

Moderator: Benj

Post Reply
gonzogonzo
Posts: 56
Joined: Mon Aug 11, 2014 3:57 pm
Has thanked: 18 times
Been thanked: 17 times
Contact:

Help with ESP8266 TCP server and HTML

Post 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

gonzogonzo
Posts: 56
Joined: Mon Aug 11, 2014 3:57 pm
Has thanked: 18 times
Been thanked: 17 times
Contact:

Re: Help with ESP8266 TCP server and HTML

Post 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>

viktor_au
Posts: 342
Joined: Fri Jan 26, 2018 12:30 pm
Location: South Australia
Has thanked: 43 times
Been thanked: 60 times
Contact:

Re: Help with ESP8266 TCP server and HTML

Post 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">
Last edited by viktor_au on Tue Aug 27, 2019 8:05 pm, edited 1 time in total.

gonzogonzo
Posts: 56
Joined: Mon Aug 11, 2014 3:57 pm
Has thanked: 18 times
Been thanked: 17 times
Contact:

Re: Help with ESP8266 TCP server and HTML

Post 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>

viktor_au
Posts: 342
Joined: Fri Jan 26, 2018 12:30 pm
Location: South Australia
Has thanked: 43 times
Been thanked: 60 times
Contact:

Re: Help with ESP8266 TCP server and HTML

Post by viktor_au »

Hello again
----
Can you post your program?
---
Last edited by viktor_au on Tue Aug 27, 2019 10:43 am, edited 1 time in total.

gonzogonzo
Posts: 56
Joined: Mon Aug 11, 2014 3:57 pm
Has thanked: 18 times
Been thanked: 17 times
Contact:

Re: Help with ESP8266 TCP server and HTML

Post 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]
Attachments
ESP8266_TCPServer_Nuovo4test.fcfx
(23.5 KiB) Downloaded 220 times

viktor_au
Posts: 342
Joined: Fri Jan 26, 2018 12:30 pm
Location: South Australia
Has thanked: 43 times
Been thanked: 60 times
Contact:

Re: Help with ESP8266 TCP server and HTML

Post by viktor_au »

Hello gonzogonzo

Looks like we need help from advanced in web communication people.
I hope Matrix team will direct us.
Last edited by viktor_au on Tue Aug 27, 2019 11:22 am, edited 1 time in total.

User avatar
LeighM
Matrix Staff
Posts: 2178
Joined: Tue Jan 17, 2012 10:07 am
Has thanked: 481 times
Been thanked: 699 times
Contact:

Re: Help with ESP8266 TCP server and HTML

Post 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"

gonzogonzo
Posts: 56
Joined: Mon Aug 11, 2014 3:57 pm
Has thanked: 18 times
Been thanked: 17 times
Contact:

Re: Help with ESP8266 TCP server and HTML

Post 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.

Post Reply