├── Main
├── RefreshButton.ino
├── IO_CTL.ino
├── A1_UserConfig.h
├── mDNS.ino
├── FarmImage.ino
├── A2_UtilsSend.h
├── NotFound.ino
├── Navigator.ino
├── ScanWifi.ino
├── B_SVG_Line.ino
├── B_SVG_Bar.ino
├── B_SliderBar.ino
├── A4_WifiCTL.ino
├── VisitorMap.ino
├── H_InfoPage.ino
├── B_SVG_Line_FH.ino
├── Main.ino
├── A2_UtilsSend.ino
├── H_AdminPage.ino
├── NTP_Client.ino
├── A3_Handlers.ino
├── H_HomePage.ino
├── A2_UtilsSupport.ino
├── H_HelpPage.ino
├── B_SVG_Clock.ino
├── B_SVG_Inst.ino
└── A1_Main.h
└── README.md
/Main/RefreshButton.ino:
--------------------------------------------------------------------------------
1 | // RefreshButton
2 |
3 | /*
4 | * Copyright (c) 2015, Eldon R. Brown - ERB - WA0UWH - eldonb@ebcon.com
5 | *
6 | * See my Blog, at: http://WA0UWH.blogspot.com
7 | *
8 | * See my Source at GitHub, at: https://github.com/wa0uwh/ERB-EspWebServer
9 | *
10 | * All rights reserved. See FULL Copyright in Main or Info Page for Exclusions
11 | *
12 | * This Effort was Inspired by work by: Majenko Technologies - 2015 Esp8266 AdvancedWebServer
13 | *
14 | * See also Arduino IDE, at: https://github.com/esp8266/Arduino
15 | */
16 |
17 |
18 | // ###########################################################
19 | //////////////////////////////////////////////////////////////
20 | //
21 | long
22 | ICACHE_FLASH_ATTR
23 | reFreshButton(String link)
24 | {
25 | long sz = 0; // Sent Size
26 |
27 | sz += wprintln( sF("
") );
30 |
31 | return sz;
32 | }
33 |
34 | // ###########################################################
35 | // End
36 |
--------------------------------------------------------------------------------
/Main/IO_CTL.ino:
--------------------------------------------------------------------------------
1 | // IO_CTL
2 |
3 | /*
4 | * Copyright (c) 2015, Eldon R. Brown - ERB - WA0UWH - eldonb@ebcon.com
5 | *
6 | * See my Blog, at: http://WA0UWH.blogspot.com
7 | *
8 | * See my Source at GitHub, at: https://github.com/wa0uwh/ERB-EspWebServer
9 | *
10 | * All rights reserved. See FULL Copyright in Main or Info Page for Exclusions
11 | *
12 | * This Effort was Inspired by work by: Majenko Technologies - 2015 Esp8266 AdvancedWebServer
13 | *
14 | * See also Arduino IDE, at: https://github.com/esp8266/Arduino
15 | */
16 |
17 |
18 | // ###########################################################
19 | //////////////////////////////////////////////////////////////
20 | //
21 | //
22 | void
23 | ICACHE_FLASH_ATTR
24 | redLed(boolean state)
25 | {
26 | gRedLedState = state;
27 | digitalWrite(gRedLED, gRedLedState);
28 | Serial.println ( sF("RedLED") + String(gRedLedState == ON ? "ON" : "OFF") );
29 | }
30 |
31 | // ###########################################################
32 | //////////////////////////////////////////////////////////////
33 | //
34 | //
35 | void
36 | ICACHE_FLASH_ATTR
37 | redLed_toggle()
38 | {
39 | gRedLedState = !gRedLedState;
40 | redLed(gRedLedState);
41 | }
42 |
43 |
44 | // ###########################################################
45 | // End
46 |
--------------------------------------------------------------------------------
/Main/A1_UserConfig.h:
--------------------------------------------------------------------------------
1 | // A1_UserConfig.h
2 |
3 |
4 | #ifndef USERCONFIG_H
5 | #define USERCONFIG_H
6 |
7 |
8 | // Note: By my convention, All Global Variables and Constants start with a letter "g".
9 |
10 | // Station Config
11 | String gSsid = "EBCON"; // Change to your SSID
12 | String gPasswd = "........"; // Change to your Passwd
13 |
14 |
15 | // Default Unit ID "Node" Name, This will be changed in Setup
16 | char gDeviceName[16] = "Nod000000";
17 |
18 |
19 | // Soft AP Config
20 | const String gSoftAPAddress = "192.168.4.1"; // Default Soft AP IP Address
21 | const int gDeviceApChannelDefault = 8; // Used when in SoftAP only Mode
22 | int gApChannel = gDeviceApChannelDefault;
23 |
24 |
25 | // Initial Automatic Page Refresh Intervals
26 | int gAutoHomeRefresh = 180;
27 | int gAutoHelpRefresh = 180;
28 | int gAutoAdminRefresh = 180;
29 |
30 |
31 | // Time ZONE
32 | const long gTimeZONE = (-7*HRs/SECs); // PDT
33 |
34 |
35 | // Used to set LED state
36 | const boolean ON = 0;
37 | const boolean OFF = !ON;
38 |
39 |
40 | // Pin numbers for LEDs
41 | const int gGrnLED = 0;
42 | const int gRedLED = 2;
43 | const int gBluLED = 4;
44 | boolean gRedLedState = OFF;
45 |
46 | // My Known Esp Unit ID's
47 | const char* knowUnitID[] = {
48 | "1083.7620", "Esp13", // Nod129
49 | "1053.1281", "Esp11",
50 | "1669.8581", "Esp11",
51 | "1053.1277", "Esp11", // Nod168
52 | };
53 |
54 | #endif // USERCONFIG_H
55 |
56 | // ###########################################################
57 | // End
58 |
59 |
--------------------------------------------------------------------------------
/Main/mDNS.ino:
--------------------------------------------------------------------------------
1 | // mDNS
2 |
3 | /*
4 | * Copyright (c) 2015, Eldon R. Brown - ERB - WA0UWH - eldonb@ebcon.com
5 | *
6 | * See my Blog, at: http://WA0UWH.blogspot.com
7 | *
8 | * See my Source at GitHub, at: https://github.com/wa0uwh/ERB-EspWebServer
9 | *
10 | * All rights reserved. See FULL Copyright in Main or Info Page for Exclusions
11 | *
12 | * This Effort was Inspired by work by: Majenko Technologies - 2015 Esp8266 AdvancedWebServer
13 | *
14 | * See also Arduino IDE, at: https://github.com/esp8266/Arduino
15 | */
16 |
17 |
18 | // ###########################################################
19 | //////////////////////////////////////////////////////////////
20 | //
21 | // mDNS Resonder
22 | //
23 | void
24 | ICACHE_FLASH_ATTR
25 | initMDNS()
26 | {
27 |
28 | digitalWrite ( gBluLED, ON );
29 | if ( gMDns.begin ( gDeviceName, WiFi.localIP() ) ) {
30 | Serial.println ( sF("MDNS Responder Started for: ") + String( gDeviceName ) );
31 | yield();
32 | gMDnsResponderReady = true;
33 | }
34 | digitalWrite ( gBluLED, OFF );
35 | yield();
36 | }
37 |
38 |
39 | // ###########################################################
40 | //////////////////////////////////////////////////////////////
41 | //
42 | // Updates mDNS
43 | //
44 | void
45 | ICACHE_FLASH_ATTR
46 | updateMDNS()
47 | {
48 |
49 | const unsigned long schdInc = 5 * MINs;
50 |
51 | if (!gMDnsResponderReady) { initMDNS(); return; }
52 |
53 | if (gNextMDnsSchd > millis()) return; // Abort, wait for next Run
54 |
55 | gNextMDnsSchd = millis() + schdInc; // Schedule Next Run
56 |
57 | digitalWrite ( gBluLED, ON );
58 | gMDns.update();
59 | yield();
60 | Serial.println ( F("\nMDMS Update Sent ...") );
61 | digitalWrite ( gBluLED, OFF );
62 | yield();
63 |
64 | }
65 |
66 |
67 | // ###########################################################
68 | // End
69 |
--------------------------------------------------------------------------------
/Main/FarmImage.ino:
--------------------------------------------------------------------------------
1 | // FarmImage
2 |
3 | /*
4 | * Copyright (c) 2015, Eldon R. Brown - ERB - WA0UWH - eldonb@ebcon.com
5 | *
6 | * See my Blog, at: http://WA0UWH.blogspot.com
7 | *
8 | * See my Source at GitHub, at: https://github.com/wa0uwh/ERB-EspWebServer
9 | *
10 | * All rights reserved. See FULL Copyright in Main or Info Page for Exclusions
11 | *
12 | * This Effort was Inspired by work by: Majenko Technologies - 2015 Esp8266 AdvancedWebServer
13 | *
14 | * See also Arduino IDE, at: https://github.com/esp8266/Arduino
15 | */
16 |
17 | #include "Farm01.h"
18 |
19 |
20 | // ###########################################################
21 | //////////////////////////////////////////////////////////////
22 | //
23 | // This Function provides the Content for the URL Requsest from WIFI
24 | //
25 | long
26 | ICACHE_FLASH_ATTR
27 | farmImage()
28 | {
29 | long sz = 0; // Sent Size
30 |
31 | DEBUG_MONITOR_REPORT_START();
32 |
33 | DEBUG_MONITOR_REPORT_ARGS();
34 |
35 | sz += wSendCBuf_P(gFarm01, sizeof(gFarm01));
36 |
37 | DEBUG_MONITOR_REPORT_END();
38 |
39 | return sz;
40 | }
41 |
42 | // ###########################################################
43 | //////////////////////////////////////////////////////////////
44 | //
45 | // This Function Handles the URL Requsest from WIFI
46 | // and reports activity on Serial
47 | //
48 | void
49 | ICACHE_FLASH_ATTR
50 | handleFarmImage()
51 | {
52 | long sz = 0; // Sent Size
53 | gSentSize = 0;
54 |
55 | digitalWrite ( gBluLED, ON );
56 | gHits++;
57 |
58 | // HTTP Header
59 | sz += wprintln( F("HTTP/1.1 200 OK") );
60 | sz += wprintln( F("Content-Type: image/jpeg") );
61 | sz += wprintln( ); // A Blank Line
62 |
63 | sz += farmImage();
64 |
65 | sz += wprint( "", SEND_FINISH ); // Final Packet
66 |
67 | DEBUG_MONITOR_REPORT_TOTAL();
68 |
69 | digitalWrite ( gBluLED, OFF );
70 | yield();
71 | }
72 |
73 | // ###########################################################
74 | // End
75 |
--------------------------------------------------------------------------------
/Main/A2_UtilsSend.h:
--------------------------------------------------------------------------------
1 | // A2_UtilsSend.h
2 |
3 | #ifndef UTILSSEND_H
4 | #define UTILSSEND_H
5 |
6 |
7 | // ###########################################################
8 | //////////////////////////////////////////////////////////////
9 | const char THIS_APP_WIFI_SEND_API[] PROGMEM = R"(
10 | /*
11 | * These Send Functions provide this App with WIFI Send Functions (APIs),
12 | * only the four High Level functions should be used, and only these.
13 | *
14 | * Each API is written dependent on a Lower Level APIs, with only one API actually
15 | * sending data to WIFI.
16 | *
17 | * The APIs are listed 'Highest' to 'Lowest" with their data flow dependence:
18 | *
19 | * High Level:
20 | *
21 | * wprintln(); // High Level, App API to Print a String with NewLine
22 | * wprint(); // Call App API Print a String
23 | *
24 | * wprint(); // High Level, App API to Print a String
25 | * _wBufStr(); // Call Low Level Private C Buffer
26 | *
27 | * wSendCBuf_P(); // High Level, App API to Send a P C buffer
28 | * wprint(); // Call App API to Print Current Content of String Buffer
29 | * _wSendCBuf(); // Call Low Level Private C Buffer
30 | *
31 | * wSendStr_P(); // High Level, App API to Send a P Strings
32 | * wprint(); // Call App API Print a String
33 | *
34 | * Low Level:
35 | *
36 | * _wBufStr(); // Low Level, Private Send Str Buffer
37 | * _wSendCBuf(); // Call Low Level Private C Buffer
38 | *
39 | * _wSendCBuf(); // Low Level, Private Send C Buffer
40 | * gServer.client().write(); // This is the single API to WIFI Transmit Function !!!!
41 | *
42 | *
43 | */
44 | )";
45 |
46 | #endif // UTILSSEND_H
47 |
48 | // ###########################################################
49 | // End
50 |
--------------------------------------------------------------------------------
/Main/NotFound.ino:
--------------------------------------------------------------------------------
1 | // NotFound
2 |
3 | /*
4 | * Copyright (c) 2015, Eldon R. Brown - ERB - WA0UWH - eldonb@ebcon.com
5 | *
6 | * See my Blog, at: http://WA0UWH.blogspot.com
7 | *
8 | * See my Source at GitHub, at: https://github.com/wa0uwh/ERB-EspWebServer
9 | *
10 | * All rights reserved. See FULL Copyright in Main or Info Page for Exclusions
11 | *
12 | * This Effort was Inspired by work by: Majenko Technologies - 2015 Esp8266 AdvancedWebServer
13 | *
14 | * See also Arduino IDE, at: https://github.com/esp8266/Arduino
15 | */
16 |
17 |
18 | // ###########################################################
19 | //////////////////////////////////////////////////////////////
20 | //
21 | // This Function Handles "unknown" URL Requsests from WIFI
22 | // and reports activity on Serial
23 | //
24 | void
25 | ICACHE_FLASH_ATTR
26 | handleNotFound()
27 | {
28 | long sz = 0; // Sent Size
29 | gSentSize = 0;
30 |
31 | DEBUG_MONITOR_REPORT_START();
32 |
33 | DEBUG_MONITOR_REPORT_ARGS();
34 |
35 | digitalWrite ( gGrnLED, ON );
36 | gHits++;
37 |
38 | // HTTP Header
39 | sz += wprintln( F("HTTP/1.1 404") );
40 | sz += wprintln( F("Content-Type: text/html") );
41 | sz += wprintln( ); // A Blank Line
42 |
43 | sz += wprintln( F("404 File Not Found") );
44 | sz += wprintln( F(" ") );
45 |
46 | sz += wprintln( sF("URI: ") + gServer.uri() );
47 | sz += wprintln( F(" ") );
48 |
49 | sz += wprintln( sF("Method: ") + String( gServer.method() == HTTP_GET ? "GET" : "POST" ) );
50 | sz += wprintln( F(" ") );
51 |
52 | sz += wprintln( sF("Arguments: ") + String( gServer.args() ) );
53 | sz += wprintln( F(" ") );
54 |
55 | for ( byte i = 0; i < gServer.args(); i++ ) {
56 | sz += wprintln( " " + gServer.argName ( i ) + ": " + gServer.arg ( i ) );
57 | sz += wprintln( F(" ") );
58 | }
59 |
60 | sz += wprint( "", SEND_FINISH ); // Final Packet
61 |
62 | DEBUG_MONITOR_REPORT_END();
63 |
64 | DEBUG_MONITOR_REPORT_TOTAL();
65 |
66 | digitalWrite ( gGrnLED, OFF );
67 |
68 | }
69 |
70 | // ###########################################################
71 | // End
72 |
--------------------------------------------------------------------------------
/Main/Navigator.ino:
--------------------------------------------------------------------------------
1 | // Navigator
2 |
3 | /*
4 | * Copyright (c) 2015, Eldon R. Brown - ERB - WA0UWH - eldonb@ebcon.com
5 | *
6 | * See my Blog, at: http://WA0UWH.blogspot.com
7 | *
8 | * See my Source at GitHub, at: https://github.com/wa0uwh/ERB-EspWebServer
9 | *
10 | * All rights reserved. See FULL Copyright in Main or Info Page for Exclusions
11 | *
12 | * This Effort was Inspired by work by: Majenko Technologies - 2015 Esp8266 AdvancedWebServer
13 | *
14 | * See also Arduino IDE, at: https://github.com/esp8266/Arduino
15 | */
16 |
17 |
18 | // ###########################################################
19 | //////////////////////////////////////////////////////////////
20 | //
21 | long
22 | ICACHE_FLASH_ATTR
23 | navigator( )
24 | {
25 | long sz = 0; // Sent Size
26 |
27 | String timeUTCBuf = "";
28 |
29 | sz += wprintln( );
30 | sz += wprintln( F("") );
31 | sz += wprintln( F("") );
32 | sz += wprintln( F(" ") );
33 |
34 | sz += wprint ( F(" | Home ") );
35 | sz += wprint ( F(" | Help ") );
36 | sz += wprint ( F(" | Admin ") );
37 | sz += wprint ( F(" | Info ") );
38 | sz += wprintln( F(" |") );
39 |
40 | sz += wprintln( F(" ") );
41 | sz += wprintln( timeUTC(timeUTCBuf, gTimeZONE) );
42 | sz += wprintln( F(" PDT ") );
43 |
44 | sz += wprint ( F(" | MFR ") );
45 | sz += wprint ( F(" | Forum ") );
46 | sz += wprint ( F(" | BBS ") );
47 | sz += wprint ( F(" | TheBOOK ") );
48 | sz += wprint ( F(" | IDE ") );
49 | sz += wprint ( F(" | GitHub ") );
50 | sz += wprintln( F(" |") );
51 |
52 | sz += wprintln( F(" ") );
53 | sz += wprintln( F("
") );
54 |
55 | sz += wprintln(sF("") + String(ESP.getFreeHeap() / 1000.0, 3) + " - " + String(gHits) + " - " + String(gRev) + F(" ") );
56 |
57 | return sz;
58 | }
59 |
60 | // ###########################################################
61 | // End
62 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | ERB-EspWebServer
2 | ================
3 |
4 | /*
5 | * This Program Provides the following for the Esp8266 as a WebServer:
6 | * But CAUTION, some functionallity may not have been throughly tested.
7 | *
8 | * The code and effort is always changing, check with the GitHub Repositor often,
9 | * See GitHub at: https://github.com/wa0uwh/ERB-EspWebServer
10 | * See Change Map at: https://github.com/wa0uwh/ERB-EspWebServer/network
11 | *
12 | * The purpose of the program is to provide an Experimental Enviroment in which
13 | * to create new functions that can be used in my other planned projects.
14 | *
15 | * Currently, all Arduino IDE TABS are '.ino' type files, which are compiled as a
16 | * single blob. The structure of this progame could be better, as normally, the TABS
17 | * should be set up as '*.h', '*.c', or '*.cpp' files, but this is easier and quicker
18 | * for my experimental efforts. Future revisions may be properly constructed.
19 | *
20 | * Current Features:
21 | *
22 | * All Web Pages are Dynamically Generated by The Esp8266 Processor
23 | * Implemented Full (1460 bytes) WIFI Buffered Transfers
24 | * All String Constants are saved in Flash, freeing RAM/Heap, via F(),
25 | * sF(), and FMT() macros.
26 | * Uses ICACHE_FLASH_ATTR to dynamically load seldom used program functions
27 | * Copyright and this Text (Introduction) is Compiled into the Executable as
28 | * a Web Page
29 | * Home Page Dashboard
30 | * Help Page
31 | * Admin Page, with WiFi Scan and Network Selection
32 | * Page Navigator and Resource Links
33 | * Raw Data Query
34 | * NTP Network Time (Unix Epoch)
35 | * mDNS Service/Client
36 | * Optional Page AutoRefresh
37 | * Auto AP Timeout
38 | * Implements and uses Html 'meter' function for FreeHeap and Vdd
39 | * Implemented SVG 12/24 Hour Clock
40 | * Implemented SVG Gauge for FreeHeap
41 | * Implemented SVG Gauge for Vdd
42 | * Implemented SVG Line Graph for FreeHeap Historical Data, with Start and
43 | * End of Page Markersand reduced Data Transfer by removing Duplicate
44 | * Y Data Points
45 | * Implemented Data Creation Rate Per Web Page Function
46 | * Implemented a Used CPU Seconds Value for Display
47 | * Implemented a link to a Visitor Map Display
48 | * Implemented Slider Bars, Currently used for Page Refresh Interval
49 | * Implemented Code to Serve Raw BINARY Data, for example: the Farm Server Image on Info Page
50 | * Moved Bulk Assignments to use 'PROGMEM = R(...)' Syntax,
51 | * See: http://en.cppreference.com/w/cpp/language/string_literal
52 | */
53 |
54 | --
55 |
--------------------------------------------------------------------------------
/Main/ScanWifi.ino:
--------------------------------------------------------------------------------
1 | // ScanWiFi
2 |
3 | /*
4 | * Copyright (c) 2015, Eldon R. Brown - ERB - WA0UWH - eldonb@ebcon.com
5 | *
6 | * See my Blog, at: http://WA0UWH.blogspot.com
7 | *
8 | * See my Source at GitHub, at: https://github.com/wa0uwh/ERB-EspWebServer
9 | *
10 | * All rights reserved. See FULL Copyright in Main or Info Page for Exclusions
11 | *
12 | * This Effort was Inspired by work by: Majenko Technologies - 2015 Esp8266 AdvancedWebServer
13 | *
14 | * See also Arduino IDE, at: https://github.com/esp8266/Arduino
15 | */
16 |
17 |
18 | // ###########################################################
19 | //////////////////////////////////////////////////////////////
20 | //
21 | // This Function provides the Content for the URL Requsest from WIFI
22 | //
23 | long
24 | ICACHE_FLASH_ATTR
25 | scanWifi()
26 | {
27 | long sz = 0; // Sent Size
28 |
29 | DEBUG_MONITOR_REPORT_START();
30 |
31 | DEBUG_MONITOR_REPORT_ARGS();
32 |
33 | // WiFi.scanNetworks will return the number of networks found
34 | byte n = WiFi.scanNetworks();
35 | if (n == 0)
36 | sz += wprintln( F(" No Networks Found") );
37 | else
38 | {
39 | sz += wprintln( sF(" ") + String(n) + F(" WIFI Networks Found") );
40 | sz += wprintln( F(" ") );
41 | sz += wprintln( F(" ") );
71 | sz += wprintln( F(" ") );
72 | }
73 |
74 | DEBUG_MONITOR_REPORT_END();
75 |
76 | return sz;
77 | }
78 |
79 | // ###########################################################
80 | // End
81 |
--------------------------------------------------------------------------------
/Main/B_SVG_Line.ino:
--------------------------------------------------------------------------------
1 | // B_SVG_Line
2 |
3 | /*
4 | * Copyright (c) 2015, Eldon R. Brown - ERB - WA0UWH - eldonb@ebcon.com
5 | *
6 | * See my Blog, at: http://WA0UWH.blogspot.com
7 | *
8 | * See my Source at GitHub, at: https://github.com/wa0uwh/ERB-EspWebServer
9 | *
10 | * All rights reserved. See FULL Copyright in Main or Info Page for Exclusions
11 | *
12 | * This Effort was Inspired by work by: Majenko Technologies - 2015 Esp8266 AdvancedWebServer
13 | *
14 | * See also Arduino IDE, at: https://github.com/esp8266/Arduino
15 | */
16 |
17 |
18 | // ###########################################################
19 | //////////////////////////////////////////////////////////////
20 | //
21 | // This Function provides the Content for the URL Requsest from WIFI
22 | //
23 | long
24 | ICACHE_FLASH_ATTR
25 | lineGraphic( int w = 300, int h = 100 )
26 | {
27 | long sz = 0; // Sent Size
28 |
29 | DEBUG_MONITOR_REPORT_START();
30 |
31 | DEBUG_MONITOR_REPORT_ARGS();
32 |
33 | sz += wprintln( );
34 | sz += wprintln( F("") );
35 |
36 | // SVG Header
37 | sz += wprintln( sF("") );
42 |
43 | sz += wprintln( );
44 | sz += wprintln( F("") );
45 | sz += wprintln( F(" ") );
48 |
49 | sz += wprintln( );
50 | sz += wprintln( F("") );
51 | sz += wprintln( F(" ") );
65 |
66 | sz += wprintln( F(" ") );
67 |
68 | DEBUG_MONITOR_REPORT_END();
69 |
70 | return sz;
71 | }
72 |
73 | // ###########################################################
74 | //////////////////////////////////////////////////////////////
75 | //
76 | // This Function Handles the URL Requsest from WIFI
77 | // and reports activity on Serial
78 | //
79 | void
80 | ICACHE_FLASH_ATTR
81 | handleLineGraph()
82 | {
83 | long sz = 0; // Sent Size
84 | gSentSize = 0;
85 |
86 | digitalWrite ( gBluLED, ON );
87 | gHits++;
88 |
89 | // HTTP Header
90 | sz += wprintln( F("HTTP/1.1 200 OK") );
91 | sz += wprintln( F("Content-Type: image/svg+xml") );
92 | sz += wprintln( ); // A Blank Line
93 |
94 | sz += wprintln( F("") );
95 | sz += lineGraphic();
96 | sz += wprintln( F(" ") );
97 |
98 | sz += wprint( "", SEND_FINISH ); // Final Packet
99 |
100 | DEBUG_MONITOR_REPORT_TOTAL();
101 |
102 | digitalWrite ( gBluLED, OFF );
103 | yield();
104 | }
105 |
106 | // ###########################################################
107 | // End
108 |
--------------------------------------------------------------------------------
/Main/B_SVG_Bar.ino:
--------------------------------------------------------------------------------
1 | // B_SVG_Bar
2 |
3 | /*
4 | * Copyright (c) 2015, Eldon R. Brown - ERB - WA0UWH - eldonb@ebcon.com
5 | *
6 | * See my Blog, at: http://WA0UWH.blogspot.com
7 | *
8 | * See my Source at GitHub, at: https://github.com/wa0uwh/ERB-EspWebServer
9 | *
10 | * All rights reserved. See FULL Copyright in Main or Info Page for Exclusions
11 | *
12 | * This Effort was Inspired by work by: Majenko Technologies - 2015 Esp8266 AdvancedWebServer
13 | *
14 | * See also Arduino IDE, at: https://github.com/esp8266/Arduino
15 | */
16 |
17 |
18 | // ###########################################################
19 | //////////////////////////////////////////////////////////////
20 | //
21 | // This Function provides the Content for the URL Requsest from WIFI
22 | //
23 | long
24 | ICACHE_FLASH_ATTR
25 | barGraphic()
26 | {
27 | long sz = 0; // Sent Size
28 |
29 | DEBUG_MONITOR_REPORT_START();
30 |
31 | DEBUG_MONITOR_REPORT_ARGS();
32 |
33 | // HTML5 Graphic
34 | sz += wprintln( );
35 | sz += wprintln( F("") );
36 |
37 | {
38 | sz += wprintln( );
39 | sz += wprintln( F("") );
40 | int Lo = VddScaleLo;
41 | int Hi = VddScaleHi;
42 | int Vdd = readvdd33();
43 |
44 | sz += wprintln( F(" ") );
45 | sz += wprintln( String( Lo/1000.0, 1 ) + F("v") );
46 | sz += wprint ( sF("VDD ") );
53 | sz += wprintln( String( Hi/1000.0, 1 ) + F("v") );
54 | sz += wprintln( F(" ") );
55 | sz += wprintln( sF("VDD = ") + String(Vdd/1000.0, 2) + F("v") );
56 | }
57 |
58 | {
59 | sz += wprintln( );
60 | sz += wprintln( F("") );
61 | int Lo = FreeHeapScaleLo;
62 | int Hi = FreeHeapScaleHi;
63 | int FreeHeap = ESP.getFreeHeap();
64 |
65 | sz += wprintln( F(" ") );
66 | sz += wprintln( String( Lo/1000 ) + F("KB") );
67 | sz += wprint ( sF("FreeMem ") );
74 | sz += wprintln( String( Hi/1000 ) + F("KB") );
75 | sz += wprintln( F(" ") );
76 | sz += wprintln( sF("Free Memory = ") + String(FreeHeap/1000.0, 1) + F("KB") );
77 | }
78 |
79 | DEBUG_MONITOR_REPORT_END();
80 |
81 | return sz;
82 | }
83 |
84 | // ###########################################################
85 | //////////////////////////////////////////////////////////////
86 | //
87 | // This Function Handles the URL Requsest from WIFI
88 | // and reports activity on Serial
89 | //
90 | void
91 | ICACHE_FLASH_ATTR
92 | handleBar()
93 | {
94 |
95 | long sz = 0; // Sent Size
96 | gSentSize = 0;
97 |
98 | digitalWrite ( gBluLED, ON );
99 | gHits++;
100 |
101 | // HTTP Header
102 | sz += wprintln( F("HTTP/1.1 200 OK") );
103 | sz += wprintln( F("Content-Type: text/html") );
104 | sz += wprintln( ); // A Blank Line
105 |
106 | sz += wprintln( F("") );
107 | sz += barGraphic();
108 | sz += wprintln( F(" ") );
109 |
110 | sz += wprint( "", SEND_FINISH ); // Final Packet
111 |
112 | DEBUG_MONITOR_REPORT_TOTAL();
113 |
114 | digitalWrite ( gBluLED, OFF );
115 | yield();
116 | }
117 |
118 | // ###########################################################
119 | // End
120 |
--------------------------------------------------------------------------------
/Main/B_SliderBar.ino:
--------------------------------------------------------------------------------
1 | // B_SliderBar
2 |
3 | /*
4 | * Copyright (c) 2015, Eldon R. Brown - ERB - WA0UWH - eldonb@ebcon.com
5 | *
6 | * See my Blog, at: http://WA0UWH.blogspot.com
7 | *
8 | * See my Source at GitHub, at: https://github.com/wa0uwh/ERB-EspWebServer
9 | *
10 | * All rights reserved. See FULL Copyright in Main or Info Page for Exclusions
11 | *
12 | * This Effort was Inspired by work by: Majenko Technologies - 2015 Esp8266 AdvancedWebServer
13 | *
14 | * See also Arduino IDE, at: https://github.com/esp8266/Arduino
15 | */
16 |
17 |
18 | // ###########################################################
19 | //////////////////////////////////////////////////////////////
20 | //
21 | // This Function provides the Content for the URL Requsest from WIFI
22 | //
23 | long
24 | ICACHE_FLASH_ATTR
25 | sliderBar( String aId = "Id0", String aLabel = "Label0", int aMin = 0, int aMax = 100, int aStp = 5, int aVal = 50, String aUnits = "", String aBaseURI = "/")
26 | {
27 | long sz = 0; // Sent Size
28 |
29 | DEBUG_MONITOR_REPORT_START();
30 |
31 | DEBUG_MONITOR_REPORT_ARGS();
32 |
33 | sz += wprintln( );
34 | sz += wprintln( F("") );
35 |
36 | sz += wprintln( F("") );
43 |
44 |
45 | sz += wprintln( );
46 | sz += wprintln( F("") );
47 |
48 | // sz += wprintln( F("") );
72 |
73 | DEBUG_MONITOR_REPORT_END();
74 |
75 | return sz;
76 | }
77 |
78 | // ###########################################################
79 | //////////////////////////////////////////////////////////////
80 | //
81 | // This Function Handles the URL Requsest from WIFI
82 | // and reports activity on Serial
83 | //
84 | void
85 | ICACHE_FLASH_ATTR
86 | handleSliderBar()
87 | {
88 | long sz = 0; // Sent Size
89 | gSentSize = 0;
90 |
91 | digitalWrite ( gBluLED, ON );
92 | gHits++;
93 |
94 | // HTTP Header
95 | sz += wprintln( F("HTTP/1.1 200 OK") );
96 | sz += wprintln( F("Content-Type: text/html") );
97 | sz += wprintln( ); // A Blank Line
98 |
99 | sz += wprintln( F("") );
100 | sz += sliderBar( F("IdData0"), F("Percent:"), 10, 90, 1, 50, F("%") );
101 | sz += wprintln( F(" ") );
102 |
103 | sz += wprint( "", SEND_FINISH ); // Final Packet
104 |
105 | DEBUG_MONITOR_REPORT_TOTAL();
106 |
107 | digitalWrite ( gBluLED, OFF );
108 | yield();
109 | }
110 |
111 | // ###########################################################
112 | // End
113 |
--------------------------------------------------------------------------------
/Main/A4_WifiCTL.ino:
--------------------------------------------------------------------------------
1 | // A4_WifiCTL
2 |
3 | /*
4 | * Copyright (c) 2015, Eldon R. Brown - ERB - WA0UWH - eldonb@ebcon.com
5 | *
6 | * See my Blog, at: http://WA0UWH.blogspot.com
7 | *
8 | * See my Source at GitHub, at: https://github.com/wa0uwh/ERB-EspWebServer
9 | *
10 | * All rights reserved. See FULL Copyright in Main or Info Page for Exclusions
11 | *
12 | * This Effort was Inspired by work by: Majenko Technologies - 2015 Esp8266 AdvancedWebServer
13 | *
14 | * See also Arduino IDE, at: https://github.com/esp8266/Arduino
15 | */
16 |
17 |
18 | // ###########################################################
19 | //////////////////////////////////////////////////////////////
20 | // Initializes the WIFI AP
21 | //
22 | void
23 | //ICACHE_FLASH_ATTR
24 | initWifiAp()
25 | {
26 |
27 | gApTimeout = 0;
28 | WiFi.mode( WIFI_AP );
29 | //WiFi.softAP( gDeviceName, "passwd1234", gApChannel );
30 | WiFi.softAP( gDeviceName, 0, gApChannel ); // For Open AP Network
31 | yield();
32 | Serial.println ( F("\nInitilize: AP Mode") );
33 |
34 | initHandlers();
35 | startWebServer();
36 | gStnLive = false;
37 | gReStartSTN = true;
38 | yield();
39 | }
40 |
41 |
42 | // ###########################################################
43 | //////////////////////////////////////////////////////////////
44 | // ReStarts the WIFI AP
45 | //
46 | void
47 | //ICACHE_FLASH_ATTR
48 | restartWifiAp()
49 | {
50 |
51 | gApTimeout = millis() + 15 * MINs;
52 | WiFi.mode( WIFI_AP_STA );
53 | //WiFi.softAP( gDeviceName, "passwd1234", gApChannel );
54 | WiFi.softAP( gDeviceName, 0, gApChannel ); // For Open AP Network
55 | yield();
56 | Serial.println ( F("\n\nReStarting: AP Mode") );
57 | }
58 |
59 |
60 | // ###########################################################
61 | //////////////////////////////////////////////////////////////
62 | // Initializes the WIFI STATION
63 | //
64 | void
65 | //ICACHE_FLASH_ATTR
66 | initWifiStn()
67 | {
68 |
69 | WiFi.mode( WIFI_AP_STA );
70 | Serial.print ( F("Trying to Connect to: ") );
71 |
72 | if (gPasswd.length() == 0) {
73 | Serial.print ( gSsid + F("(open)*") );
74 | WiFi.begin ( gSsid.c_str() );
75 | }
76 | else {
77 | Serial.print ( gSsid );
78 | WiFi.begin ( gSsid.c_str(), gPasswd.c_str() );
79 | }
80 | yield();
81 |
82 | gWifiStnAttempts = 1;
83 | }
84 |
85 |
86 | // ###########################################################
87 | //////////////////////////////////////////////////////////////
88 | // Trys to Start the WIFI STATION
89 | //
90 | void
91 | //ICACHE_FLASH_ATTR
92 | try2StartWifiStn()
93 | {
94 |
95 | if (!gWifiStnAttempts) initWifiStn();
96 |
97 | delay ( 100 );
98 | if ( WiFi.status() != WL_CONNECTED ) {
99 | delay ( 500 );
100 | Serial.print ( "." );
101 | gWifiStnAttempts = ++gWifiStnAttempts % 10;
102 | return;
103 | }
104 | yield();
105 |
106 | gStnLive = true;
107 | gReStartSTN = false;
108 | gWifiStnAttempts = 0;
109 | gWifiReStarts++;
110 |
111 | // Create Node Name from Least Digits of IPA
112 | sprintf(gDeviceName+3, FMT("%0d"), WiFi.localIP() >> 24); // Append Least IP Digits at position 3
113 |
114 |
115 | Serial.println ( sF("\nConnected to: ") + String(WiFi.SSID()) );
116 | Serial.println ( sF("IP address: ") + ipa2str(WiFi.localIP()) );
117 | Serial.println ( sF("STN Mac Address: ") + mac2str(WiFi.macAddress(gMacBuf)) );
118 | Serial.println ( sF("Soft IP address: ") + gSoftAPAddress );
119 | Serial.println ( sF("Soft AP Mac Address: ") + mac2str(WiFi.softAPmacAddress(gMacBuf)) );
120 | Serial.println ( sF("WiFi ReStarts: ") + String(gWifiReStarts) );
121 | yield();
122 |
123 | restartWifiAp();
124 |
125 | Serial.println (); Serial.println ();
126 | WiFi.printDiag(Serial);
127 | Serial.println (); Serial.println ();
128 |
129 | }
130 |
131 |
132 | // ###########################################################
133 | //////////////////////////////////////////////////////////////
134 | // Starts the WIFI WEB SERVER
135 | //
136 | void
137 | //ICACHE_FLASH_ATTR
138 | startWebServer()
139 | {
140 |
141 | gServer.begin();
142 | Serial.println ( F("HTTP Server Started") );
143 | }
144 |
145 | // ###########################################################
146 | // End
147 |
--------------------------------------------------------------------------------
/Main/VisitorMap.ino:
--------------------------------------------------------------------------------
1 | // VisitorMap
2 |
3 | /*
4 | * Copyright (c) 2015, Eldon R. Brown - ERB - WA0UWH - eldonb@ebcon.com
5 | *
6 | * See my Blog, at: http://WA0UWH.blogspot.com
7 | *
8 | * See my Source at GitHub, at: https://github.com/wa0uwh/ERB-EspWebServer
9 | *
10 | * All rights reserved. See FULL Copyright in Main or Info Page for Exclusions
11 | *
12 | * This Effort was Inspired by work by: Majenko Technologies - 2015 Esp8266 AdvancedWebServer
13 | *
14 | * See also Arduino IDE, at: https://github.com/esp8266/Arduino
15 | */
16 |
17 |
18 | // ###########################################################
19 | //////////////////////////////////////////////////////////////
20 | //
21 | // This Function provides an optional Visitors Map Graphic
22 | //
23 | long
24 | ICACHE_FLASH_ATTR
25 | visitorMap() {
26 |
27 | long sz = 0; // Sent Size
28 |
29 | DEBUG_MONITOR_REPORT_START();
30 |
31 | DEBUG_MONITOR_REPORT_ARGS();
32 |
33 | // Provide Optional Visitor Map
34 | sz += wprintln( );
35 | sz += wprintln( F("") );
36 | sz += wprintln( F(" ") );
37 | if (gVisitorMapState == true) {
38 | sz += wprintln( F("") );
39 | switch (gVisitorMapStyle) {
40 | case 1:
41 | default:
42 | sz += wprintln( F(" ") );
43 | sz += wprintln( F("") );
49 | break;
50 | case 2:
51 | sz += wprintln( F(" ") );
52 | sz += wprint ( F("") );
58 | break;
59 | }
60 | }
61 | sz += wprintln( F(" ") );
62 | sz += wprint ( F("World Wide Esp8266 Shared ") );
63 | sz += wprintln( F("Visitor Map , and ") );
64 | sz += wprint ( F("Stats ") );
67 | sz += wprintln( sF("") );
71 |
72 | if (gVisitorMapState == true) {
73 | sz += wprintln( sF("") );
77 | }
78 |
79 | DEBUG_MONITOR_REPORT_END();
80 |
81 | return sz;
82 | }
83 | // ###########################################################
84 | //////////////////////////////////////////////////////////////
85 | //
86 | // This Function Handles the URL Requsest from WIFI
87 | // and reports activity on Serial
88 | //
89 | void
90 | ICACHE_FLASH_ATTR
91 | handleVisitorMap()
92 | {
93 | long sz = 0; // Sent Size
94 | gSentSize = 0;
95 |
96 | digitalWrite ( gBluLED, ON );
97 | gHits++;
98 |
99 | // HTTP Header
100 | sz += wprintln( F("HTTP/1.1 200 OK") );
101 | sz += wprintln( F("Content-Type: text/html") );
102 | sz += wprintln( ); // A Blank Line
103 |
104 |
105 | sz += wprintln( F("") );
106 | sz += visitorMap();
107 | sz += wprintln( F(" ") );
108 |
109 | sz += wprint( "", SEND_FINISH ); // Final Packet
110 |
111 | DEBUG_MONITOR_REPORT_TOTAL();
112 |
113 | digitalWrite ( gBluLED, OFF );
114 | yield();
115 | }
116 |
117 | // ###########################################################
118 | // End
119 |
--------------------------------------------------------------------------------
/Main/H_InfoPage.ino:
--------------------------------------------------------------------------------
1 | // InfoPage
2 |
3 | /*
4 | * Copyright (c) 2015, Eldon R. Brown - ERB - WA0UWH - eldonb@ebcon.com
5 | *
6 | * See my Blog, at: http://WA0UWH.blogspot.com
7 | *
8 | * See my Source at GitHub, at: https://github.com/wa0uwh/ERB-EspWebServer
9 | *
10 | * All rights reserved. See FULL Copyright in Main or Info Page for Exclusions
11 | *
12 | * This Effort was Inspired by work by: Majenko Technologies - 2015 Esp8266 AdvancedWebServer
13 | *
14 | * See also Arduino IDE, at: https://github.com/esp8266/Arduino
15 | */
16 |
17 |
18 |
19 | // ###########################################################
20 | //////////////////////////////////////////////////////////////
21 | //
22 | // This Function Formats the Copyright Comment Text for transfer to WIFI
23 | //
24 | long
25 | ICACHE_FLASH_ATTR
26 | infoPage()
27 | {
28 | long sz = 0; // Sent Size
29 |
30 | DEBUG_MONITOR_REPORT_START();
31 |
32 | DEBUG_MONITOR_REPORT_ARGS();
33 |
34 | // Generate Html Header
35 | sz += htmlPageHeader( gDeviceName, -1 );
36 |
37 | // Page Content Starts here
38 |
39 | // Page Title Line
40 | sz += htmlPageTitle( gDeviceName, F("Info") );
41 |
42 | // Navigator
43 | sz += navigator();
44 |
45 | sz += wprintln( );
46 | sz += wprintln( F("") );
47 |
48 | sz += wprintln( F("") );
49 | {
50 | sz += wprintln( );
51 | sz += wprintln( F("") );
52 | sz += wprintln( F("Introduction: ") );
53 | sz += wprintln( F("") );
54 | sz += wSendStr_P( INTRODUCTION );
55 | sz += wprintln( );
56 | sz += wSendStr_P( THIS_APP_WIFI_SEND_API );
57 | sz += wprintln( );
58 | sz += wprintln( F(" ") );
59 |
60 | sz += wprintln( );
61 | sz += wprintln( F("") );
62 | sz += wprintln( F("") );
63 | {
64 | sz += wprintln( F("Esp8266 WEB Server Farm ") );
65 | sz += wprintln( F("") );
86 | }
87 | sz += wprintln( F(" ") );
88 |
89 | sz += wprintln( );
90 | sz += wprintln( F(" ") );
91 | sz += wprintln( F("") );
92 | sz += wprintln( F("Copyright: ") );
93 | sz += wprintln( F("") );
94 | sz += wSendStr_P( COPYRIGHT1 );
95 | sz += wSendStr_P( COPYRIGHT2 );
96 | sz += wSendStr_P( COPYRIGHT3 );
97 | sz += wprintln( );
98 | sz += wprintln( F(" ") );
99 |
100 | // sz += wprintln( );
101 | // sz += wprintln( F("") );
102 | // sz += wprintln( F("Test Transfer: ") );
103 | // sz += wprintln( F("") );
104 | // // 5 Groups of 10Kb = 50Kb
105 | // sz += wSendStr_P( TEST_10Kb ); // A 10Kb Test
106 | // sz += wSendStr_P( TEST_10Kb ); // A 10Kb Test
107 | // sz += wSendStr_P( TEST_10Kb ); // A 10Kb Test
108 | // sz += wSendStr_P( TEST_10Kb ); // A 10Kb Test
109 | // sz += wSendStr_P( TEST_10Kb ); // A 10Kb Test
110 | // sz += wprintln( );
111 | // sz += wprintln( F(" ") );
112 |
113 | }
114 | sz += wprintln( F(" ") );
115 |
116 |
117 | // Generate Html Footer
118 | sz += htmlPageFooter();
119 |
120 | DEBUG_MONITOR_REPORT_END();
121 |
122 | return sz;
123 | }
124 |
125 |
126 |
127 | // ###########################################################
128 | //////////////////////////////////////////////////////////////
129 | //
130 | // This Function Handles the URL Requsest from WIFI
131 | // and reports activity on Serial
132 | //
133 | void
134 | ICACHE_FLASH_ATTR
135 | handleInfoPage()
136 | {
137 | long sz = 0; // Sent Size
138 | gSentSize = 0;
139 |
140 | gCurrentPage = INFOPAGE;
141 |
142 | digitalWrite ( gGrnLED, ON );
143 | gHits++;
144 |
145 | // HTTP Header
146 | sz += wprintln( F("HTTP/1.1 200 OK") );
147 | sz += wprintln( F("Content-Type: text/html") );
148 | sz += wprintln( );
149 |
150 | sz += infoPage();
151 |
152 | sz += wprint( "", SEND_FINISH); // Final Packet
153 |
154 | DEBUG_MONITOR_REPORT_TOTAL();
155 |
156 | digitalWrite ( gGrnLED, OFF );
157 | yield();
158 | }
159 |
160 | // ###########################################################
161 | // End
162 |
--------------------------------------------------------------------------------
/Main/B_SVG_Line_FH.ino:
--------------------------------------------------------------------------------
1 | // SVG_Line_FH
2 |
3 | /*
4 | * Copyright (c) 2015, Eldon R. Brown - ERB - WA0UWH - eldonb@ebcon.com
5 | *
6 | * See my Blog, at: http://WA0UWH.blogspot.com
7 | *
8 | * See my Source at GitHub, at: https://github.com/wa0uwh/ERB-EspWebServer
9 | *
10 | * All rights reserved. See FULL Copyright in Main or Info Page for Exclusions
11 | *
12 | * This Effort was Inspired by work by: Majenko Technologies - 2015 Esp8266 AdvancedWebServer
13 | *
14 | * See also Arduino IDE, at: https://github.com/esp8266/Arduino
15 | */
16 |
17 |
18 | // ###########################################################
19 | //////////////////////////////////////////////////////////////
20 | //
21 | // This Function provides the Content for the URL Requsest from WIFI
22 | //
23 | long
24 | ICACHE_FLASH_ATTR
25 | lineGraphicFH( int w = 400, int h = 150 )
26 | {
27 | long sz = 0; // Sent Size
28 |
29 | int Lo = FreeHeapScaleLo/100;
30 | int Hi = FreeHeapScaleHi/100;
31 |
32 | DEBUG_MONITOR_REPORT_START();
33 |
34 | DEBUG_MONITOR_REPORT_ARGS();
35 |
36 | sz += wprintln( );
37 | sz += wprintln( F("") );
38 |
39 | // SVG Header
40 | sz += wprintln( F("") );
45 |
46 | sz += wprintln( );
47 | sz += wprintln( F("") );
48 | sz += wprint ( F(" ") );
51 |
52 | sz += wprintln( );
53 | sz += wprintln( F("") );
54 | sz += wprintln( F("") );
55 | {
56 | for (int y = Lo; y <= Hi; y += 40)
57 | {
58 | int yg = y;
59 | yg = map(yg, Lo, Hi, h-10, 10);
60 | sz += wprintln( sF(" ") );
61 | }
62 | }
63 | sz += wprintln( F(" ") );
64 |
65 | sz += wprintln( );
66 | sz += wprintln( F("") );
67 | sz += wprintln( F("") );
68 | {
69 | for (int y = Lo; y <= Hi; y += 40)
70 | {
71 | int yg = y;
72 | yg = map(yg, Lo, Hi, h-10, 10);
73 | sz += wprintln( sF(" ") + String( y/10 ) + F(" ") );
74 | }
75 | }
76 | sz += wprintln( F(" ") );
77 |
78 |
79 | sz += wprintln( );
80 | sz += wprintln( F("") );
81 | {
82 | sz += wprintln( F(" ") );
122 | }
123 |
124 | sz += wprintln( );
125 | sz += wprintln( F(" "));
126 |
127 | DEBUG_MONITOR_REPORT_END();
128 |
129 | return sz;
130 | }
131 |
132 | // ###########################################################
133 | //////////////////////////////////////////////////////////////
134 | //
135 | // This Function Handles the URL Requsest from WIFI
136 | // and reports activity on Serial
137 | //
138 | void
139 | ICACHE_FLASH_ATTR
140 | handleLineGraphFH()
141 | {
142 | long sz = 0; // Sent Size
143 | gSentSize = 0;
144 |
145 | digitalWrite ( gBluLED, ON );
146 | gHits++;
147 |
148 | // HTTP Header
149 | sz += wprintln( F("HTTP/1.1 200 OK") );
150 | sz += wprintln( F("Content-Type: image/svg+xml") );
151 | sz += wprintln( ); // A Blank Line
152 |
153 | sz += wprintln( F("") );
154 | sz += lineGraphicFH();
155 | sz += wprintln( F(" ") );
156 |
157 | sz += wprint( "", SEND_FINISH); // Final Packet
158 |
159 | DEBUG_MONITOR_REPORT_TOTAL();
160 |
161 | digitalWrite ( gBluLED, OFF );
162 | yield();
163 | }
164 |
165 | // ###########################################################
166 | // End
167 |
--------------------------------------------------------------------------------
/Main/Main.ino:
--------------------------------------------------------------------------------
1 | // MainNS
2 |
3 | /*
4 | * Copyright (c) 2015, Eldon R. Brown - ERB - WA0UWH - eldonb@ebcon.com
5 | *
6 | * See my Blog, at: http://WA0UWH.blogspot.com
7 | *
8 | * See my Source at GitHub, at: https://github.com/wa0uwh/ERB-EspWebServer
9 | *
10 | * All rights reserved. See FULL Copyright in Main or Info Page for Exclusions
11 | *
12 | * This Effort was Inspired by work by: Majenko Technologies - 2015 Esp8266 AdvancedWebServer
13 | *
14 | * See also Arduino IDE, at: https://github.com/esp8266/Arduino
15 | */
16 |
17 | #include "A1_Main.h"
18 |
19 | #include
20 | #include
21 |
22 |
23 | #include
24 | #include
25 |
26 | #include "A1_UserConfig.h"
27 |
28 | const char *gRev = "ERB_MK"; // Software Revision Code
29 |
30 |
31 | String gSsidPrev = gSsid;
32 | String gPasswdPrev = gPasswd;
33 |
34 |
35 | unsigned long gApTimeout = 0;
36 | boolean gStnLive = false;
37 | int gWifiStnAttempts = 0;
38 | int gWifiReStarts = 0;
39 | boolean gReStartSTN = false;
40 |
41 | byte gCurrentPage = HOMEPAGE;
42 |
43 | // Buffer, Used with FMT() to store constants in program space (FLASH)
44 | // See Main.h file\
45 | char gFmtBuf[64+2];
46 |
47 | char gTmpBuf[32+2]; // Generic Temp Buffer
48 |
49 | // Line Graphic will be plotted with this data
50 | byte gFreeHeapLog[512]; // Log Storage
51 | int gFreeHeapLogIndex = 0;
52 |
53 | boolean gVerbose = true; // Web Page Verbose Mode
54 |
55 | boolean gVisitorMapState = true; // Show Visitor Map
56 | String gSharedVisitorMapIdKey = "2q435yktjwx"; // A shared "IdKey" for sites that want to participate in shared Global Reverse Beacon Map
57 | String gVisitorMapIdKey = gSharedVisitorMapIdKey;
58 | int gVisitorMapStyle = 2;
59 |
60 | long gHits = 0; // Web page Hit Counter
61 |
62 | unsigned long gNextNTPSchd = millis();
63 |
64 | unsigned long gNextMDnsSchd = millis();
65 |
66 | unsigned long gPageStartTime = millis();
67 |
68 | byte gMacBuf[6]; // A buffer to hold Mac Address conversion
69 |
70 | long gIdleL = 0; // Idle counter
71 | long gUpTimeSec = 0;
72 |
73 | boolean gEpochAvailable = false;
74 | unsigned long gEpochDelta = 0; // The Time ADDED to millis() to get Epoch
75 |
76 | boolean gMarkFlag = false;
77 |
78 | long gSentSize = 0; // WEB Page Size
79 |
80 | long gLoadAvgL = 0;
81 | long gLoadAvgCountL = 0;
82 | String gLoadAvgS = "1.00";
83 | long gIdlePrevL = 0;
84 | unsigned long gOneSecSchedule = millis() + 1 * SECs;
85 |
86 | MDNSResponder gMDns;
87 | boolean gMDnsResponderReady = false;
88 |
89 | ESP8266WebServer gServer ( 80 );
90 | WiFiClient gClient;
91 |
92 |
93 | // Some often used Text Strings
94 | #define TEXT_PLAIN "text/plain"
95 | #define TEXT_HTML "text/html"
96 |
97 | // ###########################################################
98 | void
99 | ICACHE_FLASH_ATTR
100 | setup ( void )
101 | {
102 |
103 | Serial.begin ( 115200 );
104 | delay(3000);
105 |
106 | for (int i = 3; i>0; i--) {
107 | Serial.println ( F("Start: setup") );
108 | }
109 |
110 | Serial.setDebugOutput(true);
111 |
112 | pinMode ( gRedLED, OUTPUT ); digitalWrite ( gRedLED, OFF );
113 | pinMode ( gGrnLED, OUTPUT ); digitalWrite ( gGrnLED, OFF );
114 | pinMode ( gBluLED, OUTPUT ); digitalWrite ( gBluLED, OFF );
115 |
116 | // Create a "gDeviceName" from chip_id, this could be the MAC address, or the least digits
117 | // of the Chip ID, (or anything you like)
118 | // Also, See: try2StartWifiStn() for using Least Digits of IPA
119 | // sprintf(gDeviceName+3, FMT("%04d"), ESP.getChipId() % 10000); // Append ID Number at position 3
120 | sprintf(gDeviceName+3, FMT("%X"), ESP.getChipId()); // Append Hex ID Number at position 3
121 |
122 | logFreeHeapMarkDn();
123 |
124 | // Startup WIFI
125 | initWifiAp();
126 |
127 | // Serial.print ( F("TimeZONE: ") );
128 | // Serial.println ( TimeZONE );
129 |
130 | Serial.println ( F("End: setup") );
131 | Serial.println ( F("##################################") );
132 | Serial.println ( ); Serial.println ( );
133 |
134 | }
135 |
136 | // ###########################################################
137 | void
138 | loop ( void )
139 | {
140 |
141 | gIdleL++; // Idle Loop Counter
142 |
143 | gServer.handleClient();
144 |
145 | // This shortCuts the Loop, so Support Tasks only run once per second
146 | // This keeps the "loop" very fast most of the time, which is needed
147 | // for WIFI processes.
148 | if (gOneSecSchedule > millis()) return;
149 |
150 |
151 | // The following are Support Tasks
152 |
153 | gOneSecSchedule += 1 * SECs;
154 | gUpTimeSec++;
155 |
156 |
157 | if ( gReStartSTN == true ) {
158 | try2StartWifiStn();
159 | }
160 |
161 | if ( gStnLive == true ) {
162 | if ( gApTimeout && millis() > gApTimeout ) {
163 | WiFi.mode(WIFI_STA); // After AP Timeout, Switch to STN-only mode
164 | Serial.println ( F("\nEnd: AP Mode") );
165 | gApTimeout = 0;
166 | }
167 | updateMDNS(); // Scheduled MDNS Update
168 | updateNTP(); // Scheduled NTP Update
169 | }
170 |
171 | digitalWrite ( gGrnLED, ON ); // Show Loop Activity
172 | // The following provides enough time for a quick LED Blink
173 | logFreeHeap(); // This logs data for the Free Heap Display
174 | logPseudoLoadAvg(); // This logs data for the Pseudo Load Average
175 | digitalWrite ( gGrnLED, OFF );
176 |
177 | // Dubug
178 | // Serial.println ( sF("Loops Per Sec: ") + String( gIdleL - gIdlePrevL) );
179 | // gIdlePrevL = gIdleL;
180 |
181 | }
182 |
183 | // ###########################################################
184 | // End
185 |
--------------------------------------------------------------------------------
/Main/A2_UtilsSend.ino:
--------------------------------------------------------------------------------
1 | // A2_UtilsSend
2 |
3 | /*
4 | * Copyright (c) 2015, Eldon R. Brown - ERB - WA0UWH - eldonb@ebcon.com
5 | *
6 | * See my Blog, at: http://WA0UWH.blogspot.com
7 | *
8 | * See my Source at GitHub, at: https://github.com/wa0uwh/ERB-EspWebServer
9 | *
10 | * All rights reserved. See FULL Copyright in Main or Info Page for Exclusions
11 | *
12 | * This Effort was Inspired by work by: Majenko Technologies - 2015 Esp8266 AdvancedWebServer
13 | *
14 | * See also Arduino IDE, at: https://github.com/esp8266/Arduino
15 | */
16 |
17 | #include "A2_UtilsSend.h"
18 |
19 | // ###########################################################
20 | //////////////////////////////////////////////////////////////
21 | //
22 | // This is a Private String-Buffer, used to build "Blocks" of Data
23 | //
24 | String _WifiBuf = ""; // The Private WIFI Transfer Buffer
25 | //
26 |
27 |
28 | // ###########################################################
29 | //////////////////////////////////////////////////////////////
30 | //
31 | // This is a Private Send A Buffer Function, used to Transfer "Blocks" of Data to WIFI
32 | //
33 | long
34 | //ICACHE_FLASH_ATTR
35 | _wSendCBuf(const char* apBuf, long aLen, byte aFinish = SEND_WITH_BUFFERING)
36 | {
37 |
38 | long sentSize = 0;
39 | long sentSizeTmp = 0;
40 |
41 | long p = 0;
42 |
43 | if (gMarkFlag == true) logFreeHeapMarkDn(); // Mark Start of Web Page
44 |
45 | int ErrorLoops = 0;
46 | while ( p < aLen ) {
47 |
48 | if (!gServer.client().remoteIP()) {
49 | Serial.println ( F(" Aborting Connection") ); // Abort for IPA: 0.0.0.0
50 | aFinish = SEND_FINISH;
51 | break;
52 | }
53 |
54 | long size2Send = aLen - p;
55 | if (size2Send > 1460) size2Send = 1460;
56 | sentSizeTmp = gServer.client().write(apBuf + p, size2Send);
57 | Serial.println ( sF(" Wifi, Sent Buf Size: ") + String(sentSizeTmp) );
58 | yield();
59 |
60 | if (sentSizeTmp > 0) {
61 | ErrorLoops = 0;
62 | sentSize += sentSizeTmp;
63 | p += sentSizeTmp;
64 | } else { // Try again.
65 | ErrorLoops++;
66 | if (ErrorLoops > 3) {
67 | aFinish = SEND_FINISH;
68 | Serial.println ( F(" Exiting Loop with: Error") );
69 | break;
70 | }
71 | for (int i = 5; i > 0; i--) { // While Trying again, delay for at least 500ms, with yield
72 | delay(100);
73 | yield();
74 | }
75 | }
76 | }
77 |
78 | if (aFinish == SEND_FINISH ) {
79 | gServer.client().flush();
80 | yield();
81 | gServer.client().stop();
82 | yield();
83 |
84 | Serial.println ( F(" Buf Connection Flushed and Closed") );
85 |
86 | if (gMarkFlag == false) logFreeHeapMarkUp(); // Mark End of Web Page
87 | }
88 |
89 | gSentSize += sentSize;
90 |
91 | return sentSize;
92 | }
93 |
94 |
95 | // ###########################################################
96 | //////////////////////////////////////////////////////////////
97 | //
98 | // This is a Private String-Buffer Function, used to build "Blocks" of Data
99 | //
100 | long
101 | //ICACHE_FLASH_ATTR
102 | _wBufStr(String aStr = "", byte aFinish = SEND_WITH_BUFFERING)
103 | {
104 | long sz = 0; // Sent Size
105 |
106 | _WifiBuf += aStr;
107 |
108 | int size2Send = 0;
109 | if ( aFinish == SEND_WITH_BUFFERING) {
110 | size2Send = (_WifiBuf.length() / 1460) * 1460; // Buffer in Chunks of 1460 bytes
111 | if ( size2Send == 0 ) return 0;
112 | }
113 | else {
114 | size2Send = _WifiBuf.length();
115 | }
116 | sz += _wSendCBuf( _WifiBuf.c_str(), size2Send, aFinish );
117 |
118 | _WifiBuf.remove(0, sz); // Remove the Head of the buffer that was sent to WIFI
119 |
120 | if ( aFinish != SEND_WITH_BUFFERING) _WifiBuf = "";
121 |
122 | return sz;
123 |
124 | }
125 |
126 | // ###########################################################
127 | //////////////////////////////////////////////////////////////
128 | //
129 | // The rest of this APP uses this to send data to WIFI
130 | //
131 | long
132 | //ICACHE_FLASH_ATTR
133 | wprint(String aStr = "", byte aFinish = SEND_WITH_BUFFERING)
134 | {
135 | return _wBufStr( aStr, aFinish );
136 | }
137 |
138 | // ###########################################################
139 | //////////////////////////////////////////////////////////////
140 | //
141 | // The rest of this APP uses this to send data to WIFI
142 | //
143 | long
144 | //ICACHE_FLASH_ATTR
145 | wprintln(String aStr = "", byte aFinish = SEND_WITH_BUFFERING)
146 | {
147 | return wprint( aStr + F("\r\n"), aFinish );
148 | }
149 |
150 |
151 |
152 | // ###########################################################
153 | //////////////////////////////////////////////////////////////
154 | //
155 | // This is a Buf_P Function, used to Transfer "Blocks" of Data to WIFI
156 | //
157 | long
158 | //ICACHE_FLASH_ATTR
159 | wSendCBuf_P(PGM_P apBuf, long aLen, byte aFinish = SEND_WITH_BUFFERING)
160 | {
161 |
162 | long sz = 0; // Sent Size
163 |
164 | sz += wprint( "", SEND_BUFFER_NOW ); // Send Anything already in String Buffer, First, NOW
165 |
166 | sz += _wSendCBuf( (char*) apBuf, aLen, aFinish );
167 |
168 | return sz;
169 | }
170 |
171 |
172 | // ###########################################################
173 | //////////////////////////////////////////////////////////////
174 | //
175 | // This Function uses buffers to transfer "large blocks" of Text to WIFI
176 | //
177 | long
178 | ICACHE_FLASH_ATTR
179 | wSendStr_P( PGM_P apBuf, byte aFinish = SEND_WITH_BUFFERING )
180 | {
181 |
182 |
183 | long sz = 0; // Sent Size
184 | long pBufLen = strlen_P(apBuf);
185 | char buf[1460/4 + 1];
186 | PGM_P pBuf = apBuf;
187 |
188 | while(pBuf < apBuf + pBufLen) {
189 | strncpy_P(buf, pBuf, sizeof(buf));
190 | buf[sizeof(buf)] = 0;
191 | pBuf += strlen(buf);
192 | sz += wprint( String (buf) );
193 | };
194 |
195 | sz += wprint( "", aFinish );
196 |
197 | return sz;
198 | }
199 |
200 | // ###########################################################
201 | // End
202 |
203 |
204 |
--------------------------------------------------------------------------------
/Main/H_AdminPage.ino:
--------------------------------------------------------------------------------
1 | // AdminPage
2 |
3 | /*
4 | * Copyright (c) 2015, Eldon R. Brown - ERB - WA0UWH - eldonb@ebcon.com
5 | *
6 | * See my Blog, at: http://WA0UWH.blogspot.com
7 | *
8 | * See my Source at GitHub, at: https://github.com/wa0uwh/ERB-EspWebServer
9 | *
10 | * All rights reserved. See FULL Copyright in Main or Info Page for Exclusions
11 | *
12 | * This Effort was Inspired by work by: Majenko Technologies - 2015 Esp8266 AdvancedWebServer
13 | *
14 | * See also Arduino IDE, at: https://github.com/esp8266/Arduino
15 | */
16 |
17 |
18 | // ###########################################################
19 | //////////////////////////////////////////////////////////////
20 | //
21 | // This Function provides the Content for the URL Requsest from WIFI
22 | //
23 | long
24 | ICACHE_FLASH_ATTR
25 | adminPage()
26 | {
27 | long sz = 0; // Sent Size
28 |
29 | DEBUG_MONITOR_REPORT_START();
30 |
31 | DEBUG_MONITOR_REPORT_ARGS();
32 |
33 | // Parse Args
34 | for ( byte i = 0; i < gServer.args(); i++ ) {
35 | if (gServer.argName(i) == F("AutoAdminRefresh") ) gAutoAdminRefresh = constrain (gServer.arg(i).toInt(), 10, 600);
36 | }
37 |
38 | // Generate Html Header
39 | sz += htmlPageHeader( gDeviceName, gAutoAdminRefresh, F("/admin") );
40 |
41 | // Page Content Starts here
42 |
43 | // Page Title Line
44 | sz += htmlPageTitle( gDeviceName, F("Admin") );
45 |
46 | // Navigator
47 | sz += navigator();
48 |
49 | // Admin's SCAN Link
50 | sz += wprintln( F("\r\n") );
51 | if (gAutoAdminRefresh > 0)
52 | sz += wprint( F(" | ManUpdate ") );
53 | else sz += wprint( F(" | AutoUpdate ") );
54 | sz += wprint( F(" | ScanWiFi ") );
55 | sz += wprintln( F(" |") );
56 | sz += wprintln( F(" ") );
57 |
58 | // SliderBar Graphic
59 | if (gAutoAdminRefresh > 0 ) {
60 | sz += wprintln( );
61 | sz += wprintln( F("") );
62 | sz += sliderBar( F("AutoAdminRefresh"), F("Interval:"), 10, 600, 10, gAutoAdminRefresh, F("Sec"), F("/admin") );
63 | sz += wprintln( F(" ") );
64 | }
65 | sz += wprintln( F(" ") );
66 |
67 |
68 | sz += wprintln( );
69 | sz += wprintln( F("") );
70 |
71 | sz += wprintln( F("") ); // Html Indent the next Section
72 | {
73 |
74 | if ( gServer.uri() == F("/scanwifi") ) { // Report results of AP Scan
75 | sz += scanWifi();
76 | }
77 | else if ( gReStartSTN == true ) { // New Station AP Connection Message
78 | sz += wprintln( sF(" Connecting to: ") + String(WiFi.SSID()) + F(" ") );
79 | sz += wprintln( F(" ") );
80 | sz += wprintln( F("*** ReConfiguring Browser to New AP Channel, ReStarting in 10 Seconds *** ") );
81 | sz += wprintln( F(" ") );
82 | sz += wprintln( F(" ") );
85 | sz += wprintln( F(" ") );
86 | }
87 | else {
88 | // Default Page Report
89 | sz += wprintln( F("\r\n") );
90 | sz += wprintln( F("") );
91 | {
92 | sz += wprintln( F(" Connected To AP: ") );
93 | sz += wprintln( sF(" SSID: ") + String(WiFi.SSID()) + F(" ") );
94 | sz += wprintln( sF(" RSSI: ") + String(WiFi.RSSI()) + F("dBm ") );
95 | sz += wprintln( sF(" IPA: ") + ipa2str(WiFi.localIP()) + F(" ") );
96 | sz += wprintln( sF(" Gateway: ") + ipa2str(WiFi.gatewayIP()) + F(" ") );
97 | sz += wprintln( sF(" NetMask: ") + ipa2str(WiFi.subnetMask()) + F(" ") );
98 | sz += wprintln( F(" ") );
99 | }
100 | sz += wprintln( F("") );
101 | }
102 | }
103 | sz += wprintln( F("") ); // Html OutDent
104 |
105 | // Generate Html Footer
106 | sz += htmlPageFooter();
107 |
108 | DEBUG_MONITOR_REPORT_END();
109 |
110 | return sz;
111 |
112 | }
113 |
114 |
115 | // ###########################################################
116 | //////////////////////////////////////////////////////////////
117 | //
118 | // This Function Handles the URL Requsest from WIFI
119 | // and reports activity on Serial
120 | //
121 | void
122 | ICACHE_FLASH_ATTR
123 | handleAdminPage()
124 | {
125 | long sz = 0; // Sent Size
126 | gSentSize = 0;
127 |
128 | gCurrentPage = ADMINPAGE;
129 | gApTimeout = millis() + 15 * MINs;
130 |
131 | digitalWrite ( gGrnLED, ON );
132 | gHits++;
133 |
134 | // HTTP Header
135 | sz += wprintln( F("HTTP/1.1 200 OK") );
136 | sz += wprintln( F("Content-Type: text/html") );
137 | sz += wprintln( ); // A Blank Line
138 |
139 | sz += adminPage();
140 |
141 | sz += wprint( "", SEND_FINISH ); // Final Packet
142 |
143 | DEBUG_MONITOR_REPORT_TOTAL();
144 |
145 | digitalWrite ( gGrnLED, OFF );
146 | yield();
147 | }
148 |
149 |
150 | // ###########################################################
151 | //////////////////////////////////////////////////////////////
152 | //
153 | void
154 | ICACHE_FLASH_ATTR
155 | handleScan()
156 | {
157 | handleAdminPage();
158 | }
159 |
160 | // ###########################################################
161 | //////////////////////////////////////////////////////////////
162 | //
163 | void
164 | ICACHE_FLASH_ATTR
165 | handleConnect() // This may not work correctly, yet
166 | {
167 |
168 | gReStartSTN = false;
169 | gHits++;
170 |
171 | if ( gServer.arg("ReStart") == "true" ) {
172 | gReStartSTN = true;
173 |
174 | gSsidPrev = gSsid;
175 | gPasswdPrev = gPasswd;
176 |
177 | Serial.println ( F("\n\n ##############################") );
178 | Serial.println ( sF("Old AP: ") + gSsid + String(":") + gPasswd );
179 |
180 | gSsid = gServer.arg( "nSsid" );
181 | gPasswd = gServer.arg( "nPasswd" );
182 |
183 | gStnLive = false;
184 |
185 | Serial.println ( sF("New AP: ") \
186 | + gSsid + String(":") + gPasswd \
187 | + F(". ReStart Initiated: ") \
188 | + String(gReStartSTN == true ? "true" : "false") );
189 | handleAdminPage();
190 |
191 | Serial.println ( F("*** ReConfiguring Browser to New AP Channel, ReStarting in 5 Seconds ***") );
192 | delay(2000);
193 | //WiFi.mode(WIFI_AP);
194 | delay(3000);
195 | // WiFi.disconnect();
196 | }
197 | else handleAdminPage();
198 |
199 | }
200 |
201 | // ###########################################################
202 | // End
203 |
--------------------------------------------------------------------------------
/Main/NTP_Client.ino:
--------------------------------------------------------------------------------
1 | // NTP_Client
2 |
3 | /*
4 | * Copyright (c) 2015, Eldon R. Brown - ERB - WA0UWH - eldonb@ebcon.com
5 | *
6 | * See my Blog, at: http://WA0UWH.blogspot.com
7 | *
8 | * See my Source at GitHub, at: https://github.com/wa0uwh/ERB-EspWebServer
9 | *
10 | * All rights reserved. See FULL Copyright in Main or Info Page for Exclusions
11 | *
12 | * This Effort was Inspired by work by: Majenko Technologies - 2015 Esp8266 AdvancedWebServer
13 | *
14 | * See also Arduino IDE, at: https://github.com/esp8266/Arduino
15 | */
16 |
17 |
18 | unsigned int localPort = 2390; // local port to listen for UDP packets
19 |
20 | //IPAddress gTimeServer(129, 6, 15, 28); // time.nist.gov NTP server
21 | IPAddress gTimeServer(70, 35, 113, 43); // time.nist.gov NTP server
22 | //IPAddress gTimeServer(192, 168, 43, 195); // time.nist.gov NTP server
23 | //IPAddress gTimeServer(192, 168, 2, 15); // local NTP server
24 |
25 | const int NTP_PACKET_SIZE = 48; // NTP time stamp is in the first 48 bytes of the message
26 |
27 | byte packetBuffer[ NTP_PACKET_SIZE]; // buffer to hold incoming and outgoing packets
28 |
29 | // A UDP instance to let us send and receive packets over UDP
30 | WiFiUDP udp;
31 |
32 |
33 | // ###########################################################
34 | //////////////////////////////////////////////////////////////
35 | //
36 | unsigned long
37 | ICACHE_FLASH_ATTR
38 | getEpochDelta()
39 | {
40 |
41 | Serial.println ( F("\nStarting Connection to NTP Server ...") );
42 | udp.begin(localPort);
43 | yield();
44 |
45 | gEpochAvailable = false;
46 |
47 | int packetLength = udp.parsePacket();
48 | int loops = 0;
49 | while (!packetLength) {
50 | if (!(loops % 15)) {
51 | Serial.println ( " " );
52 | sendNTPpacket();
53 | Serial.print ( F(" No NTP Packets Received Yet "));
54 | }
55 | loops = ++loops % 30;
56 | if (!loops) { Serial.println ( "." ); Serial.print ( F("Re-Scheduling NTP Request\n")); return 0;}
57 | Serial.print ( "." );
58 | gServer.handleClient();
59 | delay(100);
60 | gServer.handleClient();
61 | yield();
62 | packetLength = udp.parsePacket();
63 | gServer.handleClient();
64 | delay(250);
65 | yield();
66 | }
67 |
68 | unsigned long upTimeStamp = upTime();
69 |
70 | Serial.print( F("\n NTP Packet Received, Length: ") );
71 | Serial.println ( packetLength );
72 | // We've received a packet, read the data from it
73 | udp.read(packetBuffer, NTP_PACKET_SIZE); // read the packet into the buffer
74 | yield();
75 |
76 | //the timestamp starts at byte 40 of the received packet and is four bytes,
77 | // or two words, long. First, esxtract the two words:
78 |
79 | unsigned long highWord = word(packetBuffer[40], packetBuffer[41]);
80 | unsigned long lowWord = word(packetBuffer[42], packetBuffer[43]);
81 | // combine the four bytes (two words) into a long integer
82 | // this is NTP time (seconds since Jan 1 1900):
83 | unsigned long secsSince1900 = highWord << 16 | lowWord;
84 | Serial.print( F(" Seconds since Jan 1 1900 = " ) );
85 | Serial.println ( secsSince1900 );
86 | yield();
87 |
88 | if (! secsSince1900 ) return 0;
89 |
90 | // now convert NTP time into everyday time:
91 | Serial.print( F(" Unix time = ") );
92 | // Unix time starts on Jan 1 1970. In seconds, that's 2208988800:
93 | const unsigned long seventyYears = 2208988800UL;
94 | // subtract seventy years:
95 | gEpochDelta = secsSince1900 - seventyYears - upTimeStamp;
96 | // print Unix time:
97 | Serial.println ( gEpochDelta );
98 |
99 | gEpochAvailable = true;
100 | yield();
101 |
102 | return gEpochDelta;
103 | }
104 |
105 | // ###########################################################
106 | //////////////////////////////////////////////////////////////
107 | //
108 | unsigned long
109 | ICACHE_FLASH_ATTR
110 | epoch()
111 | {
112 | if (gEpochDelta) return gEpochDelta + upTime();
113 | return 0;
114 | }
115 |
116 |
117 | // ###########################################################
118 | //////////////////////////////////////////////////////////////
119 | //
120 | void
121 | ICACHE_FLASH_ATTR
122 | updateNTP()
123 | {
124 | unsigned long schdInc = 30 * MINs;
125 |
126 | if (gEpochAvailable == false) schdInc = 1 * MINs;
127 |
128 | if (gNextNTPSchd > millis()) return; // Abort, wait for next Run
129 |
130 | gNextNTPSchd = millis()+ schdInc; // Schedule Next Run
131 |
132 | if (gEpochAvailable == false) getEpochDelta();
133 | }
134 |
135 | // ###########################################################
136 | //////////////////////////////////////////////////////////////
137 | //
138 | String &
139 | ICACHE_FLASH_ATTR
140 | timeUTC(String & timeBuf, unsigned long timezone)
141 | {
142 |
143 | if (!epoch()) return timeBuf;
144 |
145 | unsigned long timesec = epoch() + timezone;
146 | unsigned long timemin = timesec / 60;
147 | unsigned long timehr = timemin / 60;
148 | unsigned long timeday = timehr / 24;
149 | unsigned long timewday = timeday / 24;
150 | yield();
151 |
152 | timesec %= 60;
153 | timemin %= 60;
154 | timehr %= 24;
155 | timewday %= 7; timewday += 3;
156 |
157 | snprintf( gTmpBuf, sizeof(gTmpBuf),
158 | FMT("%02d:%02d:%02d"), (int) timehr, (int) timemin, (int) timesec );
159 | timeBuf = gTmpBuf;
160 | return timeBuf;
161 |
162 | }
163 |
164 | // ###########################################################
165 | //////////////////////////////////////////////////////////////
166 | //
167 | // send an NTP request to the time server at the given address
168 | //
169 | unsigned long
170 | ICACHE_FLASH_ATTR
171 | sendNTPpacket()
172 | {
173 |
174 | Serial.print( F(" Sending NTP Request Packet, to: ") );
175 | Serial.println ( gTimeServer );
176 | // set all bytes in the buffer to 0
177 | memset(packetBuffer, 0, NTP_PACKET_SIZE);
178 | // Initialize values needed to form NTP request
179 | // (see URL above for details on the packets)
180 | packetBuffer[0] = 0b11100011; // LI, Version, Mode
181 | packetBuffer[1] = 0; // Stratum, or type of clock
182 | packetBuffer[2] = 6; // Polling Interval
183 | packetBuffer[3] = 0xEC; // Peer Clock Precision
184 | // 8 bytes of zero for Root Delay & Root Dispersion
185 | packetBuffer[12] = 49; // 1
186 | packetBuffer[13] = 0x4E; // N, 78
187 | packetBuffer[14] = 49; // 1
188 | packetBuffer[15] = 52; // 4
189 |
190 | // all NTP fields have been given values, now
191 | // you can send a packet requesting a timestamp:
192 | udp.beginPacket(gTimeServer, 123); //NTP requests are to port 123
193 | Serial.println ( F(" Connecting to NTP Server Port") );
194 | yield();
195 |
196 | udp.write(packetBuffer, NTP_PACKET_SIZE);
197 | Serial.println ( F(" NTP UDP Packet Sent") );
198 | yield();
199 |
200 | udp.endPacket();
201 | Serial.println ( F(" NTP UDP Packet End") );
202 | yield();
203 | }
204 |
205 | // ###########################################################
206 | // End
207 |
--------------------------------------------------------------------------------
/Main/A3_Handlers.ino:
--------------------------------------------------------------------------------
1 | // A3_Handlers
2 |
3 | /*
4 | * Copyright (c) 2015, Eldon R. Brown - ERB - WA0UWH - eldonb@ebcon.com
5 | *
6 | * See my Blog, at: http://WA0UWH.blogspot.com
7 | *
8 | * See my Source at GitHub, at: https://github.com/wa0uwh/ERB-EspWebServer
9 | *
10 | * All rights reserved. See FULL Copyright in Main or Info Page for Exclusions
11 | *
12 | * This Effort was Inspired by work by: Majenko Technologies - 2015 Esp8266 AdvancedWebServer
13 | *
14 | * See also Arduino IDE, at: https://github.com/esp8266/Arduino
15 | */
16 |
17 |
18 | // ###########################################################
19 | //////////////////////////////////////////////////////////////
20 | //
21 | // This Function provides links to Handlers for the URL Requsest from WIFI
22 | //
23 | void
24 | ICACHE_FLASH_ATTR
25 | initHandlers()
26 | {
27 |
28 | // Page Handlers
29 | gServer.on ( "/", handleHomePage );
30 | gServer.on ( "/home", handleHomePage );
31 | gServer.on ( "/help", handleHelpPage );
32 | gServer.on ( "/admin", handleAdminPage );
33 | gServer.on ( "/info", handleInfoPage );
34 | gServer.on ( "/test.svg", handleLineGraph );
35 | gServer.on ( "/freeheap.svg", handleLineGraphFH );
36 |
37 | gServer.on ( "/clock.svg", handleClock );
38 | gServer.on ( "/clock2.svg", handleClock );
39 | gServer.on ( "/clock3.svg", handleClock );
40 | gServer.on ( "/inst.svg", handleInst );
41 | gServer.on ( "/inst2.svg", handleInst );
42 | gServer.on ( "/inst3.svg", handleInst );
43 |
44 | gServer.on ( "/bar.svg", handleBar );
45 | gServer.on ( "/sliderbar", handleSliderBar );
46 | gServer.on ( "/visitormap", handleVisitorMap );
47 | gServer.on ( "/farm01.jpg", handleFarmImage );
48 |
49 | // Verbose Option, Hidden from HELP
50 | gServer.on ( "/on/vismap", []() { gHits++; DMRAF(); gVisitorMapState = true; pageDirector();} );
51 | gServer.on ( "/off/vismap", []() { gHits++; DMRAF(); gVisitorMapState = false; pageDirector();} );
52 | gServer.on ( "/a/vismap", []() { gHits++; DMRAF(); gVisitorMapStyle = 1; pageDirector();} );
53 | gServer.on ( "/b/vismap", []() { gHits++; DMRAF(); gVisitorMapStyle = 2; pageDirector();} );
54 |
55 | // Verbose Option
56 | gServer.on ( "/t/v", []() { gHits++; DMRAF(); toggleVerboseMode(); pageDirector();} );
57 | gServer.on ( "/s/v", []() { gHits++; DMRAF(); verboseMode(true); pageDirector();} );
58 | gServer.on ( "/c/v", []() { gHits++; DMRAF(); verboseMode(false); pageDirector();} );
59 |
60 | // LED Control
61 | gServer.on ( "/t/redled", []() { gHits++; DMRAF(); redLed_toggle(); pageDirector();} );
62 | gServer.on ( "/on/redled", []() { gHits++; DMRAF(); redLed(ON); pageDirector();} );
63 | gServer.on ( "/off/redled", []() { gHits++; DMRAF(); redLed(OFF); pageDirector();} );
64 |
65 | // Auto Page Update Options
66 | gServer.on ( "/home/auto_on", []() { gHits++; DMRAF(); gAutoHomeRefresh = 60; pageDirector();} ); // Hidden from Help
67 | gServer.on ( "/home/auto_off", []() { gHits++; DMRAF(); gAutoHomeRefresh = 0; pageDirector();} ); // Hidden from Help
68 | gServer.on ( "/help/auto_on", []() { gHits++; DMRAF(); gAutoHelpRefresh = 60; pageDirector();} ); // Hidden from Help
69 | gServer.on ( "/help/auto_off", []() { gHits++; DMRAF(); gAutoHelpRefresh = 0; pageDirector();} ); // Hidden from Help
70 | gServer.on ( "/admin/auto_on", []() { gHits++; DMRAF(); gAutoAdminRefresh = 60; pageDirector();} ); // Hidden from Help
71 | gServer.on ( "/admin/auto_off",[]() { gHits++; DMRAF(); gAutoAdminRefresh = 0; pageDirector();} ); // Hidden from Help
72 |
73 | // Querys
74 | gServer.on ( "/q/mdns", []() { gHits++; DMRAF(); gServer.send ( 200, TEXT_PLAIN, String(gHits) + ": " + String(gDeviceName) + F(".local"));} );
75 | gServer.on ( "/q/ssid", []() { gHits++; DMRAF(); gServer.send ( 200, TEXT_PLAIN, String(gHits) + ": " + String(WiFi.SSID()));} );
76 | gServer.on ( "/q/rssi", []() { gHits++; DMRAF(); gServer.send ( 200, TEXT_PLAIN, String(gHits) + ": " + String(WiFi.RSSI()) + F("dBm"));} );
77 | gServer.on ( "/q/stnipa", []() { gHits++; DMRAF(); gServer.send ( 200, TEXT_PLAIN, String(gHits) + ": " + ipa2str(WiFi.localIP()));} );
78 | gServer.on ( "/q/stnmac", []() { gHits++; DMRAF(); gServer.send ( 200, TEXT_PLAIN, String(gHits) + ": " + mac2str(WiFi.macAddress(gMacBuf)));} );
79 | gServer.on ( "/q/gateway", []() { gHits++; DMRAF(); gServer.send ( 200, TEXT_PLAIN, String(gHits) + ": " + ipa2str(WiFi.gatewayIP()));} );
80 | gServer.on ( "/q/netmask", []() { gHits++; DMRAF(); gServer.send ( 200, TEXT_PLAIN, String(gHits) + ": " + ipa2str(WiFi.subnetMask()));} );
81 | gServer.on ( "/q/myipa", []() { gHits++; DMRAF(); gServer.send ( 200, TEXT_PLAIN, String(gHits) + ": " + ipa2str(gServer.client().remoteIP()));} );
82 |
83 | gServer.on ( "/q/restarts", []() { gHits++; DMRAF(); gServer.send ( 200, TEXT_PLAIN, String(gHits) + ": " + String(gWifiReStarts));} );
84 | gServer.on ( "/q/redled", []() { gHits++; DMRAF(); gServer.send ( 200, TEXT_PLAIN, String(gHits) + ": " + String(gRedLedState == ON ? "ON" : "OFF"));} );
85 | gServer.on ( "/q/uptime", []() { gHits++; DMRAF(); gServer.send ( 200, TEXT_PLAIN, String(gHits) + ": " + String(upTime()));} );
86 | // gServer.on ( "/q/utctime", []() { gHits++; DMRAF(); gServer.send ( 200, TEXT_PLAIN, String(gHits) + ": " + String(utcTime()));} );
87 | gServer.on ( "/q/epoch", []() { gHits++; DMRAF(); gServer.send ( 200, TEXT_PLAIN, String(gHits) + ": " + String(epoch()));} );
88 | gServer.on ( "/q/loadavg", []() { gHits++; DMRAF(); gServer.send ( 200, TEXT_PLAIN, String(gHits) + ": " + String(gLoadAvgS));} );
89 | gServer.on ( "/q/battvolt", []() { gHits++; DMRAF(); gServer.send ( 200, TEXT_PLAIN, String(gHits) + ": " + String(readvdd33()/1000.0, 3));} );
90 | gServer.on ( "/q/freeheap", []() { gHits++; DMRAF(); gServer.send ( 200, TEXT_PLAIN, String(gHits) + ": " + ESP.getFreeHeap());} );
91 | gServer.on ( "/q/hits", []() { gHits++; DMRAF(); gServer.send ( 200, TEXT_PLAIN, String(gHits) + ": " + String(gHits));} );
92 |
93 | gServer.on ( "/q/id", []() { gHits++; DMRAF(); gServer.send ( 200, TEXT_PLAIN, String(gHits) + ": " + String(ESP.getChipId() / 10000.0, 4));} );
94 | gServer.on ( "/q/idx", []() { gHits++; DMRAF(); gServer.send ( 200, TEXT_PLAIN, String(gHits) + ": " + String(id2hex(ESP.getChipId())));} );
95 | gServer.on ( "/q/flashid", []() { gHits++; DMRAF(); gServer.send ( 200, TEXT_PLAIN, String(gHits) + ": " + String(ESP.getFlashChipId() / 10000.0, 4));} );
96 | gServer.on ( "/q/flashsize", []() { gHits++; DMRAF(); gServer.send ( 200, TEXT_PLAIN, String(gHits) + ": " + String(ESP.getFlashChipSize() / 1000.0, 1));} );
97 | gServer.on ( "/q/flashspd", []() { gHits++; DMRAF(); gServer.send ( 200, TEXT_PLAIN, String(gHits) + ": " + String(ESP.getFlashChipSpeed() / 1000000.0, 1));} );
98 |
99 | gServer.on ( "/q/rev", []() { gHits++; DMRAF(); gServer.send ( 200, TEXT_PLAIN, String(gHits) + ": " + String(gRev));} );
100 |
101 | gServer.on ( "/q/apssid", []() { gHits++; DMRAF(); gServer.send ( 200, TEXT_PLAIN, String(gHits) + ": " + String(gDeviceName));} );
102 | gServer.on ( "/q/apipa", []() { gHits++; DMRAF(); gServer.send ( 200, TEXT_PLAIN, String(gHits) + ": " + String(ipa2str(WiFi.softAPIP())));} );
103 | gServer.on ( "/q/apmac", []() { gHits++; DMRAF(); gServer.send ( 200, TEXT_PLAIN, String(gHits) + ": " + mac2str(WiFi.softAPmacAddress(gMacBuf)));} );
104 | gServer.on ( "/q/apchannel", []() { gHits++; DMRAF(); gServer.send ( 200, TEXT_PLAIN, String(gHits) + ": " + String(gApChannel));} );
105 |
106 |
107 | // Admin functions
108 | gServer.on ( "/scanwifi", handleScan );
109 | gServer.on ( "/connect", handleConnect ); // Hidden from HELP
110 |
111 | gServer.onNotFound ( handleNotFound );
112 | }
113 |
114 |
115 | // ###########################################################
116 | // End
117 |
--------------------------------------------------------------------------------
/Main/H_HomePage.ino:
--------------------------------------------------------------------------------
1 | // HomePage
2 |
3 | /*
4 | * Copyright (c) 2015, Eldon R. Brown - ERB - WA0UWH - eldonb@ebcon.com
5 | *
6 | * See my Blog, at: http://WA0UWH.blogspot.com
7 | *
8 | * See my Source at GitHub, at: https://github.com/wa0uwh/ERB-EspWebServer
9 | *
10 | * All rights reserved. See FULL Copyright in Main or Info Page for Exclusions
11 | *
12 | * This Effort was Inspired by work by: Majenko Technologies - 2015 Esp8266 AdvancedWebServer
13 | *
14 | * See also Arduino IDE, at: https://github.com/esp8266/Arduino
15 | */
16 |
17 |
18 | // ###########################################################
19 | //////////////////////////////////////////////////////////////
20 | //
21 | // This Function provides the Content for the URL Requsest from WIFI
22 | //
23 | long
24 | ICACHE_FLASH_ATTR
25 | homePage()
26 | {
27 | long sz = 0; // Sent Size
28 |
29 | DEBUG_MONITOR_REPORT_START();
30 |
31 | DEBUG_MONITOR_REPORT_ARGS();
32 |
33 | // Parse Args
34 | for ( byte i = 0; i < gServer.args(); i++ ) {
35 | if (gServer.argName(i) == F("AutoHomeRefresh") ) gAutoHomeRefresh = constrain (gServer.arg(i).toInt(), 10, 600);
36 | }
37 |
38 | // Generate Html Header
39 | sz += htmlPageHeader( gDeviceName, gAutoHomeRefresh, gServer.uri() );
40 |
41 | // Page Content Starts here
42 |
43 | // Page Title Line
44 | sz += htmlPageTitle( gDeviceName, F("Dashboard") );
45 |
46 | // // Page Refresh Button
47 | // {
48 | // String TmpBuf = "";
49 | // sz += wprintln( F("") );
50 | // sz += wprintln( reFreshButton(TmpBuf, String("/home")) );
51 | // sz += wprintln( F(" ") );
52 | // }
53 |
54 | // Navigator
55 | sz += navigator();
56 |
57 | // Options
58 | sz += wprintln( );
59 | sz += wprintln( F("") );
60 | if (gAutoHomeRefresh>0)
61 | sz += wprint ( F(" | ManUpdate ") );
62 | else sz += wprint ( F(" | AutoUpdate ") );
63 | sz += wprint ( F(" | Verbose ") );
64 | sz += wprintln( F(" |") );
65 | sz += wprintln( F(" ") );
66 |
67 | // SliderBar Graphic
68 | if (gAutoHomeRefresh > 0 ) {
69 | sz += wprintln( );
70 | sz += wprintln( F("") );
71 | sz += sliderBar( F("AutoHomeRefresh"), F("Interval:"), 10, 600, 10, gAutoHomeRefresh, F("Sec"), F("/home") );
72 | sz += wprintln( F(" ") );
73 | }
74 | sz += wprintln( F(" ") );
75 |
76 |
77 |
78 | sz += wprintln( );
79 | sz += wprintln( F("") );
80 |
81 | // Report LED State, and Provide Toggle Option
82 | sz += wprintln( );
83 | sz += wprintln( F("") );
84 | sz += wprint ( F("") );
93 | sz += wprintln( F(" ") );
94 |
95 | // // An Experiment with Buttons
96 | // sz += wprintln( " \r\n";
97 | // sz += wprintln( "\r\n";
100 |
101 |
102 | // SVG_Line Graphic
103 | {
104 | sz += wprintln( );
105 | sz += wprintln( F("") );
106 | sz += wprintln( F("") );
107 | {
108 | sz += wprintln( F("") );
109 | sz += lineGraphic();
110 | sz += wprintln( F(" ") );
111 |
112 | sz += wprintln( );
113 | sz += wprintln( F(" ") );
114 | sz += wprintln( F("Example: Random") );
115 | sz += wprintln( F("Line Graphic ") );
116 | }
117 | sz += wprintln( F(" ") );
118 | sz += wprintln( F(" ") );
119 | }
120 |
121 |
122 |
123 | // SVG_Bar Graphic
124 | sz += wprintln( );
125 | sz += wprintln( F("") );
126 | sz += wprintln( F("") );
127 | {
128 | sz += barGraphic();
129 |
130 | sz += wprintln( );
131 | sz += wprintln( F(" ") );
132 | sz += wprintln( F("Example:") );
133 | sz += wprintln( F("Bar Graphic ") );
134 | }
135 | sz += wprintln( F(" ") );
136 | sz += wprintln( F(" ") );
137 |
138 |
139 | // SVG_Line_FH Graphic
140 | sz += wprintln( );
141 | sz += wprintln( F("") );
142 | sz += wprintln( F("") );
143 | {
144 | sz += wprintln( F("") );
145 | sz += lineGraphicFH();
146 | sz += wprintln( F(" ") );
147 |
148 | sz += wprintln( );
149 | sz += wprintln( F(" ") );
150 | sz += wprintln( F("Example:") );
151 | sz += wprintln( F("Line FreeHeap Graphic") );
152 | sz += wprintln( F(" ") );
153 | sz += wprintln( F(" ") );
154 | sz += wprintln( sF("Range: ") + String( FreeHeapScaleLo/1000 ) + F("KB to ") + String( FreeHeapScaleHi/1000 ) + F("KB") );
155 | sz += wprintln( F(" ") );
156 | sz += wprintln( sF("Count of Last Sample: ") + String( gFreeHeapLogIndex/1000.0, 2 ) + F("K") );
157 | sz += wprintln( F(" ") );
158 | sz += wprintln( F("Down Tick marks Start of Web Page Link, Up Tick marks End of Page") );
159 | sz += wprintln( F(" ") );
160 | sz += wprintln( F("Horizontal Sustained Level, is Normal Idle") );
161 | }
162 | sz += wprintln( F(" ") );
163 | sz += wprintln( F(" ") );
164 |
165 |
166 | // SVG Dial Graphic
167 | sz += wprintln( );
168 | sz += wprintln( F("") );
169 | sz += wprintln( F("") );
170 | {
171 | // SVG_Inst Graphic
172 | sz += wprintln( F("") );
173 | sz += wprintln( F(" ") );
174 |
175 | // SVG_Clock Graphic
176 | sz += wprintln( F("") );
177 | sz += wprintln( F(" ") );
178 |
179 | sz += wprintln( );
180 | sz += wprintln( F(" ") );
181 | sz += wprintln( F("Example:") );
182 | sz += wprintln( F("Inst and Clock Graphics ") );
183 |
184 | // Provide Optional Visitor Map
185 | sz += visitorMap();
186 | }
187 | sz += wprintln( F(" ") );
188 | sz += wprintln( F(" ") );
189 |
190 | // Verbose Status Info
191 | if (gVerbose == true ) {
192 | sz += wprintln( );
193 | sz += wprintln( F("") );
194 | sz += wprintln( F("") );
195 | sz += wprintln( F("Verbose List: ") );
196 | sz += wprintln( F(" ") );
197 | sz += wprintln( sF(" Uptime: ") + String(upTimeStr()) + F(" ") );
198 | sz += wprintln( sF(" Batt Voltage: ") + String(readvdd33()/1000.0, 2) + F("V ") );
199 | sz += wprintln( sF(" Free Heap Size: ") + String(ESP.getFreeHeap() / 1000.0, 3) + F("KB ") );
200 | sz += wprintln( sF(" Hits: ") + String(gHits) + F(" ") );
201 | sz += wprintln( sF(" Unit ID: ") + String(ESP.getChipId() / 10000.0, 4) + F(" ") );
202 | sz += wprintln( sF(" STN IPA: ") + String(ipa2str(WiFi.localIP())) + F(" ") );
203 | sz += wprintln( sF(" My IPA: ") + String(ipa2str(gServer.client().remoteIP())) + F(" ") );
204 | sz += wprintln( sF(" Sketch Rev: ") + String(gRev) + F(" ") );
205 | sz += wprintln( F(" ") );
206 | sz += wprintln( F(" ") );
207 | sz += wprintln( F(" ") );
208 | }
209 |
210 | // Generate Html Footer
211 | sz += htmlPageFooter();
212 |
213 | DEBUG_MONITOR_REPORT_END();
214 |
215 | return sz;
216 |
217 | }
218 |
219 |
220 | // ###########################################################
221 | //////////////////////////////////////////////////////////////
222 | //
223 | // This Function Handles the URL Requsest from WIFI
224 | // and reports activity on Serial
225 | //
226 | void
227 | ICACHE_FLASH_ATTR
228 | handleHomePage()
229 | {
230 | long sz = 0; // Sent Size
231 | gSentSize = 0;
232 |
233 | gCurrentPage = HOMEPAGE;
234 |
235 | digitalWrite ( gGrnLED, ON );
236 | gHits++;
237 |
238 | // HTTP Header
239 | sz += wprintln( F("HTTP/1.1 200 OK") );
240 | sz += wprintln( F("Content-Type: text/html") );
241 | sz += wprintln( ); // A Blank Line
242 |
243 | sz += homePage();
244 |
245 | sz += wprint( "", SEND_FINISH ); // Final Packet
246 |
247 | DEBUG_MONITOR_REPORT_TOTAL();
248 |
249 | digitalWrite ( gGrnLED, OFF );
250 | yield();
251 | }
252 |
253 | // ###########################################################
254 | // End
255 |
--------------------------------------------------------------------------------
/Main/A2_UtilsSupport.ino:
--------------------------------------------------------------------------------
1 | // A2_UtilsSupport
2 |
3 | /*
4 | * Copyright (c) 2015, Eldon R. Brown - ERB - WA0UWH - eldonb@ebcon.com
5 | *
6 | * See my Blog, at: http://WA0UWH.blogspot.com
7 | *
8 | * See my Source at GitHub, at: https://github.com/wa0uwh/ERB-EspWebServer
9 | *
10 | * All rights reserved. See FULL Copyright in Main or Info Page for Exclusions
11 | *
12 | * This Effort was Inspired by work by: Majenko Technologies - 2015 Esp8266 AdvancedWebServer
13 | *
14 | * See also Arduino IDE, at: https://github.com/esp8266/Arduino
15 | */
16 |
17 | // ###########################################################
18 | //////////////////////////////////////////////////////////////
19 | //
20 | // Html Page Header: Common Header Text for all Web Pages
21 | //
22 | long
23 | ICACHE_FLASH_ATTR
24 | htmlPageHeader( String aTitle, int aAutoRefresh = 0, String aURL = "/" )
25 | {
26 | long sz = 0; // Sent Size
27 |
28 | gPageStartTime = millis();
29 |
30 | // Html Page Header: Common Header for all Web Pages
31 | sz += wprintln( F("") );
32 | sz += wprintln( F("") );
33 | sz += wprintln( F(" ") );
34 | sz += wprintln( sF(" ") + aTitle + F(" ") );
35 | if (aAutoRefresh > 0 ) sz += wprintln( sF(" ") );
36 | sz += wprintln( F(" ") );
37 | sz += wprintln( F(" ") );
38 | sz += wprintln( F(" ") ); // Redirect requests for "/favicon.ico"
39 | sz += wprintln( F(" ") );
42 | sz += wprintln( F(" ") );
43 | sz += wprintln( );
44 | sz += wprintln( F(" ") );
45 | sz += wprintln( F(" ") );
46 |
47 | return sz;
48 | }
49 |
50 | // ###########################################################
51 | //////////////////////////////////////////////////////////////
52 | //
53 | // Html Page Title: Common Title Text for all Web Pages
54 | //
55 | long
56 | ICACHE_FLASH_ATTR
57 | htmlPageTitle( String aNodeName, String aTitle )
58 | {
59 | long sz = 0; // Sent Size
60 | sz += wprintln( F("") );
61 | sz += wprintln( String(aNodeName) );
62 | sz += wprintln( F(" - ") );
63 | sz += wprintln( String(aTitle) );
64 | sz += wprintln( F("ERB's Esp8266 Experimental Web Server ") );
65 | sz += wprintln( F(" ") );
66 | return sz;
67 | }
68 |
69 | // ###########################################################
70 | //////////////////////////////////////////////////////////////
71 | //
72 | // Html Page Footer: Common Footer and Trailer-Text for all Web Pages
73 | //
74 | long
75 | ICACHE_FLASH_ATTR
76 | htmlPageFooter()
77 | {
78 | long sz = 0; // Sent Size
79 |
80 | sz += wprintln( );
81 | sz += wprintln( F("") );
82 | sz += wprintln( F("") );
83 | sz += wprintln( F(" ") );
84 |
85 | sz += wprintln( F("Created at: ") );
86 | sz += wprint ( String ( (gSentSize / ((millis() - gPageStartTime)/1000.0)/1000.0), 1 ) );
87 | sz += wprint ( F(" MB/Sec") );
88 | sz += wprint ( F(" - ") );
89 | sz += wprint ( String ( (millis() - gPageStartTime)/1000.0, 3 ) );
90 | sz += wprint ( F(" CPU Secs - ") );
91 | sz += wprint ( gLoadAvgS ); // Pseudo Load Average
92 | sz += wprintln( F(" LoadAvg (pseudo)") );
93 | sz += wprintln( F(" ") );
94 | sz += wprintln( F(" ") );
95 |
96 | sz += wprintln( F("Powered by: Esp8266 ") );
97 | sz += wprintln( F(" ") );
98 |
99 | sz += wprintln( F("Contact Mgr at: 202-555-1212 ") );
100 | sz += wprintln( F(" ") );
101 |
102 | sz += wprintln( F("Copyright 2015 ") );
103 | sz += wprintln( F(" ") );
104 |
105 | sz += wprintln( F(" -") );
106 | sz += wprintln( F(" ") );
107 |
108 | sz += wprintln( );
109 | sz += wprintln( F(" ") );
110 | sz += wprintln( F(" ") );
111 | sz += wprintln( F("") );
112 |
113 | return sz;
114 | }
115 |
116 |
117 | // ###########################################################
118 | //////////////////////////////////////////////////////////////
119 | //
120 | // A Previous Page Director
121 | //
122 | void
123 | ICACHE_FLASH_ATTR
124 | pageDirector(int page = gCurrentPage )
125 | {
126 | switch ( page ) {
127 | case ADMINPAGE: handleAdminPage(); break;
128 | case HELPPAGE: handleHelpPage(); break ;
129 | case INFOPAGE: handleInfoPage(); break ;
130 | case HOMEPAGE: // Fall thru to Default
131 | default: handleHomePage();
132 | }
133 | }
134 |
135 |
136 | // ###########################################################
137 | //////////////////////////////////////////////////////////////
138 | //
139 | // Toggles Page Verbose Mode
140 | //
141 | void
142 | ICACHE_FLASH_ATTR
143 | toggleVerboseMode()
144 | {
145 | gVerbose = !gVerbose;
146 | }
147 |
148 | // ###########################################################
149 | //////////////////////////////////////////////////////////////
150 | //
151 | // Sets Page Verbose Mode
152 | //
153 | void
154 | ICACHE_FLASH_ATTR
155 | verboseMode(boolean aMode = true)
156 | {
157 | gVerbose = aMode;
158 | }
159 |
160 |
161 | // ###########################################################
162 | //////////////////////////////////////////////////////////////
163 | //
164 | // Provides UpTime in Seconds
165 | //
166 | unsigned long
167 | upTime()
168 | {
169 | return millis() / 1000;
170 | }
171 |
172 |
173 | // ###########################################################
174 | //////////////////////////////////////////////////////////////
175 | //
176 | // Converts Uptime to a String Value, Days, Hours:Minutes:Seconds
177 | //
178 | String
179 | upTimeStr()
180 | {
181 | // char buf[PBUFSIZE];
182 |
183 | int uptimesec = upTime();
184 | int uptimemin = uptimesec / 60;
185 | int uptimehr = uptimemin / 60;
186 | int uptimeday = uptimehr / 24;
187 | yield();
188 |
189 | uptimesec %= 60;
190 | uptimemin %= 60;
191 | uptimehr %= 24;
192 |
193 | snprintf( gTmpBuf, sizeof(gTmpBuf),
194 | FMT("%d Days, %02d:%02d:%02d"), uptimeday, uptimehr, uptimemin, uptimesec );
195 | yield();
196 |
197 | return gTmpBuf;
198 | }
199 |
200 | // ###########################################################
201 | //////////////////////////////////////////////////////////////
202 | //
203 | // Converts MAC Address to String
204 | //
205 | String
206 | ICACHE_FLASH_ATTR
207 | mac2str( byte mac[6] )
208 | {
209 |
210 | snprintf(gTmpBuf, sizeof(gTmpBuf),
211 | FMT("%X:%X:%X:%X:%X:%X"), mac[0], mac[1], mac[2], mac[3], mac[4], mac[5]);
212 | yield();
213 |
214 | return gTmpBuf;
215 | }
216 |
217 | // ###########################################################
218 | //////////////////////////////////////////////////////////////
219 | //
220 | // Converts ID to HEX String
221 | //
222 | String
223 | ICACHE_FLASH_ATTR
224 | id2hex( int id )
225 | {
226 |
227 | snprintf(gTmpBuf, sizeof(gTmpBuf),
228 | FMT("%X"), id);
229 | yield();
230 |
231 | return gTmpBuf;
232 | }
233 |
234 |
235 | // ###########################################################
236 | //////////////////////////////////////////////////////////////
237 | //
238 | // Converts numeric IPA to String
239 | //
240 | String
241 | ICACHE_FLASH_ATTR
242 | ipa2str( IPAddress ipa )
243 | {
244 |
245 | snprintf(gTmpBuf, sizeof(gTmpBuf),
246 | FMT("%d.%d.%d.%d"), ipa[0], ipa[1], ipa[2], ipa[3]);
247 | yield();
248 |
249 | return gTmpBuf;
250 | }
251 |
252 |
253 | // ###########################################################
254 | //////////////////////////////////////////////////////////////
255 | //
256 | // Logs the FreeHeap Data, this is called periodically
257 | //
258 | int
259 | //ICACHE_FLASH_ATTR
260 | logFreeHeap()
261 | {
262 | gFreeHeapLog[gFreeHeapLogIndex++ % sizeof(gFreeHeapLog)] = (byte) constrain(ESP.getFreeHeap()/100, 0, 255);
263 | // Serial.println ( sF(" FreeHeap: ") + String( ESP.getFreeHeap()/1000.0, 1 ) ); // Debug
264 | }
265 |
266 | // ###########################################################
267 | //////////////////////////////////////////////////////////////
268 | //
269 | // Creates/Inserts a Tick Mark in the FreeHeap Data Record
270 | //
271 | int
272 | //ICACHE_FLASH_ATTR
273 | _logFreeHeapMark(int aDir)
274 | {
275 | // Insert a visible Mark in the Free Heap Log
276 | const int MarkAmp = 16; // Mark Amplitude
277 | aDir = constrain(aDir, -1, +1);
278 | byte Save = gFreeHeapLog[(gFreeHeapLogIndex + sizeof(gFreeHeapLog) -1) % sizeof(gFreeHeapLog)];
279 | gFreeHeapLog[(gFreeHeapLogIndex++) % sizeof(gFreeHeapLog)] = (byte) constrain(Save + MarkAmp*aDir, 0, 255); // The Mark
280 | // gFreeHeapLog[(gFreeHeapLogIndex++) % sizeof(gFreeHeapLog)] = (byte) constrain(Save + MarkAmp*aDir, 0, 255); // Make it Wider
281 | gFreeHeapLog[(gFreeHeapLogIndex++) % sizeof(gFreeHeapLog)] = Save;
282 | }
283 |
284 | // ###########################################################
285 | //////////////////////////////////////////////////////////////
286 | //
287 | // Marks the End of a Web Page in Free Heap Log
288 | //
289 | int
290 | //ICACHE_FLASH_ATTR
291 | logFreeHeapMarkUp()
292 | {
293 | // Put a visible Mark "up" in the Free Heap Log
294 | _logFreeHeapMark(+1);
295 | gMarkFlag = true;
296 | }
297 |
298 | // ###########################################################
299 | //////////////////////////////////////////////////////////////
300 | //
301 | // Marks the Beginning of a Web Page in Free Heap Log
302 | //
303 | int
304 | //ICACHE_FLASH_ATTR
305 | logFreeHeapMarkDn()
306 | {
307 | // Put a visible Mark "dn" in the Free Heap Log
308 | _logFreeHeapMark(-1);
309 | gMarkFlag = false;
310 | }
311 |
312 |
313 | // ###########################################################
314 | //////////////////////////////////////////////////////////////
315 | //
316 | // Provides easy access to Global Load Avg Value
317 | //
318 | String
319 | //ICACHE_FLASH_ATTR
320 | pseudoLoadAvgStr() {
321 | return gLoadAvgS;
322 | }
323 |
324 | // ###########################################################
325 | //////////////////////////////////////////////////////////////
326 | //
327 | // Logs a Pseudo Load Average, this is called periodically
328 | // This is NOT real, it is based on just some timing numbers
329 | // A better method of computing Load Average should be found
330 | //
331 | void
332 | //ICACHE_FLASH_ATTR
333 | logPseudoLoadAvg() {
334 |
335 | // Computed as: Load Avg = (ExpectedCount / gLoadAvgCount) - 1
336 |
337 | #define ExpectedCount (92000)
338 |
339 | if (gLoadAvgL <= 0) gLoadAvgL = ExpectedCount; // Initialization
340 |
341 |
342 | long curDeltaL = gIdleL - gLoadAvgCountL;
343 |
344 | gLoadAvgL = ( (gLoadAvgL * 7) + (curDeltaL * 3) ) / 10; // Weigthed 7:3 Running Average
345 |
346 | gLoadAvgS = String ( ((1.0 * ExpectedCount / gLoadAvgL) - 1 ), 2 );
347 |
348 | // // For Debug
349 | // Serial.println ( \
350 | // sF("curDeltaL: ") + curDeltaL \
351 | // + F(", gLoadAvgL: ") + gLoadAvgL \
352 | // + F(", gLoadAvgS: ") + gLoadAvgS );
353 |
354 | gLoadAvgCountL = gIdleL;
355 |
356 | return;
357 | }
358 |
359 | // ###########################################################
360 | // End
361 |
--------------------------------------------------------------------------------
/Main/H_HelpPage.ino:
--------------------------------------------------------------------------------
1 | // HelpPage
2 |
3 | /*
4 | * Copyright (c) 2015, Eldon R. Brown - ERB - WA0UWH - eldonb@ebcon.com
5 | *
6 | * See my Blog, at: http://WA0UWH.blogspot.com
7 | *
8 | * See my Source at GitHub, at: https://github.com/wa0uwh/ERB-EspWebServer
9 | *
10 | * All rights reserved. See FULL Copyright in Main or Info Page for Exclusions
11 | *
12 | * This Effort was Inspired by work by: Majenko Technologies - 2015 Esp8266 AdvancedWebServer
13 | *
14 | * See also Arduino IDE, at: https://github.com/esp8266/Arduino
15 | */
16 |
17 |
18 | // ###########################################################
19 | //////////////////////////////////////////////////////////////
20 | //
21 | // This Function provides the Content for the URL Requsest from WIFI
22 | //
23 | long
24 | ICACHE_FLASH_ATTR
25 | helpPage()
26 | {
27 | long sz = 0; // Sent Size
28 |
29 | DEBUG_MONITOR_REPORT_START();
30 |
31 | DEBUG_MONITOR_REPORT_ARGS();
32 |
33 | // Parse Args
34 | for ( byte i = 0; i < gServer.args(); i++ ) {
35 | if (gServer.argName(i) == F("AutoHelpRefresh") ) gAutoHelpRefresh = constrain (gServer.arg(i).toInt(), 10, 600);
36 | }
37 |
38 | // Generate Html Header
39 | sz += htmlPageHeader( gDeviceName, gAutoHelpRefresh, F("/help") );
40 |
41 | // Page Content Starts here
42 |
43 | // Page Title Line
44 | sz += htmlPageTitle( gDeviceName, F("Help") );
45 |
46 | // // Page Refresh Button
47 | // {
48 | // String TmpBuf = "";
49 | // sz += wprintln( F("") );
50 | // sz += wprintln( reFreshButton(TmpBuf, String("/help"));
51 | // sz += wprintln( F(" ") );
52 | // }
53 |
54 | // Navigator
55 | sz += navigator();
56 |
57 | // Verbose Option
58 | sz += wprintln( );
59 | sz += wprintln( F("") );
60 | if (gAutoHelpRefresh > 0)
61 | sz += wprint( F(" | ManUpdate ") );
62 | else sz += wprint( F(" | AutoUpdate ") );
63 | sz += wprintln( F(" |") );
64 | sz += wprintln( F(" ") );
65 |
66 | // SliderBar Graphic
67 | if (gAutoHelpRefresh > 0 ) {
68 | sz += wprintln( );
69 | sz += wprintln( F("") );
70 | sz += sliderBar( F("AutoHelpRefresh"), F("Interval:"), 10, 600, 10, gAutoHelpRefresh, F("Sec"), F("/help") );
71 | sz += wprintln( F(" ") );
72 | }
73 | sz += wprintln( F(" ") );
74 |
75 | // Page Report
76 | sz += wprintln( );
77 | sz += wprintln( F("") );;
78 | sz += wprintln( F("") );
79 |
80 | // Page Links
81 | sz += wprintln( );
82 | sz += wprintln( F(" Pages: ") );
83 | sz += wprintln( F(" URL/home = Home Dashboard (with refresh)") );
84 | sz += wprintln( F(" URL/help = This Message") );
85 | sz += wprintln( F(" URL/admin = Admin Page") );
86 | sz += wprintln( F(" URL/info = General Information Page") );
87 |
88 | sz += wprintln( F(" URL/test.svg = Just The Test Graphic") );
89 | sz += wprintln( F(" URL/clock.svg = Just The Test Clock Graphic") );
90 | sz += wprintln( F(" URL/inst.svg = Just The Test Inst Graphic") );
91 | sz += wprintln( F(" URL/bar.svg = Just The Test Bar Graphic, Note: This is not Actually an SVG") );
92 | sz += wprintln( F(" URL/sliderbar = Just The Test SliderBar Graphic") );
93 | sz += wprintln( F(" URL/visitormap = Just The Test VisitorMap Graphic") );
94 | sz += wprintln( F(" URL/farm01.jpg = Just The Test Esp Web Server Farm Image") );
95 | sz += wprintln( F(" ") );
96 |
97 | // Modes
98 | sz += wprintln( );
99 | sz += wprintln( F("Modes: ") );
100 | sz += wprintln( F(" URL/t/v = Toggle Verbose Mode") );
101 | sz += wprintln( sF(" URL/s/v = Verbose Mode ") + String( gVerbose ? "(current)" : "") + F(" ") );
102 | sz += wprintln( sF(" URL/c/v = Silent Mode ") + String(!gVerbose ? "(current)" : "") + F(" ") );
103 | sz += wprintln( sF(" URL/t/redled = Toggle Red Led, is ") + String(gRedLedState == ON ? "ON" : "OFF") + F(" ") );
104 | sz += wprintln( F(" URL/on/redled = Turn Red Led ON") );
105 | sz += wprintln( F(" URL/off/redled = Turn Red Led OFF") );
106 | sz += wprintln( F(" ") );
107 |
108 | // Querys
109 | sz += wprintln( );
110 | String TmpNodeName = String(gDeviceName) + F(".local");
111 | String TmpUrlNod = sF("" + TmpNodeName + " ";
112 | String TmpUrlIPA = sF("" + ipa2str(WiFi.localIP()) + " ";
113 |
114 | sz += wprintln( F("Query: ") );
115 | sz += wprintln( sF(" URL/q/ssid = SSID: ") + String(WiFi.SSID()) + F(" ") );
116 | sz += wprintln( sF(" URL/q/rssi = RSSI: ") + String(WiFi.RSSI()) + F("dBm ") );
117 | sz += wprintln( sF(" URL/q/mdns = mDNS Name: ") + String(TmpUrlNod) + F(" ") );
118 | sz += wprintln( sF(" URL/q/stnipa = STN IPA: ") + String(TmpUrlIPA) + F(" ") );
119 | sz += wprintln( sF(" URL/q/stnmac = STN Mac: ") + String(mac2str(WiFi.macAddress(gMacBuf))) + F(" ") );
120 | sz += wprintln( sF(" URL/q/gateway = Gateway: ") + String(ipa2str(WiFi.gatewayIP())) + F(" ") );
121 | sz += wprintln( sF(" URL/q/netmask = Netmask: ") + String(ipa2str(WiFi.subnetMask())) + F(" ") );
122 | sz += wprintln( sF(" URL/q/myipa = My IPA: ") + String(ipa2str(gServer.client().remoteIP())) + F(" ") );
123 | // sz += wprintln( sF(" URL/q/myport = My Port: ") + String(gServer.client().remotePort()) + F(" ") );
124 |
125 | sz += wprintln( );
126 | sz += wprintln( sF(" URL/q/restarts = WiFi ReStarts: ") + String(gWifiReStarts) + F(" ") );
127 | sz += wprintln( sF(" URL/q/redled = Red Led State: ") + String(gRedLedState == ON ? "ON" : "OFF") + F(" ") );
128 | sz += wprintln( sF(" URL/q/uptime = Uptime Seconds: ") + String(upTime()) + F("s ") );
129 | // sz += wprintln( sF(" URL/q/utctime = Utctime Seconds: ") + String(utcTime()) + F(" ") );
130 | sz += wprintln( sF(" URL/q/epoch = Epoch (Unix Time): ") + String(epoch()) + F(" ") );
131 | sz += wprintln( sF(" URL/q/loadavg = Load Avg (Pseudo): ") + String(gLoadAvgS) + F(" ") );
132 | sz += wprintln( sF(" URL/q/battvolt = Battery Voltage: ") + String(readvdd33()/1000.0, 2) + F("V ") );
133 | sz += wprintln( sF(" URL/q/freeheap = Free Heap Size: ") + String(ESP.getFreeHeap() / 1000.0, 3) + F("KB ") );
134 | sz += wprintln( sF(" URL/q/hits = Hit Counter: ") + String(gHits) + F(" ") );
135 |
136 | sz += wprintln( sF(" URL/q/id = Unit ID: ") + String(ESP.getChipId() / 10000.0, 4) + F(" ") );
137 | sz += wprintln( sF(" URL/q/idx = Unit ID Hex: ") + String(id2hex(ESP.getChipId())) + F(" ") );
138 | sz += wprintln( sF(" URL/q/flashid = Flash ID: ") + String(ESP.getFlashChipId() / 10000.0, 4) + F(" ") );
139 | sz += wprintln( sF(" URL/q/flashsize = Flash Size: ") + String(ESP.getFlashChipSize() / 1000.0, 1) + F("KB ") );
140 | sz += wprintln( sF(" URL/q/flashspd = Flash Speed: ") + String(ESP.getFlashChipSpeed() / 1000000.0, 1) + F("MHz ") );
141 |
142 | sz += wprintln( sF(" URL/q/rev = Software Revision: ") + String(gRev) + F(" ") );
143 | sz += wprintln( F(" ") );
144 |
145 | // AP Mode Querys
146 | sz += wprintln( );
147 | sz += wprintln( F("AP Mode Query: ") );
148 | sz += wprintln( sF(" URL/q/apssid = AP SSID: ") + String(gDeviceName) + F(" ") );
149 | sz += wprintln( sF(" URL/q/apipa = AP IPA: ") + String(ipa2str(WiFi.softAPIP())) + F(" ") );
150 | sz += wprintln( sF(" URL/q/apmac = AP Mac: ") + String(mac2str(WiFi.softAPmacAddress(gMacBuf))) + F(" ") );
151 | sz += wprintln( sF(" URL/q/apchannel = AP Only Channel: ") + String(gApChannel) + F(" ") );
152 | sz += wprintln( F(" ") );
153 |
154 | // Information
155 | sz += wprintln( );
156 | sz += wprintln( F("Information: ") );
157 | sz += wprintln( F(" URL/help = This Message") );
158 | sz += wprintln( F(" URL/info = General Information and Copyright Message") );
159 | sz += wprintln( F(" ") );
160 |
161 | // Admin
162 | sz += wprintln( );
163 | sz += wprintln( F("Admin: ") );
164 | sz += wprintln( F(" URL/admin = Admin Page") );
165 | sz += wprintln( F(" URL/scanwifi = Admin WIFI Scan") );
166 | sz += wprintln( F(" ") );
167 |
168 | // Error Handler
169 | sz += wprintln( );
170 | sz += wprintln( F("Errors: ") );
171 | sz += wprintln( F(" URL/else = All else = Error Message") );
172 | sz += wprintln( F(" ") );
173 |
174 | sz += wprintln( F("") );
175 |
176 | // Generate Html Footer
177 | sz += htmlPageFooter();
178 |
179 | DEBUG_MONITOR_REPORT_END();
180 |
181 | return sz;
182 |
183 | }
184 |
185 |
186 | // ###########################################################
187 | //////////////////////////////////////////////////////////////
188 | //
189 | // This Function Handles the URL Requsest from WIFI
190 | // and reports activity on Serial
191 | //
192 | void
193 | ICACHE_FLASH_ATTR
194 | handleHelpPage()
195 | {
196 | int sz = 0;
197 | gSentSize = 0;
198 |
199 | gCurrentPage = HELPPAGE;
200 |
201 | digitalWrite ( gGrnLED, ON );
202 | gHits++;
203 |
204 | // HTTP Header
205 | sz += wprintln( F("HTTP/1.1 200 OK") );
206 | sz += wprintln( F("Content-Type: text/html") );
207 | sz += wprintln( ); // A Blank Line
208 |
209 | sz += helpPage();
210 |
211 | sz += wprint( "", SEND_FINISH ); // Final Packet
212 |
213 | DEBUG_MONITOR_REPORT_TOTAL();
214 |
215 | digitalWrite ( gGrnLED, OFF );
216 | yield();
217 | }
218 |
219 | // ###########################################################
220 | // End
221 |
--------------------------------------------------------------------------------
/Main/B_SVG_Clock.ino:
--------------------------------------------------------------------------------
1 | // B_SVG_Clock
2 |
3 | /*
4 | * Copyright (c) 2015, Eldon R. Brown - ERB - WA0UWH - eldonb@ebcon.com
5 | *
6 | * See my Blog, at: http://WA0UWH.blogspot.com
7 | *
8 | * See my Source at GitHub, at: https://github.com/wa0uwh/ERB-EspWebServer
9 | *
10 | * All rights reserved. See FULL Copyright in Main or Info Page for Exclusions
11 | *
12 | * This Effort was Inspired by work by: Majenko Technologies - 2015 Esp8266 AdvancedWebServer
13 | *
14 | * See also Arduino IDE, at: https://github.com/esp8266/Arduino
15 | */
16 |
17 |
18 | // ###########################################################
19 | //////////////////////////////////////////////////////////////
20 | //
21 | // This Function provides the Content for the URL Requsest from WIFI
22 | //
23 | long
24 | ICACHE_FLASH_ATTR
25 | clockGauge(int w = 200, int h = 200)
26 | {
27 | long sz = 0; // Sent Size
28 |
29 | DEBUG_MONITOR_REPORT_START();
30 |
31 | DEBUG_MONITOR_REPORT_ARGS();
32 |
33 | sz += wprintln( );
34 | sz += wprintln( F("") );
35 |
36 | // SVG Header
37 | sz += wprintln( F("") );
43 |
44 | // Red LED Color Gradient
45 | sz += wprintln( );
46 | sz += wprintln( F("") );
47 | sz += wprintln( F(" ") );
48 | sz += wprintln( F(" ") );
49 | sz += wprintln( F(" ") );
50 | sz += wprintln( F(" ") );
51 | sz += wprintln( F(" ") );
52 |
53 | // Green LED Color Gradient
54 | sz += wprintln( );
55 | sz += wprintln( F("") );
56 | sz += wprintln( F(" ") );
57 | sz += wprintln( F(" ") );
58 | sz += wprintln( F(" ") );
59 | sz += wprintln( F(" ") );
60 | sz += wprintln( F(" ") );
61 |
62 | // Rim Color Gradient
63 | sz += wprintln( );
64 | sz += wprintln( F("") );
65 | sz += wprintln( F(" ") );
66 | sz += wprintln( F(" ") );
67 | sz += wprintln( F(" ") );
68 | sz += wprintln( F(" ") );
69 | sz += wprintln( F(" ") );
70 |
71 | // Face Color Gradient
72 | sz += wprintln( );
73 | sz += wprintln( F("") );
74 | sz += wprintln( F(" ") );
75 | sz += wprintln( F(" ") );
76 | sz += wprintln( F(" ") );
77 | sz += wprintln( F(" ") );
78 | sz += wprintln( F(" ") );
79 |
80 | // Dish Color Gradient
81 | sz += wprintln( );
82 | sz += wprintln( F("") );
83 | sz += wprintln( F(" ") );
84 | sz += wprintln( F(" ") );
85 | sz += wprintln( F(" ") );
86 | sz += wprintln( F(" ") );
87 | sz += wprintln( F(" ") );
88 |
89 | // Bezel
90 | sz += wprintln( );
91 | sz += wprintln( F("") );
92 | sz += wprintln( F(" ") );
96 | sz += wprintln( F(" ") );
97 |
98 | // Red LED
99 | sz += wprintln( );
100 | sz += wprintln( F("") );
101 | sz += wprintln( F(" ") );
105 | sz += wprintln( F(" ") );
106 |
107 | // Green LED
108 | sz += wprintln( );
109 | sz += wprintln( F("") );
110 | sz += wprintln( F(" ") );
114 | sz += wprintln( F(" ") );
115 |
116 | // Dish
117 | sz += wprintln( );
118 | sz += wprintln( F("") );
119 | sz += wprintln( F(" ") );
123 | sz += wprintln( F(" ") );
124 |
125 | // Face
126 | sz += wprintln( );
127 | sz += wprintln( F("") );
128 | sz += wprintln( F(" ") );
132 | sz += wprintln( F(" ") );
133 |
134 | // Major Tic
135 | sz += wprintln( );
136 | sz += wprintln( F("") );
137 | sz += wprintln( F(" ") );
142 | sz += wprintln( F(" ") );
143 |
144 | // Minor Tic
145 | sz += wprintln( );
146 | sz += wprintln( F("") );
147 | sz += wprintln( F(" ") );
152 | sz += wprintln( F(" ") );
153 |
154 | // Pointer
155 | sz += wprintln( );
156 | sz += wprintln( F("") );
157 | sz += wprintln( F(" ") );
158 | sz += wprintln( F(" ") );
164 | sz += wprintln( F(" ") );
165 | sz += wprintln( F(" ") );
166 |
167 | // Pointer
168 | sz += wprintln( );
169 | sz += wprintln( F("") );
170 | sz += wprintln( F(" ") );
171 | sz += wprintln( F(" ") );
172 |
173 | // Pointer
174 | sz += wprintln( );
175 | sz += wprintln( F("") );
176 | sz += wprintln( F(" ") );
177 | sz += wprintln( F(" ") );
178 |
179 | // Create the Image
180 | sz += wprintln( );
181 | sz += wprintln( F("") );
182 | sz += wprintln( F("") );
183 | {
184 | sz += wprintln( F(" ") );
185 | sz += wprintln( F(" ") );
186 | sz += wprintln( F(" ") );
187 |
188 | // Create the Tic Marks and Labels
189 | sz += wprintln( );
190 | sz += wprintln( F(" ") );
191 | for (int a = 1; a <= 120; a += 1) {
192 | {
193 | if (! (a % 5)) {
194 | sz += wprint( sF(" ") );
195 | // 24 Hours
196 | sz += wprint( sF("") + String(a/5) + F(" ") );
197 |
198 | if (! (a % 10)) {
199 | // Major Tic
200 | sz += wprint( F(" ") );
201 | // Hours
202 | sz += wprint( sF("") + String(a/5/2) + F(" ") );
203 | // Minutes
204 | sz += wprint( sF("") + String(a/2) + F(" ") );
205 | }
206 | sz += wprintln( F(" ") );
207 | }
208 | else if (! (a % 2)) {
209 | sz += wprint( sF(" ") );
210 | // Minor Tic
211 | sz += wprint( F(" ") );
212 | sz += wprintln( F(" ") );
213 | }
214 | }
215 | }
216 |
217 |
218 | // LED and Pointers
219 | sz += wprintln( );
220 | sz += wprintln( F(" ") );
221 | if (gEpochAvailable == false) {
222 | sz += wprintln( F(" ") );
223 | }
224 | else {
225 | sz += wprintln( F(" ") );
226 |
227 | // Create the Pointers
228 | {
229 | long Secs = epoch();
230 | long Mins = Secs / 60;
231 | long Hrs = Mins / 60;
232 | Secs %= 60;
233 | Mins %= 60;
234 | Hrs %= 24;
235 |
236 | sz += wprint ( F(" ") ); // Hour Hand, PDT
238 | sz += wprint ( F(" ") ); // GMT Hour Hand
240 | sz += wprint ( F(" ") ); // Min Hand
242 | }
243 | }
244 |
245 | // Crystal/Glass Labels
246 | sz += wprintln( );
247 | sz += wprintln( F(" ") );
248 | sz += wprintln( F(" WA0UWH ") );
249 | sz += wprintln( F(" PDT / UTC ") );
250 |
251 | // Center of Dial
252 | sz += wprintln( );
253 | sz += wprintln( F(" ") );
254 | sz += wprintln( F(" ") );
255 |
256 |
257 | }
258 | sz += wprintln( F(" ") );
259 |
260 | sz += wprintln( F(" "));
261 |
262 | DEBUG_MONITOR_REPORT_END();
263 |
264 | return sz;
265 | }
266 |
267 | // ###########################################################
268 | //////////////////////////////////////////////////////////////
269 | //
270 | // This Function Handles the URL Requsest from WIFI
271 | // and reports activity on Serial
272 | //
273 | void
274 | ICACHE_FLASH_ATTR
275 | handleClock()
276 | {
277 | long sz = 0; // Sent Size
278 | gSentSize = 0;
279 |
280 | digitalWrite ( gBluLED, ON );
281 | gHits++;
282 |
283 | sz += wprintln( F("HTTP/1.1 200 OK") );
284 | sz += wprintln( F("Content-Type: image/svg+xml") );
285 | sz += wprintln( ); // A Blank Line
286 |
287 | sz += clockGauge( 200, 200 );
288 |
289 | sz += wprint( "", SEND_FINISH); // Final Packet
290 |
291 | DEBUG_MONITOR_REPORT_TOTAL();
292 |
293 | digitalWrite ( gBluLED, OFF );
294 | yield();
295 | }
296 |
297 | // ###########################################################
298 | // End
299 |
--------------------------------------------------------------------------------
/Main/B_SVG_Inst.ino:
--------------------------------------------------------------------------------
1 | // B_SVG_Inst
2 |
3 | /*
4 | * Copyright (c) 2015, Eldon R. Brown - ERB - WA0UWH - eldonb@ebcon.com
5 | *
6 | * See my Blog, at: http://WA0UWH.blogspot.com
7 | *
8 | * See my Source at GitHub, at: https://github.com/wa0uwh/ERB-EspWebServer
9 | *
10 | * All rights reserved. See FULL Copyright in Main or Info Page for Exclusions
11 | *
12 | * This Effort was Inspired by work by: Majenko Technologies - 2015 Esp8266 AdvancedWebServer
13 | *
14 | * See also Arduino IDE, at: https://github.com/esp8266/Arduino
15 | */
16 |
17 |
18 | // ###########################################################
19 | //////////////////////////////////////////////////////////////
20 | //
21 | // This Function provides the Content for the URL Requsest from WIFI
22 | //
23 | long
24 | ICACHE_FLASH_ATTR
25 | instGauge( int w = 200, int h = 200)
26 | {
27 | long sz = 0; // Sent Size
28 |
29 | DEBUG_MONITOR_REPORT_START();
30 |
31 | DEBUG_MONITOR_REPORT_ARGS();
32 |
33 | int startingFreeHeap = ESP.getFreeHeap();
34 |
35 | sz += wprintln( );
36 | sz += wprintln( F("") );
37 |
38 | // SVG Header
39 | sz += wprintln( F("") );
45 |
46 |
47 | // Rim Color Gradient
48 | sz += wprintln();
49 | sz += wprintln( F("") );
50 | sz += wprintln( F("") );
51 | sz += wprintln( F(" ") );
52 | sz += wprintln( F(" ") );
53 | sz += wprintln( F(" ") );
54 | sz += wprintln( F(" ") );
55 | sz += wprintln( F(" ") );
56 |
57 | // Face Color Gradient
58 | sz += wprintln();
59 | sz += wprintln( F("") );
60 | sz += wprintln( F("") );
61 | sz += wprintln( F(" ") );
62 | sz += wprintln( F(" ") );
63 | sz += wprintln( F(" ") );
64 | sz += wprintln( F(" ") );
65 | sz += wprintln( F(" ") );
66 |
67 | // Dish Color Gradient
68 | sz += wprintln();
69 | sz += wprintln( F("") );
70 | sz += wprintln( F("") );
71 | sz += wprintln( F(" ") );
72 | sz += wprintln( F(" ") );
73 | sz += wprintln( F(" ") );
74 | sz += wprintln( F(" ") );
75 | sz += wprintln( F(" ") );
76 |
77 | // Bezel
78 | sz += wprintln();
79 | sz += wprintln( F("") );
80 | sz += wprintln( F("") );
81 | sz += wprintln( F(" ") );
85 | sz += wprintln( F(" ") );
86 |
87 |
88 | // Dish
89 | sz += wprintln();
90 | sz += wprintln( F("") );
91 | sz += wprintln( F("") );
92 | sz += wprintln( F(" ") );
96 | sz += wprintln( F(" ") );
97 |
98 | // Face
99 | sz += wprintln();
100 | sz += wprintln( F("") );
101 | sz += wprintln( F("") );
102 | sz += wprintln( F(" ") );
106 | sz += wprintln( F(" ") );
107 |
108 | // Major Tic
109 | sz += wprintln();
110 | sz += wprintln( F("") );
111 | sz += wprintln( F("") );
112 | sz += wprintln( F(" ") );
117 | sz += wprintln( F(" ") );
118 |
119 | // Minor Tic
120 | sz += wprintln();
121 | sz += wprintln( F("") );
122 | sz += wprintln( F("") );
123 | sz += wprintln( F(" ") );
128 | sz += wprintln( F(" ") );
129 |
130 | // Pointer
131 | sz += wprintln();
132 | sz += wprintln( F("") );
133 | sz += wprintln( F("") );
134 | sz += wprintln( F(" ") );
135 | sz += wprintln( F(" ") );
141 | sz += wprintln( F(" ") );
142 | sz += wprintln( F(" ") );
143 |
144 | // Pointer
145 | sz += wprintln();
146 | sz += wprintln( F("") );
147 | sz += wprintln( F("") );
148 | sz += wprintln( F(" ") );
149 | sz += wprintln( F(" ") );
150 |
151 | // Pointer
152 | sz += wprintln();
153 | sz += wprintln( F("") );
154 | sz += wprintln( F("") );
155 | sz += wprintln( F(" ") );
156 | sz += wprintln( F(" ") );
157 |
158 | // Create the Image
159 | sz += wprintln();
160 | sz += wprintln( F("") );
161 | sz += wprintln( F("") );
162 |
163 | sz += wprintln();
164 | sz += wprintln( F("") );
165 | {
166 | sz += wprintln( F(" ") );
167 | sz += wprintln( F(" ") );
168 | sz += wprintln( F(" ") );
169 |
170 | sz += wprintln();
171 | sz += wprintln( F("") );
172 |
173 | sz += wprintln( F("") );
174 | {
175 | sz += wprintln();
176 | sz += wprintln( F("") );
177 | const int LO_VAL = VddScaleLo - 60;
178 | const int HI_VAL = VddScaleHi + 60;
179 | const int LO_ANGLE = (0 + 15) * 10; // Times 10 Multiplier used to increase Image resolution
180 | const int HI_ANGLE = (180 - 30) * 10;
181 |
182 | // Create the Tic Marks and Labels
183 | for (int val = LO_VAL; val <= HI_VAL; val += 20) {
184 | int angle = map(val, LO_VAL, HI_VAL, HI_ANGLE, LO_ANGLE);
185 | if (! (val % 100)) { // Major Tic with Label
186 | sz += wprintln( sF("") );
187 | sz += wprintln( F(" ") );
188 | if ((val/100) % 2) { // Is Odd
189 | sz += wprintln( sF(" ") + String(val/1000.0, 1) + F(" ") );
190 | }
191 | sz += wprintln( F(" ") );
192 | }
193 | else if (! (val % 2)) { // Is Even, Minor Tic
194 | sz += wprintln( sF("") );
195 | sz += wprintln( F(" ") );
196 | sz += wprintln( F(" ") );
197 | }
198 | }
199 | // Map the VDD Pointer
200 | int vdd = readvdd33(); // Voltage
201 | sz += wprintln();
202 | sz += wprintln( sF("") ); // Raw Vdd Value
203 | vdd = constrain(vdd, LO_VAL, HI_VAL);
204 | vdd = map(vdd, LO_VAL, HI_VAL, HI_ANGLE, LO_ANGLE);
205 | sz += wprint ( F(" ") ); // Vdd Pointer
207 | }
208 |
209 | sz += wprintln();
210 | sz += wprintln( F("") );
211 | {
212 | const int LO_VAL = FreeHeapScaleLo - 600;
213 | const int HI_VAL = FreeHeapScaleHi + 600;
214 | const int LO_ANGLE = (180 + 30) * 10; // Times 10 Multiplier used to increase Image resolution
215 | const int HI_ANGLE = (360 - 15) * 10;
216 |
217 | // Create the Tic Marks and Labels
218 | for (int val = LO_VAL; val <= HI_VAL; val += 100) {
219 | int angle = map(val, LO_VAL, HI_VAL, LO_ANGLE, HI_ANGLE);
220 | if (! (val % 2000)) { // Major Tic with Label
221 | sz += wprintln( sF("") );
222 | sz += wprintln( F(" ") );
223 | if (! (val % 4000)) {
224 | sz += wprintln( F(" ") );
225 | sz += wprintln( String(val/1000) + F(" ") );
226 | }
227 | sz += wprintln( F(" ") );
228 | }
229 | else if (! (val % 500)) { // Minor Tic
230 | sz += wprintln( sF("") );
231 | sz += wprintln( F(" ") );
232 | sz += wprintln( F(" ") );
233 | }
234 | }
235 | {
236 | // Map the Initial Free Heap Pointer
237 | int fm = startingFreeHeap; // Initial Free Memory
238 | sz += wprintln();
239 | sz += wprintln( sF("") ); // Raw FM Value
240 | fm = constrain(fm, LO_VAL, HI_VAL);
241 | fm = map(fm, LO_VAL, HI_VAL, LO_ANGLE, HI_ANGLE);
242 | sz += wprint ( F(" ") ); // FreeMem Pointer
244 | }
245 |
246 | {
247 | // Map the Current Free Heap Pointer
248 | int fm = ESP.getFreeHeap(); // Free Memory
249 | sz += wprintln();
250 | sz += wprintln( sF("") ); // Raw FM Value
251 | fm = constrain(fm, LO_VAL, HI_VAL);
252 | fm = map(fm, LO_VAL, HI_VAL, LO_ANGLE, HI_ANGLE);
253 | sz += wprint ( F(" ") ); // FreeMem Pointer
255 | }
256 | }
257 |
258 | sz += wprintln( F(" ") );
259 |
260 | // Crystal/Glass Labels
261 | sz += wprintln();
262 | sz += wprintln( F("") );
263 | sz += wprintln( F(" Free ") );
264 | sz += wprintln( F(" Mem ") );
265 | sz += wprintln( F(" (K) ") );
266 | sz += wprintln( F(" VDD ") );
267 | sz += wprintln( F(" (Volts) ") );
268 | sz += wprintln( F(" WA0UWH ") );
269 |
270 | // Center of Inst
271 | sz += wprintln( F(" ") );
272 |
273 | }
274 | sz += wprintln();
275 | sz += wprintln( F(" ") );
276 |
277 | sz += wprintln( F(" ") );
278 |
279 | DEBUG_MONITOR_REPORT_END();
280 |
281 | return sz;
282 | }
283 |
284 | // ###########################################################
285 | //////////////////////////////////////////////////////////////
286 | //
287 | // This Function Handles the URL Requsest from WIFI
288 | // and reports activity on Serial
289 | //
290 | void
291 | ICACHE_FLASH_ATTR
292 | handleInst()
293 | {
294 | long sz = 0; // Sent Size
295 | gSentSize = 0;
296 |
297 | digitalWrite ( gBluLED, ON );
298 | gHits++;
299 |
300 | sz += wprintln( F("HTTP/1.1 200 OK") );
301 | sz += wprintln( F("Content-Type: image/svg+xml") );
302 | sz += wprintln( ); // A Blank Line
303 |
304 | sz += instGauge(200, 200); // Create SVG Image
305 |
306 | sz += wprintln( "", SEND_FINISH ); // Final Packet
307 |
308 | DEBUG_MONITOR_REPORT_TOTAL();
309 |
310 | digitalWrite ( gBluLED, OFF );
311 | yield();
312 | }
313 |
314 | // ###########################################################
315 | // End
316 |
--------------------------------------------------------------------------------
/Main/A1_Main.h:
--------------------------------------------------------------------------------
1 | // A2_Main.h
2 |
3 | /*
4 | * Copyright (c) 2015, Eldon R. Brown - ERB - WA0UWH - eldonb@ebcon.com
5 | *
6 | * See my Blog, at: http://WA0UWH.blogspot.com
7 | *
8 | * See my Source at GitHub, at: https://github.com/wa0uwh/ERB-EspWebServer
9 | *
10 | * All rights reserved. See FULL Copyright in Main or Info Page for Exclusions
11 | *
12 | * This Effort was Inspired by work by: Majenko Technologies - 2015 Esp8266 AdvancedWebServer
13 | *
14 | * See also Arduino IDE, at: https://github.com/esp8266/Arduino
15 | */
16 |
17 |
18 | #ifndef MAIN_H
19 | #define MAIN_H
20 |
21 | #include
22 |
23 |
24 | const char COPYRIGHT1[] PROGMEM = R"(
25 | /*
26 | * Copyright (c) 2015, Eldon R. Brown - ERB - WA0UWH - eldonb@ebcon.com
27 | *
28 | * See my Blog, at: http://WA0UWH.blogspot.com
29 | *
30 | * See my Source at GitHub, at: https://github.com/wa0uwh/ERB-EspWebServer
31 | *
32 | * All rights reserved. See FULL Copyright in Main.ino, or Info Web Page for Exclusions
33 | *
34 | * This Effort was Inspired by work by: Majenko Technologies - 2015 Esp8266 AdvancedWebServer
35 | *
36 | * See also Arduino IDE, at: https://github.com/esp8266/Arduino
37 | *
38 | * Contritutors:
39 | *
40 | *
41 | */
42 | )";
43 |
44 |
45 | const char INTRODUCTION[] PROGMEM = R"(
46 | /*
47 | * This Program Provides the following for the Esp8266 as a WebServer:
48 | * But CAUTION, some functionallity may not have been throughly tested.
49 | *
50 | * The code and effort is always changing, check with the GitHub Repositor often,
51 | * See GitHub at: https://github.com/wa0uwh/ERB-EspWebServer
52 | * See Change Map at: https://github.com/wa0uwh/ERB-EspWebServer/network
53 | *
54 | * The purpose of the program is to provide an Experimental Enviroment in which
55 | * to create new functions that can be used in my other planned projects.
56 | *
57 | * Currently, all Arduino IDE TABS are '.ino' type files, which are compiled as a
58 | * single blob. The structure of this progame could be better, as normally, the TABS
59 | * should be set up as '*.h', '*.c', or '*.cpp' files, but this is easier and quicker
60 | * for my experimental efforts. Future revisions may be properly constructed.
61 | *
62 | * Current Features:
63 | *
64 | * All Web Pages are Dynamically Generated by The Esp8266 Processor
65 | * Implemented Full (1460 bytes) WIFI Buffered Transfers
66 | * All String Constants are saved in Flash, freeing RAM/Heap, via F(),
67 | * sF(), and FMT() macros.
68 | * Uses ICACHE_FLASH_ATTR to dynamically load seldom used program functions
69 | * Copyright and this Text (Introduction) is Compiled into the Executable as
70 | * a Web Page
71 | * Home Page Dashboard
72 | * Help Page
73 | * Admin Page, with WiFi Scan and Network Selection
74 | * Info Page
75 | * Page Navigator and Resource Links
76 | * Raw Data Query
77 | * NTP Network Time (Unix Epoch)
78 | * mDNS Service/Client
79 | * Optional Page AutoRefresh
80 | * Auto AP Timeout
81 | * Implements and uses Html 'meter' function for FreeHeap and Vdd
82 | * Implemented SVG 12/24 Hour Clock
83 | * Implemented SVG Gauge for FreeHeap
84 | * Implemented SVG Gauge for Vdd
85 | * Implemented SVG Line Graph for FreeHeap Historical Data, with Start and
86 | * End of Page Markersand reduced Data Transfer by removing Duplicate
87 | * Y Data Points
88 | * Implemented Data Creation Rate Per Web Page Function
89 | * Implemented a Used CPU Seconds Value for Display
90 | * Implemented a link to a Visitor Map Display
91 | * Implemented Slider Bars, Currently used for Page Refresh Interval
92 | * Implemented Code to Serve Raw BINARY Data, for example: the Farm Server Image on Info Page
93 | * Moved Bulk Assignments to use 'PROGMEM = R(...)' Syntax,
94 | * See: http://en.cppreference.com/w/cpp/language/string_literal
95 | */
96 | )";
97 |
98 |
99 | extern "C" {
100 | #include "user_interface.h"
101 | uint16 readvdd33(void);
102 | }
103 |
104 | // Page Type being Sent
105 | enum {
106 | HOMEPAGE = 0,
107 | HELPPAGE,
108 | ADMINPAGE,
109 | INFOPAGE,
110 | };
111 |
112 |
113 | enum { // Send Buffer Mode
114 | SEND_WITH_BUFFERING = 0,
115 | SEND_BUFFER_NOW,
116 | SEND_FINISH,
117 | };
118 |
119 | // Define Multipliers for Ms Counters
120 | #define MSECs (1)
121 | #define SECs (MSECs * 1000)
122 | #define MINs (SECs * 60)
123 | #define HRs (MINs * 60)
124 | #define DAYs (HRs * 24)
125 | #define WKs (DAYs * 7)
126 |
127 |
128 | // ERB - Force format stings and string constants into FLASH Memory
129 | #define sF(x) (String) F(x) // Used as an F() is being used as the first Element of a Multi-Element Expression
130 | #define FMT(x) strcpy_P(gFmtBuf, PSTR(x)) // Used with printf() for the format string
131 | // USE WITH CAUTION !
132 |
133 | #define VddScaleLo (2900)
134 | #define VddScaleHi (3700)
135 |
136 | #define FreeHeapScaleLo (4000)
137 | #define FreeHeapScaleHi (20000)
138 |
139 |
140 |
141 | #define DEBUG_MONITOR_REPORT_START() Serial.println ( sF("\nStart ") + String( __func__ )\
142 | + F(" Build for: ")\
143 | + String(ipa2str(gServer.client().remoteIP())) +F(" . . ") )
144 |
145 | #define DEBUG_MONITOR_REPORT_END() Serial.println ( sF(" . . Finshed ") + String( __func__ )\
146 | + F(" Build") )
147 |
148 | #define DEBUG_MONITOR_REPORT_TOTAL() Serial.println( sF("Sent: ") + String(__func__)\
149 | + F(", URI: ") + gServer.uri()\
150 | + F(", FreeHeap: ") + String( ESP.getFreeHeap() / 1000.0, 3 )\
151 | + F(", PageSize: ") + String( sz / 1000.0, 3 )\
152 | + F(", Hits: ") + String(gHits) + F("\r\n") )
153 |
154 | #define DEBUG_MONITOR_REPORT_ANONYMOUS_FUNCTION() Serial.println( sF("Sent: Data for Query")\
155 | + F(", URI: ") + gServer.uri()\
156 | + F(" for: ")\
157 | + String(ipa2str(gServer.client().remoteIP()) )\
158 | + F(", Hits: ") + String(gHits) + F("\r\n") )
159 |
160 | // Shorthand for the above
161 | #define DMRAF() DEBUG_MONITOR_REPORT_ANONYMOUS_FUNCTION()
162 |
163 | #define DEBUG_MONITOR_REPORT_ARGS() if ( gServer.args() ) {\
164 | Serial.println(" Args:");\
165 | for ( byte i = 0; i < gServer.args(); i++ )\
166 | Serial.println( " " + gServer.argName(i) + "=" + gServer.arg(i) );\
167 | }
168 |
169 |
170 |
171 |
172 |
173 | const char COPYRIGHT2[] PROGMEM = R"(
174 | /*
175 | * Redistribution and use in source and binary forms, with or without modification,
176 | * are permitted provided that the following conditions are met:
177 | *
178 | * * Redistributions of source code must retain the above copyright notice, this
179 | * list of conditions and the following disclaimer.
180 | *
181 | * * Redistributions in binary form must reproduce the above copyright notice, this
182 | * list of conditions and the following disclaimer in the documentation and/or
183 | * other materials provided with the distribution.
184 | *
185 | * * Neither the name of Majenko Technologies nor the names of its
186 | * contributors may be used to endorse or promote products derived from
187 | * this software without specific prior written permission.
188 | */
189 | )";
190 |
191 |
192 | const char COPYRIGHT3[] PROGMEM = R"(
193 | /*
194 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 'AS IS' AND ANY
195 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
196 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
197 | * SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,INCIDENTAL,
198 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
199 | * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
200 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
201 | * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
202 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
203 | */
204 | )";
205 |
206 | // This is a 10Kb character Test Pattern, Note: this is "optomized out" if not used, see Info Code Page
207 | const char TEST_10Kb[] PROGMEM = R"(
208 | /*
209 | * THIS IS A 1KB TEST BLOCK ---- 123456789 123456789 123456789 123456789 123456789 123456789 123456789
210 | * 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789
211 | * 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789
212 | * 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789
213 | * 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789
214 | * 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789
215 | * 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789
216 | * 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789
217 | * 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789
218 | * 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789
219 | *
220 | * THIS IS A 1KB TEST BLOCK ---- 123456789 123456789 123456789 123456789 123456789 123456789 123456789
221 | * 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789
222 | * 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789
223 | * 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789
224 | * 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789
225 | * 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789
226 | * 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789
227 | * 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789
228 | * 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789
229 | * 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789
230 | *
231 | * THIS IS A 1KB TEST BLOCK ---- 123456789 123456789 123456789 123456789 123456789 123456789 123456789
232 | * 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789
233 | * 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789
234 | * 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789
235 | * 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789
236 | * 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789
237 | * 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789
238 | * 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789
239 | * 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789
240 | * 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789
241 | *
242 | * THIS IS A 1KB TEST BLOCK ---- 123456789 123456789 123456789 123456789 123456789 123456789 123456789
243 | * 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789
244 | * 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789
245 | * 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789
246 | * 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789
247 | * 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789
248 | * 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789
249 | * 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789
250 | * 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789
251 | * 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789
252 | *
253 | * THIS IS A 1KB TEST BLOCK ---- 123456789 123456789 123456789 123456789 123456789 123456789 123456789
254 | * 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789
255 | * 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789
256 | * 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789
257 | * 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789
258 | * 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789
259 | * 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789
260 | * 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789
261 | * 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789
262 | * 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789
263 | *
264 | * THIS IS A 1KB TEST BLOCK ---- 123456789 123456789 123456789 123456789 123456789 123456789 123456789
265 | * 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789
266 | * 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789
267 | * 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789
268 | * 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789
269 | * 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789
270 | * 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789
271 | * 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789
272 | * 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789
273 | * 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789
274 | *
275 | * THIS IS A 1KB TEST BLOCK ---- 123456789 123456789 123456789 123456789 123456789 123456789 123456789
276 | * 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789
277 | * 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789
278 | * 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789
279 | * 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789
280 | * 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789
281 | * 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789
282 | * 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789
283 | * 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789
284 | * 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789
285 | *
286 | * THIS IS A 1KB TEST BLOCK ---- 123456789 123456789 123456789 123456789 123456789 123456789 123456789
287 | * 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789
288 | * 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789
289 | * 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789
290 | * 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789
291 | * 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789
292 | * 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789
293 | * 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789
294 | * 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789
295 | * 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789
296 | *
297 | * THIS IS A 1KB TEST BLOCK ---- 123456789 123456789 123456789 123456789 123456789 123456789 123456789
298 | * 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789
299 | * 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789
300 | * 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789
301 | * 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789
302 | * 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789
303 | * 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789
304 | * 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789
305 | * 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789
306 | * 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789
307 | *
308 | * THIS IS A 1KB TEST BLOCK ---- 123456789 123456789 123456789 123456789 123456789 123456789 123456789
309 | * 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789
310 | * 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789
311 | * 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789
312 | * 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789
313 | * 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789
314 | * 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789
315 | * 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789
316 | * 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789
317 | * 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789
318 | *
319 | */
320 | )";
321 |
322 | #endif
323 |
324 | // ###########################################################
325 | // End
326 |
--------------------------------------------------------------------------------