Webserver (WIZ810MJ) component

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

Moderator: Benj

Post Reply
streammaster
Posts: 78
Joined: Mon Jul 31, 2017 11:14 am
Has thanked: 7 times
Been thanked: 13 times
Contact:

Webserver (WIZ810MJ) component

Post by streammaster »

Hi All,

I need a help. I created an example app using the Webserver component:
Apps_Internet_Ex1_Webserver test.fcfx
(50.62 KiB) Downloaded 249 times

The application utilizes 8 physical buttons to toggle the LED states on and off. This is possible on a physical panel as well by using the WEB page.
The goal is to show the update of the LED on the web independently and also to be able to flip the lights from the web. I succeeded more or less, so I need your help to improve in particular the web part.

I believe there are a few issues (potentially bugs) with the WIZ810MJ webserver component in Flowcode7. Not sure if I'm doing something wrong or indeed there is a bug. I spent quite a time by trying to debug this and I decided to seek your help.

Please find attached Flowcode app. The 3D panel has only 4 groups of components:
8x Switches (individual)
8x LED (array)
1x LCD
1x Webserver
Server started.PNG
(27.72 KiB) Downloaded 2985 times
The application has a web page (which is really clumsy if you have any improvement suggestions you are very much welcome).
Please note that the status background for SW5,6,and 7 is not working (the code is not updating the %x parameters). This are black as incorrect value is in the HTML. Have a look for problem description bellow.
Web page.PNG
(13.08 KiB) Downloaded 2985 times
So in general terms, the concept is working but there are a few issues:

1. The SetOutValue function is working for index from 0, 1, 2, 3, 4 only. Any index over 4 is creating interference. Like index 5 will override the 0.
My code in "Set_WEB_Button_color" jumps to end after doing indexes from 0-4. You can comment this out, so to see the problem. Not sure if this is a feature or a bug. I would expect at least 16 indexes to be available to create any decent web page.

2. The GetInValue keeps the last received value for ever. In my example, this is a problem since the button controls should arrive on each click of the button. So if the same button is pushed more than once, there is no way for an application to determine. I created a lock mechanism so the WEB control is executed only once (until changes it). However, this would prevent to toggle the same button. Another button needs to be pushed in order to get change. Kind of workaround was in web page java script to have different (neutral) value when the page is refreshed: location.href = "?0=SW8". My used data are from SW0 - SW7 and SW8 are not used. I'm not HTML nor JS expert, so to find this solution (as I coded for the webpage) it took me a lot of digging around and trial and error.

3. A smooth WEB refresh solution. I know this has nothing to do with flow code, but it is a struggle to get a basic. I believe having some buttons to push or submit some value and have a real-time update from the device is something that is really expected with today's (other) web technology in place. If anyone can provide some input and make the page refresh to go smoothly it would be really good. I'm sure it would help many people (like me). It would be really good if such "web page code builder" is part of the Flowcode to match the capability of the simple web server. Perhaps the AJAX parsing could be implemented in future components?

I would appreciate any suggestions and solution which you may have to get this all going as I originally intended.

Regards,

Igor

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: Webserver (WIZ810MJ) component

Post by LeighM »

Hello Igor,

I will have a further look at your code, but just a couple of quick answers ..
1. The SetOutValue function is working for index from 0, 1, 2, 3, 4 only
Check the Webserver Properties, "Substitutions" Count values, e.g your Outgoing is currently 3, so only index 0,1,2 will work.
2. The GetInValue keeps the last received value for ever.
These values are cleared whenever a get request is received, and then the new values are populated from the new get request string.

The index is taken from any numeric content in the name, e.g. http://127.0.0.1/?mybutton2=pressed index 2 will contain "pressed"

Hope that helps,
Leigh

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: Webserver (WIZ810MJ) component

Post by LeighM »

Another button needs to be pushed in order to get change.
Yes you are right, for historic reasons, the webserver sends a reply to the request automatically.
Which means that you are reading the in values in the Flowcode program after a reply has been sent, which has unmodified out values.
So auto refreshing the page is a good solution.
What you can also do is direct the button press to a different page to the auto update index.html page, e.g. an action.html page with <form action="/action.html">

streammaster
Posts: 78
Joined: Mon Jul 31, 2017 11:14 am
Has thanked: 7 times
Been thanked: 13 times
Contact:

Re: Webserver (WIZ810MJ) component

Post by streammaster »

Perhaps the 'CheckSocketActivity' could return a status which is cleared every time when the function is called, i hope this would not have any 'legacy' issues. Maybe return could be a counter which shows how many requests where received since last check. Ideally the circular buffer would be good to have attached on 'GetInValue'

Thanks for other reply.
How hard would be to increase the number of Outgoing indexes from limitation of 5?
our Outgoing is currently 3, so only index 0,1,2 will work.
This is strange as all 5 are working for me with this settings.

Do you have some better solution for the update of the page in your sleeve?

Regards,
Igor

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: Webserver (WIZ810MJ) component

Post by LeighM »

Our latest component has outgoing of up to 12, I think this was updated a few months ago,
perhaps you could try updating your Flowcode?

The CheckSocketActivity() macro already returns a value, you just need to add a test for this in your main code,
it returns 0 if no activity since last call, no-zero if there has been activity.

Leigh

streammaster
Posts: 78
Joined: Mon Jul 31, 2017 11:14 am
Has thanked: 7 times
Been thanked: 13 times
Contact:

Re: Webserver (WIZ810MJ) component

Post by streammaster »

Hi Leigh,
Thanks for this info. I need to test this but currently, i'm working on other projects not involving the web server.
I will need to do it next month, so I will report back how this will go.

Regards,

Igor

johnsondav
Posts: 188
Joined: Thu Jun 28, 2012 7:29 pm
Location: Durham
Has thanked: 86 times
Been thanked: 186 times
Contact:

Re: Webserver (WIZ810MJ) component

Post by johnsondav »

Hi Leigh

You are right in thinking that this component has been updated to allow more variables to be included in the web page. Here is the link to that post made by Ben:

viewtopic.php?f=63&t=18581

Regards
Dave

Post Reply