correct end char termination

This commit is contained in:
1technophile committed 2017-12-31 11:26:39 +01:00
1 parent 4077a954ca
commit 87364e2897
1 file changed
+15 -16
+15 -16
View File
@@ -51,7 +51,7 @@
#include <PubSubClient.h>
// array to store previous received RFs, IRs codes and their timestamps
#ifdef ESP8266
#if defined(ESP8266) || defined(ESP32)
#define array_size 12
unsigned long ReceivedSignal[array_size][2] ={{0,0},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0}};
#else
@@ -63,10 +63,12 @@ unsigned long ReceivedSignal[array_size][2] ={{0,0},{0,0},{0,0},{0,0}};
//adding this to bypass the problem of the arduino builder issue 50
void callback(char*topic, byte* payload,unsigned int length);
#ifdef ESP8266
#ifdef ESP32
#include <WiFi.h>
#include <ArduinoOTA.h>
WiFiClient eClient;
#elif defined(ESP8266)
#include <ESP8266WiFi.h>
#include <ESP8266mDNS.h>
#include <WiFiUdp.h>
#include <ArduinoOTA.h>
WiFiClient eClient;
#else
@@ -135,9 +137,9 @@ void callback(char* topic, byte* payload, unsigned int length) {
void setup()
{
#ifdef ESP8266
#if defined(ESP8266) || defined(ESP32)
//Launch serial for debugging purposes
#ifdef ZgatewaySRFB
#if defined(ZgatewaySRFB) || defined(ESP32)
Serial.begin(SERIAL_BAUD); // in the case of sonoff RF Bridge the link to the RF emitter/receiver is made by serial and need TX/RX
#else
Serial.begin(SERIAL_BAUD, SERIAL_8N1, SERIAL_TX_ONLY);
@@ -189,9 +191,6 @@ void setup()
#ifdef ZsensorBH1750
setupZsensorBH1750();
#endif
#ifdef ZsensorTSL2561
setupZsensorTSL2561();
#endif
#ifdef ZgatewayIR
setupIR();
#endif
@@ -215,7 +214,7 @@ void setup()
#endif
}
#ifdef ESP8266
#if defined(ESP8266) || defined(ESP32)
void setup_wifi() {
delay(10);
WiFi.mode(WIFI_STA);
@@ -268,7 +267,7 @@ void loop()
// MQTT loop
client.loop();
#ifdef ESP8266
#if defined(ESP8266) || defined(ESP32)
ArduinoOTA.handle();
#endif
@@ -278,9 +277,6 @@ void loop()
#ifdef ZsensorBH1750
MeasureLightIntensity(); //Addon to measure Light Intensity with a BH1750
#endif
#ifdef ZsensorTSL2561
MeasureLightIntensityTSL2561(); // Addon to measure Light Intensity with a TSL2561
#endif
#ifdef ZsensorDHT
MeasureTempAndHum(); //Addon to measure the temperature with a DHT
#endif
@@ -312,8 +308,10 @@ void loop()
delay(100);
#endif
#ifdef ZgatewayBT
if(BTtoMQTT())
trc(F("BTtoMQTT OK"));
#ifndef ESP32
if(BTtoMQTT())
trc(F("BTtoMQTT OK"));
#endif
#endif
#ifdef ZgatewayRFM69
if(RFM69toMQTT())
@@ -411,6 +409,7 @@ void extract_char(char * token_char, char * subset, int start ,int l, boolean re
if (reverse) revert_hex_data(tmp_subset, subset, l+1);
else strncpy( subset, tmp_subset , l+1);
}
subset[l] = '\0';
}
void revert_hex_data(char * in, char * out, int l){