Download Smart & Mobile Embedded Web Server User Guide
Transcript
function is called, thus setting the current threshold. The periodic timer executed every 200 ms
compares the current temperature to this threshold. If needed, it triggers the channel, thus sending
the current time to every registered clients. This produces an infinite HTTP response: the Web
browser receives new data whenever the threshold is reached.
3.3
Post request processing
Smews supports post request processing, which are used to send lots of data. Smews considers
two types of data : forms and files. The C files containing XML specific code (as C comment) like
to generate dynamic content (see 3.2 section).
3.3.1
Form
Example of a HTML form :
<form a c t i o n=” p o s t t e s t 1 ” method=post >
<l a b e l >i n t : </ l a b e l >
<i n p u t type=” t e x t ” name=” i 1 ” i d=” i 1 ” v a l u e=” 4 ” />
<br />
<l a b e l >s t r : </ l a b e l >
<i n p u t type=” t e x t ” name=” s ” i d=” s ” v a l u e=” t o t o ” />
<br />
<l a b e l >i n t : </ l a b e l >
<i n p u t type=” t e x t ” name=” i 2 ” i d=” i 2 ” v a l u e=” 5 ” />
<i n p u t type=submit v a l u e=” Submit ”/>
</form>
Display from a web browser :
SMEWS needs doPost function and arguments (like to parse URL arguments, see 3.2.2 section).
/∗
<g e n e r a t o r >
<h a n d l e r s doPost=” o u t p u t a r g s ”/>
<a r g s >
<a r g name=” i 1 ” t y p e=” u i n t 8 ” />
<a r g name=”s ” t y p e=” s t r ” s i z e =”6” />
<a r g name=” i 2 ” t y p e=”u i n t 1 6 ” />
</a r g s >
</g e n e r a t o r >
∗/
s t a t i c char o u t p u t a r g s ( struct a r g s t ∗ a r g s ) {
i f ( args ) {
out str (” f i r s t int : ” );
o u t u i n t ( a r g s −>i 1 ) ;
o u t s t r ( ”\ n s t r : ” ) ;
o u t s t r ( a r g s −>s ) ;
13