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.
main.cpp@0:d764cafa5989, 2016-07-01 (annotated)
- Committer:
- fpucher
- Date:
- Fri Jul 01 18:08:04 2016 +0000
- Revision:
- 0:d764cafa5989
- Child:
- 1:b9fd13f34c2d
M0 communication to configurable-Web-Server (MQTT); Version 0.1
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
fpucher | 0:d764cafa5989 | 1 | #include "mbed.h" |
fpucher | 0:d764cafa5989 | 2 | #include <stdio.h> |
fpucher | 0:d764cafa5989 | 3 | #include <string.h> |
fpucher | 0:d764cafa5989 | 4 | #include <stdint.h> |
fpucher | 0:d764cafa5989 | 5 | #include "SerialEvent.h" |
fpucher | 0:d764cafa5989 | 6 | #include "LM75B.h" |
fpucher | 0:d764cafa5989 | 7 | |
fpucher | 0:d764cafa5989 | 8 | #define STR_MAX 40 |
fpucher | 0:d764cafa5989 | 9 | |
fpucher | 0:d764cafa5989 | 10 | DigitalOut Led1(LED1); |
fpucher | 0:d764cafa5989 | 11 | DigitalOut Led2(LED2); |
fpucher | 0:d764cafa5989 | 12 | DigitalOut Led3(LED3); |
fpucher | 0:d764cafa5989 | 13 | DigitalOut Led4(LED4); |
fpucher | 0:d764cafa5989 | 14 | |
fpucher | 0:d764cafa5989 | 15 | Serial pc(USBTX, USBRX); |
fpucher | 0:d764cafa5989 | 16 | SerialEvent se(p9, p10); |
fpucher | 0:d764cafa5989 | 17 | LM75B sensor(p28, p27); |
fpucher | 0:d764cafa5989 | 18 | |
fpucher | 0:d764cafa5989 | 19 | char str[STR_MAX]; |
fpucher | 0:d764cafa5989 | 20 | int index=0; |
fpucher | 0:d764cafa5989 | 21 | |
fpucher | 0:d764cafa5989 | 22 | int main(int argc, char* argv[]) |
fpucher | 0:d764cafa5989 | 23 | { |
fpucher | 0:d764cafa5989 | 24 | char* pFelder[ANZ_FELDER]; |
fpucher | 0:d764cafa5989 | 25 | |
fpucher | 0:d764cafa5989 | 26 | while(1) { |
fpucher | 0:d764cafa5989 | 27 | Led1 = !Led1;; |
fpucher | 0:d764cafa5989 | 28 | while(1) { |
fpucher | 0:d764cafa5989 | 29 | if(se.checkFlag()) { |
fpucher | 0:d764cafa5989 | 30 | se.getString(str); |
fpucher | 0:d764cafa5989 | 31 | //printf("String: %s\n", str); |
fpucher | 0:d764cafa5989 | 32 | break; |
fpucher | 0:d764cafa5989 | 33 | } |
fpucher | 0:d764cafa5989 | 34 | } |
fpucher | 0:d764cafa5989 | 35 | ParseFelder(str, pFelder, ANZ_FELDER, TRENNZEICHEN); |
fpucher | 0:d764cafa5989 | 36 | for (int i = 0; i < 4; i++) { |
fpucher | 0:d764cafa5989 | 37 | //printf("\n%s", pFelder[i]); |
fpucher | 0:d764cafa5989 | 38 | } |
fpucher | 0:d764cafa5989 | 39 | |
fpucher | 0:d764cafa5989 | 40 | // set/clear Led4 |
fpucher | 0:d764cafa5989 | 41 | if(strcmp(pFelder[0], "M0")==0) { |
fpucher | 0:d764cafa5989 | 42 | if(strcmp(pFelder[1], "SD")==0) { |
fpucher | 0:d764cafa5989 | 43 | if(strcmp(pFelder[2], "04")==0) { |
fpucher | 0:d764cafa5989 | 44 | if(strcmp(pFelder[3], "1")==0) |
fpucher | 0:d764cafa5989 | 45 | Led4 = 1; |
fpucher | 0:d764cafa5989 | 46 | else |
fpucher | 0:d764cafa5989 | 47 | Led4 = 0; |
fpucher | 0:d764cafa5989 | 48 | } |
fpucher | 0:d764cafa5989 | 49 | } |
fpucher | 0:d764cafa5989 | 50 | } |
fpucher | 0:d764cafa5989 | 51 | |
fpucher | 0:d764cafa5989 | 52 | // send temp from LM75B |
fpucher | 0:d764cafa5989 | 53 | if(strcmp(pFelder[0], "M0")==0) { |
fpucher | 0:d764cafa5989 | 54 | if(strcmp(pFelder[1], "GA")==0) { |
fpucher | 0:d764cafa5989 | 55 | //if(strcmp(pFelder[2], "LM")==0) { |
fpucher | 0:d764cafa5989 | 56 | char s[20]; |
fpucher | 0:d764cafa5989 | 57 | sprintf(s, "Temp: %f", (float)sensor); |
fpucher | 0:d764cafa5989 | 58 | se.pc_send(s); |
fpucher | 0:d764cafa5989 | 59 | } |
fpucher | 0:d764cafa5989 | 60 | } |
fpucher | 0:d764cafa5989 | 61 | } |
fpucher | 0:d764cafa5989 | 62 | } |