ESP01 Webserver STM32 Steuerung

Dependencies:   LCD_i2c_GSOE ESP8266WebserverGSOE

Committer:
jack1930
Date:
Mon Jul 26 08:48:24 2021 +0000
Revision:
7:40e19bb6820a
Parent:
6:5353c5484d58
Child:
10:54b312c82e18
mit /html

Who changed what in which revision?

UserRevisionLine numberNew contents of line
jack1930 0:829bac853c96 1 /* ATCmdParser usage example
jack1930 0:829bac853c96 2 * Copyright (c) 2016 ARM Limited
jack1930 0:829bac853c96 3 *
jack1930 0:829bac853c96 4 * Licensed under the Apache License, Version 2.0 (the "License");
jack1930 0:829bac853c96 5 * you may not use this file except in compliance with the License.
jack1930 0:829bac853c96 6 * You may obtain a copy of the License at
jack1930 0:829bac853c96 7 *
jack1930 0:829bac853c96 8 * http://www.apache.org/licenses/LICENSE-2.0
jack1930 0:829bac853c96 9 *
jack1930 0:829bac853c96 10 * Unless required by applicable law or agreed to in writing, software
jack1930 0:829bac853c96 11 * distributed under the License is distributed on an "AS IS" BASIS,
jack1930 0:829bac853c96 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
jack1930 0:829bac853c96 13 * See the License for the specific language governing permissions and
jack1930 0:829bac853c96 14 * limitations under the License.
jack1930 0:829bac853c96 15 */
jack1930 0:829bac853c96 16
jack1930 0:829bac853c96 17 #include "mbed.h"
jack1930 0:829bac853c96 18 #include "ESP8266Webserver.h"
jack1930 0:829bac853c96 19 #include "LCD.h"
jack1930 0:829bac853c96 20
jack1930 0:829bac853c96 21 lcd myLCD;
jack1930 1:1f13f5f1fdbc 22 ESP8266Webserver myWebserver;
jack1930 7:40e19bb6820a 23 AnalogIn poti(PA_0);
jack1930 5:b4ae03006c7d 24 string getRootPage()
jack1930 0:829bac853c96 25 {
jack1930 6:5353c5484d58 26 string webpage;
jack1930 7:40e19bb6820a 27 webpage="<!DOCTYPE html>";
jack1930 3:8dba70d37b7d 28 //HTML
jack1930 7:40e19bb6820a 29 webpage+="<html>";
jack1930 7:40e19bb6820a 30 webpage+="<head>";
jack1930 7:40e19bb6820a 31 webpage+="<title>STM32 HTTP</title>";
jack1930 7:40e19bb6820a 32 webpage+="</head>";
jack1930 7:40e19bb6820a 33 webpage+="<body>";
jack1930 0:829bac853c96 34 webpage+="<h1>WIFI mit STM32 ESP01</h1>\n";
jack1930 7:40e19bb6820a 35 webpage+="<p>Poti:"+to_string(poti)+"</p>\n";
jack1930 7:40e19bb6820a 36 webpage+="</body>";
jack1930 7:40e19bb6820a 37 webpage+="</html>";
jack1930 0:829bac853c96 38 return webpage;
jack1930 0:829bac853c96 39 }
jack1930 0:829bac853c96 40
jack1930 0:829bac853c96 41
jack1930 0:829bac853c96 42 void testfunc()
jack1930 0:829bac853c96 43 {
jack1930 5:b4ae03006c7d 44 myWebserver.send(200,"text/html",getRootPage());
jack1930 0:829bac853c96 45 }
jack1930 0:829bac853c96 46
jack1930 0:829bac853c96 47
jack1930 7:40e19bb6820a 48 int main() {
jack1930 0:829bac853c96 49 myWebserver.on("/",&testfunc);
jack1930 7:40e19bb6820a 50 myWebserver.begin();
jack1930 2:c25aefe81534 51 myLCD.clear();
jack1930 2:c25aefe81534 52 myLCD.cursorpos(0);
jack1930 2:c25aefe81534 53 myLCD.printf("%s",myWebserver.gibIP());
jack1930 7:40e19bb6820a 54 while(1) {
jack1930 0:829bac853c96 55 myWebserver.handleClient();
jack1930 0:829bac853c96 56 }
jack1930 0:829bac853c96 57 }