App Developper: From Webserver to App Developper

Post here to discuss any new features, components, chips, etc, that you would like to see in Flowcode.
Post Reply
stefan.erni
Valued Contributor
Posts: 738
http://meble-kuchenne.info.pl
Joined: Wed Dec 02, 2020 10:53 am
Has thanked: 149 times
Been thanked: 170 times

App Developper: From Webserver to App Developper

Post by stefan.erni »

Hi Ben

I get your webserver from this topic.
viewtopic.php?f=9&t=739

I changed it a little and took the date and time as simulated AD values. I wrote these values in an HTML table. I can look at this table in Explorer and also automatically insert and refresh this table in Excel. I just have to enter the IP address. I would now like to read and process this table with the app developper. How can I do that?

regards

Stefan
AppDev_Webserver_tab.fcsx
(20.98 KiB) Downloaded 109 times
web_server_2021-11-04_16-09-32.png
web_server_2021-11-04_16-09-32.png (120.25 KiB) Viewed 3653 times
how to choose the webserver for Excel and insert the tabel
web_3_2021-11-04_16-38-18.png
web_3_2021-11-04_16-38-18.png (152.88 KiB) Viewed 3653 times

BenR
Matrix Staff
Posts: 1707
Joined: Mon Dec 07, 2020 10:06 am
Has thanked: 435 times
Been thanked: 598 times

Re: App Developper: From Webserver to App Developper

Post by BenR »

Hello Stefan,

That looks great.

Ok let me try and understand what exactly you're trying to do.

Are you A) trying to read the HTML table in a second instance of app developer say running on a different machine on the network, or B) trying to read back the processed data from Excel.

For A) have a look here.
https://www.flowcode.co.uk/wiki/images/ ... lient.fcfx

Your GET command might look like this.

Code: Select all

"GET /index.htm HTTP/1.1\nHost: 192.168.1.10\n\n"
For B) can you save the Excel file in CSV format, if you can then the CSV read/write component will help.

stefan.erni
Valued Contributor
Posts: 738
Joined: Wed Dec 02, 2020 10:53 am
Has thanked: 149 times
Been thanked: 170 times

Re: App Developper: From Webserver to App Developper

Post by stefan.erni »

Hi Ben

I only need version A.
I have different ESP32 web servers here in the building and for testing purposes I also have an AppDevelopper web server on a computer. The web server on the Appdevelopper works and is very convenient to not always program the ESP32. The HTML code remains the same, regardless of whether it is ESP32 or AppDevelopper Program

Yes, I will try the GET command. Thank you very much

The goal is that I can read the table from every room with a web browser (cell phone, tablet or notebook) and from my office I can then read out all clients via the Appdevelopper program and save the values.

The ESP32 web server and the Appdevelopper web server are already working.

With the AppDevelopper I just want to read a table in the received HTML code and recognize the words and values correctly regardless of the format

For that I'm trying to convert the HTML string from <table> to </table> into words and values.

regards

Stefan

Code: Select all

<html>
<body>
<h1>Flowcode App Developer Webserver</h1>

<table>
  <tr>
    <th>Signal</th>
    <th>Pin</th>
    <th>Value</th>
  </tr>
  <tr>
    <td>ADC1</td>
    <td>A1</td>
    <td>%11.</td>
   </tr>
   <tr>
     <td>ADC2</td>
     <td>A2</td>
     <td>%12.</td>
   </tr>
   <tr>
     <td>ADC3</td>
     <td>A3</td>
     <td>%13.</td>
   </tr>
   <tr>
     <td>ADC4</td>
     <td>A4</td>
     <td>%14.</td>
   </tr>
   <tr>
     <td>ADC4</td>
     <td>A5</td>
     <td>%15.</td>
   </tr>
  <tr>
     <td>ADC4</td>
     <td>A6</td>
     <td>%16.</td>
   </tr>
</table>
</body>
</html>

BenR
Matrix Staff
Posts: 1707
Joined: Mon Dec 07, 2020 10:06 am
Has thanked: 435 times
Been thanked: 598 times

Re: App Developper: From Webserver to App Developper

Post by BenR »

This might work with the XML parser.

Let me have a play as that would potentially save you writing a finite state machine to parse through the raw text.

You could always format as XML on the server end and this might make things easier but then it probably wouldn't be as nice to look at if you need it to be presented in a table.

BenR
Matrix Staff
Posts: 1707
Joined: Mon Dec 07, 2020 10:06 am
Has thanked: 435 times
Been thanked: 598 times

Re: App Developper: From Webserver to App Developper

Post by BenR »

Yes it does work as is with the XML parser. HTML and XML are very similar.

Here's a simple example to parse the data string and print data to the console.
XML_Example.fcsx
(15.36 KiB) Downloaded 105 times
You would just need to combine this with the example with the GET request and then you will be able to collect the data string from the server and parse through the data table.

stefan.erni
Valued Contributor
Posts: 738
Joined: Wed Dec 02, 2020 10:53 am
Has thanked: 149 times
Been thanked: 170 times

Re: App Developper: From Webserver to App Developper

Post by stefan.erni »

Hi Ben

Thanks a lot for the example. I put both together and it looks like it works,
but not enough characters are received. One times it will be 179 or then 19 or 79 or 139. I tried to make all the arrays bigger but without success.


regards

Stefan
Web_Get_From_Server.fcsx
(21.34 KiB) Downloaded 121 times
Attachments
WEB_2021-11-10_11-24-58.jpg
WEB_2021-11-10_11-24-58.jpg (18.74 KiB) Viewed 3576 times

BenR
Matrix Staff
Posts: 1707
Joined: Mon Dec 07, 2020 10:06 am
Has thanked: 435 times
Been thanked: 598 times

Re: App Developper: From Webserver to App Developper

Post by BenR »

Hi Stefan,

So it's the Network Comms that is receiving not all the data. Maybe try adding a small delay in between issuing the GET command and receiving the data, this will allow the data to be collected and ready when you call the receive function. Maybe try a delay of 1s and see how you get on. If this works well then you can try reducing to see what you can get away with.

Another way might be to receive data and store into a circular buffer char by char, then try and receive more data and repeat until you get a timeout or instead search the CB for the "</html>" tag to indicate the end of the data.

I could maybe add routines to the CB component to allow you to easily store and retrive a string. I'll look into this now for you.

stefan.erni
Valued Contributor
Posts: 738
Joined: Wed Dec 02, 2020 10:53 am
Has thanked: 149 times
Been thanked: 170 times

Re: App Developper: From Webserver to App Developper

Post by stefan.erni »

Hi Ben

Perfect!

It's working with a delay 500ms (100ms is to short)


One more question

When I put the table (webserver) on my page on the Internet
How does the GET command look like?

Code: Select all

"GET /index.htm HTTP / 1.1 \ nHost: https://www.tennwil.ch/\n\n"

regards

Stefan

parsing_2021-11-10_12-43-57.jpg
parsing_2021-11-10_12-43-57.jpg (32.62 KiB) Viewed 3565 times
parsing_2021-11-10_12-44-23.jpg
parsing_2021-11-10_12-44-23.jpg (13.02 KiB) Viewed 3565 times
Attachments
Web_Get_From_Server.fcsx
(21.52 KiB) Downloaded 114 times

BenR
Matrix Staff
Posts: 1707
Joined: Mon Dec 07, 2020 10:06 am
Has thanked: 435 times
Been thanked: 598 times

Re: App Developper: From Webserver to App Developper

Post by BenR »

Hi Stefan,

At the moment talking with a https server will be problematic. Can you connect using http instead?

Code: Select all

"GET /index.htm HTTP / 1.1 \ nHost: http://www.tennwil.ch/\n\n"
We have started with https support for app developer but it's not really been well tested yet. It's on my list to do but at the moment it's low priority. I could try and bump it up if that would help.

stefan.erni
Valued Contributor
Posts: 738
Joined: Wed Dec 02, 2020 10:53 am
Has thanked: 149 times
Been thanked: 170 times

Re: App Developper: From Webserver to App Developper

Post by stefan.erni »

Hi Ben
but it's not really been well tested yet
that's always okay with me

I add the CSV writer and It is very convenient to save an Excel file on the PC with the data from a Flowcode web server

regards

Stefan

Web_Get_From_Server_csv.fcsx
(24.16 KiB) Downloaded 124 times
parsing to excel_2021-11-10_16-25-05.jpg
parsing to excel_2021-11-10_16-25-05.jpg (42.04 KiB) Viewed 3549 times

Post Reply