Publish refactoring (#298)

* factoring of the publishing function
* integration of json publishing to MQTT
* receiving and transcode json messages from mqtt
* replace the TRACE runtime condition by a buildtime one so as to decrease program size
* remove retainFlag parameter not necessary for the moment
* Increase the scope of tests for arduino mega and esp32
* Update arduinojson library to 5.13.3
* add macros to choose between simple or json publishing or both
* differentiate build test for ATmega2560
* correct wrong sprintf definition
* change IDE version for continuous integration
* let default warning level in arduino ide
* correct pins for ESP32
* reorganize user_config
This commit is contained in:
Florian authored and GitHub committed 2018-11-05 22:02:27 +01:00
1 parent f77df7347f
commit d8dba15a81
182 files changed
+2701 -20768

No files matched your search

+10 -12
View File
@@ -25,11 +25,10 @@
*/
#ifdef ZsensorGPIOKeyCode
int InputStateGPIOKeyCode = 0x0f; // Set to 3 so that it reads on startup
int lastInputStateGPIOKeyCode = 0x0f;
int lastLatchStateGPIOKeyCode = 0;
unsigned long lastDebounceTime = 0;
int InputState = 0x0f; // Set to 3 so that it reads on startup
int lastInputState = 0x0f;
int lastLatchState = 0;
void setupGPIOKeyCode() {
pinMode(GPIOKeyCode_LATCH_PIN, INPUT_PULLUP); //
@@ -54,8 +53,7 @@ void MeasureGPIOKeyCode(){
yield();
#endif
// if the Input state has changed:
if (latch > 0 && lastLatchState != latch) {
if (latch > 0 && lastLatchStateGPIOKeyCode != latch) {
int reading = digitalRead(GPIOKeyCode_D0_PIN)
| (digitalRead(GPIOKeyCode_D1_PIN) << 1)
| (digitalRead(GPIOKeyCode_D2_PIN) << 2);
@@ -63,23 +61,23 @@ void MeasureGPIOKeyCode(){
char hex[3];
InputState = reading;
sprintf(hex, "%02x", InputState);
InputStateGPIOKeyCode = reading;
sprintf(hex, "%02x", InputStateGPIOKeyCode);
hex[2] = 0;
Serial.printf("GPIOKeyCode %s\n", hex);
client.publish(subjectGPIOKeyCodetoMQTT,hex);
lastLatchState = latch;
lastLatchStateGPIOKeyCode = latch;
}
if (latch != lastLatchState) {
lastLatchState = latch;
if (latch != lastLatchStateGPIOKeyCode) {
lastLatchStateGPIOKeyCode = latch;
Serial.printf("GPIOKeyCode latch %d\n", latch);
if (latch == 0)
client.publish(subjectGPIOKeyCodeStatetoMQTT, "done");
}
// save the reading. Next time through the loop, it'll be the lastInputState:
lastInputState = InputState;
lastInputStateGPIOKeyCode = InputStateGPIOKeyCode;
}
}
#endif