Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: LCD_i2c_GSOE ESP8266WebserverGSOE
main.cpp
00001 /* ATCmdParser usage example 00002 * Copyright (c) 2016 ARM Limited 00003 * 00004 * Licensed under the Apache License, Version 2.0 (the "License"); 00005 * you may not use this file except in compliance with the License. 00006 * You may obtain a copy of the License at 00007 * 00008 * http://www.apache.org/licenses/LICENSE-2.0 00009 * 00010 * Unless required by applicable law or agreed to in writing, software 00011 * distributed under the License is distributed on an "AS IS" BASIS, 00012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 00013 * See the License for the specific language governing permissions and 00014 * limitations under the License. 00015 */ 00016 00017 #include "mbed.h" 00018 #include "ESP8266Webserver.h" 00019 #include "LCD.h" 00020 00021 lcd myLCD; 00022 ESP8266Webserver myWebserver; 00023 AnalogIn poti(PA_0); 00024 DigitalOut myled(PC_0); 00025 string getRootPage() 00026 { 00027 string webpage; 00028 webpage="<!DOCTYPE html>"; 00029 //HTML 00030 webpage+="<html>"; 00031 webpage+="<head>"; 00032 webpage+="<title>STM32 HTTP</title>"; 00033 webpage+="</head>"; 00034 webpage+="<body>"; 00035 webpage+="<h1>WIFI mit STM32 ESP01</h1>\n"; 00036 webpage+="<p>Poti:"+to_string(poti)+"</p>\n"; 00037 webpage+="<a href=\"ledAn\"><button>ON</button></a>\n"; 00038 webpage+="<a href=\"ledAus\"><button>OFF</button></a>\n"; 00039 webpage+="</body>"; 00040 webpage+="</html>"; 00041 return webpage; 00042 } 00043 00044 00045 void testfunc() 00046 { 00047 myWebserver.send(200,"text/html",getRootPage()); 00048 } 00049 00050 void testfunc2() 00051 { 00052 myled=0; 00053 myWebserver.send(200,"text/html",getRootPage()); 00054 } 00055 00056 void testfunc3() 00057 { 00058 myled=1; 00059 myWebserver.send(200,"text/html",getRootPage()); 00060 } 00061 00062 int main() { 00063 myWebserver.on("ledAus",&testfunc2); 00064 myWebserver.on("ledAn",&testfunc3); 00065 myWebserver.on("/",&testfunc); 00066 myWebserver.begin(); 00067 myLCD.clear(); 00068 myLCD.cursorpos(0); 00069 myLCD.printf("%s",myWebserver.gibIP()); 00070 while(1) { 00071 myWebserver.handleClient(); 00072 } 00073 }
Generated on Wed Dec 7 2022 01:15:27 by
1.7.2