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.
Diff: main.cpp
- Revision:
- 1:b9fd13f34c2d
- Parent:
- 0:d764cafa5989
- Child:
- 2:63135b94c898
diff -r d764cafa5989 -r b9fd13f34c2d main.cpp --- a/main.cpp Fri Jul 01 18:08:04 2016 +0000 +++ b/main.cpp Sun Nov 06 15:36:07 2016 +0000 @@ -1,62 +1,48 @@ -#include "mbed.h" -#include <stdio.h> -#include <string.h> -#include <stdint.h> -#include "SerialEvent.h" -#include "LM75B.h" +#include <mbed.h> +//#include <config.h> // Bertl +#include <LM75B.h> -#define STR_MAX 40 +DigitalOut LedD1(LED1); +DigitalOut LedD2(LED2); +DigitalOut LedD3(LED3); +DigitalOut LedD4(LED4); -DigitalOut Led1(LED1); -DigitalOut Led2(LED2); -DigitalOut Led3(LED3); -DigitalOut Led4(LED4); - +//Serial wifi(P1_0, P0_20); // Bertl +Serial wifi(p9, p10); // M0 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]; +char str[30]; - 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]); - } +int main() +{ + wifi.printf("Hello M3 MQTT\n"); - // 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; - } + while (1) { + wifi.scanf("%s", str); + //wifi.printf("str: %s\n", str); + if(str[0] == 'H' && str[1] == 'L') // 1. GET--> Serving Requests part in http-server + wifi.printf( "HL Msg: %s\n", str); + if(str[0] == 'M' && str[1] == 'V') // 1. GET--> Serving Requests part in http-server + ;//Move(); // ?reqest=MV + else if(str[0] == 'T') { + if (str[1] == 'L') + ;//TurnLeft(); + else if (str[1] == 'R') + ;//TurnRight(); + } else { // 3. GET--> Serving M0 Board part in http-server + if(str[7] == '1') { // ?M0=SD&chan=04&state=1 --> M0_SD_04_1 + LedD1 = (str[9] -'0'); + wifi.printf( "LedD1\n"); } + if(str[7] == '2') + LedD2 = (str[9] -'0'); + if(str[7] == '3') + LedD3 = (str[9] -'0'); + if(str[7] == '4') + LedD4 = (str[9] -'0'); + if(str[3] == 'G') + wifi.printf( "Temp: %f\n", sensor.read()); } - - // 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); - } - } - } -} + } // 2. GET-->Serving Web Pages for config and reset +} \ No newline at end of file