M0 communication to configurable-Web-Server (MQTT) Version 0.1

Dependencies:   LM75B mbed

Siehe auch FTKL-Tagung 2016

main.cpp

Committer:
fpucher
Date:
2016-11-06
Revision:
1:b9fd13f34c2d
Parent:
0:d764cafa5989
Child:
2:63135b94c898

File content as of revision 1:b9fd13f34c2d:

#include <mbed.h>
//#include <config.h>   // Bertl
#include <LM75B.h>

DigitalOut  LedD1(LED1);
DigitalOut  LedD2(LED2);
DigitalOut  LedD3(LED3);
DigitalOut  LedD4(LED4);

//Serial wifi(P1_0, P0_20); // Bertl
Serial wifi(p9, p10);       // M0
Serial pc(USBTX, USBRX);
LM75B sensor(p28, p27);

char str[30];

int main()
{
    wifi.printf("Hello M3 MQTT\n");

    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());
        }
    }                                       // 2. GET-->Serving Web Pages for config and reset
}