![](/media/cache/profiles/7c39a5f991bef4a1e34187677a65871d.jpg.50x50_q85.jpg)
A remote timer, equipped with a scheduling Web interface, controls a "DigitalOut".
Dependencies: Timezone NTPClient
WebTimer
The WebTimer is an Mbed device enabling to remotely control a DigitalOut. It has a "calendar-like" user interface to edit the schedule - a table you can click on (or tap on a touch-screen device).
The program was ported to Mbed from the Tuxgraphics site. Thank you Guido for sharing!
- When starting, it will print it's IP address over the USB serial link to the terminal screen. However, you can set a different static IP address if you modify the code in the
main.cpp
. - To connect to the WebTimer, type the IP address into the web browser edit box and hit
ENTER
. - When a cell is green then the timer keeps it's output
ON
during that period of time. If a cell is not green it means the output isOFF
.
- To select or deselect multiple cells you can click (keep down the button) and move the mouse over more cells.
- The smallest time interval on this 24h timer is 15minutes.
- To save the changes type in the password and hit
ENTER
or click on theSave
button. - The default password is "secret". But you can change it by editing the source code in
main.cpp
.
![]() | ![]() |
Diff: main.cpp
- Revision:
- 3:2862fe67dce0
- Parent:
- 2:6d02d3d314a2
- Child:
- 4:fe9189193dcd
diff -r 6d02d3d314a2 -r 2862fe67dce0 main.cpp --- a/main.cpp Thu Nov 12 18:23:29 2020 +0000 +++ b/main.cpp Thu Nov 12 18:36:25 2020 +0000 @@ -199,7 +199,6 @@ strcpy(httpHeader, "HTTP/1.0 200 OK"); memset(httpBuf, 0, sizeof(httpBuf)); strcpy(httpBuf, "<meta name=viewport content=\"width=device-width\">\n"); - /*$off*/ strcat ( httpBuf, @@ -221,7 +220,6 @@ "</script>\n" "</pre><hr>\n" ); - /*$on*/ } /** @@ -268,9 +266,6 @@ void printJavaScriptFunctions(void) { setHeaderToHttp200ok(); - - // - /*$off*/ memset(httpBuf, 0, sizeof(httpBuf)); strcpy ( @@ -312,7 +307,6 @@ "}\n" "}" ); - /*$on*/ } /** @@ -331,7 +325,6 @@ "<meta name=viewport content=\"width=device-width\">\n" "<a href=/sw>[Switch]</a> <a href=/sc>[Set clock]</a> <a href=/>[↻Refresh]</a>\n" ); - /*$on*/ strcat(httpBuf, "<h2><pre>Watering Timer<br>"); strcat(httpBuf, "Output: "); @@ -348,7 +341,6 @@ strcat(httpBuf, ":"); addHttpDataUint8(tmNow.tm_min); strcat(httpBuf, "</pre></h2>\n"); - /*$off*/ strcat ( httpBuf, @@ -374,7 +366,7 @@ "dw(\"</table></td></tr></table>\");\n" "dw(\"1 cell=15min\");\n" ); - /*$on*/ + // initialize the table with the current settings strcat(httpBuf, "it(new Array("); addHttpDataUint16(tablebitmap[0]); @@ -387,7 +379,6 @@ } strcat(httpBuf, "));\n"); - /*$off*/ strcat( httpBuf, "</script>\n" @@ -398,12 +389,19 @@ "<input type=submit value=save>\n" "</form>\n" ); - /*$on*/ } -// takes a string of the form command/Number and analyse it (e.g "cc?tv=8%3A15&pw=secret HTTP/1.1") - -// The first char of the url ('/') is already removed. +/** + * @brief Takes a string of the form command/Number and analyses it. + * @note Thre string is like "cc?tv=8%3A15&pw=secret HTTP/1.1" + * The first char of the url ('/') is already removed. + * @param str The string to be analysed. + * @retval -1 Unauthorized + * 0 Page not found + * 1 Send page + * 2 Send Java Script function + * + */ int8_t analyseUrl(char* str) { int8_t i;