Franz Pucher
/
ESP8266_HTTP_MQTT_Server
M0 communication to configurable-Web-Server (MQTT) Version 0.1
- Arduino IDE
- Sensoren
- ESP-Programmierung
- Web-Server
- Netzwerktopologie
- Browser basierende Kommunikation
- M2M Kommunikation
- MQTT over TLS-M3-Projekt (1/2018)
Siehe auch FTKL-Tagung 2016
Diff: main.cpp
- Revision:
- 0:d764cafa5989
- Child:
- 1:b9fd13f34c2d
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Fri Jul 01 18:08:04 2016 +0000 @@ -0,0 +1,62 @@ +#include "mbed.h" +#include <stdio.h> +#include <string.h> +#include <stdint.h> +#include "SerialEvent.h" +#include "LM75B.h" + +#define STR_MAX 40 + +DigitalOut Led1(LED1); +DigitalOut Led2(LED2); +DigitalOut Led3(LED3); +DigitalOut Led4(LED4); + +Serial pc(USBTX, USBRX); +SerialEvent se(p9, p10); +LM75B sensor(p28, p27); + +char str[STR_MAX]; +int index=0; + +int main(int argc, char* argv[]) +{ + char* pFelder[ANZ_FELDER]; + + while(1) { + Led1 = !Led1;; + while(1) { + if(se.checkFlag()) { + se.getString(str); + //printf("String: %s\n", str); + break; + } + } + ParseFelder(str, pFelder, ANZ_FELDER, TRENNZEICHEN); + for (int i = 0; i < 4; i++) { + //printf("\n%s", pFelder[i]); + } + + // set/clear Led4 + if(strcmp(pFelder[0], "M0")==0) { + if(strcmp(pFelder[1], "SD")==0) { + if(strcmp(pFelder[2], "04")==0) { + if(strcmp(pFelder[3], "1")==0) + Led4 = 1; + else + Led4 = 0; + } + } + } + + // send temp from LM75B + if(strcmp(pFelder[0], "M0")==0) { + if(strcmp(pFelder[1], "GA")==0) { + //if(strcmp(pFelder[2], "LM")==0) { + char s[20]; + sprintf(s, "Temp: %f", (float)sensor); + se.pc_send(s); + } + } + } +}