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