ESP01 Webserver STM32 Steuerung
Dependencies: LCD_i2c_GSOE ESP8266WebserverGSOE
main.cpp@8:7c2ab1322fb2, 2021-07-26 (annotated)
- Committer:
- jack1930
- Date:
- Mon Jul 26 08:02:04 2021 +0000
- Revision:
- 8:7c2ab1322fb2
- Parent:
- 6:5353c5484d58
- Child:
- 9:f27879c4d306
statisch
Who changed what in which revision?
User | Revision | Line number | New 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 | 0:829bac853c96 | 23 | |
jack1930 | 5:b4ae03006c7d | 24 | string getRootPage() |
jack1930 | 0:829bac853c96 | 25 | { |
jack1930 | 6:5353c5484d58 | 26 | string webpage; |
jack1930 | 8:7c2ab1322fb2 | 27 | webpage="<!DOCTYPE html>"; |
jack1930 | 3:8dba70d37b7d | 28 | //HTML |
jack1930 | 8:7c2ab1322fb2 | 29 | webpage+="<html>"; |
jack1930 | 8:7c2ab1322fb2 | 30 | webpage+="<head>"; |
jack1930 | 8:7c2ab1322fb2 | 31 | webpage+="<title>STM32 HTTP</title>"; |
jack1930 | 8:7c2ab1322fb2 | 32 | webpage+="</head>"; |
jack1930 | 8:7c2ab1322fb2 | 33 | webpage+="<body>"; |
jack1930 | 8:7c2ab1322fb2 | 34 | webpage+="<h1>WIFI mit STM32 ESP01</h1>"; |
jack1930 | 8:7c2ab1322fb2 | 35 | webpage+="</body>"; |
jack1930 | 8:7c2ab1322fb2 | 36 | webpage+="</html>"; |
jack1930 | 0:829bac853c96 | 37 | return webpage; |
jack1930 | 0:829bac853c96 | 38 | } |
jack1930 | 0:829bac853c96 | 39 | |
jack1930 | 0:829bac853c96 | 40 | |
jack1930 | 0:829bac853c96 | 41 | void testfunc() |
jack1930 | 0:829bac853c96 | 42 | { |
jack1930 | 5:b4ae03006c7d | 43 | myWebserver.send(200,"text/html",getRootPage()); |
jack1930 | 0:829bac853c96 | 44 | } |
jack1930 | 0:829bac853c96 | 45 | |
jack1930 | 0:829bac853c96 | 46 | |
jack1930 | 8:7c2ab1322fb2 | 47 | int main() { |
jack1930 | 0:829bac853c96 | 48 | myWebserver.on("/",&testfunc); |
jack1930 | 8:7c2ab1322fb2 | 49 | myWebserver.begin(); |
jack1930 | 2:c25aefe81534 | 50 | myLCD.clear(); |
jack1930 | 2:c25aefe81534 | 51 | myLCD.cursorpos(0); |
jack1930 | 2:c25aefe81534 | 52 | myLCD.printf("%s",myWebserver.gibIP()); |
jack1930 | 8:7c2ab1322fb2 | 53 | while(1) { |
jack1930 | 0:829bac853c96 | 54 | myWebserver.handleClient(); |
jack1930 | 0:829bac853c96 | 55 | } |
jack1930 | 0:829bac853c96 | 56 | } |