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.
Dependencies: QEI MFRC522 HTS221 IoTKit BMP180 MQTT
Fork of MQTTPublish by
Diff: main.cpp
- Revision:
- 22:b671b01d00f9
- Parent:
- 21:4693a8b2a665
- Child:
- 23:4d8f3061890e
diff -r 4693a8b2a665 -r b671b01d00f9 main.cpp --- a/main.cpp Sat Sep 01 17:13:11 2018 +0000 +++ b/main.cpp Sun Sep 02 16:20:11 2018 +0000 @@ -24,6 +24,7 @@ // UI OLEDDisplay oled( PTE26, PTE0, PTE1); DigitalOut led1( D10 ); +DigitalOut alert( D13 ); /** Hilfsfunktion zum Publizieren auf MQTT Broker */ void publish( MQTTNetwork &mqttNetwork, MQTT::Client<MQTTNetwork, Countdown> &client, char* topic ) @@ -69,6 +70,7 @@ { uint8_t id; float temp, hum; + alert = 0; oled.clear(); oled.printf( "MQTTPublish\r\n" ); @@ -98,11 +100,18 @@ // alert Tuer offen if ( hallSensor.read() > 0.6f ) { - sprintf( buf, "door open" ); - message.payload = (void*) buf; - message.payloadlen = strlen(buf)+1; - publish( mqttNetwork, client, topicALERT ); + // nur einmal Melden!, bis Reset + if ( alert == 0 ) + { + sprintf( buf, "door open" ); + message.payload = (void*) buf; + message.payloadlen = strlen(buf)+1; + publish( mqttNetwork, client, topicALERT ); + alert = 1; + } } + else + alert = 0; wait ( 2.0f ); } }